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 764372 - h264parse removes padding from byte streams
h264parse removes padding from byte streams
Status: RESOLVED OBSOLETE
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
git master
Other Linux
: Normal normal
: git master
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2016-03-30 15:13 UTC by Georg Lippitsch
Modified: 2018-11-03 13:48 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Georg Lippitsch 2016-03-30 15:13:41 UTC
When using h264parse element without a conversion (bytestream to bytestream), it removes padding bytes from the original h264 stream. Producing a real constant bitrate is then not possible anymore.

This can be reproduced with the following command line (you need 10Bit libx264):
# gst-launch-1.0 videotestsrc ! video/x-raw,width=1920,height=1080,format=I422_10LE,framerate=25/1 ! x264enc trellis=false option-string=avcintra-class=100 ! video/x-h264,stream-format=byte-stream ! h264parse ! mpegtsmux ! filesink location=test.ts

Every frame should then have exactly 568832 bytes. But checking the file test.ts with ffprobe gives different frame sizes for every frame. The frames sizes can be checked with:
# ffprobe -show_frames test.ts | grep pkt_size

Removing the "h264parse" element from the above pipeline and checking the frame sizes gives the expected size of 568832 bytes for every frame.
Comment 1 Sebastian Dröge (slomo) 2016-03-31 12:31:47 UTC
Like all other parsers, it shouldn't drop any padding or other information by default. There's going to be a reason why it exists.
Comment 2 Sebastian Dröge (slomo) 2016-04-01 12:44:38 UTC
https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/gst-libs/gst/codecparsers/gsth264parser.c#n1366

The problem is this, which drops all the padding from the NALUs. Commenting out that code gives almost the correct size (it produces a bit more for some reason).
Comment 3 Sebastian Dröge (slomo) 2016-04-01 12:48:26 UTC
Which was added in https://bugzilla.gnome.org/show_bug.cgi?id=721384 as the spec does not allow trailing zeroes.
Comment 4 Sebastian Dröge (slomo) 2016-04-02 07:54:04 UTC
In combination I would say that there are incompatible requirements here. AVC Intra (the official one) is all good probably, the Panasonic one we're talking about here seems incompatible with the H264 spec.

The Panasonic one requires each frame to be padded with zeroes after the end of the last NALU so that all frames have the same size. H264 forbids a NAL to end with a 0x00 byte (which the padding would do). But it allows 0x00 bytes before the next start code. So we could probably move the padding to the beginning of the next frame, but that again defeats the whole purpose of the padding to make each frame the same size.

For AVC stream format this is even worse as the only way to have the padding there would be to make it part of the current frame (i.e. padding at the end of the frame, not valid h264)... as otherwise for the next frame it wouldn't directly start with a NALU after the AVC header and nothing can handle that.



Not sure what to do about this here. I guess one could write another element for redoing the padding or having it done in muxers as needed.
Comment 5 Nicolas Dufresne (ndufresne) 2016-04-02 14:11:10 UTC
I integrated once a Panasonic HW codec, I don't remember having to add padding to make it work. I wonder if this "format" is relevant, if it isn't something from a very old pass ?
Comment 6 Sebastian Dröge (slomo) 2016-04-02 14:29:39 UTC
See https://en.wikipedia.org/wiki/AVC-Intra

"AVC-Intra is compliant with the H.264/MPEG-4 AVC standard[2] and Panasonic claims to follow the SMPTE RP 2027–2007[3] recommended practice specification.[4] Analysis by the x264 project has shown that Panasonic does not comply with this specification[5]"


The encoder is already adding the padding, the problem is that h264parse is going to remove the padding :)
Comment 7 Nicolas Dufresne (ndufresne) 2016-04-02 14:39:10 UTC
(In reply to Sebastian Dröge (slomo) from comment #6)
> The encoder is already adding the padding, the problem is that h264parse is
> going to remove the padding :)

I see, thanks for explaining.
Comment 8 Edward Hervey 2016-06-28 12:51:32 UTC
Since this doesn't respect the standard, what we need is a new variant for those panasonic modes so we can workaround the issues properly.
Comment 9 GStreamer system administrator 2018-11-03 13:48:21 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/gst-plugins-bad/issues/364.