vaapi{h264,h265}enc: Missing frames when encode with B frames from YUV file and num-buffers specified
@ullysses.a.eoff
Submitted by Ullysses A Eoff Link to original bug (#796495)
Description
When filesrc num-buffers=N is specified in encode pipeline for vaapi encode and max-bframes > 0, the resulting encoded video does not contain N frames.
- Generate 100-frame YUV file:
$ gst-launch-1.0 videotestsrc num-buffers=100 ! video/x-raw,format=NV12,width=1920,height=1080 ! filesink location=./test.yuv
- Encode 90 frames from previous YUV output file:
$ gst-launch-1.0 filesrc location=test.yuv num-buffers=90 ! rawvideoparse format=nv12 width=1920 height=1080 ! vaapih264enc rate-control=cbr bitrate=5000 keyframe-period=30 num-slices=4 max-bframes=2 ! h264parse ! filesink location=./test.h264
...the resulting file, test.h264 only contains 88 frames, which is NOT expected.
- If we switch the encoder to msdkh264enc:
gst-launch-1.0 filesrc location=test.yuv num-buffers=90 ! rawvideoparse format=nv12 width=1920 height=1080 ! msdkh264enc rate-control=cbr bitrate=5000 gop-size=30 num-slices=4 b-frames=2 ! h264parse ! filesink location=./test.h264
...the resulting file contains the requested 90 frames, which is expected.
Other encoders like ffmpeg and yami output the correct number of frames. Thus, only gstreamer-vaapi encoders (all encoders that support b-frames) exhibit the incorrect number of frames in encoded output.