VPU Performance Issues on iMX8DX with Torizon OS 6

Hi,

I’m using an iMX8DX with Viola, Torizon OS 6, and the wayland-base-vivante:3 image. I’ve been trying to use the VPU, but I’m still facing performance issues, and CPU usage is very high.

I’m using a USB camera with MJPEG video format.

Here is the pipeline I’m currently using:


gst-launch-1.0 v4l2src device=/dev/video4 ! image/jpeg, width=1280, height=720, framerate=30/1 ! v4l2jpegdec ! videoconvert ! video/x-raw, format=NV12 ! v4l2h264enc ! h264parse ! mp4mux ! filesink location=output.mp4

Here’s the output from htop during execution:

And here’s the output before execution:

The result is a poor video around 16 fps.

I also tried using dmabuf, but it didn’t work:

root@colibri-imx8x-07202809:~/app# gst-launch-1.0 v4l2src device=/dev/video4 io-mode=dmabuf ! v4l2jpegdec output-io-mode=dmabuf-import ! videoconvert ! video/x-raw, format=NV12 ! v4l2h264enc output-io-mode=dmabuf-import ! h264parse ! mp4mux ! filesink location=output.mp4
Setting pipeline to PAUSED ...

====== V4L2ENC: 1.20.0 build on Mar 21 2023 18:43:32. ======

====== V4L2DEC: 1.20.0 build on Mar 21 2023 18:43:32. ======
Pipeline is live and does not need PREROLL ...
Pipeline is PREROLLED ...
Setting pipeline to PLAYING ...
New clock: GstSystemClock
Redistribute latency...
Redistribute latency...
ERROR: from element /GstPipeline:pipeline0/GstV4l2Src:v4l2src0: Internal data stream error.

Additional debug info:

../libs/gst/base/gstbasesrc.c(3132): gst_base_src_loop (): /GstPipeline:pipeline0/GstV4l2Src:v4l2src0:
streaming stopped, reason error (-5)
Execution ended after 0:00:01.219342288
Setting pipeline to NULL ...
Freeing pipeline ...
root@colibri-imx8x-07202809:~/app# 

I based this setup on the iMX8 VPU example, although it seems that this example may not apply to the iMX8DX specifically.

Is there VPU support for the iMX8DX in Torizon 7?

Could you please help me troubleshoot this issue?

Dockerfile (8.0 KB)

Hi, I’m the Toradex AI Assistant.

I might make mistakes. Our support team will step in if needed. If I answered your question, please tick the “Solution” checkbox. For follow-up questions to me, please use @ToradexAI in your post.

Did you like my answer? :+1: :-1:


Hello, and thank you for sharing a detailed description of your setup and issue.

1. VPU Support on iMX8DX with Torizon OS 6

Based on the currently available documentation, there is no explicit confirmation that the i.MX8DX’s VPU is officially supported for hardware video encoding/decoding in Torizon OS 6 or 7. While Toradex provides VPU-accelerated GStreamer pipelines for i.MX8 families, specific support or stability for the i.MX8DX variant is not documented. This can result in software fallbacks and high CPU usage (Video Processing GStreamer), (How to Use GStreamer on TorizonCore).

2. Pipeline Analysis and Troubleshooting

Your GStreamer pipeline:

gst-launch-1.0 v4l2src device=/dev/video4 ! image/jpeg, width=1280, height=720, framerate=30/1 ! v4l2jpegdec ! videoconvert ! video/x-raw, format=NV12 ! v4l2h264enc ! h264parse ! mp4mux ! filesink location=output.mp4

Observations:

  • Both v4l2jpegdec and v4l2h264enc depend on the underlying VPU driver support and correct device mapping in the container.
  • High CPU usage usually indicates that decoding/encoding is happening in software due to missing or unsupported hardware acceleration.

Key checks and suggestions:

A. VPU-Backed Elements

  • The recommended hardware-accelerated encoder for i.MX8 is vpuenc_h264 (not v4l2h264enc). Example usage:
    ... ! videoconvert ! vpuenc_h264 ! video/x-h264 ! h264parse ! ...
    
  • Make sure the necessary VPU-related GStreamer plugins (e.g., gstreamer1.0-imx or equivalent) are available in your container. The wayland-base-vivante image is designed for this.

B. Pipeline Optimization

  • Try running with vpuenc_h264 if available:
    gst-launch-1.0 v4l2src device=/dev/video4 ! image/jpeg, width=1280, height=720, framerate=30/1 ! jpegdec ! videoconvert ! vpuenc_h264 ! h264parse ! mp4mux ! filesink location=output.mp4
    
  • Replace jpegdec with v4l2jpegdec only if hardware-accelerated decoding is confirmed to be available.

C. Container Device Access

  • Ensure the container is running with access to /dev/video4, /dev/video-dec0, and /dev/video-enc0 (or similarly named devices, depending on your kernel, usually exposed by the VPU).

D. dmabuf Mode

  • Failure with dmabuf usually suggests that the kernel, driver, or GStreamer plugins lack the necessary support or compatibility for zero-copy operation on your current OS and hardware combination.

3. Next Steps

  • Double-check the presence of VPU device nodes (e.g., ls /dev/video*).
  • List the available GStreamer encoders:
    gst-inspect-1.0 | grep 264enc
    gst-inspect-1.0 | grep vpu
    
  • If vpuenc_h264 is available, use it as in the official example:
    GStreamer Hardware Encoding Example
  • If not available or pipeline still falls back to software, then current Torizon version may not support hardware VPU on iMX8DX, and performance will be CPU-bound.

References:

If you need help interpreting your pipeline, please paste the output of gst-inspect-1.0 | grep vpu and any error logs from a pipeline invocation using vpuenc_h264, if available.

Best regards,
Toradex AI Assistant.