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);
573 free_input_threads();
599 "Error closing vstats file, loss of information possible: %s\n",
668 ost2->
finished |= ost == ost2 ? this_stream : others;
702 "Too many packets buffered for output stream %d:%d.\n",
750 av_log(s,
AV_LOG_WARNING,
"Invalid DTS: %"PRId64
" PTS: %"PRId64
" in output stream %d:%d, replacing by guess\n",
763 if (pkt->
dts < max) {
765 av_log(s, loglevel,
"Non-monotonous DTS in output stream "
766 "%d:%d; previous: %"PRId64
", current: %"PRId64
"; ",
772 av_log(s, loglevel,
"changing to %"PRId64
". This may result "
773 "in incorrect timestamps in the output file.\n",
790 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s size:%d\n",
853 if (idx < ost->nb_bitstream_filters) {
917 "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
939 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
957 int subtitle_out_max_size = 1024 * 1024;
958 int subtitle_out_size, nb, i;
992 for (i = 0; i < nb; i++) {
993 unsigned save_num_rects = sub->
num_rects;
1010 subtitle_out_max_size, sub);
1013 if (subtitle_out_size < 0) {
1020 pkt.
size = subtitle_out_size;
1041 int ret, format_video_sync;
1046 int nb_frames, nb0_frames, i;
1047 double delta, delta0;
1057 if (frame_rate.
num > 0 && frame_rate.
den > 0)
1071 if (!next_picture) {
1106 if (delta0 < -0.6) {
1115 switch (format_video_sync) {
1127 }
else if (delta < -1.1)
1129 else if (delta > 1.1) {
1130 nb_frames =
lrintf(delta);
1132 nb0_frames =
lrintf(delta0 - 0.6);
1138 else if (delta > 0.6)
1151 nb0_frames =
FFMIN(nb0_frames, nb_frames);
1161 "*** dropping frame %d from stream %d at ts %"PRId64
"\n",
1164 if (nb_frames > (nb0_frames && ost->
last_dropped) + (nb_frames > nb0_frames)) {
1177 ost->
last_dropped = nb_frames == nb0_frames && next_picture;
1180 for (i = 0; i < nb_frames; i++) {
1186 if (i < nb0_frames && ost->last_frame) {
1189 in_picture = next_picture;
1203 #if FF_API_LAVF_FMT_RAWPICTURE
1222 int forced_keyframe = 0;
1245 forced_keyframe = 1;
1251 ff_dlog(
NULL,
"force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n",
1259 forced_keyframe = 1;
1271 forced_keyframe = 1;
1274 if (forced_keyframe) {
1282 "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
1303 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
1315 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
1320 frame_size = pkt.
size;
1357 return -10.0 * log10(d);
1364 double ti1, bitrate, avg_bitrate;
1379 fprintf(
vstats_file,
"frame= %5d q= %2.1f ", frame_number,
1396 avg_bitrate = (double)(ost->
data_size * 8) / ti1 / 1000.0;
1397 fprintf(
vstats_file,
"s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
1398 (
double)ost->
data_size / 1024, ti1, bitrate, avg_bitrate);
1442 char error[1024] =
"";
1463 "Error in av_buffersink_get_frame_flags(): %s\n",
av_err2str(ret));
1486 float_pts +=
FFSIGN(float_pts) * 1.0 / (1<<17);
1488 filtered_frame->
pts =
1513 "Audio filter graph output is not normalized and encoder does not support parameter changes\n");
1532 uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
1533 uint64_t subtitle_size = 0;
1534 uint64_t data_size = 0;
1535 float percent = -1.0;
1545 default: other_size += ost->
data_size;
break;
1554 if (data_size && total_size>0 && total_size >= data_size)
1555 percent = 100.0 * (total_size - data_size) / data_size;
1557 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: ",
1558 video_size / 1024.0,
1559 audio_size / 1024.0,
1560 subtitle_size / 1024.0,
1561 other_size / 1024.0,
1562 extra_size / 1024.0);
1572 uint64_t total_packets = 0, total_size = 0;
1601 total_packets, total_size);
1606 uint64_t total_packets = 0, total_size = 0;
1635 total_packets, total_size);
1637 if(video_size + data_size + audio_size + subtitle_size + extra_size == 0){
1650 AVBPrint buf_script;
1655 int frame_number, vid, i;
1658 int64_t
pts = INT64_MIN + 1;
1659 static int64_t last_time = -1;
1660 static int qp_histogram[52];
1661 int hours, mins, secs, us;
1665 if (!
print_stats && !is_last_report && !progress_avio)
1668 if (!is_last_report) {
1669 if (last_time == -1) {
1673 if ((cur_time - last_time) < 500000)
1678 t = (cur_time-timer_start) / 1000000.0;
1681 oc = output_files[0]->
ctx;
1684 if (total_size <= 0)
1692 ost = output_streams[i];
1698 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"q=%2.1f ", q);
1699 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1706 fps = t > 1 ? frame_number / t : 0;
1707 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"frame=%5d fps=%3.*f q=%3.1f ",
1708 frame_number, fps < 9.95, fps, q);
1709 av_bprintf(&buf_script,
"frame=%d\n", frame_number);
1711 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1714 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"L");
1720 for (j = 0; j < 32; j++)
1721 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"%X",
av_log2(qp_histogram[j] + 1));
1726 double error, error_sum = 0;
1727 double scale, scale_sum = 0;
1729 char type[3] = {
'Y',
'U',
'V' };
1730 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"PSNR=");
1731 for (j = 0; j < 3; j++) {
1732 if (is_last_report) {
1733 error = enc->
error[j];
1734 scale = enc->
width * enc->
height * 255.0 * 255.0 * frame_number;
1736 error = ost->
error[j];
1743 p =
psnr(error / scale);
1744 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"%c:%2.2f ", type[j], p);
1745 av_bprintf(&buf_script,
"stream_%d_%d_psnr_%c=%2.2f\n",
1748 p =
psnr(error_sum / scale_sum);
1749 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"*:%2.2f ",
psnr(error_sum / scale_sum));
1750 av_bprintf(&buf_script,
"stream_%d_%d_psnr_all=%2.2f\n",
1770 bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
1771 speed = t != 0.0 ? (double)pts /
AV_TIME_BASE / t : -1;
1773 if (total_size < 0)
snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1775 else snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1776 "size=%8.0fkB time=", total_size / 1024.0);
1778 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"-");
1779 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1780 "%02d:%02d:%02d.%02d ", hours, mins, secs,
1784 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"bitrate=N/A");
1787 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"bitrate=%6.1fkbits/s", bitrate);
1788 av_bprintf(&buf_script,
"bitrate=%6.1fkbits/s\n", bitrate);
1791 if (total_size < 0)
av_bprintf(&buf_script,
"total_size=N/A\n");
1792 else av_bprintf(&buf_script,
"total_size=%"PRId64
"\n", total_size);
1793 av_bprintf(&buf_script,
"out_time_ms=%"PRId64
"\n", pts);
1794 av_bprintf(&buf_script,
"out_time=%02d:%02d:%02d.%06d\n",
1795 hours, mins, secs, us);
1798 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
" dup=%d drop=%d",
1804 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
" speed=N/A");
1807 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
" speed=%4.3gx", speed);
1808 av_bprintf(&buf_script,
"speed=%4.3gx\n", speed);
1812 const char end = is_last_report ?
'\n' :
'\r';
1814 fprintf(stderr,
"%s %c", buf, end);
1821 if (progress_avio) {
1823 is_last_report ?
"end" :
"continue");
1825 FFMIN(buf_script.len, buf_script.size - 1));
1828 if (is_last_report) {
1831 "Error closing progress log, loss of information possible: %s\n",
av_err2str(ret));
1855 char error[1024] =
"";
1858 "Finishing stream %d:%d without any data written to it.\n",
1865 if (ifilter->
format < 0) {
1901 #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) {
2272 if (ret < 0 && ret !=
AVERROR(EAGAIN))
2287 if (i < ist->nb_filters - 1) {
2299 "Failed to inject frame into filter network: %s\n",
av_err2str(ret));
2321 ret =
decode(avctx, decoded_frame, got_output, pkt);
2334 if (!*got_output || ret < 0)
2352 decoded_frame->
pts = pkt->
pts;
2355 decoded_frame->
pts = ist->
dts;
2362 ist->nb_samples = decoded_frame->nb_samples;
2367 return err < 0 ? err : ret;
2374 int i, ret = 0, err = 0;
2375 int64_t best_effort_timestamp;
2382 if (!eof && pkt && pkt->
size == 0)
2420 "video_delay is larger in decoder than demuxer %d > %d.\n"
2421 "If you want to help, upload a sample "
2422 "of this file to ftp://upload.ffmpeg.org/incoming/ "
2423 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n",
2431 if (*got_output && ret >= 0) {
2435 av_log(NULL,
AV_LOG_DEBUG,
"Frame parameters mismatch context %d,%d,%d != %d,%d,%d\n",
2436 decoded_frame->
width,
2445 if (!*got_output || ret < 0)
2482 "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",
2485 best_effort_timestamp,
2499 return err < 0 ? err : ret;
2508 &subtitle, got_output, pkt);
2512 if (ret < 0 || !*got_output) {
2524 if (end < ist->prev_sub.subtitle.end_display_time) {
2526 "Subtitle duration reduced from %"PRId32
" to %d%s\n",
2528 end <= 0 ?
", dropping it" :
"");
2595 int eof_reached = 0;
2632 int decode_failed = 0;
2645 if (!repeating || !pkt || got_output) {
2668 if (!pkt && ret >= 0)
2681 if (decode_failed) {
2759 return !eof_reached;
2771 if (!output_files[i]->header_written)
2780 avc[j] = output_files[i]->
ctx;
2791 printf(
"SDP:\n%s\n", sdp);
2811 if (
hwaccels[i].pix_fmt == pix_fmt)
2822 for (p = pix_fmts; *p != -1; p++) {
2835 ret = hwaccel->
init(s);
2839 "%s hwaccel requested for input stream #%d:%d, "
2840 "but cannot be initialized.\n", hwaccel->
name,
2879 snprintf(error, error_len,
"Decoder (codec %s) not found for input stream #%d:%d",
2894 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");
2910 "Error while opening decoder for input stream "
2933 return FFDIFFSIGN(*(
const int64_t *)a, *(
const int64_t *)b);
2952 "Could not write header for output file #%d "
2953 "(incorrect codec parameters ?): %s\n",
3027 uint32_t codec_tag = par_dst->
codec_tag;
3036 "Error setting up codec context options.\n");
3042 unsigned int codec_tag_tmp;
3068 if (ost->st->duration <= 0 && ist->st->duration > 0)
3069 ost->st->duration =
av_rescale_q(ist->st->duration, ist->st->time_base, ost->st->time_base);
3072 ost->st->disposition = ist->st->disposition;
3074 if (ist->st->nb_side_data) {
3076 sizeof(*ist->st->side_data));
3077 if (!ost->st->side_data)
3080 ost->st->nb_side_data = 0;
3081 for (i = 0; i < ist->st->nb_side_data; i++) {
3091 ost->st->nb_side_data++;
3095 if (ost->rotate_overridden) {
3104 if (!ost->parser_avctx)
3107 switch (par_dst->codec_type) {
3113 if((par_dst->block_align == 1 || par_dst->block_align == 1152 || par_dst->block_align == 576) && par_dst->codec_id ==
AV_CODEC_ID_MP3)
3114 par_dst->block_align= 0;
3116 par_dst->block_align= 0;
3119 if (ost->frame_aspect_ratio.num) {
3122 (
AVRational){ par_dst->height, par_dst->width });
3124 "with stream copy may produce invalid files\n");
3126 else if (ist->st->sample_aspect_ratio.num)
3127 sar = ist->st->sample_aspect_ratio;
3129 sar = par_src->sample_aspect_ratio;
3130 ost->st->sample_aspect_ratio = par_dst->sample_aspect_ratio = sar;
3131 ost->st->avg_frame_rate = ist->st->avg_frame_rate;
3132 ost->st->r_frame_rate = ist->st->r_frame_rate;
3136 ost->mux_timebase = ist->st->time_base;
3146 int encoder_string_len;
3147 int format_flags = 0;
3169 encoder_string =
av_mallocz(encoder_string_len);
3170 if (!encoder_string)
3176 av_strlcpy(encoder_string,
"Lavc ", encoder_string_len);
3177 av_strlcat(encoder_string, ost->
enc->name, encoder_string_len);
3189 for (p = kf; *p; p++)
3200 for (i = 0; i <
n; i++) {
3201 char *next = strchr(p,
',');
3206 if (!memcmp(p,
"chapters", 8)) {
3215 "Could not allocate forced key frames array.\n");
3289 "about the input framerate is available. Falling "
3290 "back to a default value of 25fps for output stream #%d:%d. Use the -r option "
3291 "if you want a different framerate.\n",
3295 if (ost->
enc->supported_framerates && !ost->
force_fps) {
3324 "Please consider specifying a lower framerate, a different muxer or -vsync 2\n");
3337 if (!strncmp(ost->
enc->name,
"libx264", 7) &&
3341 "No pixel format specified, %s for H.264 encoding chosen.\n"
3342 "Use -pix_fmt yuv420p for compatibility with outdated media players.\n",
3344 if (!strncmp(ost->
enc->name,
"mpeg2video", 10) &&
3348 "No pixel format specified, %s for MPEG-2 encoding chosen.\n"
3349 "Use -pix_fmt yuv420p for compatibility with outdated media players.\n",
3390 if (!enc_ctx->
width) {
3402 ost->mux_timebase = enc_ctx->time_base;
3450 "Error while opening encoder for output stream #%d:%d - "
3451 "maybe incorrect parameters such as bit_rate, rate, width or height",
3462 " It takes bits/s as argument, not kbits/s\n");
3467 "Error initializing the output stream codec context.\n");
3524 if (ost->
st->
duration <= 0 && ist && ist->st->duration > 0)
3528 }
else if (ost->stream_copy) {
3543 if (ost->disposition) {
3545 {
"disposition" ,
NULL, 0,
AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit =
"flags" },
3561 static const AVClass class = {
3567 const AVClass *pclass = &
class;
3569 ret =
av_opt_eval_flags(&pclass, &opts[0], ost->disposition, &ost->st->disposition);
3581 ost->initialized = 1;
3592 InputFile *file = input_files[input_index];
3598 "New %s stream %d:%d at pos:%"PRId64
" and DTS:%ss\n",
3607 int ret = 0, i, j, k;
3611 char error[1024] = {0};
3622 if (fg->
inputs[0]->
ist == input_streams[k])
3640 ost = output_streams[i];
3649 if (output_streams[i]->
filter)
3675 oc = output_files[i]->
ctx;
3687 ist = input_streams[i];
3694 if (nb_filtergraphs > 1)
3702 ost = output_streams[i];
3714 if (nb_filtergraphs > 1)
3736 const char *decoder_name =
"?";
3737 const char *in_codec_name =
"?";
3738 const char *encoder_name =
"?";
3739 const char *out_codec_name =
"?";
3743 decoder_name = in_codec->
name;
3746 in_codec_name = desc->
name;
3747 if (!strcmp(decoder_name, in_codec_name))
3748 decoder_name =
"native";
3752 encoder_name = out_codec->
name;
3755 out_codec_name = desc->
name;
3756 if (!strcmp(encoder_name, out_codec_name))
3757 encoder_name =
"native";
3761 in_codec_name, decoder_name,
3762 out_codec_name, encoder_name);
3811 int64_t opts_min = INT64_MAX;
3820 av_log(
NULL,
AV_LOG_DEBUG,
"cur_dts is invalid (this is harmless if it occurs once at the start per stream)\n");
3825 if (!ost->
finished && opts < opts_min) {
3837 if (tcgetattr(0, &tty) == 0) {
3838 if (on) tty.c_lflag |=
ECHO;
3839 else tty.c_lflag &= ~
ECHO;
3840 tcsetattr(0, TCSANOW, &tty);
3848 static int64_t last_time;
3871 if (key ==
'c' || key ==
'C'){
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) {
3887 target, time, command, arg);
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'){
3914 debug = input_streams[0]->
st->codec->debug<<1;
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");
3933 input_streams[i]->
st->codec->debug = debug;
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)
3978 if (flags && ret ==
AVERROR(EAGAIN)) {
3982 "Thread message queue blocking; consider raising the "
3983 "thread_queue_size option (current value: %d)\n",
3984 f->thread_queue_size);
3989 "Unable to send packet to main thread: %s\n",
4000 static void free_input_threads(
void)
4008 if (!f || !f->in_thread_queue)
4020 static int init_input_threads(
void)
4024 if (nb_input_files == 1)
4032 f->non_blocking = 1;
4034 f->thread_queue_size,
sizeof(
AVPacket));
4039 av_log(
NULL,
AV_LOG_ERROR,
"pthread_create failed: %s. Try to increase `ulimit -v` or decrease `ulimit -s`.\n", strerror(ret));
4069 if (nb_input_files > 1)
4070 return get_input_packet_mt(f, pkt);
4079 if (output_streams[i]->unavailable)
4088 input_files[i]->eagain = 0;
4090 output_streams[i]->unavailable = 0;
4101 return tmp_time_base;
4104 ret =
av_compare_ts(*duration, time_base, tmp, tmp_time_base);
4107 return tmp_time_base;
4117 int i, ret, has_audio = 0;
4125 ist = input_streams[ifile->
ist_index + i];
4142 ist = input_streams[ifile->
ist_index + i];
4157 }
else duration = 1;
4168 if (ifile->
loop > 0)
4198 if (ret < 0 && ifile->
loop) {
4215 ist = input_streams[ifile->
ist_index + i];
4246 goto discard_packet;
4255 goto discard_packet;
4264 "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",
4275 int64_t stime, stime2;
4282 int64_t new_start_time = INT64_MAX;
4325 memcpy(dst_data, src_sd->
data, src_sd->
size);
4349 "Inter stream timestamp discontinuity %"PRId64
", new offset= %"PRId64
"\n",
4379 "timestamp discontinuity %"PRId64
", new offset= %"PRId64
"\n",
4407 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",
4435 int nb_requests, nb_requests_max = 0;
4453 for (i = 0; i < graph->
nb_inputs; i++) {
4454 ifilter = graph->
inputs[i];
4460 if (nb_requests > nb_requests_max) {
4461 nb_requests_max = nb_requests;
4510 }
else if (ost->
filter) {
4550 int64_t timer_start;
4551 int64_t total_packets_written = 0;
4564 if ((ret = init_input_threads()) < 0)
4595 free_input_threads();
4600 ist = input_streams[i];
4611 os = output_files[i]->
ctx;
4612 if (!output_files[i]->header_written) {
4614 "Nothing was written into output file %d (%s), because "
4615 "at least one of its streams received no packets.\n",
4631 ost = output_streams[i];
4645 ist = input_streams[i];