From: Michael Niedermayer Date: Mon, 11 Jun 2012 01:00:28 +0000 (+0200) Subject: ffmpeg: allow overriding framerate for stream copy X-Git-Url: https://git.sesse.net/?a=commitdiff_plain;ds=sidebyside;h=0478d5f9fe3d6d80b82c18dc5deb4f4661da73ab;p=ffmpeg ffmpeg: allow overriding framerate for stream copy Signed-off-by: Michael Niedermayer --- diff --git a/ffmpeg.c b/ffmpeg.c index 29c115424a8..c779cea5c98 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -2870,6 +2870,10 @@ static int transcode_init(void) codec->time_base.num *= icodec->ticks_per_frame; } } + + if(ost->frame_rate.num) + codec->time_base = (AVRational){ost->frame_rate.den, ost->frame_rate.num}; + av_reduce(&codec->time_base.num, &codec->time_base.den, codec->time_base.num, codec->time_base.den, INT_MAX); @@ -4573,25 +4577,26 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in AVStream *st; OutputStream *ost; AVCodecContext *video_enc; + char *frame_rate = NULL; ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index); st = ost->st; video_enc = st->codec; + MATCH_PER_STREAM_OPT(frame_rates, str, frame_rate, oc, st); + if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) { + av_log(NULL, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate); + exit_program(1); + } + if (!ost->stream_copy) { const char *p = NULL; - char *forced_key_frames = NULL, *frame_rate = NULL, *frame_size = NULL; + char *forced_key_frames = NULL, *frame_size = NULL; char *frame_aspect_ratio = NULL, *frame_pix_fmt = NULL; char *intra_matrix = NULL, *inter_matrix = NULL; const char *filters = "null"; int i; - MATCH_PER_STREAM_OPT(frame_rates, str, frame_rate, oc, st); - if (frame_rate && av_parse_video_rate(&ost->frame_rate, frame_rate) < 0) { - av_log(NULL, AV_LOG_FATAL, "Invalid framerate value: %s\n", frame_rate); - exit_program(1); - } - MATCH_PER_STREAM_OPT(frame_sizes, str, frame_size, oc, st); if (frame_size && av_parse_video_size(&video_enc->width, &video_enc->height, frame_size) < 0) { av_log(NULL, AV_LOG_FATAL, "Invalid frame size: %s.\n", frame_size);