From: Vishwanath Dixit <vdi...@akamai.com> Forced key frames creation functionality was assuming the first PTS value to be zero, but, when 'copyts' is enalbed, the first PTS can be any big number. This was eventually forcing all the frames as key frames. To overcome this issue, the actual first PTS value has to be considered. --- fftools/ffmpeg.c | 5 ++++- fftools/ffmpeg_opt.c | 1 + 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index 4dbe721..d9bb78a 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -1227,7 +1227,7 @@ static void do_video_out(OutputFile *of, in_picture->pict_type = 0; pts_time = in_picture->pts != AV_NOPTS_VALUE ? - in_picture->pts * av_q2d(enc->time_base) : NAN; + (in_picture->pts - ost->first_pts) * av_q2d(enc->time_base) : NAN; if (ost->forced_kf_index < ost->forced_kf_count && in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) { ost->forced_kf_index++; @@ -1477,6 +1477,9 @@ static int reap_filters(int flush) filtered_frame->pts = av_rescale_q(filtered_frame->pts, filter_tb, enc->time_base) - av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base); + + if (ost->first_pts == AV_NOPTS_VALUE) + ost->first_pts = filtered_frame->pts; } //if (ost->source_index >= 0) // *filtered_frame= *input_streams[ost->source_index]->decoded_frame; //for me_threshold diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 8ae68ae..24efbd7 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -1510,6 +1510,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e input_streams[source_index]->st->discard = input_streams[source_index]->user_set_discard; } ost->last_mux_dts = AV_NOPTS_VALUE; + ost->first_pts = AV_NOPTS_VALUE; ost->muxing_queue = av_fifo_alloc(8 * sizeof(AVPacket)); if (!ost->muxing_queue) -- 1.9.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel