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 719704 - Segfault while trying to encode an mkv/yuv source file to h264 (without parsing manually with videoparse)
Segfault while trying to encode an mkv/yuv source file to h264 (without parsi...
Status: RESOLVED FIXED
Product: gstreamer-vaapi
Classification: Other
Component: general
0.5.8
Other Linux
: Normal normal
: ---
Assigned To: gstreamer-vaapi maintainer(s)
gstreamer-vaapi maintainer(s)
Depends on:
Blocks: 719412
 
 
Reported: 2013-12-02 17:19 UTC by Florent Thiéry
Modified: 2014-01-13 16:35 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Florent Thiéry 2013-12-02 17:19:43 UTC
1) generate a mkv/yuv (i420) video sample

gst-launch-1.0 videotestsrc num-buffers=10 ! "video/x-raw, format=(string)I420, width=(int)1920, height=(int)1080" ! matroskamux ! filesink location=test.mkv

2) launch an h264 encoding with vaapiencode_h264

[ubicast@easycast-intel yuv_samples]$ gst-launch-1.0 filesrc location=sample.mkv ! matroskademux !  queue name=vaapi ! vaapiencode_h264 ! fakesink sync=false silent=true -v
Setting pipeline to PAUSED ...
libva info: VA-API version 0.34.0
libva info: va_getDriverName() returns 0
libva info: Trying to open /usr/lib/dri/i965_drv_video.so
libva info: Found init function __vaDriverInit_0_34
libva info: va_openDriver() returns 0
Pipeline is PREROLLING ...
Got context from element 'vaapiencodeh264-0': gst.vaapi.Display=context, display=(GstVaapiDisplay)NULL;
ERROR: from element /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0: GStreamer encountered a general stream error.
Additional debug info:
matroska-demux.c(4672): gst_matroska_demux_loop (): /GstPipeline:pipeline0/GstMatroskaDemux:matroskademux0:
stream stopped, reason not-negotiated
Caught SIGSEGV
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Spinning.  Please run 'gdb gst-launch-1.0 1711' to continue debugging, Ctrl-C to quit, or Ctrl-\ to dump core.


[ubicast@easycast-intel yuv_samples]$ LANG=C mkvinfo test.mkv 
+ EBML head
|+ Doc type: matroska
|+ Doc type version: 2
|+ Doc type read version: 2
+ Segment, size 31104965
|+ Seek head (subentries will be skipped)
|+ Segment information
| + Segment UID: 0x3e 0xc9 0xe2 0xef 0x79 0x18 0xfd 0x83 0x3c 0x61 0xeb 0xd9 0x70 0x3a 0xda 0x3a
| + Timecode scale: 1000000
| + Duration: 0.333s (00:00:00.333)
| + Muxing application: GStreamer plugin version 1.2.1
| + Writing application: GStreamer Matroska muxer
| + Date: Mon Dec  2 17:15:07 2013 UTC
|+ Segment tracks
| + A track
|  + Track number: 1 (track ID for mkvmerge & mkvextract: 0)
|  + Track type: video
|  + Track UID: 2787662959
|  + Default duration: 33.333ms (30.000 frames/fields per second for a video track)
|  + Name: Video
|  + Video track
|   + Pixel width: 1920
|   + Pixel height: 1080
|   + Colour space: length 4, data: 0x49 0x34 0x32 0x30
|  + Codec ID: V_UNCOMPRESSED
|+ Cluster

However, directly pushing frames from videotestsrc works:
gst-launch-1.0 videotestsrc num-buffers=100 ! "video/x-raw, format=(string)I420, width=(int)1920, height=(int)1080, framerate=(fraction)30/1" ! vaapiencode_h264 ! fakesink
Comment 1 Florent Thiéry 2013-12-02 17:30:00 UTC
Note that it works with x264enc:
gst-launch-1.0 filesrc location=test.mkv ! matroskademux ! x264enc ! fakesink
Comment 2 Florent Thiéry 2013-12-02 17:34:01 UTC
It looks like videoparse is required :
gst-launch-1.0 filesrc location=test.mkv ! matroskademux ! videoparse width=1920 height=1080 !  vaapiencode_h264 ! fakesink
Comment 3 Gwenole Beauchesne 2014-01-11 13:57:18 UTC
Hi, it seems this is because matroskademux does not like that vaapiencode_* exposes interlace-mode=(string)progressive to its sink pad (template) caps.
Comment 4 Gwenole Beauchesne 2014-01-13 06:29:27 UTC
I think I will only fix the crash for now, i.e. check for NULL GstVaapiEncoder instance in ::finish() IIRC; and let GStreamer return GST_FLOW_NOT_NEGOTIATED. I don't really want to remove the caps where we specify that only progressive frames are supported since this is really what is only supported.

So, inserting videoparse or vaapipostproc before vaapiencode_* elements looks like the thing to do anyway.
Comment 5 Gwenole Beauchesne 2014-01-13 16:35:22 UTC
commit 2c4fde0eae02383a9780e8e87ce1e3d442bf80ce
Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com>
Date:   Mon Jan 13 17:18:42 2014 +0100

    vaapiencode: don't crash on NULL encoder on _finish().
    
    Don't try to destroy an encoder, in GstVideoEncoder::finish() handler,
    if it was not created in the first place. Return "not-negotiated" error
    since this means we did not even reach GstVideoEncoder::set_format(),
    where the encoder could have been created.
    
    This fixes a crash when the vaapiencode_* plug-in elements get deallocated
    and that we failed to negotiate either pad.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=719704