imx8mp gstreamer not working

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

imx8mp gstreamer not working

Jump to solution
1,785 Views
pwhewell
Contributor III

I built the Hardknott 5.10.72 release of Yocto and i was attempting to use the VPU for encoding as a test.

root@ucm-imx8m-plus:~# gst-launch-1.0 -v videotestsrc ! video/x-raw, format=I420, width=640, height=480 ! vpuenc_h264 ! filesink location=test.mp4
Setting pipeline to PAUSED ...
====== VPUENC: 4.6.3 build on Apr 5 2011 23:00:00. ======
wrapper: 3.0.0 (VPUWRAPPER_ARM64_LINUX Build on Apr 5 2011 23:00:00)
vpulib: 1.1.1
firmware: 1.1.1.43690
Pipeline is PREROLLING ...
/GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)640, height=(int)480, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:src: caps = video/x-raw, format=(string)I420, width=(int)640, height=(int)480, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/vpuenc_h264:vpuenc_h264-0.GstPad:sink: caps = video/x-raw, format=(string)I420, width=(int)640, height=(int)480, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
/GstPipeline:pipeline0/GstCapsFilter:capsfilter0.GstPad:sink: caps = video/x-raw, format=(string)I420, width=(int)640, height=(int)480, framerate=(fraction)30/1, multiview-mode=(string)mono, pixel-aspect-ratio=(fraction)1/1, interlace-mode=(string)progressive
VCEncCheckCfg: Invalid width
VCEncInit: ERROR Invalid configuration
ERROR: from element /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0: Internal data stream error.
Additional debug info:
../git/libs/gst/base/gstbasesrc.c(3127): gst_base_src_loop (): /GstPipeline:pipeline0/GstVideoTestSrc:videotestsrc0:
streaming stopped, reason error (-5)
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
Freeing pipeline ...

As you can see the VPU complains about the width but using the verbose print of gstreamer it should work fine. Is there any way to debug this further? The command is out of the imx 8 Gstreamer users guide.

0 Kudos
1 Solution
1,758 Views
pwhewell
Contributor III

I have solved my problem.

The problem comes from internal changes to the encoder. We had added capability to use H264 profiles with the encoder and introduced a bug. When other non-internal applications (e.g. gstreamer) used the encoder we were trying to pass a profile that the application wasn't using. So it resulted in the failure. I fixed the bug by defaulting back to the Base profile in these cases and everything works fine.

View solution in original post

0 Kudos
4 Replies
1,716 Views
malik_cisse
Senior Contributor I

Ok, that makes sense.
Good going

0 Kudos
1,776 Views
malik_cisse
Senior Contributor I

Hi,

I am using Zeus 5.4.70 and your command line will not provide any errors. However the produced files are not playable as such. You need to add h264parse as well as mp4mux:
gst-launch-1.0 -v videotestsrc num-buffers=150 ! video/x-raw, format=I420, width=640, height=480 ! vpuenc_h264 ! h264parse ! mp4mux ! filesink location=test.mp4

Note also that you need to close your mp4 files correctly, otherwise it is not valid. MP4 needs to write key=frame locations at the end of the file. Thus you need to add "num-buffers=150" or any other number of frames to force EOS in gst.

These command will also produce correct mpeg-ts videos (which do not need to be terminated as MP4, thus you can terminate gst command via ctl-c)
gst-launch-1.0 -v videotestsrc num-buffers=300 ! video/x-raw,width=640,height=480,format=YUY2 ! vpuenc_h264 ! h264parse ! mpegtsmux name=mux ! queue ! filesink location=test1.ts
gst-launch-1.0 -v videotestsrc num-buffers=150 ! video/x-raw, format=I420, width=640, height=480 ! vpuenc_h264 ! h264parse ! mpegtsmux ! filesink location=test2.ts

0 Kudos
1,770 Views
pwhewell
Contributor III

I have attempted with earlier versions and have not had problems, for exmaple

 

root@ucm-imx8m-plus:~# gst-launch-1.0 videotestsrc ! video/x-raw, format=I420, width=640, height=480 ! vpuenc_h264 ! filesink location=test.mp4
Setting pipeline to PAUSED ...
====== VPUENC: 4.6.2 build on Aug 27 2021 07:05:03. ======
wrapper: 3.0.0 (VPUWRAPPER_ARM64_LINUX Build on Jul 16 2021 02:05:07)
vpulib: 1.1.1
firmware: 1.1.1.43690
Pipeline is PREROLLING ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
[ 19.359520] imx-dwmac 30bf0000.ethernet eth0: Link is Up - 100Mbps/Full - flow control rx/tx
[ 19.368024] IPv6: ADDRCONF(NETDEV_CHANGE): eth0: link becomes ready
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:02.145019750
Setting pipeline to NULL ...
Freeing pipeline ...

That is the reason i was specifically asking with the version info I included. I'm wondering if there is a problem with the version of VPUENC that is being used. 4.6.2 works but 4.6.3 doesn't

0 Kudos
1,759 Views
pwhewell
Contributor III

I have solved my problem.

The problem comes from internal changes to the encoder. We had added capability to use H264 profiles with the encoder and introduced a bug. When other non-internal applications (e.g. gstreamer) used the encoder we were trying to pass a profile that the application wasn't using. So it resulted in the failure. I fixed the bug by defaulting back to the Base profile in these cases and everything works fine.

0 Kudos