33 #include <stdatomic.h>
73 #if HAVE_SYS_RESOURCE_H
75 #include <sys/types.h>
76 #include <sys/resource.h>
77 #elif HAVE_GETPROCESSTIMES
80 #if HAVE_GETPROCESSMEMORYINFO
84 #if HAVE_SETCONSOLECTRLHANDLER
90 #include <sys/select.h>
95 #include <sys/ioctl.h>
164 static struct termios oldtty;
165 static int restore_tty;
169 static void free_input_threads(
void);
183 ist->sub2video.frame->width =
ist->dec_ctx->width ?
ist->dec_ctx->width :
ist->sub2video.w;
184 ist->sub2video.frame->height =
ist->dec_ctx->height ?
ist->dec_ctx->height :
ist->sub2video.h;
195 uint32_t *pal, *dst2;
203 if (
r->x < 0 ||
r->x +
r->w >
w ||
r->y < 0 ||
r->y +
r->h >
h) {
205 r->x,
r->y,
r->w,
r->h,
w,
h
210 dst +=
r->y * dst_linesize +
r->x * 4;
212 pal = (uint32_t *)
r->data[1];
213 for (y = 0; y <
r->h; y++) {
214 dst2 = (uint32_t *)dst;
216 for (x = 0; x <
r->w; x++)
217 *(dst2++) = pal[*(src2++)];
219 src +=
r->linesize[0];
231 for (
i = 0;
i <
ist->nb_filters;
i++) {
247 int64_t
pts, end_pts;
256 num_rects =
sub->num_rects;
262 pts =
ist->sub2video.initialize ?
263 heartbeat_pts :
ist->sub2video.end_pts;
269 "Impossible to get a blank canvas.\n");
272 dst =
frame->data [0];
273 dst_linesize =
frame->linesize[0];
274 for (
i = 0;
i < num_rects;
i++)
277 ist->sub2video.end_pts = end_pts;
278 ist->sub2video.initialize = 0;
299 if (pts2 <= ist2->sub2video.last_pts)
306 for (j = 0, nb_reqs = 0; j < ist2->
nb_filters; j++)
318 if (
ist->sub2video.end_pts < INT64_MAX)
320 for (
i = 0;
i <
ist->nb_filters;
i++) {
333 tcsetattr (0, TCSANOW, &oldtty);
358 ret = write(2,
"Received > 3 system signals, hard exiting\n",
359 strlen(
"Received > 3 system signals, hard exiting\n"));
365 #if HAVE_SETCONSOLECTRLHANDLER
366 static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
373 case CTRL_BREAK_EVENT:
377 case CTRL_CLOSE_EVENT:
378 case CTRL_LOGOFF_EVENT:
379 case CTRL_SHUTDOWN_EVENT:
398 #define SIGNAL(sig, func) \
400 action.sa_handler = func; \
401 sigaction(sig, &action, NULL); \
404 #define SIGNAL(sig, func) \
410 #if defined __linux__
411 struct sigaction action = {0};
415 sigfillset(&action.sa_mask);
418 action.sa_flags = SA_RESTART;
424 if (tcgetattr (0, &tty) == 0) {
428 tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
429 |INLCR|IGNCR|ICRNL|IXON);
430 tty.c_oflag |= OPOST;
431 tty.c_lflag &= ~(
ECHO|ECHONL|ICANON|IEXTEN);
432 tty.c_cflag &= ~(CSIZE|PARENB);
437 tcsetattr (0, TCSANOW, &tty);
449 signal(SIGPIPE, SIG_IGN);
451 #if HAVE_SETCONSOLECTRLHANDLER
452 SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE);
469 n = select(1, &rfds,
NULL,
NULL, &tv);
478 # if HAVE_PEEKNAMEDPIPE
480 static HANDLE input_handle;
483 input_handle = GetStdHandle(STD_INPUT_HANDLE);
484 is_pipe = !GetConsoleMode(input_handle, &dw);
489 if (!PeekNamedPipe(input_handle,
NULL, 0,
NULL, &nchars,
NULL)) {
539 if (
ist->sub2video.sub_queue) {
622 free_input_threads();
649 "Error closing vstats file, loss of information possible: %s\n",
709 "bench: %8" PRIu64
" user %8" PRIu64
" sys %8" PRIu64
" real %s \n",
723 ost2->
finished |=
ost == ost2 ? this_stream : others;
754 unsigned int are_we_over_size =
759 if (new_size <= cur_size) {
761 "Too many packets buffered for output stream %d:%d.\n",
813 av_log(
s,
AV_LOG_WARNING,
"Invalid DTS: %"PRId64
" PTS: %"PRId64
" in output stream %d:%d, replacing by guess\n",
830 av_log(
s, loglevel,
"Non-monotonous DTS in output stream "
831 "%d:%d; previous: %"PRId64
", current: %"PRId64
"; ",
837 av_log(
s, loglevel,
"changing to %"PRId64
". This may result "
838 "in incorrect timestamps in the output file.\n",
855 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s size:%d\n",
956 float_pts +=
FFSIGN(float_pts) * 1.0 / (1<<17);
978 char *
error,
int error_len);
984 char error[1024] = {0};
1022 "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
1044 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
1062 int subtitle_out_max_size = 1024 * 1024;
1063 int subtitle_out_size, nb,
i;
1097 for (
i = 0;
i < nb;
i++) {
1098 unsigned save_num_rects =
sub->num_rects;
1107 sub->end_display_time -=
sub->start_display_time;
1108 sub->start_display_time = 0;
1115 subtitle_out_max_size,
sub);
1117 sub->num_rects = save_num_rects;
1118 if (subtitle_out_size < 0) {
1125 pkt->
size = subtitle_out_size;
1150 int nb_frames, nb0_frames,
i;
1151 double delta, delta0;
1165 if (frame_rate.
num > 0 && frame_rate.
den > 0)
1180 if (!next_picture) {
1197 if (delta0 < -0.6) {
1218 }
else if (
delta < -1.1)
1220 else if (
delta > 1.1) {
1223 nb0_frames =
llrintf(delta0 - 0.6);
1229 else if (
delta > 0.6)
1242 nb0_frames =
FFMIN(nb0_frames, nb_frames);
1252 "*** dropping frame %d from stream %d at ts %"PRId64
"\n",
1255 if (nb_frames > (nb0_frames &&
ost->
last_dropped) + (nb_frames > nb0_frames)) {
1272 for (
i = 0;
i < nb_frames;
i++) {
1274 int forced_keyframe = 0;
1277 if (i < nb0_frames && ost->last_frame->buf[0]) {
1280 in_picture = next_picture;
1302 forced_keyframe = 1;
1308 ff_dlog(
NULL,
"force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n",
1316 forced_keyframe = 1;
1329 forced_keyframe = 1;
1337 if (forced_keyframe) {
1345 "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
1368 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
1380 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
1417 return -10.0 * log10(
d);
1424 double ti1,
bitrate, avg_bitrate;
1439 fprintf(
vstats_file,
"frame= %5d q= %2.1f ", frame_number,
1456 avg_bitrate = (double)(
ost->
data_size * 8) / ti1 / 1000.0;
1457 fprintf(
vstats_file,
"s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
1519 "Error in av_buffersink_get_frame_flags(): %s\n",
av_err2str(
ret));
1542 "Audio filter graph output is not normalized and encoder does not support parameter changes\n");
1561 uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
1562 uint64_t subtitle_size = 0;
1564 float percent = -1.0;
1586 av_log(
NULL,
AV_LOG_INFO,
"video:%1.0fkB audio:%1.0fkB subtitle:%1.0fkB other streams:%1.0fkB global headers:%1.0fkB muxing overhead: ",
1587 video_size / 1024.0,
1588 audio_size / 1024.0,
1589 subtitle_size / 1024.0,
1590 other_size / 1024.0,
1591 extra_size / 1024.0);
1601 uint64_t total_packets = 0, total_size = 0;
1606 for (j = 0; j <
f->nb_streams; j++) {
1610 total_size +=
ist->data_size;
1611 total_packets +=
ist->nb_packets;
1616 ist->nb_packets,
ist->data_size);
1618 if (
ist->decoding_needed) {
1620 ist->frames_decoded);
1630 total_packets, total_size);
1635 uint64_t total_packets = 0, total_size = 0;
1664 total_packets, total_size);
1666 if(video_size +
data_size + audio_size + subtitle_size + extra_size == 0){
1676 static void print_report(
int is_last_report, int64_t timer_start, int64_t cur_time)
1678 AVBPrint buf, buf_script;
1683 int frame_number, vid,
i;
1686 int64_t
pts = INT64_MIN + 1;
1687 static int64_t last_time = -1;
1688 static int first_report = 1;
1689 static int qp_histogram[52];
1690 int hours, mins, secs,
us;
1691 const char *hours_sign;
1698 if (!is_last_report) {
1699 if (last_time == -1) {
1700 last_time = cur_time;
1702 if (((cur_time - last_time) <
stats_period && !first_report) ||
1705 last_time = cur_time;
1708 t = (cur_time-timer_start) / 1000000.0;
1714 if (total_size <= 0)
1729 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1736 fps = t > 1 ? frame_number / t : 0;
1737 av_bprintf(&buf,
"frame=%5d fps=%3.*f q=%3.1f ",
1738 frame_number, fps < 9.95, fps, q);
1739 av_bprintf(&buf_script,
"frame=%d\n", frame_number);
1741 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1750 for (j = 0; j < 32; j++)
1756 double error, error_sum = 0;
1757 double scale, scale_sum = 0;
1759 char type[3] = {
'Y',
'U',
'V' };
1761 for (j = 0; j < 3; j++) {
1762 if (is_last_report) {
1775 av_bprintf(&buf_script,
"stream_%d_%d_psnr_%c=%2.2f\n",
1778 p =
psnr(error_sum / scale_sum);
1780 av_bprintf(&buf_script,
"stream_%d_%d_psnr_all=%2.2f\n",
1807 hours_sign = (
pts < 0) ?
"-" :
"";
1809 bitrate =
pts && total_size >= 0 ? total_size * 8 / (
pts / 1000.0) : -1;
1812 if (total_size < 0)
av_bprintf(&buf,
"size=N/A time=");
1813 else av_bprintf(&buf,
"size=%8.0fkB time=", total_size / 1024.0);
1829 if (total_size < 0)
av_bprintf(&buf_script,
"total_size=N/A\n");
1830 else av_bprintf(&buf_script,
"total_size=%"PRId64
"\n", total_size);
1832 av_bprintf(&buf_script,
"out_time_us=N/A\n");
1833 av_bprintf(&buf_script,
"out_time_ms=N/A\n");
1838 av_bprintf(&buf_script,
"out_time=%s%02d:%02d:%02d.%06d\n",
1839 hours_sign, hours, mins, secs,
us);
1852 av_bprintf(&buf_script,
"speed=%4.3gx\n", speed);
1856 const char end = is_last_report ?
'\n' :
'\r';
1858 fprintf(stderr,
"%s %c", buf.str, end);
1868 is_last_report ?
"end" :
"continue");
1870 FFMIN(buf_script.len, buf_script.size - 1));
1873 if (is_last_report) {
1876 "Error closing progress log, loss of information possible: %s\n",
av_err2str(
ret));
1917 "Finishing stream %d:%d without any data written to it.\n",
2046 ist->pts < comp_start :
2057 if (
f->recording_time != INT64_MAX) {
2085 opkt->
pts = opkt->
dts - ost_tb_start_time;
2088 opkt->
dts -= ost_tb_start_time;
2101 if (!
dec->channel_layout) {
2102 char layout_name[256];
2104 if (
dec->channels >
ist->guess_layout_max)
2107 if (!
dec->channel_layout)
2110 dec->channels,
dec->channel_layout);
2112 "#%d.%d : %s\n",
ist->file_index,
ist->st->index, layout_name);
2151 int need_reinit,
ret;
2192 if (need_reinit || !fg->
graph) {
2287 for (
i = 0;
i <
ist->nb_filters;
i++) {
2293 "Failed to inject frame into filter network: %s\n",
av_err2str(
ret));
2326 ist->frames_decoded++;
2336 decoded_frame_tb =
ist->st->time_base;
2339 decoded_frame_tb =
ist->st->time_base;
2357 return err < 0 ? err :
ret;
2364 int i,
ret = 0, err = 0;
2365 int64_t best_effort_timestamp;
2386 ist->dts_buffer =
new;
2387 ist->dts_buffer[
ist->nb_dts_buffer++] =
dts;
2398 if (
ist->st->codecpar->video_delay <
ist->dec_ctx->has_b_frames) {
2400 ist->st->codecpar->video_delay =
ist->dec_ctx->has_b_frames;
2403 "video_delay is larger in decoder than demuxer %d > %d.\n"
2404 "If you want to help, upload a sample "
2405 "of this file to https://streams.videolan.org/upload/ "
2406 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n",
2407 ist->dec_ctx->has_b_frames,
2408 ist->st->codecpar->video_delay);
2422 ist->dec_ctx->width,
2423 ist->dec_ctx->height,
2424 ist->dec_ctx->pix_fmt);
2431 if(
ist->top_field_first>=0)
2434 ist->frames_decoded++;
2446 if (
ist->framerate.num)
2447 best_effort_timestamp =
ist->cfr_next_pts++;
2450 best_effort_timestamp =
ist->dts_buffer[0];
2452 for (
i = 0;
i <
ist->nb_dts_buffer - 1;
i++)
2453 ist->dts_buffer[
i] =
ist->dts_buffer[
i + 1];
2454 ist->nb_dts_buffer--;
2461 ist->next_pts =
ist->pts = ts;
2466 "frame_pts:%s frame_pts_time:%s best_effort_ts:%"PRId64
" best_effort_ts_time:%s keyframe:%d frame_type:%d time_base:%d/%d\n",
2469 best_effort_timestamp,
2472 ist->st->time_base.num,
ist->st->time_base.den);
2475 if (
ist->st->sample_aspect_ratio.num)
2482 return err < 0 ? err :
ret;
2502 if (
ist->fix_sub_duration) {
2504 if (
ist->prev_sub.got_output) {
2507 if (end < ist->
prev_sub.subtitle.end_display_time) {
2509 "Subtitle duration reduced from %"PRId32
" to %d%s\n",
2510 ist->prev_sub.subtitle.end_display_time, end,
2511 end <= 0 ?
", dropping it" :
"");
2512 ist->prev_sub.subtitle.end_display_time = end;
2525 if (
ist->sub2video.frame) {
2527 }
else if (
ist->nb_filters) {
2528 if (!
ist->sub2video.sub_queue)
2530 if (!
ist->sub2video.sub_queue)
2544 ist->frames_decoded++;
2569 for (
i = 0;
i <
ist->nb_filters;
i++) {
2582 int eof_reached = 0;
2586 if (!
ist->saw_first_ts) {
2595 ist->saw_first_ts = 1;
2599 ist->next_dts =
ist->dts;
2601 ist->next_pts =
ist->pts;
2617 while (
ist->decoding_needed) {
2618 int64_t duration_dts = 0;
2619 int64_t duration_pts = 0;
2621 int decode_failed = 0;
2623 ist->pts =
ist->next_pts;
2624 ist->dts =
ist->next_dts;
2626 switch (
ist->dec_ctx->codec_type) {
2638 }
else if(
ist->dec_ctx->framerate.num != 0 &&
ist->dec_ctx->framerate.den != 0) {
2641 ist->dec_ctx->framerate.den * ticks) /
2642 ist->dec_ctx->framerate.num /
ist->dec_ctx->ticks_per_frame;
2646 ist->next_dts += duration_dts;
2652 if (duration_pts > 0) {
2655 ist->next_pts += duration_dts;
2678 if (decode_failed) {
2683 "data for stream #%d:%d\n",
ist->file_index,
ist->st->index);
2691 ist->got_output = 1;
2712 if (!
pkt &&
ist->decoding_needed && eof_reached && !no_eof) {
2721 if (!
ist->decoding_needed &&
pkt) {
2722 ist->dts =
ist->next_dts;
2723 switch (
ist->dec_ctx->codec_type) {
2726 if (
ist->dec_ctx->sample_rate) {
2728 ist->dec_ctx->sample_rate;
2734 if (
ist->framerate.num) {
2741 }
else if(
ist->dec_ctx->framerate.num != 0) {
2744 ist->dec_ctx->framerate.den * ticks) /
2745 ist->dec_ctx->framerate.num /
ist->dec_ctx->ticks_per_frame;
2750 ist->next_pts =
ist->next_dts;
2761 return !eof_reached;
2798 printf(
"SDP:\n%s\n", sdp);
2840 if (
config->pix_fmt == *p)
2849 "%s hwaccel requested for input stream #%d:%d, "
2850 "but cannot be initialized.\n",
2852 ist->file_index,
ist->st->index);
2858 ist->hwaccel_pix_fmt = *p;
2871 if (
ist->decoding_needed) {
2874 snprintf(
error, error_len,
"Decoder (codec %s) not found for input stream #%d:%d",
2879 ist->dec_ctx->opaque =
ist;
2881 #if LIBAVCODEC_VERSION_MAJOR < 60
2883 ist->dec_ctx->thread_safe_callbacks = 1;
2891 av_log(
NULL,
AV_LOG_WARNING,
"Warning using DVB subtitles for filtering and output at the same time is not fully supported, also see -compute_edt [0|1]\n");
2896 ist->dec_ctx->pkt_timebase =
ist->st->time_base;
2907 "decoder on input stream #%d:%d : %s",
2917 "Error while opening decoder for input stream "
2940 return FFDIFFSIGN(*(
const int64_t *)
a, *(
const int64_t *)
b);
2959 "Could not write header for output file #%d "
2960 "(incorrect codec parameters ?): %s\n",
3035 uint32_t codec_tag = par_dst->
codec_tag;
3044 "Error setting up codec context options.\n");
3051 "Error getting reference codec parameters.\n");
3056 unsigned int codec_tag_tmp;
3093 if (
ist->st->nb_side_data) {
3094 for (
i = 0;
i <
ist->st->nb_side_data;
i++) {
3101 memcpy(dst_data, sd_src->
data, sd_src->
size);
3127 (
AVRational){ par_dst->height, par_dst->width });
3129 "with stream copy may produce invalid files\n");
3131 else if (
ist->st->sample_aspect_ratio.num)
3132 sar =
ist->st->sample_aspect_ratio;
3150 uint8_t *encoder_string;
3151 int encoder_string_len;
3152 int format_flags = 0;
3174 encoder_string =
av_mallocz(encoder_string_len);
3175 if (!encoder_string)
3181 av_strlcpy(encoder_string,
"Lavc ", encoder_string_len);
3194 for (p = kf; *p; p++)
3205 for (
i = 0;
i < n;
i++) {
3206 char *next = strchr(p,
',');
3211 if (!memcmp(p,
"chapters", 8)) {
3220 "Could not allocate forced key frames array.\n");
3295 "about the input framerate is available. Falling "
3296 "back to a default value of 25fps for output stream #%d:%d. Use the -r option "
3297 "if you want a different framerate.\n",
3341 "Please consider specifying a lower framerate, a different muxer or -vsync 2\n");
3377 if (
frame->interlaced_frame) {
3416 if (!enc_ctx->
width) {
3434 char *
error,
int error_len)
3449 if (
dec &&
dec->subtitle_header) {
3463 "encoder on output stream #%d:%d : %s",
3469 int input_props = 0, output_props = 0;
3474 if (input_descriptor)
3476 if (output_descriptor)
3478 if (input_props && output_props && input_props != output_props) {
3480 "Subtitle encoding currently only possible from text to text "
3481 "or bitmap to bitmap");
3490 "Error while opening encoder for output stream #%d:%d - "
3491 "maybe incorrect parameters such as bit_rate, rate, width or height",
3503 " It takes bits/s as argument, not kbits/s\n");
3508 "Error initializing the output stream codec context.\n");
3522 memcpy(dst_data, sd_src->
data, sd_src->
size);
3535 for (
i = 0;
i <
ist->st->nb_side_data;
i++) {
3585 "New %s stream %d:%d at pos:%"PRId64
" and DTS:%ss\n",
3594 int ret = 0,
i, j, k;
3598 char error[1024] = {0};
3619 for (j = 0; j <
ifile->nb_streams; j++)
3656 for (j = 0; j <
ifile->ctx->nb_programs; j++) {
3685 for (j = 0; j <
ist->nb_filters; j++) {
3688 ist->file_index,
ist->st->index,
ist->dec ?
ist->dec->name :
"?",
3689 ist->filters[j]->name);
3732 const char *decoder_name =
"?";
3733 const char *in_codec_name =
"?";
3734 const char *encoder_name =
"?";
3735 const char *out_codec_name =
"?";
3739 decoder_name = in_codec->
name;
3742 in_codec_name =
desc->name;
3743 if (!strcmp(decoder_name, in_codec_name))
3744 decoder_name =
"native";
3748 encoder_name = out_codec->
name;
3751 out_codec_name =
desc->name;
3752 if (!strcmp(encoder_name, out_codec_name))
3753 encoder_name =
"native";
3757 in_codec_name, decoder_name,
3758 out_codec_name, encoder_name);
3807 int64_t opts_min = INT64_MAX;
3817 "cur_dts is invalid st:%d (%d) [init:%d i_done:%d finish:%d] (this is harmless if it occurs once at the start per stream)\n",
3835 if (tcgetattr(0, &tty) == 0) {
3836 if (
on) tty.c_lflag |=
ECHO;
3837 else tty.c_lflag &= ~
ECHO;
3838 tcsetattr(0, TCSANOW, &tty);
3846 static int64_t last_time;
3852 last_time = cur_time;
3871 if (
key ==
'c' ||
key ==
'C'){
3872 char buf[4096], target[64],
command[256],
arg[256] = {0};
3875 fprintf(stderr,
"\nEnter command: <target>|all <time>|-1 <command>[ <argument>]\n");
3878 while ((k =
read_key()) !=
'\n' && k !=
'\r' &&
i <
sizeof(buf)-1)
3883 fprintf(stderr,
"\n");
3885 (n = sscanf(buf,
"%63[^ ] %lf %255[^ ] %255[^\n]", target, &time,
command,
arg)) >= 3) {
3894 fprintf(stderr,
"Command reply for stream %d: ret:%d res:\n%s",
i,
ret, buf);
3895 }
else if (
key ==
'c') {
3896 fprintf(stderr,
"Queuing commands only on filters supporting the specific command is unsupported\n");
3901 fprintf(stderr,
"Queuing command failed with error %s\n",
av_err2str(
ret));
3907 "Parse error, at least 3 arguments were expected, "
3908 "only %d given in string '%s'\n", n, buf);
3911 if (
key ==
'd' ||
key ==
'D'){
3915 if(!debug) debug = 1;
3923 while ((k =
read_key()) !=
'\n' && k !=
'\r' &&
i <
sizeof(buf)-1)
3928 fprintf(stderr,
"\n");
3929 if (k <= 0 || sscanf(buf,
"%d", &debug)!=1)
3930 fprintf(stderr,
"error parsing debug value\n");
3940 fprintf(stderr,
"debug=%d\n", debug);
3943 fprintf(stderr,
"key function\n"
3944 "? show this help\n"
3945 "+ increase verbosity\n"
3946 "- decrease verbosity\n"
3947 "c Send command to first matching filter supporting it\n"
3948 "C Send/Queue command to all matching filters\n"
3949 "D cycle through available debug modes\n"
3950 "h dump packets/hex press to cycle through the 3 states\n"
3952 "s Show QP histogram\n"
3959 static void *input_thread(
void *
arg)
3989 "Thread message queue blocking; consider raising the "
3990 "thread_queue_size option (current value: %d)\n",
3991 f->thread_queue_size);
3996 "Unable to send packet to main thread: %s\n",
4007 static void free_input_thread(
int i)
4012 if (!
f || !
f->in_thread_queue)
4023 static void free_input_threads(
void)
4028 free_input_thread(
i);
4031 static int init_input_thread(
int i)
4036 if (
f->thread_queue_size < 0)
4038 if (!
f->thread_queue_size)
4041 if (
f->ctx->pb ? !
f->ctx->pb->seekable :
4042 strcmp(
f->ctx->iformat->name,
"lavfi"))
4043 f->non_blocking = 1;
4045 f->thread_queue_size,
sizeof(
f->pkt));
4050 av_log(
NULL,
AV_LOG_ERROR,
"pthread_create failed: %s. Try to increase `ulimit -v` or decrease `ulimit -s`.\n", strerror(
ret));
4058 static int init_input_threads(
void)
4063 ret = init_input_thread(
i);
4080 if (
f->readrate ||
f->rate_emu) {
4082 int64_t file_start =
copy_ts * (