I can do GPU encoding with the multimedia reference image using the gstreamer plugin v4l2h264enc. However, none of the example containers from the toradex documentation nor gstreamer example container have gstreamer v4l2h264enc. I have also tried installing the gstreamer1.0-plugins-good-imx package on the wayland-base-vivante:2 container. Currently streaming using the x264enc in a docker container results in maxed out CPU loads. How can I install imx’s v4l2h264enc in a docker container?
I now successfully built the docker container following these instructions.
I had to use docker buildx build --platform linux/arm64 to build it as I am on a linux/amd64 system. However, v4l2h264enc still doesn’t work inside the docker container with the following error message.
root@apalis-imx8-07307976:/gst-plugin-pylon# gst-launch-1.0 videotestsrc ! v4l2h264enc ! fakesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
ERROR: from element /GstPipeline:pipeline0/v4l2h264enc:v4l2h264enc0: Device '/dev/video13' does support non-contiguous planes
Additional debug info:
../sys/v4l2/gstv4l2object.c(4012): gst_v4l2_object_set_format_full (): /GstPipeline:pipeline0/v4l2h264enc:v4l2h264enc0:
Device wants 2 planes
ERROR: pipeline doesn't want to preroll.
Setting pipeline to NULL ...
ERROR: from element /GstPipeline:pipeline0/v4l2h264enc:v4l2h264enc0: Could not get/set settings from/on resource.
Additional debug info:
../sys/v4l2/gstv4l2object.c(3462): gst_v4l2_object_set_format_full (): /GstPipeline:pipeline0/v4l2h264enc:v4l2h264enc0:
Device is in streaming mode
ERROR: pipeline doesn't want to preroll.
Freeing pipeline ...
Running v4l2-ctl --info shows:
root@apalis-imx8-07307976:/gst-plugin-pylon# v4l2-ctl --info
Driver Info:
Driver name : mxc-jpeg decode
Card type : mxc-jpeg decoder
Bus info : platform:58400000.jpegdec
Driver version : 5.4.193
Capabilities : 0x84204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04204000
Video Memory-to-Memory Multiplanar
Streaming
Extended Pix Format
After consulting with our team internally I was able to come up with something. So first of all to get v4l2h264enc working you need to use the downstream gstreamer packages as detailed here: How to use Gstreamer on TorizonCore | Toradex Developer Center
Once I did that pipelines with v4l2h264enc were now working:
root@e903a1fbbb7c:/# gst-launch-1.0 videotestsrc ! v4l2h264enc ! fakesink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
^Chandling interrupt.
Interrupt: Stopping pipeline ...
Execution ended after 0:00:09.151688780
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
root@e903a1fbbb7c:/# gst-launch-1.0 videotestsrc num-buffers=150 ! video/x-raw, width=640, height=480 ! v4l2h264enc ! filesink location=test.h264
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:01.051328730
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Freeing pipeline ...
root@e903a1fbbb7c:/# gst-launch-1.0 filesrc location=test.h264 ! h264parse ! v4l2h264dec ! autovideosink
Setting pipeline to PAUSED ...
Pipeline is PREROLLING ...
Redistribute latency...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Got EOS from element "pipeline0".
Execution ended after 0:00:04.999721924
Setting pipeline to PAUSED ...
Setting pipeline to READY ...
Setting pipeline to NULL ...
Total showed frames (150), playing for (0:00:05.000571542), fps (29.997).
Freeing pipeline ...
Now all that said the team did confirm accelerated VPU support was still not complete. So even with this I’m not sure if you will get the performance you were looking for.
Sorry for the delayed response. I was able to successfully follow those instructions and got a container with gpu accelerated encoding. Thank you. What is the best way to monitor the gpu usage? I have tried the gputop container and the numbers just show all 0’s.
Try using the arrow keys to move over some pages you can see more usage statistics that way. Though as I said before we don’t have gstreamer VPU hardware accelerated yet so I’m unsure if you’ll see any hardware activity from this in the tool here.