vah264enc,vah265enc: Ignores input timestamp
VA encoders don't respect input timestamp and re-timestamping with a wrong assumption that input stream is completely linear (no frame gap at all) and each buffer has perfect timestamp. See the code
static void
gst_va_h264_enc_prepare_output (GstVaBaseEnc * base, GstVideoCodecFrame * frame)
{
GstVaH264Enc *self = GST_VA_H264_ENC (base);
GstVaH264EncFrame *frame_enc;
frame_enc = _enc_frame (frame);
frame->pts =
base->start_pts + base->frame_duration * frame_enc->total_frame_count;
/* The PTS should always be later than the DTS. */
frame->dts = base->start_pts + base->frame_duration *
((gint64) base->output_frame_count -
(gint64) self->gop.num_reorder_frames);
base->output_frame_count++;
frame->duration = base->frame_duration;
}
Correct handling there would be,
- don't touch
frame->pts
- calculate
frame->dts
ifframe->pts
is valid.- There can be various approaches though, I guess one simple approach would be doing similar to that of codectimestamper (i.e., hold a timestamp queue and re-map)