Forced key frames generation functionality was assuming the first PTS
value as zero, but, when 'copyts' is enabled, the first PTS can be any
big number. This was eventually forcing all the frames as key frames.
To resolve this issue, update has been made to use first input pts as
reference pts.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
in_picture->quality = enc->global_quality;
in_picture->pict_type = 0;
+ if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE &&
+ in_picture->pts != AV_NOPTS_VALUE)
+ ost->forced_kf_ref_pts = in_picture->pts;
+
pts_time = in_picture->pts != AV_NOPTS_VALUE ?
- in_picture->pts * av_q2d(enc->time_base) : NAN;
+ (in_picture->pts - ost->forced_kf_ref_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++;
AVRational frame_aspect_ratio;
/* forced key frames */
+ int64_t forced_kf_ref_pts;
int64_t *forced_kf_pts;
int forced_kf_count;
int forced_kf_index;
ost->file_index = nb_output_files - 1;
ost->index = idx;
ost->st = st;
+ ost->forced_kf_ref_pts = AV_NOPTS_VALUE;
st->codecpar->codec_type = type;
ret = choose_encoder(o, oc, ost);