After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 796495 - vaapi{h264,h265}enc: Missing frames when encode with B frames from YUV file and num-buffers specified
vaapi{h264,h265}enc: Missing frames when encode with B frames from YUV file a...
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gstreamer-vaapi
git master
Other Linux
: Normal major
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2018-06-04 18:58 UTC by U. Artie Eoff
Modified: 2018-11-03 15:54 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description U. Artie Eoff 2018-06-04 18:58:22 UTC
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.

1. 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

2. 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.

3. 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.
Comment 1 U. Artie Eoff 2018-06-05 00:46:22 UTC
FWIW:

gst-launch-1.0 filesrc location=test.yuv num-buffers=90 ! rawvideoparse format=nv12 width=1920 height=1080 ! checksumsink

...outputs 90 values
Comment 2 Nicolas Dufresne (ndufresne) 2018-06-05 01:38:21 UTC
Looks like is the b-frames setting that impact the results here, a simpler way to reproduce the issue:

gst-launch-1.0 videotestsrc num-buffers=90 ! vaapih264enc max-bframes=4 ! h264parse ! multifilesink

If you move it back to 0 bframes, there it's good. I'm confirming this issue.
Comment 3 U. Artie Eoff 2018-06-15 17:48:45 UTC
@Victor, I see you changed the subject.  Please not that this happens with vaapih265enc too!
Comment 4 U. Artie Eoff 2018-06-15 17:52:54 UTC
(In reply to U. Artie Eoff from comment #3)
> @Victor, I see you changed the subject.  Please not that this happens with
> vaapih265enc too!

/not/note/
Comment 5 Fei 2018-08-14 06:23:50 UTC
Take a example, if set max-bframes as 4, then encoder need 4 frames in a list together to encode the 4 B frames per time. If the total frame number can not divide by 4, then there will be less than 4 frames in list in the end. And the list will be release and the frames will be drop in it during flush. So one solution is to change B frame into P frame in flush and re-encode all the remind frames instead of drop them. But seems it is hard to implement because encode/flush are called in video encode base class. Any suggestion on this?
Comment 6 Nicolas Dufresne (ndufresne) 2018-08-14 13:13:18 UTC
I can't comment on the solution, I would have to check what other encoders do by parsing the results, but it seems fair.

The base class will signal the moment you should do that on finish() virtual function. It's of course harder than usual, as we are implementing a part of the encoder.
Comment 7 GStreamer system administrator 2018-11-03 15:54:43 UTC
-- GitLab Migration Automatic Message --

This bug has been migrated to freedesktop.org's GitLab instance and has been closed from further activity.

You can subscribe and participate further through the new bug through this link to our GitLab instance: https://gitlab.freedesktop.org/gstreamer/gstreamer-vaapi/issues/97.