fftools/ffmpeg: make specifying thread_queue_size turn on threaded input
Threaded input can increase smoothness of e.g. x11grab significantly. Before this patch, in order to activate threaded input the user had to specify a "dummy" additional input, with this change it is no longer required. Signed-off-by: Marton Balint <cus@passwd.hu>
This commit is contained in:
parent
6ceaeecaf5
commit
53a4620fba
|
@ -1689,8 +1689,9 @@ not start from timestamp 0, such as transport streams.
|
||||||
@item -thread_queue_size @var{size} (@emph{input})
|
@item -thread_queue_size @var{size} (@emph{input})
|
||||||
This option sets the maximum number of queued packets when reading from the
|
This option sets the maximum number of queued packets when reading from the
|
||||||
file or device. With low latency / high rate live streams, packets may be
|
file or device. With low latency / high rate live streams, packets may be
|
||||||
discarded if they are not read in a timely manner; raising this value can
|
discarded if they are not read in a timely manner; setting this value can
|
||||||
avoid it.
|
force ffmpeg to use a separate input thread and read packets as soon as they
|
||||||
|
arrive. By default ffmpeg only do this if multiple inputs are specified.
|
||||||
|
|
||||||
@item -sdp_file @var{file} (@emph{global})
|
@item -sdp_file @var{file} (@emph{global})
|
||||||
Print sdp information for an output stream to @var{file}.
|
Print sdp information for an output stream to @var{file}.
|
||||||
|
|
|
@ -4051,7 +4051,9 @@ static int init_input_thread(int i)
|
||||||
int ret;
|
int ret;
|
||||||
InputFile *f = input_files[i];
|
InputFile *f = input_files[i];
|
||||||
|
|
||||||
if (nb_input_files == 1)
|
if (f->thread_queue_size < 0)
|
||||||
|
f->thread_queue_size = (nb_input_files > 1 ? 8 : 0);
|
||||||
|
if (!f->thread_queue_size)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (f->ctx->pb ? !f->ctx->pb->seekable :
|
if (f->ctx->pb ? !f->ctx->pb->seekable :
|
||||||
|
@ -4105,7 +4107,7 @@ static int get_input_packet(InputFile *f, AVPacket *pkt)
|
||||||
}
|
}
|
||||||
|
|
||||||
#if HAVE_THREADS
|
#if HAVE_THREADS
|
||||||
if (nb_input_files > 1)
|
if (f->thread_queue_size)
|
||||||
return get_input_packet_mt(f, pkt);
|
return get_input_packet_mt(f, pkt);
|
||||||
#endif
|
#endif
|
||||||
return av_read_frame(f->ctx, pkt);
|
return av_read_frame(f->ctx, pkt);
|
||||||
|
|
|
@ -228,6 +228,7 @@ static void init_options(OptionsContext *o)
|
||||||
o->limit_filesize = UINT64_MAX;
|
o->limit_filesize = UINT64_MAX;
|
||||||
o->chapters_input_file = INT_MAX;
|
o->chapters_input_file = INT_MAX;
|
||||||
o->accurate_seek = 1;
|
o->accurate_seek = 1;
|
||||||
|
o->thread_queue_size = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int show_hwaccels(void *optctx, const char *opt, const char *arg)
|
static int show_hwaccels(void *optctx, const char *opt, const char *arg)
|
||||||
|
@ -1270,7 +1271,7 @@ static int open_input_file(OptionsContext *o, const char *filename)
|
||||||
f->duration = 0;
|
f->duration = 0;
|
||||||
f->time_base = (AVRational){ 1, 1 };
|
f->time_base = (AVRational){ 1, 1 };
|
||||||
#if HAVE_THREADS
|
#if HAVE_THREADS
|
||||||
f->thread_queue_size = o->thread_queue_size > 0 ? o->thread_queue_size : 8;
|
f->thread_queue_size = o->thread_queue_size;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* check if all codec options have been used */
|
/* check if all codec options have been used */
|
||||||
|
|
Loading…
Reference in New Issue
Block a user