69 #if HAVE_SYS_RESOURCE_H
71 #include <sys/types.h>
72 #include <sys/resource.h>
73 #elif HAVE_GETPROCESSTIMES
76 #if HAVE_GETPROCESSMEMORYINFO
80 #if HAVE_SETCONSOLECTRLHANDLER
86 #include <sys/select.h>
91 #include <sys/ioctl.h>
153 static struct termios oldtty;
154 static int restore_tty;
158 static void free_input_threads(
void);
184 uint32_t *pal, *dst2;
192 if (r->
x < 0 || r->
x + r->
w > w || r->
y < 0 || r->
y + r->
h > h) {
194 r->
x, r->
y, r->
w, r->
h, w, h
199 dst += r->
y * dst_linesize + r->
x * 4;
202 for (y = 0; y < r->
h; y++) {
203 dst2 = (uint32_t *)dst;
205 for (x = 0; x < r->
w; x++)
206 *(dst2++) = pal[*(src2++)];
231 int64_t
pts, end_pts;
248 "Impossible to get a blank canvas.\n");
251 dst = frame->
data [0];
253 for (i = 0; i < num_rects; i++)
277 if (pts2 <= ist2->sub2video.last_pts)
281 for (j = 0, nb_reqs = 0; j < ist2->
nb_filters; j++)
304 tcsetattr (0, TCSANOW, &oldtty);
327 write(2,
"Received > 3 system signals, hard exiting\n",
328 strlen(
"Received > 3 system signals, hard exiting\n"));
334 #if HAVE_SETCONSOLECTRLHANDLER
335 static BOOL WINAPI CtrlHandler(
DWORD fdwCtrlType)
342 case CTRL_BREAK_EVENT:
346 case CTRL_CLOSE_EVENT:
347 case CTRL_LOGOFF_EVENT:
348 case CTRL_SHUTDOWN_EVENT:
371 if (tcgetattr (0, &tty) == 0) {
375 tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
376 |INLCR|IGNCR|ICRNL|IXON);
377 tty.c_oflag |= OPOST;
378 tty.c_lflag &= ~(
ECHO|ECHONL|ICANON|IEXTEN);
379 tty.c_cflag &= ~(CSIZE|PARENB);
384 tcsetattr (0, TCSANOW, &tty);
395 #if HAVE_SETCONSOLECTRLHANDLER
396 SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler,
TRUE);
413 n = select(1, &rfds,
NULL,
NULL, &tv);
422 # if HAVE_PEEKNAMEDPIPE
424 static HANDLE input_handle;
427 input_handle = GetStdHandle(STD_INPUT_HANDLE);
428 is_pipe = !GetConsoleMode(input_handle, &dw);
433 if (!PeekNamedPipe(input_handle,
NULL, 0,
NULL, &nchars,
NULL)) {
537 free_input_threads();
562 "Error closing vstats file, loss of information possible: %s\n",
631 ost2->
finished |= ost == ost2 ? this_stream : others;
702 av_log(s,
AV_LOG_WARNING,
"Invalid DTS: %"PRId64
" PTS: %"PRId64
" in output stream %d:%d, replacing by guess\n",
715 if (pkt->
dts < max) {
717 av_log(s, loglevel,
"Non-monotonous DTS in output stream "
718 "%d:%d; previous: %"PRId64
", current: %"PRId64
"; ",
724 av_log(s, loglevel,
"changing to %"PRId64
". This may result "
725 "in incorrect timestamps in the output file.\n",
742 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s size:%d\n",
807 "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
823 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
837 int subtitle_out_max_size = 1024 * 1024;
838 int subtitle_out_size, nb, i;
872 for (i = 0; i < nb; i++) {
873 unsigned save_num_rects = sub->
num_rects;
890 subtitle_out_max_size, sub);
893 if (subtitle_out_size < 0) {
900 pkt.
size = subtitle_out_size;
907 pkt.
pts += 90 * sub->start_display_time;
909 pkt.
pts += 90 * sub->end_display_time;
921 int ret, format_video_sync;
925 int nb_frames, nb0_frames, i;
926 double delta, delta0;
994 switch (format_video_sync) {
1006 }
else if (delta < -1.1)
1008 else if (delta > 1.1) {
1009 nb_frames =
lrintf(delta);
1011 nb0_frames =
lrintf(delta0 - 0.6);
1017 else if (delta > 0.6)
1030 nb0_frames =
FFMIN(nb0_frames, nb_frames);
1040 "*** dropping frame %d from stream %d at ts %"PRId64
"\n",
1043 if (nb_frames > (nb0_frames && ost->
last_dropped) + (nb_frames > nb0_frames)) {
1052 ost->
last_dropped = nb_frames == nb0_frames && next_picture;
1055 for (i = 0; i < nb_frames; i++) {
1061 if (i < nb0_frames && ost->last_frame) {
1064 in_picture = next_picture;
1078 #if FF_API_LAVF_FMT_RAWPICTURE
1097 int got_packet, forced_keyframe = 0;
1120 forced_keyframe = 1;
1126 ff_dlog(
NULL,
"force_key_frame: n:%f n_forced:%f prev_forced_n:%f t:%f prev_forced_t:%f -> res:%f\n",
1134 forced_keyframe = 1;
1146 forced_keyframe = 1;
1149 if (forced_keyframe) {
1157 "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
1174 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
1186 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s\n",
1191 frame_size = pkt.
size;
1223 return -10.0 * log10(d);
1230 double ti1, bitrate, avg_bitrate;
1244 fprintf(
vstats_file,
"frame= %5d q= %2.1f ", frame_number,
1257 avg_bitrate = (double)(ost->
data_size * 8) / ti1 / 1000.0;
1258 fprintf(
vstats_file,
"s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
1259 (
double)ost->
data_size / 1024, ti1, bitrate, avg_bitrate);
1312 "Error in av_buffersink_get_frame_flags(): %s\n",
av_err2str(ret));
1334 float_pts +=
FFSIGN(float_pts) * 1.0 / (1<<17);
1336 filtered_frame->
pts =
1361 "Audio filter graph output is not normalized and encoder does not support parameter changes\n");
1380 uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
1381 uint64_t subtitle_size = 0;
1382 uint64_t data_size = 0;
1383 float percent = -1.0;
1393 default: other_size += ost->
data_size;
break;
1402 if (data_size && total_size>0 && total_size >= data_size)
1403 percent = 100.0 * (total_size - data_size) / data_size;
1405 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: ",
1406 video_size / 1024.0,
1407 audio_size / 1024.0,
1408 subtitle_size / 1024.0,
1409 other_size / 1024.0,
1410 extra_size / 1024.0);
1420 uint64_t total_packets = 0, total_size = 0;
1449 total_packets, total_size);
1454 uint64_t total_packets = 0, total_size = 0;
1483 total_packets, total_size);
1485 if(video_size + data_size + audio_size + subtitle_size + extra_size == 0){
1498 AVBPrint buf_script;
1503 int frame_number, vid, i;
1506 int64_t
pts = INT64_MIN + 1;
1507 static int64_t last_time = -1;
1508 static int qp_histogram[52];
1509 int hours, mins, secs, us;
1513 if (!
print_stats && !is_last_report && !progress_avio)
1516 if (!is_last_report) {
1517 if (last_time == -1) {
1521 if ((cur_time - last_time) < 500000)
1526 t = (cur_time-timer_start) / 1000000.0;
1529 oc = output_files[0]->
ctx;
1532 if (total_size <= 0)
1540 ost = output_streams[i];
1546 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"q=%2.1f ", q);
1547 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1554 fps = t > 1 ? frame_number / t : 0;
1555 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"frame=%5d fps=%3.*f q=%3.1f ",
1556 frame_number, fps < 9.95, fps, q);
1557 av_bprintf(&buf_script,
"frame=%d\n", frame_number);
1559 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1562 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"L");
1568 for (j = 0; j < 32; j++)
1569 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"%X",
av_log2(qp_histogram[j] + 1));
1574 double error, error_sum = 0;
1575 double scale, scale_sum = 0;
1577 char type[3] = {
'Y',
'U',
'V' };
1578 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"PSNR=");
1579 for (j = 0; j < 3; j++) {
1580 if (is_last_report) {
1581 error = enc->
error[j];
1582 scale = enc->
width * enc->
height * 255.0 * 255.0 * frame_number;
1584 error = ost->
error[j];
1591 p =
psnr(error / scale);
1592 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"%c:%2.2f ", type[j], p);
1593 av_bprintf(&buf_script,
"stream_%d_%d_psnr_%c=%2.2f\n",
1596 p =
psnr(error_sum / scale_sum);
1597 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"*:%2.2f ",
psnr(error_sum / scale_sum));
1598 av_bprintf(&buf_script,
"stream_%d_%d_psnr_all=%2.2f\n",
1618 bitrate = pts && total_size >= 0 ? total_size * 8 / (pts / 1000.0) : -1;
1619 speed = t != 0.0 ? (double)pts /
AV_TIME_BASE / t : -1;
1621 if (total_size < 0)
snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1623 else snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1624 "size=%8.0fkB time=", total_size / 1024.0);
1626 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"-");
1627 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
1628 "%02d:%02d:%02d.%02d ", hours, mins, secs,
1632 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"bitrate=N/A");
1635 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
"bitrate=%6.1fkbits/s", bitrate);
1636 av_bprintf(&buf_script,
"bitrate=%6.1fkbits/s\n", bitrate);
1639 if (total_size < 0)
av_bprintf(&buf_script,
"total_size=N/A\n");
1640 else av_bprintf(&buf_script,
"total_size=%"PRId64
"\n", total_size);
1641 av_bprintf(&buf_script,
"out_time_ms=%"PRId64
"\n", pts);
1642 av_bprintf(&buf_script,
"out_time=%02d:%02d:%02d.%06d\n",
1643 hours, mins, secs, us);
1646 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
" dup=%d drop=%d",
1652 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
" speed=N/A");
1655 snprintf(buf + strlen(buf),
sizeof(buf) - strlen(buf),
" speed=%4.3gx", speed);
1656 av_bprintf(&buf_script,
"speed=%4.3gx\n", speed);
1660 const char end = is_last_report ?
'\n' :
'\r';
1662 fprintf(stderr,
"%s %c", buf, end);
1669 if (progress_avio) {
1671 is_last_report ?
"end" :
"continue");
1673 FFMIN(buf_script.len, buf_script.size - 1));
1676 if (is_last_report) {
1679 "Error closing progress log, loss of information possible: %s\n",
av_err2str(ret));
1695 int stop_encoding = 0;
1702 #if FF_API_LAVF_FMT_RAWPICTURE
1733 ret = encode(enc, &pkt,
NULL, &got_packet);
1753 pkt_size = pkt.
size;
1806 ist->
pts < comp_start :
1840 opkt.
dts -= ost_tb_start_time;
1860 &opkt.data, &opkt.size,
1879 #if FF_API_LAVF_FMT_RAWPICTURE
1882 (of->ctx->oformat->flags & AVFMT_RAWPICTURE)) {
1884 int ret =
avpicture_fill(&pict, opkt.data, ost->st->codec->pix_fmt, ost->st->codec->width, ost->st->codec->height);
1904 char layout_name[256];
1921 if (*got_output || ret<0)
1939 int i, ret, err = 0, resample_changed;
1959 if (!*got_output || ret < 0)
1978 if (resample_changed) {
1979 char layout1[64], layout2[64];
1983 "layout for Input Stream #%d.%d\n", ist->
file_index,
1995 "Input stream #%d:%d frame changed from rate:%d fmt:%s ch:%d chl:%s to rate:%d fmt:%s ch:%d chl:%s\n",
2026 decoded_frame->
pts = pkt->
pts;
2029 decoded_frame->
pts = ist->
dts;
2037 ist->nb_samples = decoded_frame->nb_samples;
2038 for (i = 0; i < ist->nb_filters; i++) {
2039 if (i < ist->nb_filters - 1) {
2040 f = ist->filter_frame;
2057 return err < 0 ? err : ret;
2063 int i, ret = 0, err = 0, resample_changed;
2064 int64_t best_effort_timestamp;
2076 decoded_frame, got_output, pkt);
2086 "has_b_frames is larger in decoder than demuxer %d > %d.\n"
2087 "If you want to help, upload a sample "
2088 "of this file to ftp://upload.ffmpeg.org/incoming/ "
2089 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)",
2096 if (*got_output && ret >= 0) {
2101 decoded_frame->
width,
2110 if (!*got_output || ret < 0)
2131 "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",
2134 best_effort_timestamp,
2148 if (resample_changed) {
2150 "Input stream #%d:%d frame changed from size:%dx%d fmt:%s to size:%dx%d fmt:%s\n",
2170 if (!frame_sample_aspect->
num)
2173 if (i < ist->nb_filters - 1) {
2183 }
else if (ret < 0) {
2185 "Failed to inject frame into filter network: %s\n",
av_err2str(ret));
2193 return err < 0 ? err : ret;
2200 &subtitle, got_output, pkt);
2204 if (ret < 0 || !*got_output) {
2215 if (end < ist->prev_sub.subtitle.end_display_time) {
2217 "Subtitle duration reduced from %d to %d%s\n",
2219 end <= 0 ?
", dropping it" :
"");
2315 "Multiple frames in a packet from stream %d\n", pkt->
stream_index);
2371 if (got_output && !pkt)
2436 avc[j] = output_files[i]->
ctx;
2447 printf(
"SDP:\n%s\n", sdp);
2467 if (
hwaccels[i].pix_fmt == pix_fmt)
2478 for (p = pix_fmts; *p != -1; p++) {
2491 ret = hwaccel->
init(s);
2495 "%s hwaccel requested for input stream #%d:%d, "
2496 "but cannot be initialized.\n", hwaccel->
name,
2528 snprintf(error, error_len,
"Decoder (codec %s) not found for input stream #%d:%d",
2543 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");
2553 "Error while opening decoder for input stream "
2576 return FFDIFFSIGN(*(
const int64_t *)a, *(
const int64_t *)b);
2610 "Error while opening encoder for output stream #%d:%d - "
2611 "maybe incorrect parameters such as bit_rate, rate, width or height",
2622 " It takes bits/s as argument, not kbits/s\n");
2627 "Error initializing the output stream codec context.\n");
2660 "Error setting up codec context options.\n");
2677 for (p = kf; *p; p++)
2688 for (i = 0; i <
n; i++) {
2689 char *next = strchr(p,
',');
2694 if (!memcmp(p,
"chapters", 8)) {
2703 "Could not allocate forced key frames array.\n");
2735 InputFile *file = input_files[input_index];
2741 "New %s stream %d:%d at pos:%"PRId64
" and DTS:%ss\n",
2753 int encoder_string_len;
2754 int format_flags = 0;
2776 encoder_string =
av_mallocz(encoder_string_len);
2777 if (!encoder_string)
2783 av_strlcpy(encoder_string,
"Lavc ", encoder_string_len);
2791 int ret = 0, i, j, k;
2795 char error[1024] = {0};
2807 if (fg->
inputs[0]->
ist == input_streams[k])
2825 ost = output_streams[i];
2853 uint64_t extra_size;
2859 if (extra_size > INT_MAX) {
2868 unsigned int codec_tag;
2917 if( copy_tb<0 && dec_ctx->time_base.den
2980 #if FF_API_AUDIOENC_DELAY
2998 "with stream copy may produce invalid files\n");
3024 snprintf(error,
sizeof(error),
"Encoder (codec %s) not found for output stream #%d:%d",
3059 "about the input framerate is available. Falling "
3060 "back to a default value of 25fps for output stream #%d:%d. Use the -r option "
3061 "if you want a different framerate.\n",
3076 switch (enc_ctx->codec_type) {
3082 enc_ctx->time_base = (
AVRational){ 1, enc_ctx->sample_rate };
3086 if (!(enc_ctx->time_base.num && enc_ctx->time_base.den))
3091 "Please consider specifying a lower framerate, a different muxer or -vsync 2\n");
3096 enc_ctx->time_base);
3104 if (!strncmp(ost->
enc->
name,
"libx264", 7) &&
3108 "No pixel format specified, %s for H.264 encoding chosen.\n"
3109 "Use -pix_fmt yuv420p for compatibility with outdated media players.\n",
3111 if (!strncmp(ost->
enc->
name,
"mpeg2video", 10) &&
3115 "No pixel format specified, %s for MPEG-2 encoding chosen.\n"
3116 "Use -pix_fmt yuv420p for compatibility with outdated media players.\n",
3152 if (!enc_ctx->width) {
3165 if (ost->disposition) {
3167 {
"disposition" ,
NULL, 0,
AV_OPT_TYPE_FLAGS, { .i64 = 0 }, INT64_MIN, INT64_MAX, .unit =
"flags" },
3183 static const AVClass class = {
3189 const AVClass *pclass = &
class;
3191 ret =
av_opt_eval_flags(&pclass, &opts[0], ost->disposition, &ost->st->disposition);
3208 ost = output_streams[i];
3232 oc = output_files[i]->
ctx;
3236 "Could not write header for output file #%d "
3237 "(incorrect codec parameters ?): %s",
3243 if (strcmp(oc->oformat->name,
"rtp")) {
3258 ist = input_streams[i];
3260 for (j = 0; j < ist->nb_filters; j++) {
3261 if (ist->filters[j]->graph->graph_desc) {
3263 ist->file_index, ist->st->index, ist->dec ? ist->dec->name :
"?",
3264 ist->filters[j]->name);
3273 ost = output_streams[i];
3275 if (ost->attachment_filename) {
3278 ost->attachment_filename, ost->file_index, ost->index);
3282 if (ost->filter && ost->filter->graph->graph_desc) {
3289 ost->index, ost->enc ? ost->enc->name :
"?");
3294 input_streams[ost->source_index]->
file_index,
3295 input_streams[ost->source_index]->
st->
index,
3298 if (ost->sync_ist != input_streams[ost->source_index])
3300 ost->sync_ist->file_index,
3301 ost->sync_ist->st->index);
3302 if (ost->stream_copy)
3305 const AVCodec *in_codec = input_streams[ost->source_index]->
dec;
3306 const AVCodec *out_codec = ost->enc;
3307 const char *decoder_name =
"?";
3308 const char *in_codec_name =
"?";
3309 const char *encoder_name =
"?";
3310 const char *out_codec_name =
"?";
3314 decoder_name = in_codec->
name;
3317 in_codec_name = desc->
name;
3318 if (!strcmp(decoder_name, in_codec_name))
3319 decoder_name =
"native";
3323 encoder_name = out_codec->
name;
3326 out_codec_name = desc->
name;
3327 if (!strcmp(encoder_name, out_codec_name))
3328 encoder_name =
"native";
3332 in_codec_name, decoder_name,
3333 out_codec_name, encoder_name);
3386 int64_t opts_min = INT64_MAX;
3395 av_log(
NULL,
AV_LOG_DEBUG,
"cur_dts is invalid (this is harmless if it occurs once at the start per stream)\n");
3397 if (!ost->
finished && opts < opts_min) {
3409 if (tcgetattr(0, &tty) == 0) {
3410 if (on) tty.c_lflag |=
ECHO;
3411 else tty.c_lflag &= ~
ECHO;
3412 tcsetattr(0, TCSANOW, &tty);
3420 static int64_t last_time;
3443 if (key ==
'c' || key ==
'C'){
3447 fprintf(stderr,
"\nEnter command: <target>|all <time>|-1 <command>[ <argument>]\n");
3450 while ((k =
read_key()) !=
'\n' && k !=
'\r' && i <
sizeof(buf)-1)
3455 fprintf(stderr,
"\n");
3457 (n = sscanf(buf,
"%63[^ ] %lf %255[^ ] %255[^\n]", target, &time, command, arg)) >= 3) {
3459 target, time, command, arg);
3466 fprintf(stderr,
"Command reply for stream %d: ret:%d res:\n%s", i, ret, buf);
3467 }
else if (key ==
'c') {
3468 fprintf(stderr,
"Queing commands only on filters supporting the specific command is unsupported\n");
3473 fprintf(stderr,
"Queing command failed with error %s\n",
av_err2str(ret));
3479 "Parse error, at least 3 arguments were expected, "
3480 "only %d given in string '%s'\n", n, buf);
3483 if (key ==
'd' || key ==
'D'){
3487 if(!debug) debug = 1;
3495 while ((k =
read_key()) !=
'\n' && k !=
'\r' && i <
sizeof(buf)-1)
3500 fprintf(stderr,
"\n");
3501 if (k <= 0 || sscanf(buf,
"%d", &debug)!=1)
3502 fprintf(stderr,
"error parsing debug value\n");
3512 fprintf(stderr,
"debug=%d\n", debug);
3515 fprintf(stderr,
"key function\n"
3516 "? show this help\n"
3517 "+ increase verbosity\n"
3518 "- decrease verbosity\n"
3519 "c Send command to first matching filter supporting it\n"
3520 "C Send/Que command to all matching filters\n"
3521 "D cycle through available debug modes\n"
3522 "h dump packets/hex press to cycle through the 3 states\n"
3524 "s Show QP histogram\n"
3531 static void *input_thread(
void *
arg)
3550 if (flags && ret ==
AVERROR(EAGAIN)) {
3554 "Thread message queue blocking; consider raising the "
3555 "thread_queue_size option (current value: %d)\n",
3556 f->thread_queue_size);
3561 "Unable to send packet to main thread: %s\n",
3572 static void free_input_threads(
void)
3580 if (!f || !f->in_thread_queue)
3592 static int init_input_threads(
void)
3596 if (nb_input_files == 1)
3604 f->non_blocking = 1;
3606 f->thread_queue_size,
sizeof(
AVPacket));
3611 av_log(
NULL,
AV_LOG_ERROR,
"pthread_create failed: %s. Try to increase `ulimit -v` or decrease `ulimit -s`.\n", strerror(ret));
3641 if (nb_input_files > 1)
3642 return get_input_packet_mt(f, pkt);
3651 if (output_streams[i]->unavailable)
3660 input_files[i]->eagain = 0;
3662 output_streams[i]->unavailable = 0;
3673 return tmp_time_base;
3676 ret =
av_compare_ts(*duration, time_base, tmp, tmp_time_base);
3679 return tmp_time_base;
3689 int i, ret, has_audio = 0;
3697 ist = input_streams[ifile->
ist_index + i];
3714 ist = input_streams[ifile->
ist_index + i];
3729 }
else duration = 1;
3740 if (ifile->
loop > 0)
3755 InputFile *ifile = input_files[file_index];
3770 if (ret < 0 && ifile->
loop) {
3783 ist = input_streams[ifile->
ist_index + i];
3814 goto discard_packet;
3823 goto discard_packet;
3832 "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",
3843 int64_t stime, stime2;
3850 int64_t new_start_time = INT64_MAX;
3894 memcpy(dst_data, src_sd->
data, src_sd->
size);
3918 "Inter stream timestamp discontinuity %"PRId64
", new offset= %"PRId64
"\n",
3948 "timestamp discontinuity %"PRId64
", new offset= %"PRId64
"\n",
3976 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",
4004 int nb_requests, nb_requests_max = 0;
4022 for (i = 0; i < graph->
nb_inputs; i++) {
4023 ifilter = graph->
inputs[i];
4029 if (nb_requests > nb_requests_max) {
4030 nb_requests_max = nb_requests;
4096 int64_t timer_start;
4097 int64_t total_packets_written = 0;
4110 if ((ret = init_input_threads()) < 0)
4141 free_input_threads();
4146 ist = input_streams[i];
4157 os = output_files[i]->
ctx;
4170 ost = output_streams[i];
4184 ist = input_streams[i];
4197 free_input_threads();
4200 if (output_streams) {
4202 ost = output_streams[i];
4207 "Error closing logfile, loss of information possible: %s\n",
4228 struct rusage rusage;
4230 getrusage(RUSAGE_SELF, &rusage);
4231 return (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec;
4232 #elif HAVE_GETPROCESSTIMES
4234 FILETIME
c, e, k, u;
4235 proc = GetCurrentProcess();
4236 GetProcessTimes(proc, &c, &e, &k, &u);
4237 return ((int64_t) u.dwHighDateTime << 32 | u.dwLowDateTime) / 10;
4245 #if HAVE_GETRUSAGE && HAVE_STRUCT_RUSAGE_RU_MAXRSS
4246 struct rusage rusage;
4247 getrusage(RUSAGE_SELF, &rusage);
4248 return (int64_t)rusage.ru_maxrss * 1024;
4249 #elif HAVE_GETPROCESSMEMORYINFO
4251 PROCESS_MEMORY_COUNTERS memcounters;
4252 proc = GetCurrentProcess();
4253 memcounters.cb =
sizeof(memcounters);
4254 GetProcessMemoryInfo(proc, &memcounters,
sizeof(memcounters));
4255 return memcounters.PeakPagefileUsage;
4272 setvbuf(stderr,
NULL,_IONBF,0);
4277 if(argc>1 && !strcmp(argv[1],
"-d")){
4301 if (nb_output_files <= 0 && nb_input_files == 0) {
4308 if (nb_output_files <= 0) {
unsigned int nb_chapters
Number of chapters in AVChapter array.
#define AV_CODEC_FLAG_INTERLACED_ME
interlaced motion estimation
#define FF_DEBUG_VIS_MB_TYPE
only access through AVOptions from outside libavcodec
static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *pkt)
int64_t first_dts
Timestamp corresponding to the last dts sync point.
int guess_input_channel_layout(InputStream *ist)
const struct AVCodec * codec
#define AVERROR_INVALIDDATA
Invalid data found when processing input.
static enum AVPixelFormat pix_fmt
int64_t recording_time
desired length of the resulting file in microseconds == AV_TIME_BASE units
int64_t avio_size(AVIOContext *s)
Get the filesize.
void av_bprintf(AVBPrint *buf, const char *fmt,...)
int64_t av_frame_get_pkt_duration(const AVFrame *frame)
#define DECODING_FOR_FILTER
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
#define av_realloc_f(p, o, n)
This structure describes decoded (raw) audio or video data.
int avfilter_graph_queue_command(AVFilterGraph *graph, const char *target, const char *cmd, const char *arg, int flags, double ts)
Queue a command for one or more filter instances.
AVCodec * avcodec_find_encoder(enum AVCodecID id)
Find a registered encoder with a matching codec ID.
int av_interleaved_write_frame(AVFormatContext *s, AVPacket *pkt)
Write a packet to an output media file ensuring correct interleaving.
int x
top left corner of pict, undefined when pict is not set
AVIOInterruptCB interrupt_callback
Custom interrupt callbacks for the I/O layer.
void av_thread_message_queue_set_err_recv(AVThreadMessageQueue *mq, int err)
Set the receiving error code.
static void flush(AVCodecContext *avctx)
static void sub2video_flush(InputStream *ist)
uint64_t error[AV_NUM_DATA_POINTERS]
error
char * filters
filtergraph associated to the -filter option
#define AV_CODEC_FLAG_INTERLACED_DCT
Use interlaced DCT.
static int process_input(int file_index)
static int init_output_stream(OutputStream *ost, char *error, int error_len)
#define AV_LOG_WARNING
Something somehow does not look correct.
int64_t bit_rate
the average bitrate
#define LIBAVUTIL_VERSION_INT
Main libavfilter public API header.
int64_t pos
byte position in stream, -1 if unknown
#define AV_DICT_DONT_OVERWRITE
Don't overwrite existing entries.
Memory buffer source API.
void av_log_set_level(int level)
Set the log level.
int h
agreed upon image height
AVCodecParserContext * parser
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown)
FilterGraph * init_simple_filtergraph(InputStream *ist, OutputStream *ost)
static void print_report(int is_last_report, int64_t timer_start, int64_t cur_time)
int index
stream index in AVFormatContext
static int64_t getmaxrss(void)
static InputStream * get_input_stream(OutputStream *ost)
#define AVIO_FLAG_WRITE
write-only
AVRational sample_aspect_ratio
sample aspect ratio (0 if unknown) That is the width of a pixel divided by the height of the pixel...
void avfilter_graph_free(AVFilterGraph **graph)
Free a graph, destroy its links, and set *graph to NULL.
Immediately push the frame to the output.
void show_banner(int argc, char **argv, const OptionDef *options)
Print the program banner to stderr.
enum AVPixelFormat pix_fmt
Pixel format, see AV_PIX_FMT_xxx.
AVBitStreamFilterContext * bitstream_filters
static void abort_codec_experimental(AVCodec *c, int encoder)
static int transcode_init(void)
static int compare_int64(const void *a, const void *b)
static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eof)
char * stats_in
pass2 encoding statistics input buffer Concatenated stuff from stats_out of pass1 should be placed he...
void avdevice_register_all(void)
Initialize libavdevice and register all the input and output devices.
int av_usleep(unsigned usec)
Sleep for a period of time.
int av_expr_parse(AVExpr **expr, const char *s, const char *const *const_names, const char *const *func1_names, double(*const *funcs1)(void *, double), const char *const *func2_names, double(*const *funcs2)(void *, double, double), int log_offset, void *log_ctx)
Parse an expression.
AVPacketSideData * side_data
An array of side data that applies to the whole stream (i.e.
int avcodec_encode_audio2(AVCodecContext *avctx, AVPacket *avpkt, const AVFrame *frame, int *got_packet_ptr)
Encode a frame of audio.
int bits_per_raw_sample
Bits per sample/pixel of internal libavcodec pixel/sample format.
void avcodec_register_all(void)
Register all the codecs, parsers and bitstream filters which were enabled at configuration time...
int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, int *got_sub_ptr, AVPacket *avpkt)
Decode a subtitle message.
static void report_new_stream(int input_index, AVPacket *pkt)
int avcodec_copy_context(AVCodecContext *dest, const AVCodecContext *src)
Copy the settings of the source AVCodecContext into the destination AVCodecContext.
int block_align
number of bytes per packet if constant and known or 0 Used by some WAV based audio codecs...
attribute_deprecated AVPicture pict
float dts_error_threshold
int64_t start_time
start time in microseconds == AV_TIME_BASE units
int av_bprint_finalize(AVBPrint *buf, char **ret_str)
Finalize a print buffer.
static int decode_interrupt_cb(void *ctx)
AVRational time_base
This is the fundamental unit of time (in seconds) in terms of which frame timestamps are represented...
enum AVAudioServiceType audio_service_type
Type of service that th