ost->frame_number++;
}
+ if (bsfc)
+ av_packet_split_side_data(pkt);
+
while (bsfc) {
AVPacket new_pkt = *pkt;
int a = av_bitstream_filter_filter(bsfc, avctx, NULL,
else
pkt.pts += 90 * sub->end_display_time;
}
+ pkt.dts = pkt.pts;
write_frame(s, &pkt, ost);
}
}
fprintf(vstats_file,"f_size= %6d ", frame_size);
/* compute pts value */
- ti1 = ost->st->pts.val * av_q2d(enc->time_base);
+ ti1 = av_stream_get_end_pts(ost->st) * av_q2d(ost->st->time_base);
if (ti1 < 0.01)
ti1 = 0.01;
vid = 1;
}
/* compute min output value */
- if (ost->st->pts.val != AV_NOPTS_VALUE)
- pts = FFMAX(pts, av_rescale_q(ost->st->pts.val,
+ if (av_stream_get_end_pts(ost->st) != AV_NOPTS_VALUE)
+ pts = FFMAX(pts, av_rescale_q(av_stream_get_end_pts(ost->st),
ost->st->time_base, AV_TIME_BASE_Q));
}
file->nb_streams_warn = pkt->stream_index + 1;
}
+static void set_encoder_id(OutputFile *of, OutputStream *ost)
+{
+ AVDictionaryEntry *e;
+
+ uint8_t *encoder_string;
+ int encoder_string_len;
+ int format_flags = 0;
+ int codec_flags = 0;
+
+ if (av_dict_get(ost->st->metadata, "encoder", NULL, 0))
+ return;
+
+ e = av_dict_get(of->opts, "fflags", NULL, 0);
+ if (e) {
+ const AVOption *o = av_opt_find(of->ctx, "fflags", NULL, 0, 0);
+ if (!o)
+ return;
+ av_opt_eval_flags(of->ctx, o, e->value, &format_flags);
+ }
+ e = av_dict_get(ost->encoder_opts, "flags", NULL, 0);
+ if (e) {
+ const AVOption *o = av_opt_find(ost->st->codec, "flags", NULL, 0, 0);
+ if (!o)
+ return;
+ av_opt_eval_flags(ost->st->codec, o, e->value, &codec_flags);
+ }
+
+ encoder_string_len = sizeof(LIBAVCODEC_IDENT) + strlen(ost->enc->name) + 2;
+ encoder_string = av_mallocz(encoder_string_len);
+ if (!encoder_string)
+ exit_program(1);
+
+ if (!(format_flags & AVFMT_FLAG_BITEXACT) && !(codec_flags & CODEC_FLAG_BITEXACT))
+ av_strlcpy(encoder_string, LIBAVCODEC_IDENT " ", encoder_string_len);
+ else
+ av_strlcpy(encoder_string, "Lavc ", encoder_string_len);
+ av_strlcat(encoder_string, ost->enc->name, encoder_string_len);
+ av_dict_set(&ost->st->metadata, "encoder", encoder_string,
+ AV_DICT_DONT_STRDUP_VAL | AV_DICT_DONT_OVERWRITE);
+}
+
static int transcode_init(void)
{
int ret = 0, i, j, k;
InputFile *ifile = input_files[i];
if (ifile->rate_emu)
for (j = 0; j < ifile->nb_streams; j++)
- input_streams[j + ifile->ist_index]->start = av_gettime();
+ input_streams[j + ifile->ist_index]->start = av_gettime_relative();
}
/* output stream init */
ist->decoding_needed++;
ost->encoding_needed = 1;
+ set_encoder_id(output_files[ost->file_index], ost);
+
if (!ost->filter &&
(enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO ||
enc_ctx->codec_type == AVMEDIA_TYPE_AUDIO)) {
av_get_pix_fmt_name(ost->filter->filter->inputs[0]->format));
enc_ctx->pix_fmt = ost->filter->filter->inputs[0]->format;
+ ost->st->avg_frame_rate = ost->frame_rate;
+
if (!dec_ctx ||
enc_ctx->width != dec_ctx->width ||
enc_ctx->height != dec_ctx->height ||
DEFAULT_PASS_LOGFILENAME_PREFIX,
i);
if (!strcmp(ost->enc->name, "libx264")) {
- av_dict_set(&ost->opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
+ av_dict_set(&ost->encoder_opts, "stats", logfilename, AV_DICT_DONT_OVERWRITE);
} else {
if (enc_ctx->flags & CODEC_FLAG_PASS2) {
char *logbuffer;
memcpy(ost->st->codec->subtitle_header, dec->subtitle_header, dec->subtitle_header_size);
ost->st->codec->subtitle_header_size = dec->subtitle_header_size;
}
- if (!av_dict_get(ost->opts, "threads", NULL, 0))
- av_dict_set(&ost->opts, "threads", "auto", 0);
- if ((ret = avcodec_open2(ost->st->codec, codec, &ost->opts)) < 0) {
+ if (!av_dict_get(ost->encoder_opts, "threads", NULL, 0))
+ av_dict_set(&ost->encoder_opts, "threads", "auto", 0);
+ if ((ret = avcodec_open2(ost->st->codec, codec, &ost->encoder_opts)) < 0) {
if (ret == AVERROR_EXPERIMENTAL)
abort_codec_experimental(codec, 1);
snprintf(error, sizeof(error), "Error while opening encoder for output stream #%d:%d - maybe incorrect parameters such as bit_rate, rate, width or height",
!(ost->enc->capabilities & CODEC_CAP_VARIABLE_FRAME_SIZE))
av_buffersink_set_frame_size(ost->filter->filter,
ost->st->codec->frame_size);
- assert_avoptions(ost->opts);
+ assert_avoptions(ost->encoder_opts);
if (ost->st->codec->bit_rate && ost->st->codec->bit_rate < 1000)
av_log(NULL, AV_LOG_WARNING, "The bitrate parameter is set too low."
" It takes bits/s as argument, not kbits/s\n");
} else {
- av_opt_set_dict(ost->st->codec, &ost->opts);
+ av_opt_set_dict(ost->st->codec, &ost->encoder_opts);
}
}
av_fifo_generic_read(f->fifo, &pkt, sizeof(pkt), NULL);
av_free_packet(&pkt);
}
- av_fifo_free(f->fifo);
+ av_fifo_freep(&f->fifo);
}
}
for (i = 0; i < nb_input_files; i++) {
InputFile *f = input_files[i];
- if (!(f->fifo = av_fifo_alloc(8*sizeof(AVPacket))))
+ if (!(f->fifo = av_fifo_alloc_array(8, sizeof(AVPacket))))
return AVERROR(ENOMEM);
if (f->ctx->pb ? !f->ctx->pb->seekable :
for (i = 0; i < f->nb_streams; i++) {
InputStream *ist = input_streams[f->ist_index + i];
int64_t pts = av_rescale(ist->dts, 1000000, AV_TIME_BASE);
- int64_t now = av_gettime() - ist->start;
+ int64_t now = av_gettime_relative() - ist->start;
if (pts > now)
return AVERROR(EAGAIN);
}
av_log(NULL, AV_LOG_INFO, "Press [q] to stop, [?] for help\n");
}
- timer_start = av_gettime();
+ timer_start = av_gettime_relative();
#if HAVE_PTHREADS
if ((ret = init_input_threads()) < 0)
#endif
while (!received_sigterm) {
- int64_t cur_time= av_gettime();
+ int64_t cur_time= av_gettime_relative();
/* if 'q' pressed, exits */
if (stdin_interaction)
}
/* dump report by using the first video and audio streams */
- print_report(1, timer_start, av_gettime());
+ print_report(1, timer_start, av_gettime_relative());
/* close each encoder */
for (i = 0; i < nb_output_streams; i++) {
av_freep(&ost->st->codec->subtitle_header);
av_freep(&ost->forced_kf_pts);
av_freep(&ost->apad);
- av_dict_free(&ost->opts);
+ av_dict_free(&ost->encoder_opts);
av_dict_free(&ost->swr_opts);
av_dict_free(&ost->resample_opts);
}