33 #include <stdatomic.h>
72 #if HAVE_SYS_RESOURCE_H
74 #include <sys/types.h>
75 #include <sys/resource.h>
76 #elif HAVE_GETPROCESSTIMES
79 #if HAVE_GETPROCESSMEMORYINFO
83 #if HAVE_SETCONSOLECTRLHANDLER
89 #include <sys/select.h>
94 #include <sys/ioctl.h>
160 static struct termios oldtty;
161 static int restore_tty;
165 static void free_input_threads(
void);
191 uint32_t *pal, *dst2;
199 if (r->
x < 0 || r->
x + r->
w > w || r->
y < 0 || r->
y + r->
h > h) {
201 r->
x, r->
y, r->
w, r->
h, w, h
206 dst += r->
y * dst_linesize + r->
x * 4;
208 pal = (uint32_t *)r->
data[1];
209 for (y = 0; y < r->
h; y++) {
210 dst2 = (uint32_t *)dst;
212 for (x = 0; x < r->
w; x++)
213 *(dst2++) = pal[*(src2++)];
238 int64_t
pts, end_pts;
255 "Impossible to get a blank canvas.\n");
258 dst = frame->
data [0];
260 for (i = 0; i < num_rects; i++)
284 if (pts2 <= ist2->sub2video.last_pts)
288 for (j = 0, nb_reqs = 0; j < ist2->
nb_filters; j++)
311 tcsetattr (0, TCSANOW, &oldtty);
334 write(2,
"Received > 3 system signals, hard exiting\n",
335 strlen(
"Received > 3 system signals, hard exiting\n"));
341 #if HAVE_SETCONSOLECTRLHANDLER
342 static BOOL WINAPI CtrlHandler(
DWORD fdwCtrlType)
349 case CTRL_BREAK_EVENT:
353 case CTRL_CLOSE_EVENT:
354 case CTRL_LOGOFF_EVENT:
355 case CTRL_SHUTDOWN_EVENT:
378 if (tcgetattr (0, &tty) == 0) {
382 tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
383 |INLCR|IGNCR|ICRNL|IXON);
384 tty.c_oflag |= OPOST;
385 tty.c_lflag &= ~(
ECHO|ECHONL|ICANON|IEXTEN);
386 tty.c_cflag &= ~(CSIZE|PARENB);
391 tcsetattr (0, TCSANOW, &tty);
402 #if HAVE_SETCONSOLECTRLHANDLER
403 SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler,
TRUE);
420 n = select(1, &rfds,
NULL,
NULL, &tv);
429 # if HAVE_PEEKNAMEDPIPE
431 static HANDLE input_handle;
434 input_handle = GetStdHandle(STD_INPUT_HANDLE);
435 is_pipe = !GetConsoleMode(input_handle, &dw);
440 if (!PeekNamedPipe(input_handle,
NULL, 0,
NULL, &nchars,
NULL)) {
482 sizeof(frame),
NULL);
490 &sub,
sizeof(sub),
NULL);
572 free_input_threads();
598 "Error closing vstats file, loss of information possible: %s\n",
667 ost2->
finished |= ost == ost2 ? this_stream : others;
701 "Too many packets buffered for output stream %d:%d.\n",
749 av_log(s,
AV_LOG_WARNING,
"Invalid DTS: %"PRId64
" PTS: %"PRId64
" in output stream %d:%d, replacing by guess\n",
762 if (pkt->
dts < max) {
764 av_log(s, loglevel,
"Non-monotonous DTS in output stream "
765 "%d:%d; previous: %"PRId64
", current: %"PRId64
"; ",
771 av_log(s, loglevel,
"changing to %"PRId64
". This may result "
772 "in incorrect timestamps in the output file.\n",
789 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s size:%d\n",
856 if (idx < ost->nb_bitstream_filters) {
916 "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
938 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
956 int subtitle_out_max_size = 1024 * 1024;
957 int subtitle_out_size, nb, i;
991 for (i = 0; i < nb; i++) {
992 unsigned save_num_rects = sub->
num_rects;
1009 subtitle_out_max_size, sub);
1012 if (subtitle_out_size < 0) {
1019 pkt.
size = subtitle_out_size;
1040 int ret, format_video_sync;
1045 int nb_frames, nb0_frames, i;
1046 double delta, delta0;
1056 if (frame_rate.
num > 0 && frame_rate.
den > 0)
1070 if (!next_picture) {
1105 if (delta0 < -0.6) {
1114 switch (format_video_sync) {
1126 }
else if (delta < -1.1)
1128 else if (delta > 1.1) {
1129 nb_frames =
lrintf(delta);
1131 nb0_frames =
lrintf(delta0 - 0.6);
1137 else if (delta > 0.6)
1150 nb0_frames =
FFMIN(nb0_frames, nb_frames);
1160 "*** dropping frame %d from stream %d at ts %"PRId64
"\n",
1163 if (nb_frames > (nb0_frames && ost->
last_dropped) + (nb_frames > nb0_frames)) {
1176 ost->
last_dropped = nb_frames == nb0_frames && next_picture;
1179 for (i = 0; i < nb_frames; i++) {
1185 if (i < nb0_frames && ost->last_frame) {
1188 in_picture = next_picture;
1202 #if FF_API_LAVF_FMT_RAWPICTURE
1221 int forced_keyframe = 0;
1244 forced_keyframe = 1;
1250 ff_dlog(
NULL,
"force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n",
1258 forced_keyframe = 1;
1270 forced_keyframe = 1;
1273 if (forced_keyframe) {
1281 "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
1302 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
1314 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
1319 frame_size = pkt.
size;
1356 return -10.0 * log10(d);
1363 double ti1, bitrate, avg_bitrate;
1378 fprintf(
vstats_file,
"frame= %5d q= %2.1f ", frame_number,
1395 avg_bitrate = (double)(ost->
data_size * 8) / ti1 / 1000.0;
1396 fprintf(
vstats_file,
"s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
1397 (
double)ost->
data_size / 1024, ti1, bitrate, avg_bitrate);
1441 char error[1024] =
"";
1462 "Error in av_buffersink_get_frame_flags(): %s\n",
av_err2str(ret));
1485 float_pts +=
FFSIGN(float_pts) * 1.0 / (1<<17);
1487 filtered_frame->
pts =
1512 "Audio filter graph output is not normalized and encoder does not support parameter changes\n");
1531 uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
1532 uint64_t subtitle_size = 0;
1533 uint64_t data_size = 0;
1534 float percent = -1.0;
1544 default: other_size += ost->
data_size;
break;
1553 if (data_size && total_size>0 && total_size >= data_size)
1554 percent = 100.0 * (total_size - data_size) / data_size;
1556 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: ",
1557 video_size / 1024.0,
1558 audio_size / 1024.0,
1559 subtitle_size / 1024.0,
1560 other_size / 1024.0,
1561 extra_size / 1024.0);
1571 uint64_t total_packets = 0, total_size = 0;
1600 total_packets, total_size);
1605 uint64_t total_packets = 0, total_size = 0;
1634 total_packets, total_size);
1636 if(video_size + data_size + audio_size + subtitle_size + extra_size == 0){
1649 AVBPrint buf_script;
1654 int frame_number, vid, i;
1657 int64_t
pts = INT64_MIN + 1;
1658 static int64_t last_time = -1;
1659 static int qp_histogram[52];
1660 int hours, mins, secs, us;
1664 if (!
print_stats && !is_last_report && !progress_avio)
1667 if (!is_last_report) {
1668 if (last_time == -1) {
1672 if ((cur_time - last_time) < 500000)
1677 t = (cur_time-timer_start) / 1000000.0;
1680 oc = output_files[0]->
ctx;
1683 if (total_size <= 0)
1691 ost = output_streams[i];
1697 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"q=%2.1f ", q);
1698 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1705 fps = t > 1 ? frame_number / t : 0;
1706 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"frame=%5d fps=%3.*f q=%3.1f ",
1707 frame_number, fps < 9.95, fps, q);
1708 av_bprintf(&buf_script,
"frame=%d\n", frame_number);
1710 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1713 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"L");
1719 for (j = 0; j < 32; j++)
1720 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"%X",
av_log2(qp_histogram[j] + 1));
1725 double error, error_sum = 0;
1726 double scale, scale_sum = 0;
1728 char type[3] = {
'Y',
'U',
'V' };
1729 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"PSNR=");
1730 for (j = 0; j < 3; j++) {
1731 if (is_last_report) {
1732 error = enc->
error[j];
1733 scale = enc->
width * enc->
height * 255.0 * 255.0 * frame_number;
1735 error = ost->
error[j];
1742 p =
psnr(error / scale);
1743 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"%c:%2.2f ", type[j], p);
1744 av_bprintf(&buf_script,
"stream_%d_%d_psnr_%c=%2.2f\n",
1747 p =
psnr(error_sum / scale_sum);
1748 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"*:%2.2f ",
psnr(error_sum / scale_sum));
1749 av_bprintf(&buf_script,
"stream_%d_%d_psnr_all=%2.2f\n",
1769 bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
1770 speed = t != 0.0 ? (double)pts /
AV_TIME_BASE / t : -1;
1772 if (total_size < 0)
snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1774 else snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1775 "size=%8.0fkB time=", total_size / 1024.0);
1777 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"-");
1778 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1779 "%02d:%02d:%02d.%02d ", hours, mins, secs,
1783 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"bitrate=N/A");
1786 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"bitrate=%6.1fkbits/s", bitrate);
1787 av_bprintf(&buf_script,
"bitrate=%6.1fkbits/s\n", bitrate);
1790 if (total_size < 0)
av_bprintf(&buf_script,
"total_size=N/A\n");
1791 else av_bprintf(&buf_script,
"total_size=%"PRId64
"\n", total_size);
1792 av_bprintf(&buf_script,
"out_time_ms=%"PRId64
"\n", pts);
1793 av_bprintf(&buf_script,
"out_time=%02d:%02d:%02d.%06d\n",
1794 hours, mins, secs, us);
1797 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
" dup=%d drop=%d",
1803 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
" speed=N/A");
1806 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
" speed=%4.3gx", speed);
1807 av_bprintf(&buf_script,
"speed=%4.3gx\n", speed);
1811 const char end = is_last_report ?
'\n' :
'\r';
1813 fprintf(stderr,
"%s %c", buf, end);
1820 if (progress_avio) {
1822 is_last_report ?
"end" :
"continue");
1824 FFMIN(buf_script.len, buf_script.size - 1));
1827 if (is_last_report) {
1830 "Error closing progress log, loss of information possible: %s\n",
av_err2str(ret));
1854 char error[1024] =
"";
1857 "Finishing stream %d:%d without any data written to it.\n",
1864 if (ifilter->
format < 0) {
1900 #if FF_API_LAVF_FMT_RAWPICTURE
1959 pkt_size = pkt.
size;
2008 ist->
pts < comp_start :
2042 opkt.
dts -= ost_tb_start_time;
2063 &opkt.data, &opkt.size,
2082 #if FF_API_LAVF_FMT_RAWPICTURE
2085 (of->ctx->oformat->flags & AVFMT_RAWPICTURE)) {
2087 int ret =
avpicture_fill(&pict, opkt.data, ost->st->codecpar->format, ost->st->codecpar->width, ost->st->codecpar->height);
2107 char layout_name[256];
2124 if (*got_output || ret<0)
2153 int need_reinit, ret, i;
2168 need_reinit |= ifilter->
width != frame->
width ||
2180 if (need_reinit || !fg->
graph) {
2273 if (ret < 0 && ret !=
AVERROR(EAGAIN))
2288 if (i < ist->nb_filters - 1) {
2300 "Failed to inject frame into filter network: %s\n",
av_err2str(ret));
2322 ret =
decode(avctx, decoded_frame, got_output, pkt);
2335 if (!*got_output || ret < 0)
2353 decoded_frame->
pts = pkt->
pts;
2356 decoded_frame->
pts = ist->
dts;
2363 ist->nb_samples = decoded_frame->nb_samples;
2368 return err < 0 ? err : ret;
2375 int i, ret = 0, err = 0;
2376 int64_t best_effort_timestamp;
2383 if (!eof && pkt && pkt->
size == 0)
2421 "video_delay is larger in decoder than demuxer %d > %d.\n"
2422 "If you want to help, upload a sample "
2423 "of this file to ftp://upload.ffmpeg.org/incoming/ "
2424 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n",
2432 if (*got_output && ret >= 0) {
2436 av_log(NULL,
AV_LOG_DEBUG,
"Frame parameters mismatch context %d,%d,%d != %d,%d,%d\n",
2437 decoded_frame->
width,
2446 if (!*got_output || ret < 0)
2484 "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",
2487 best_effort_timestamp,
2501 return err < 0 ? err : ret;
2510 &subtitle, got_output, pkt);
2514 if (ret < 0 || !*got_output) {
2526 if (end < ist->prev_sub.subtitle.end_display_time) {
2528 "Subtitle duration reduced from %"PRId32
" to %d%s\n",
2530 end <= 0 ?
", dropping it" :
"");
2601 int eof_reached = 0;
2636 int64_t duration_dts = 0;
2637 int64_t duration_pts = 0;
2639 int decode_failed = 0;
2650 ret =
decode_video (ist, repeating ?
NULL : &avpkt, &got_output, &duration_pts, !pkt,
2652 if (!repeating || !pkt || got_output) {
2669 if (duration_pts > 0) {
2680 if (!pkt && ret >= 0)
2693 if (decode_failed) {
2771 return !eof_reached;
2783 if (!output_files[i]->header_written)
2792 avc[j] = output_files[i]->
ctx;
2803 printf(
"SDP:\n%s\n", sdp);
2823 if (
hwaccels[i].pix_fmt == pix_fmt)
2834 for (p = pix_fmts; *p != -1; p++) {
2847 ret = hwaccel->
init(s);
2851 "%s hwaccel requested for input stream #%d:%d, "
2852 "but cannot be initialized.\n", hwaccel->
name,
2891 snprintf(error, error_len,
"Decoder (codec %s) not found for input stream #%d:%d",
2906 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");
2923 snprintf(error, error_len,
"Device setup failed for "
2924 "decoder on input stream #%d:%d : %s",
2934 "Error while opening decoder for input stream "
2957 return FFDIFFSIGN(*(
const int64_t *)a, *(
const int64_t *)b);
2976 "Could not write header for output file #%d "
2977 "(incorrect codec parameters ?): %s\n",
3051 uint32_t codec_tag = par_dst->
codec_tag;
3060 "Error setting up codec context options.\n");
3066 unsigned int codec_tag_tmp;
3092 if (ost->st->duration <= 0 && ist->st->duration > 0)
3093 ost->st->duration =
av_rescale_q(ist->st->duration, ist->st->time_base, ost->st->time_base);
3096 ost->st->disposition = ist->st->disposition;
3098 if (ist->st->nb_side_data) {
3099 for (i = 0; i < ist->st->nb_side_data; i++) {
3106 memcpy(dst_data, sd_src->
data, sd_src->
size);
3110 if (ost->rotate_overridden) {
3119 if (!ost->parser_avctx)
3122 switch (par_dst->codec_type) {
3128 if((par_dst->block_align == 1 || par_dst->block_align == 1152 || par_dst->block_align == 576) && par_dst->codec_id ==
AV_CODEC_ID_MP3)
3129 par_dst->block_align= 0;
3131 par_dst->block_align= 0;
3134 if (ost->frame_aspect_ratio.num) {
3137 (
AVRational){ par_dst->height, par_dst->width });
3139 "with stream copy may produce invalid files\n");
3141 else if (ist->st->sample_aspect_ratio.num)
3142 sar = ist->st->sample_aspect_ratio;
3144 sar = par_src->sample_aspect_ratio;
3145 ost->st->sample_aspect_ratio = par_dst->sample_aspect_ratio = sar;
3146 ost->st->avg_frame_rate = ist->st->avg_frame_rate;
3147 ost->st->r_frame_rate = ist->st->r_frame_rate;
3151 ost->mux_timebase = ist->st->time_base;
3161 int encoder_string_len;
3162 int format_flags = 0;
3184 encoder_string =
av_mallocz(encoder_string_len);
3185 if (!encoder_string)
3191 av_strlcpy(encoder_string,
"Lavc ", encoder_string_len);
3192 av_strlcat(encoder_string, ost->
enc->name, encoder_string_len);
3204 for (p = kf; *p; p++)
3215 for (i = 0; i <
n; i++) {
3216 char *next = strchr(p,
',');
3221 if (!memcmp(p,
"chapters", 8)) {
3230 "Could not allocate forced key frames array.\n");
3328 "about the input framerate is available. Falling "
3329 "back to a default value of 25fps for output stream #%d:%d. Use the -r option "
3330 "if you want a different framerate.\n",
3334 if (ost->
enc->supported_framerates && !ost->
force_fps) {
3366 "Please consider specifying a lower framerate, a different muxer or -vsync 2\n");
3419 if (!enc_ctx->
width) {
3431 ost->mux_timebase = enc_ctx->time_base;
3476 snprintf(error, error_len,
"Device setup failed for "
3477 "encoder on output stream #%d:%d : %s",
3487 "Error while opening encoder for output stream #%d:%d - "
3488 "maybe incorrect parameters such as bit_rate, rate, width or height",
3499 " It takes bits/s as argument, not kbits/s\n");
3504 "Error initializing the output stream codec context.\n");
3524 memcpy(dst_data, sd_src->
data, sd_src->
size);
3553 if (ost->
st->
duration <= 0 && ist && ist->st->duration > 0)
3557 }
else if (ost->stream_copy) {
3572 if (ost->disposition) {
3574 {
"disposition" ,
NULL, 0,
AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit =
"flags" },
3590 static const AVClass class = {
3596 const AVClass *pclass = &
class;
3598 ret =
av_opt_eval_flags(&pclass, &opts[0], ost->disposition, &ost->st->disposition);
3610 ost->initialized = 1;
3621 InputFile *file = input_files[input_index];
3627 "New %s stream %d:%d at pos:%"PRId64
" and DTS:%ss\n",
3636 int ret = 0, i, j, k;
3640 char error[1024] = {0};
3651 if (fg->
inputs[0]->
ist == input_streams[k])
3669 ost = output_streams[i];
3678 if (output_streams[i]->
filter)
3704 oc = output_files[i]->
ctx;
3716 ist = input_streams[i];
3723 if (nb_filtergraphs > 1)
3731 ost = output_streams[i];
3743 if (nb_filtergraphs > 1)
3765 const char *decoder_name =
"?";
3766 const char *in_codec_name =
"?";
3767 const char *encoder_name =
"?";
3768 const char *out_codec_name =
"?";
3772 decoder_name = in_codec->
name;
3775 in_codec_name = desc->
name;
3776 if (!strcmp(decoder_name, in_codec_name))
3777 decoder_name =
"native";
3781 encoder_name = out_codec->
name;
3784 out_codec_name = desc->
name;
3785 if (!strcmp(encoder_name, out_codec_name))
3786 encoder_name =
"native";
3790 in_codec_name, decoder_name,
3791 out_codec_name, encoder_name);
3840 int64_t opts_min = INT64_MAX;
3849 av_log(
NULL,
AV_LOG_DEBUG,
"cur_dts is invalid (this is harmless if it occurs once at the start per stream)\n");
3854 if (!ost->
finished && opts < opts_min) {
3866 if (tcgetattr(0, &tty) == 0) {
3867 if (on) tty.c_lflag |=
ECHO;
3868 else tty.c_lflag &= ~
ECHO;
3869 tcsetattr(0, TCSANOW, &tty);
3877 static int64_t last_time;
3900 if (key ==
'c' || key ==
'C'){
3904 fprintf(stderr,
"\nEnter command: <target>|all <time>|-1 <command>[ <argument>]\n");
3907 while ((k =
read_key()) !=
'\n' && k !=
'\r' && i <
sizeof(buf)-1)
3912 fprintf(stderr,
"\n");
3914 (n = sscanf(buf,
"%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {
3916 target, time, command, arg);
3923 fprintf(stderr,
"Command reply for stream %d: ret:%d res:\n%s", i, ret, buf);
3924 }
else if (key ==
'c') {
3925 fprintf(stderr,
"Queuing commands only on filters supporting the specific command is unsupported\n");
3930 fprintf(stderr,
"Queuing command failed with error %s\n",
av_err2str(ret));
3936 "Parse error, at least 3 arguments were expected, "
3937 "only %d given in string '%s'\n", n, buf);
3940 if (key ==
'd' || key ==
'D'){
3943 debug = input_streams[0]->
st->codec->debug<<1;
3944 if(!debug) debug = 1;
3956 while ((k =
read_key()) !=
'\n' && k !=
'\r' && i <
sizeof(buf)-1)
3961 fprintf(stderr,
"\n");
3962 if (k <= 0 || sscanf(buf,
"%d", &debug)!=1)
3963 fprintf(stderr,
"error parsing debug value\n");
3966 input_streams[i]->
st->codec->debug = debug;
3973 fprintf(stderr,
"debug=%d\n", debug);
3976 fprintf(stderr,
"key function\n"
3977 "? show this help\n"
3978 "+ increase verbosity\n"
3979 "- decrease verbosity\n"
3980 "c Send command to first matching filter supporting it\n"
3981 "C Send/Queue command to all matching filters\n"
3982 "D cycle through available debug modes\n"
3983 "h dump packets/hex press to cycle through the 3 states\n"
3985 "s Show QP histogram\n"
3992 static void *input_thread(
void *
arg)
4011 if (flags && ret ==
AVERROR(EAGAIN)) {
4015 "Thread message queue blocking; consider raising the "
4016 "thread_queue_size option (current value: %d)\n",
4017 f->thread_queue_size);
4022 "Unable to send packet to main thread: %s\n",
4033 static void free_input_threads(
void)
4041 if (!f || !f->in_thread_queue)
4053 static int init_input_threads(
void)
4057 if (nb_input_files == 1)
4065 f->non_blocking = 1;
4067 f->thread_queue_size,
sizeof(
AVPacket));
4072 av_log(
NULL,
AV_LOG_ERROR,
"pthread_create failed: %s. Try to increase `ulimit -v` or decrease `ulimit -s`.\n", strerror(ret));
4102 if (nb_input_files > 1)
4103 return get_input_packet_mt(f, pkt);
4112 if (output_streams[i]->unavailable)
4121 input_files[i]->eagain = 0;
4123 output_streams[i]->unavailable = 0;
4134 return tmp_time_base;
4137 ret =
av_compare_ts(*duration, time_base, tmp, tmp_time_base);
4140 return tmp_time_base;
4150 int i, ret, has_audio = 0;
4158 ist = input_streams[ifile->
ist_index + i];
4175 ist = input_streams[ifile->
ist_index + i];
4190 }
else duration = 1;
4201 if (ifile->
loop > 0)
4231 if (ret < 0 && ifile->
loop) {
4248 ist = input_streams[ifile->
ist_index + i];
4279 goto discard_packet;
4288 goto discard_packet;
4297 "next_dts:%s next_dts_time:%s next_pts:%s next_pts_time:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%s off_time:%s\n",
4308 int64_t stime, stime2;
4315 int64_t new_start_time = INT64_MAX;
4358 memcpy(dst_data, src_sd->
data, src_sd->
size);
4382 "Inter stream timestamp discontinuity %"PRId64
", new offset= %"PRId64
"\n",
4412 "timestamp discontinuity %"PRId64
", new offset= %"PRId64
"\n",
4440 av_log(
NULL,
AV_LOG_INFO,
"demuxer+ffmpeg -> ist_index:%d type:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s off:%s off_time:%s\n",
4468 int nb_requests, nb_requests_max = 0;
4486 for (i = 0; i < graph->
nb_inputs; i++) {
4487 ifilter = graph->
inputs[i];
4493 if (nb_requests > nb_requests_max) {
4494 nb_requests_max = nb_requests;
4540 char error[1024] = {0};
4552 }
else if (ost->
filter) {
4592 int64_t timer_start;
4593 int64_t total_packets_written = 0;
4606 if ((ret = init_input_threads()) < 0)
4637 free_input_threads();
4642 ist = input_streams[i];
4653 os = output_files[i]->
ctx;
4654 if (!output_files[i]->header_written) {
4656 "Nothing was written into output file %d (%s), because "
4657 "at least one of its streams received no packets.\n",
4673 ost = output_streams[i];