GNOME Bugzilla – Bug 743567
cannot encode video from UYVY and YUY2 file and usb camera base Gstreamer-1.4.5 and Vaapi-0.5.9
Last modified: 2015-01-28 07:55:51 UTC
There are two issues after update to Gstreamer-1.4.5 and vaapi-0.5.9 : 1. YUV420 NV12 and YV12 format encode is ok, but UYVY and YUY2 format cannot encode. 2. Encode video from usb camera cannot work. Test environment: Gstreamer-1.4.5 Gstreamer-vaapi 0.5.9 libva-1.5.0 intel-driver-1.5.0 Linux kernel 3.10.61 For UYVY_Prog_Packed_176x144.yuv test file,encode error message as below: [root@localhost media]# gst-launch-1.0 filesrc location= ./UYVY_Prog_Packed_176x144.yuv ! videoparse format=uyvy width=176 height=144 framerate=30/1 ! vaapiencode_h264 ! vaapiparse_h264 ! qtmux ! filesink location=./test4.mp4 Setting pipeline to PAUSED ... libva info: VA-API version 0.37.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_37 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/GstVaapiEncodeH264:vaapiencodeh264-0: GStreamer error: negotiation problem. Additional debug info: gstvideoencoder.c(1463): gst_video_encoder_chain (): /GstPipeline:pipeline0/GstVaapiEncodeH264:vaapiencodeh264-0: encoder not initialized ERROR: pipeline doesn't want to preroll. Setting pipeline to NULL ... Freeing pipeline ... [root@localhost media]# For YUV420_Prog_Planar_176x144.yuv and NV12_Prog_Planar_176x144.yuv, below commands work ok: [root@localhost media]# gst-launch-1.0 filesrc location= ./YUV420_Prog_Planar_176x144.yuv ! videoparse format=i420 width=176 height=144 framerate=30/1 ! queue ! vaapiencode_h264 ! vaapiparse_h264 ! qtmux ! filesink location=./test2.mp4 [root@localhost media]# gst-launch-1.0 filesrc location= ./NV12_Prog_Planar_176x144.yuv ! videoparse format=nv12 width=176 height=144 framerate=30/1 ! queue ! vaapiencode_h264 ! vaapiparse_h264 ! qtmux ! filesink location=./test2.mp4 For encode video from usb camera, the command I use and error message as below: [root@localhost media]# gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=200 ! video/x-raw,format=YUY2,width=1920,height=1080 ! vaapipostproc ! queue ! vaapiencode_h264 ! qtmux ! filesink location=test2.mp4 libva info: VA-API version 0.37.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_37 libva info: va_openDriver() returns 0 Setting pipeline to PAUSED ... Pipeline is live and does not need PREROLL ... Got context from element 'vaapipostproc0': gst.vaapi.Display=context, display=(GstVaapiDisplay)NULL; Setting pipeline to PLAYING ... New clock: GstSystemClock ERROR: from element /GstPipeline:pipeline0/GstVaapiEncodeH264:vaapiencodeh264-0: GStreamer error: negotiation problem. Additional debug info: gstvideoencoder.c(1463): gst_video_encoder_chain (): /GstPipeline:pipeline0/GstVaapiEncodeH264:vaapiencodeh264-0: encoder not initialized Execution ended after 0:00:00.473133572 Setting pipeline to PAUSED ... Setting pipeline to READY ... Setting pipeline to NULL ... Freeing pipeline ...
The driver is only supports YUV420 (nv12/yv12/i420) for encoding. So you should use a vaapipostproc for other formats like UYVY. This still need a fix though. I have pushed a patch to the git master now (cffe87df89870ce7a68dc5bc39826bb66f817a57), please have a try. ....! vaapipostproc ! vaapiencode_h264 ! vaapiparse_h264 ! .......
*** This bug has been marked as a duplicate of bug 743035 ***
thank you sreerenj,after push below two main branch patches to gstreamer-vaapi-0.5.9, all test is ok now. Thank you! commit cffe87df89870ce7a68dc5bc39826bb66f817a57 Author: Sreerenj Balachandran <sreerenj.balachandran@intel.com> Date: Tue Jan 27 12:38:45 2015 +0200 gstvaapiencoder: Fix the negotiation issue with _ENCODED format handling Don't error out for the video format GST_VIDEO_FORMAT_ENCODED with in gstvaapiencoder, since the vaaapi context creation (gstvaapicontext.c) can still use the default chroma type which is YUV420. https://bugzilla.gnome.org/show_bug.cgi?id=743567 https://bugzilla.gnome.org/show_bug.cgi?id=743035 commit a4d88db0fdf208bb5c999cf2cca2742993b17cd8 Author: Gwenole Beauchesne <gwenole.beauchesne@intel.com> Date: Tue Nov 18 14:57:02 2014 +0100 plugins: preserve framerate when updating src caps video format. In the current implementation, gst_video_info_set_format() would reset the whole GstVideoInfo structure first, prior to setting video format and size. So, coleteral information like framerate or pixel-aspect- ratio are lost. Provide and use a unique gst_video_info_change_format() for overcome this issue, i.e. only have it change the format and video size, and copy over the rest of the fields. https://bugzilla.gnome.org/show_bug.cgi?id=734665 the command I use as below: gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=200 ! video/x-raw,format=YUY2,width=1920,height=1080 ! vaapipostproc ! queue ! vaapiencode_h264 ! vaapiparse_h264 ! qtmux ! filesink location=test2.mp4 gst-launch-1.0 v4l2src device=/dev/video0 num-buffers=200 ! video/x-raw,format=YUY2,width=1920,height=1080 ! vaapipostproc ! queue ! vaapiencode_mpeg2 ! mpegvideoparse ! mpegtsmux ! filesink location=test2.mpg gst-launch-1.0 filesrc location= ./UYVY_Prog_Packed_176x144.yuv ! videoparse format=uyvy width=176 height=144 framerate=30/1 ! vaapipostproc ! queue ! vaapiencode_h264 ! vaapiparse_h264 ! qtmux ! filesink location=test2.mp4 gst-launch-1.0 filesrc location= ./UYVY_Prog_Packed_176x144.yuv ! videoparse format=uyvy width=176 height=144 framerate=30/1 ! vaapipostproc ! queue ! vaapiencode_mpeg2 ! mpegvideoparse ! mpegtsmux ! filesink location=test2.mpg