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 682589 - h264parse parse data error when AVC head only 2 bytes
h264parse parse data error when AVC head only 2 bytes
Status: RESOLVED FIXED
Product: GStreamer
Classification: Platform
Component: gst-plugins-bad
0.11.x
Other All
: Normal major
: 0.11.x
Assigned To: GStreamer Maintainers
GStreamer Maintainers
Depends on:
Blocks:
 
 
Reported: 2012-08-24 08:08 UTC by zhangyanping
Modified: 2012-08-28 09:26 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Only h264 files, mp4 is too large (641.21 KB, application/zip)
2012-08-24 08:45 UTC, zhangyanping
Details
This is the gdp file of first 500 bytes of the mp4 file (500.00 KB, application/octet-stream)
2012-08-27 02:00 UTC, zhangyanping
Details

Description zhangyanping 2012-08-24 08:08:25 UTC
use this cmd pipeline:

kulou1.mp4 is a video from youtube, and can not be played, so I download it for checking.

gst-launch filesrc location=/workspace/avdata/kulou1.mp4 num-buffers=1000 ! qtdemux ! h264parse ! capsfilter caps=" video/x-h264, stream-format=(string)byte-stream"  ! filesink location=./mykulou.h264 --gst-debug=*264*:5 -v


0.11 verison is not ok. Otherwisse 0.10 version works good.

And I checked the H264 file dumped by 0.10 version, and I find that the AVC header is only two bytes. But the verison 0.11 treated it as 4 bytes, so it will parse out error data.

The attachment is the mp4 file , h264 data dumped by 0.11 gstreamer, h264 data dumped by 0.10 gstreamer
Comment 1 zhangyanping 2012-08-24 08:45:23 UTC
Created attachment 222292 [details]
Only h264 files, mp4 is too large
Comment 2 Tim-Philipp Müller 2012-08-24 08:55:22 UTC
Could you provide some of the input data? This might work:

  gst-launch-0.10 filesrc location=foo.mp4 ! qtdemux name=d  d.video_00 ! gdppay ! filesink location=foo-h264.gdp

And then

  head --bytes=500k foo-h264.gdp > foo-h264-avc-start.gdp

And then attach foo-h264-avc-start.gdp ?

Unless you can make the full .mp4 available somewhere else, which would be helpful too.
Comment 3 zhangyanping 2012-08-27 02:00:33 UTC
Created attachment 222505 [details]
This is the gdp file of first 500 bytes of the mp4 file
Comment 4 zhangyanping 2012-08-27 02:02:35 UTC
Hello Müller .

  I run this cmd :

gst-launch-0.10 filesrc location=kulou.mp4 ! qtdemux name=d  d.video_00 ! gdppay ! filesink location=kulou-h264.gdp

head --bytes=500k kulou-h264.gdp > kulou-h264-avc-start.gdp


 And I got the gdp file , just see the attachment. Thank you.
Comment 5 zhangyanping 2012-08-28 08:16:16 UTC
Hello all,

       I resoloved this problems.

       In gst\videoparsers]gsth264parse.c 

static GstBuffer *
gst_h264_parse_wrap_nal (GstH264Parse * h264parse, guint format, guint8 * data,
                         guint size)
{
      ......
      //old is this
      //buf = gst_buffer_new_allocate (NULL, nl + size, NULL); 
      
     //change to this
      buf = gst_buffer_new_allocate (NULL, 4 + size, NULL); 
     ......
}

Because the first 4 bytes are 00 00 00 01. If the nl is 2, the data buffer is not enough, and will drop the last 2 bytes. So change it to 4 will be OK.

In the gstreamer-0.10 version, the codes like this:
/* make a buffer consisting of a 4-byte start code following by
 * (a copy of) given nal data */
static GstBuffer *
gst_h264_parse_make_nal (GstH264Parse * h264parse, const guint8 * data,
    guint len)
{
  GstBuffer *buf;

  buf = gst_buffer_new_and_alloc (4 + len);
  GST_WRITE_UINT32_BE (GST_BUFFER_DATA (buf), 1);
  memcpy (GST_BUFFER_DATA (buf) + 4, data, len);

  return buf;
}


Hope it will be useful to you, and release the 0.11 stable version  as soon as possible.

Thanks.
Comment 6 Mark Nauwelaerts 2012-08-28 09:26:06 UTC
Thanks, fixed along aforementioned lines.

commit 4f2bcc324389fa32216baece1786389914f3a2f4
Author: Mark Nauwelaerts <mark.nauwelaerts@collabora.co.uk>
Date:   Tue Aug 28 11:07:41 2012 +0200

    h264parse: ensure sufficiently sized buffer when wrapping NAL
    
    Noted by <zhangyanping210@yahoo.com.cn>
    
    Fixes https://bugzilla.gnome.org/show_bug.cgi?id=682589