33 #include <stdatomic.h>
74 #if HAVE_SYS_RESOURCE_H
76 #include <sys/types.h>
77 #include <sys/resource.h>
78 #elif HAVE_GETPROCESSTIMES
81 #if HAVE_GETPROCESSMEMORYINFO
85 #if HAVE_SETCONSOLECTRLHANDLER
91 #include <sys/select.h>
96 #include <sys/ioctl.h>
160 static struct termios oldtty;
161 static int restore_tty;
187 uint32_t *pal, *dst2;
195 if (
r->x < 0 ||
r->x +
r->w >
w ||
r->y < 0 ||
r->y +
r->h >
h) {
197 r->x,
r->y,
r->w,
r->h,
w,
h
202 dst +=
r->y * dst_linesize +
r->x * 4;
204 pal = (uint32_t *)
r->data[1];
205 for (y = 0; y <
r->h; y++) {
206 dst2 = (uint32_t *)dst;
208 for (x = 0; x <
r->w; x++)
209 *(dst2++) = pal[*(
src2++)];
211 src +=
r->linesize[0];
239 int64_t
pts, end_pts;
248 num_rects =
sub->num_rects;
261 "Impossible to get a blank canvas.\n");
264 dst =
frame->data [0];
265 dst_linesize =
frame->linesize[0];
266 for (
i = 0;
i < num_rects;
i++)
291 if (pts2 <= ist2->sub2video.last_pts)
298 for (j = 0, nb_reqs = 0; j < ist2->
nb_filters; j++)
325 tcsetattr (0, TCSANOW, &oldtty);
350 ret = write(2,
"Received > 3 system signals, hard exiting\n",
351 strlen(
"Received > 3 system signals, hard exiting\n"));
357 #if HAVE_SETCONSOLECTRLHANDLER
358 static BOOL WINAPI CtrlHandler(DWORD fdwCtrlType)
365 case CTRL_BREAK_EVENT:
369 case CTRL_CLOSE_EVENT:
370 case CTRL_LOGOFF_EVENT:
371 case CTRL_SHUTDOWN_EVENT:
390 #define SIGNAL(sig, func) \
392 action.sa_handler = func; \
393 sigaction(sig, &action, NULL); \
396 #define SIGNAL(sig, func) \
402 #if defined __linux__
403 struct sigaction action = {0};
407 sigfillset(&action.sa_mask);
410 action.sa_flags = SA_RESTART;
416 if (tcgetattr (0, &tty) == 0) {
420 tty.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP
421 |INLCR|IGNCR|ICRNL|IXON);
422 tty.c_oflag |= OPOST;
423 tty.c_lflag &= ~(
ECHO|ECHONL|ICANON|IEXTEN);
424 tty.c_cflag &= ~(CSIZE|PARENB);
429 tcsetattr (0, TCSANOW, &tty);
441 signal(SIGPIPE, SIG_IGN);
443 #if HAVE_SETCONSOLECTRLHANDLER
444 SetConsoleCtrlHandler((PHANDLER_ROUTINE) CtrlHandler, TRUE);
461 n = select(1, &rfds,
NULL,
NULL, &tv);
470 # if HAVE_PEEKNAMEDPIPE
472 static HANDLE input_handle;
475 input_handle = GetStdHandle(STD_INPUT_HANDLE);
476 is_pipe = !GetConsoleMode(input_handle, &dw);
481 if (!PeekNamedPipe(input_handle,
NULL, 0,
NULL, &nchars,
NULL)) {
579 #if FFMPEG_OPT_MAP_CHANNEL
581 ost->audio_channels_mapped = 0;
618 "Error closing vstats file, loss of information possible: %s\n",
678 "bench: %8" PRIu64
" user %8" PRIu64
" sys %8" PRIu64
" real %s \n",
692 if (
ost->sq_idx_encode >= 0)
722 err_msg =
"submitting a packet for bitstream filtering";
733 err_msg =
"applying bitstream filters to a packet";
750 err_msg =
"submitting a packet to the muxer";
781 !enc || !
ost->filter || !
ost->filter->graph->graph)
791 orig_pts =
frame->pts;
799 float_pts +=
FFSIGN(float_pts) * 1.0 / (1<<17);
812 filter_tb.
num, filter_tb.
den);
826 char *
error,
int error_len);
832 char error[1024] = {0};
834 if (
ost->initialized)
851 return -10.0 * log10(
d);
859 int64_t frame_number;
860 double ti1,
bitrate, avg_bitrate;
884 frame_number =
ost->packets_encoded;
886 fprintf(
vstats_file,
"frame= %5"PRId64
" q= %2.1f ", frame_number,
889 fprintf(
vstats_file,
"out= %2d st= %2d frame= %5"PRId64
" q= %2.1f ",
ost->file_index,
ost->
index, frame_number,
903 avg_bitrate = (
double)(
ost->data_size * 8) / ti1 / 1000.0;
904 fprintf(
vstats_file,
"s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s ",
905 (
double)
ost->data_size / 1024, ti1,
bitrate, avg_bitrate);
914 const char *action =
frame ?
"encode" :
"flush";
918 ost->frames_encoded++;
919 ost->samples_encoded +=
frame->nb_samples;
923 "frame_pts:%s frame_pts_time:%s time_base:%d/%d\n",
954 }
else if (
ret < 0) {
961 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s "
962 "duration:%s duration_time:%s\n",
973 "pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s "
974 "duration:%s duration_time:%s\n",
984 ost->packets_encoded++;
997 if (
ost->sq_idx_encode < 0)
1023 }
else if (
ret < 0) {
1061 int subtitle_out_max_size = 1024 * 1024;
1062 int subtitle_out_size, nb,
i,
ret;
1088 for (
i = 0;
i < nb;
i++) {
1089 unsigned save_num_rects =
sub->num_rects;
1104 sub->end_display_time -=
sub->start_display_time;
1105 sub->start_display_time = 0;
1109 ost->frames_encoded++;
1113 sub->num_rects = save_num_rects;
1114 if (subtitle_out_size < 0) {
1143 int64_t nb_frames, nb0_frames,
i;
1144 double delta, delta0;
1153 if (
ost->source_index >= 0)
1157 if (frame_rate.
num > 0 && frame_rate.
den > 0)
1163 if (!
ost->filters_script &&
1172 if (!next_picture) {
1174 nb0_frames = nb_frames =
mid_pred(
ost->last_nb0_frames[0],
1175 ost->last_nb0_frames[1],
1176 ost->last_nb0_frames[2]);
1178 delta0 = sync_ipts -
ost->sync_opts;
1189 if (delta0 < -0.6) {
1193 sync_ipts =
ost->sync_opts;
1198 switch (
ost->vsync_method) {
1200 if (
ost->vsync_frame_number == 0 && delta0 >= 0.5) {
1210 }
else if (
delta < -1.1)
1212 else if (
delta > 1.1) {
1215 nb0_frames =
llrintf(delta0 - 0.6);
1222 else if (
delta > 0.6)
1241 nb_frames =
FFMIN(nb_frames,
ost->max_frames -
ost->vsync_frame_number);
1242 nb0_frames =
FFMIN(nb0_frames, nb_frames);
1244 memmove(
ost->last_nb0_frames + 1,
1245 ost->last_nb0_frames,
1247 ost->last_nb0_frames[0] = nb0_frames;
1249 if (nb0_frames == 0 &&
ost->last_dropped) {
1252 "*** dropping frame %"PRId64
" from stream %d at ts %"PRId64
"\n",
1255 if (nb_frames > (nb0_frames &&
ost->last_dropped) + (nb_frames > nb0_frames)) {
1261 nb_frames_dup += nb_frames - (nb0_frames &&
ost->last_dropped) - (nb_frames > nb0_frames);
1268 ost->last_dropped = nb_frames == nb0_frames && next_picture;
1269 ost->dropped_keyframe =
ost->last_dropped && next_picture && next_picture->key_frame;
1272 for (
i = 0;
i < nb_frames;
i++) {
1274 int forced_keyframe = 0;
1277 if (i < nb0_frames && ost->last_frame->buf[0]) {
1278 in_picture =
ost->last_frame;
1280 in_picture = next_picture;
1285 in_picture->
pts =
ost->sync_opts;
1295 ost->forced_kf_ref_pts = in_picture->
pts;
1299 if (
ost->forced_kf_index <
ost->forced_kf_count &&
1300 in_picture->
pts >=
ost->forced_kf_pts[
ost->forced_kf_index]) {
1301 ost->forced_kf_index++;
1302 forced_keyframe = 1;
1303 }
else if (
ost->forced_keyframes_pexpr) {
1305 ost->forced_keyframes_expr_const_values[
FKF_T] = pts_time;
1307 ost->forced_keyframes_expr_const_values,
NULL);
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",
1309 ost->forced_keyframes_expr_const_values[
FKF_N],
1312 ost->forced_keyframes_expr_const_values[
FKF_T],
1316 forced_keyframe = 1;
1318 ost->forced_keyframes_expr_const_values[
FKF_N];
1320 ost->forced_keyframes_expr_const_values[
FKF_T];
1324 ost->forced_keyframes_expr_const_values[
FKF_N] += 1;
1325 }
else if (
ost->forced_keyframes
1326 && !strncmp(
ost->forced_keyframes,
"source", 6)
1329 forced_keyframe = 1;
1330 }
else if (
ost->forced_keyframes
1331 && !strncmp(
ost->forced_keyframes,
"source_no_drop", 14)
1333 forced_keyframe = (in_picture->
key_frame == 1) ||
ost->dropped_keyframe;
1334 ost->dropped_keyframe = 0;
1337 if (forced_keyframe) {
1347 ost->vsync_frame_number++;
1374 if (!
ost->filter || !
ost->filter->graph->graph)
1390 filtered_frame =
ost->filtered_frame;
1398 "Error in av_buffersink_get_frame_flags(): %s\n",
av_err2str(
ret));
1405 if (
ost->finished) {
1418 if (!
ost->frame_aspect_ratio.num)
1427 "Audio filter graph output is not normalized and encoder does not support parameter changes\n");
1446 uint64_t video_size = 0, audio_size = 0, extra_size = 0, other_size = 0;
1447 uint64_t subtitle_size = 0;
1449 float percent = -1.0;
1460 default: other_size +=
ost->data_size;
break;
1473 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: ",
1474 video_size / 1024.0,
1475 audio_size / 1024.0,
1476 subtitle_size / 1024.0,
1477 other_size / 1024.0,
1478 extra_size / 1024.0);
1488 uint64_t total_packets = 0, total_size = 0;
1493 for (j = 0; j <
f->nb_streams; j++) {
1517 total_packets, total_size);
1522 uint64_t total_packets = 0, total_size = 0;
1531 total_size +=
ost->data_size;
1538 ost->frames_encoded);
1551 total_packets, total_size);
1553 if(video_size +
data_size + audio_size + subtitle_size + extra_size == 0){
1563 static void print_report(
int is_last_report, int64_t timer_start, int64_t cur_time)
1565 AVBPrint buf, buf_script;
1570 int64_t
pts = INT64_MIN + 1;
1571 static int64_t last_time = -1;
1572 static int first_report = 1;
1573 static int qp_histogram[52];
1574 int hours, mins, secs,
us;
1575 const char *hours_sign;
1582 if (!is_last_report) {
1583 if (last_time == -1) {
1584 last_time = cur_time;
1586 if (((cur_time - last_time) <
stats_period && !first_report) ||
1589 last_time = cur_time;
1592 t = (cur_time-timer_start) / 1000000.0;
1604 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1611 fps = t > 1 ? frame_number / t : 0;
1612 av_bprintf(&buf,
"frame=%5"PRId64
" fps=%3.*f q=%3.1f ",
1613 frame_number, fps < 9.95, fps, q);
1614 av_bprintf(&buf_script,
"frame=%"PRId64
"\n", frame_number);
1616 av_bprintf(&buf_script,
"stream_%d_%d_q=%.1f\n",
1625 for (j = 0; j < 32; j++)
1632 double error, error_sum = 0;
1633 double scale, scale_sum = 0;
1635 char type[3] = {
'Y',
'U',
'V' };
1637 for (j = 0; j < 3; j++) {
1638 if (is_last_report) {
1651 av_bprintf(&buf_script,
"stream_%d_%d_psnr_%c=%2.2f\n",
1654 p =
psnr(error_sum / scale_sum);
1656 av_bprintf(&buf_script,
"stream_%d_%d_psnr_all=%2.2f\n",
1682 hours_sign = (
pts < 0) ?
"-" :
"";
1684 bitrate =
pts && total_size >= 0 ? total_size * 8 / (
pts / 1000.0) : -1;
1687 if (total_size < 0)
av_bprintf(&buf,
"size=N/A time=");
1688 else av_bprintf(&buf,
"size=%8.0fkB time=", total_size / 1024.0);
1704 if (total_size < 0)
av_bprintf(&buf_script,
"total_size=N/A\n");
1705 else av_bprintf(&buf_script,
"total_size=%"PRId64
"\n", total_size);
1707 av_bprintf(&buf_script,
"out_time_us=N/A\n");
1708 av_bprintf(&buf_script,
"out_time_ms=N/A\n");
1713 av_bprintf(&buf_script,
"out_time=%s%02d:%02d:%02d.%06d\n",
1714 hours_sign, hours, mins, secs,
us);
1727 av_bprintf(&buf_script,
"speed=%4.3gx\n", speed);
1731 const char end = is_last_report ?
'\n' :
'\r';
1733 fprintf(stderr,
"%s %c", buf.str, end);
1743 is_last_report ?
"end" :
"continue");
1745 FFMIN(buf_script.len, buf_script.size - 1));
1748 if (is_last_report) {
1751 "Error closing progress log, loss of information possible: %s\n",
av_err2str(
ret));
1786 if (
ost->sq_idx_encode >= 0)
1800 if (!
ost->initialized) {
1804 "Finishing stream %d:%d without any data written to it.\n",
1811 if (ifilter->
format < 0 &&
1850 if (
ost->source_index != ist_index)
1878 !
ost->copy_initial_nonkeyframes)
1881 if (!
ost->streamcopy_started && !
ost->copy_prior_start) {
1883 ist->
pts <
ost->ts_copy_start :
1894 if (
f->recording_time != INT64_MAX) {
1922 opkt->
pts = opkt->
dts - ost_tb_start_time;
1925 opkt->
dts -= ost_tb_start_time;
1933 ost->streamcopy_started = 1;
1970 int need_reinit,
ret;
1985 need_reinit |= ifilter->
width !=
frame->width ||
2010 if (need_reinit || !fg->
graph) {
2058 if (ifilter->
format < 0) {
2110 "Failed to inject frame into filter network: %s\n",
av_err2str(
ret));
2174 return err < 0 ? err :
ret;
2181 int i,
ret = 0, err = 0;
2182 int64_t best_effort_timestamp;
2220 "video_delay is larger in decoder than demuxer %d > %d.\n"
2221 "If you want to help, upload a sample "
2222 "of this file to https://streams.videolan.org/upload/ "
2223 "and contact the ffmpeg-devel mailing list. (ffmpeg-devel@ffmpeg.org)\n",
2282 "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",
2285 best_effort_timestamp,
2298 return err < 0 ? err :
ret;
2323 if (end < ist->
prev_sub.subtitle.end_display_time) {
2325 "Subtitle duration reduced from %"PRId32
" to %d%s\n",
2327 end <= 0 ?
", dropping it" :
"");
2397 int eof_reached = 0;
2433 int64_t duration_dts = 0;
2434 int64_t duration_pts = 0;
2436 int decode_failed = 0;
2467 if (duration_pts > 0) {
2493 if (decode_failed) {
2579 return !eof_reached;
2605 if (
config->pix_fmt == *p)
2614 "%s hwaccel requested for input stream #%d:%d, "
2615 "but cannot be initialized.\n",
2639 snprintf(
error, error_len,
"Decoder (codec %s) not found for input stream #%d:%d",
2646 #if LIBAVCODEC_VERSION_MAJOR < 60
2656 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");
2672 "decoder on input stream #%d:%d : %s",
2682 "Error while opening decoder for input stream "
2698 if (
ost->source_index >= 0)
2705 return FFDIFFSIGN(*(
const int64_t *)
a, *(
const int64_t *)
b);
2759 "Error setting up codec context options.\n");
2768 "Error getting reference codec parameters.\n");
2773 unsigned int codec_tag_tmp;
2782 if (!
ost->frame_rate.num)
2785 if (
ost->frame_rate.num)
2796 if (
ost->frame_rate.num)
2806 if (!
ost->copy_prior_start) {
2823 memcpy(dst_data, sd_src->
data, sd_src->
size);
2827 if (
ost->rotate_overridden) {
2843 if (
ost->frame_aspect_ratio.num) {
2848 "with stream copy may produce invalid files\n");
2867 uint8_t *encoder_string;
2868 int encoder_string_len;
2874 encoder_string =
av_mallocz(encoder_string_len);
2875 if (!encoder_string)
2881 av_strlcpy(encoder_string,
"Lavc ", encoder_string_len);
2882 av_strlcat(encoder_string,
ost->enc->name, encoder_string_len);
2894 for (p = kf; *p; p++)
2905 for (
i = 0;
i < n;
i++) {
2906 char *next = strchr(p,
',');
2911 if (!memcmp(p,
"chapters", 8)) {
2919 if (nb_ch > INT_MAX -
size ||
2923 "Could not allocate forced key frames array.\n");
2929 for (j = 0; j < nb_ch; j++) {
2950 ost->forced_kf_pts =
pts;
2958 if (
ost->enc_timebase.num > 0) {
2963 if (
ost->enc_timebase.num < 0) {
2970 "Input stream data for output stream #%d:%d not available, "
2971 "using default time base\n",
ost->file_index,
ost->
index);
2992 if (!
ost->frame_rate.num)
2994 if (ist && !
ost->frame_rate.num && !
ost->max_frame_rate.num) {
2998 "about the input framerate is available. Falling "
2999 "back to a default value of 25fps for output stream #%d:%d. Use the -r option "
3000 "if you want a different framerate.\n",
3004 if (
ost->max_frame_rate.num &&
3006 !
ost->frame_rate.den))
3007 ost->frame_rate =
ost->max_frame_rate;
3009 if (
ost->enc->supported_framerates && !
ost->force_fps) {
3011 ost->frame_rate =
ost->enc->supported_framerates[idx];
3016 ost->frame_rate.num,
ost->frame_rate.den, 65535);
3028 if (
ost->bits_per_raw_sample)
3030 else if (
dec_ctx &&
ost->filter->graph->is_meta)
3046 "Please consider specifying a lower framerate, a different muxer or "
3047 "setting vsync/fps_mode to vfr\n");
3053 ost->frame_aspect_ratio.num ?
3059 if (
ost->bits_per_raw_sample)
3061 else if (
dec_ctx &&
ost->filter->graph->is_meta)
3080 ost->top_field_first >= 0)
3081 frame->top_field_first = !!
ost->top_field_first;
3083 if (
frame->interlaced_frame) {
3093 if (
ost->top_field_first == 0) {
3095 }
else if (
ost->top_field_first == 1) {
3099 if (
ost->forced_keyframes) {
3100 if (!strncmp(
ost->forced_keyframes,
"expr:", 5)) {
3105 "Invalid force_key_frames expression '%s'\n",
ost->forced_keyframes+5);
3108 ost->forced_keyframes_expr_const_values[
FKF_N] = 0;
3115 }
else if(strncmp(
ost->forced_keyframes,
"source", 6)) {
3122 if (!enc_ctx->
width) {
3137 if (
ost->sq_idx_encode >= 0)
3146 char *
error,
int error_len)
3162 if (
dec &&
dec->subtitle_header) {
3165 if (!
ost->enc_ctx->subtitle_header)
3167 memcpy(
ost->enc_ctx->subtitle_header,
dec->subtitle_header,
dec->subtitle_header_size);
3168 ost->enc_ctx->subtitle_header_size =
dec->subtitle_header_size;
3176 "encoder on output stream #%d:%d : %s",
3182 int input_props = 0, output_props = 0;
3187 if (input_descriptor)
3189 if (output_descriptor)
3191 if (input_props && output_props && input_props != output_props) {
3193 "Subtitle encoding currently only possible from text to text "
3194 "or bitmap to bitmap");
3203 "Error while opening encoder for output stream #%d:%d - "
3204 "maybe incorrect parameters such as bit_rate, rate, width or height",
3211 ost->enc_ctx->frame_size);
3213 if (
ost->enc_ctx->bit_rate &&
ost->enc_ctx->bit_rate < 1000 &&
3216 " It takes bits/s as argument, not kbits/s\n");
3221 "Error initializing the output stream codec context.\n");
3225 if (
ost->enc_ctx->nb_coded_side_data) {
3228 for (
i = 0;
i <
ost->enc_ctx->nb_coded_side_data;
i++) {
3235 memcpy(dst_data, sd_src->
data, sd_src->
size);
3268 }
else if (
ost->source_index >= 0) {
3281 if (
ost->sq_idx_mux >= 0)
3284 ost->initialized = 1;
3295 int ret = 0,
i, j, k;
3298 char error[1024] = {0};
3319 for (j = 0; j <
ifile->nb_streams; j++)
3327 int64_t new_start_time = INT64_MAX;
3333 for (
int j = 0; j <
is->nb_streams; j++) {
3339 if (new_start_time >
is->start_time) {
3341 ifile->ts_offset = -new_start_time;
3373 for (j = 0; j <
ifile->ctx->nb_programs; j++) {
3407 if (
ost->attachment_filename) {
3433 const char *decoder_name =
"?";
3434 const char *in_codec_name =
"?";
3435 const char *encoder_name =
"?";
3436 const char *out_codec_name =
"?";
3440 decoder_name = in_codec->
name;
3443 in_codec_name =
desc->name;
3444 if (!strcmp(decoder_name, in_codec_name))
3445 decoder_name =
"native";
3449 encoder_name = out_codec->
name;
3452 out_codec_name =
desc->name;
3453 if (!strcmp(encoder_name, out_codec_name))
3454 encoder_name =
"native";
3458 in_codec_name, decoder_name,
3459 out_codec_name, encoder_name);
3500 int64_t opts_min = INT64_MAX;
3511 INT64_MIN :
ost->last_mux_dts;
3514 "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",
3518 if (!
ost->initialized && !
ost->inputs_done)
3521 if (!
ost->finished &&
opts < opts_min) {
3533 if (tcgetattr(0, &tty) == 0) {
3534 if (
on) tty.c_lflag |=
ECHO;
3535 else tty.c_lflag &= ~
ECHO;
3536 tcsetattr(0, TCSANOW, &tty);
3544 static int64_t last_time;
3548 if (cur_time - last_time >= 100000) {
3550 last_time = cur_time;
3560 if (
key ==
'c' ||
key ==
'C'){
3561 char buf[4096], target[64],
command[256],
arg[256] = {0};
3564 fprintf(stderr,
"\nEnter command: <target>|all <time>|-1 <command>[ <argument>]\n");
3567 while ((k =
read_key()) !=
'\n' && k !=
'\r' &&
i <
sizeof(buf)-1)
3572 fprintf(stderr,
"\n");
3574 (n = sscanf(buf,
"%63[^ ] %lf %255[^ ] %255[^\n]", target, &time,
command,
arg)) >= 3) {
3583 fprintf(stderr,
"Command reply for stream %d: ret:%d res:\n%s",
i,
ret, buf);
3584 }
else if (
key ==
'c') {
3585 fprintf(stderr,
"Queuing commands only on filters supporting the specific command is unsupported\n");
3590 fprintf(stderr,
"Queuing command failed with error %s\n",
av_err2str(
ret));
3596 "Parse error, at least 3 arguments were expected, "
3597 "only %d given in string '%s'\n", n, buf);
3600 if (
key ==
'd' ||
key ==
'D'){
3604 if(!debug) debug = 1;
3612 while ((k =
read_key()) !=
'\n' && k !=
'\r' &&
i <
sizeof(buf)-1)
3617 fprintf(stderr,
"\n");
3618 if (k <= 0 || sscanf(buf,
"%d", &debug)!=1)
3619 fprintf(stderr,
"error parsing debug value\n");
3627 ost->enc_ctx->debug = debug;
3630 fprintf(stderr,
"debug=%d\n", debug);
3633 fprintf(stderr,
"key function\n"
3634 "? show this help\n"
3635 "+ increase verbosity\n"
3636 "- decrease verbosity\n"
3637 "c Send command to first matching filter supporting it\n"
3638 "C Send/Queue command to all matching filters\n"
3639 "D cycle through available debug modes\n"
3640 "h dump packets/hex press to cycle through the 3 states\n"
3642 "s Show QP histogram\n"
3668 for (
int i = 0;
i <
ifile->nb_streams;
i++) {
3701 int disable_discontinuity_correction =
copy_ts;
3711 disable_discontinuity_correction = 0;
3716 if (fmt_is_discont) {
3721 "timestamp discontinuity for stream #%d:%d "
3722 "(id=%d, type=%s): %"PRId64
", new offset= %"PRId64
"\n",
3750 "Inter stream timestamp discontinuity %"PRId64
", new offset= %"PRId64
"\n",
3815 for (
i = 0;
i <
ifile->nb_streams;
i++) {
3827 if (
ost->source_index ==
ifile->ist_index +
i &&
3835 ifile->eof_reached = 1;
3847 goto discard_packet;
3865 memcpy(dst_data, src_sd->
data, src_sd->
size);
3873 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 duration:%s duration_time:%s off:%s off_time:%s\n",
3903 int nb_requests, nb_requests_max = 0;
3928 if (nb_requests > nb_requests_max) {
3929 nb_requests_max = nb_requests;
3963 if (
ost->filter && !
ost->filter->graph->graph) {
3973 if (
ost->filter &&
ost->filter->graph->graph) {
4002 }
else if (
ost->filter) {
4004 for (
i = 0;
i <
ost->filter->graph->nb_inputs;
i++) {
4012 ost->inputs_done = 1;
4023 ost->unavailable = 1;
4041 int64_t timer_start;
4042 int64_t total_packets_written = 0;
4105 uint64_t packets_written;
4108 total_packets_written += packets_written;
4141 if (fclose(
ost->logfile))
4143 "Error closing logfile, loss of information possible: %s\n",
4163 struct rusage rusage;
4165 getrusage(RUSAGE_SELF, &rusage);
4167 (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec;
4169 (rusage.ru_stime.tv_sec * 1000000LL) + rusage.ru_stime.tv_usec;
4170 #elif HAVE_GETPROCESSTIMES
4172 FILETIME
c, e, k,
u;
4173 proc = GetCurrentProcess();
4174 GetProcessTimes(proc, &
c, &e, &k, &
u);
4176 ((int64_t)
u.dwHighDateTime << 32 |
u.dwLowDateTime) / 10;
4178 ((int64_t)k.dwHighDateTime << 32 | k.dwLowDateTime) / 10;
4187 #if HAVE_GETRUSAGE && HAVE_STRUCT_RUSAGE_RU_MAXRSS
4188 struct rusage rusage;
4189 getrusage(RUSAGE_SELF, &rusage);
4190 return (int64_t)rusage.ru_maxrss * 1024;
4191 #elif HAVE_GETPROCESSMEMORYINFO
4193 PROCESS_MEMORY_COUNTERS memcounters;
4194 proc = GetCurrentProcess();
4195 memcounters.cb =
sizeof(memcounters);
4196 GetProcessMemoryInfo(proc, &memcounters,
sizeof(memcounters));
4197 return memcounters.PeakPagefileUsage;
4212 setvbuf(stderr,
NULL,_IONBF,0);
4245 int64_t utime, stime, rtime;
4251 "bench: utime=%0.3fs stime=%0.3fs rtime=%0.3fs\n",
4252 utime / 1000000.0, stime / 1000000.0, rtime / 1000000.0);