Skip to main content
This section covers Python-based multimedia sample applications that demonstrate camera streaming, video playback, and transformation on Qualcomm platforms.

Prerequisites

See the Prerequisites section in the Python AI page for device setup, Wi-Fi, artifact download, and enabling qticamsrc and libcamera.

Multimedia Applications

Camera encoding

The gst-camera-encode.py application allows you to record and encode a single camera stream. For information about the plugins used in this pipeline, see Pipeline flow. camera encode pipeline Application: gst-camera-encode.py
1

Complete prerequisites

Ensure that you complete the Prerequisites.
2

Run the application

gst-camera-encode.py
To display all available options:
gst-camera-encode.py -h
3

Pull output from device

scp root@<IP address of target device>:/etc/media/recording.mp4 .

Expected output

The output is saved in a file at /etc/media/recording.mp4.

Pipeline flow

PluginDescription
qticamsrcCaptures the camera live stream. Capsfilter enforces constraints on raw video data.
v4l2h264encEncodes the video using H.264 format.
h264parseParses the encoded video.
mp4muxMultiplexes the video into an MP4 container.
filesinkWrites the video to a file.

Camera Streaming using OpenCV

The gst-camera-opencv-resize.py application uses OpenCV APIs to capture a camera frame from a live camera stream and apply color conversion or resize. The output is displayed on the screen. For information about the plugins used in this pipeline, see Pipeline flow. camera resize pipeline Application: gst-camera-opencv-resize.py
1

Complete prerequisites

Ensure that you complete the Prerequisites.
2

Run the application

gst-camera-opencv-resize.py --inwidth 1280 --inheight 720 --outwidth 640 --outheight 480
To display all available options:
gst-camera-opencv-resize.py -h

Expected output

The stream is displayed on the screen.Camera Resize Output

Troubleshoot GTK backend failure in root mode

When running a GTK-based application as root, GTK may fail to initialize the backend. Export the active display session before running:

Pipeline flow

PluginDescription
qticamsrcCaptures the video stream and feeds it into the capsfilter.
capsfilterEnforces constraints on the raw video data.
queueBuffers video data.
qtivtransformTransforms the video data.
waylandsinkDisplays the video stream on the Wayland display.

Concurrent video playback (video wall) using Python

The gst-concurrent-videoplay-composition.py application supports concurrent video playback for MP4 AVC (H.264) videos and performs composition on a video wall display. For information about the plugins used in this pipeline, see Pipeline flow. concurrent playback pipeline Application: gst-concurrent-videoplay-composition.py
1

Complete prerequisites

Ensure that you complete the Prerequisites.
2

Run the application

gst-concurrent-videoplay-composition.py --infile /etc/media/video_avc.mp4
To change the number of sessions, update -c with 2, 4, 8, or 16.To display all available options:
gst-concurrent-videoplay-composition.py -h

Expected output

The individual composed streams are tiled together to display as a unified stream.Concurrent Playback Output

Pipeline flow

PluginDescription
filesrcReads the video data.
qtdemuxDemultiplexes the video data.
h264parseParses H.264 video streams.
v4l2h264decDecodes H.264 video streams.
qtivcomposerComposes decoded streams and sends to display.
waylandsinkDisplays the video stream on the Wayland display.

Video transformation using OpenCV

The gst-opencv-transform.py application captures and transforms a video frame then displays the video on the screen using the OpenCV VideoCapture() function. For information about the plugins used in this pipeline, see Pipeline flow. camera transform pipeline Application: gst-opencv-transform.py
1

Complete prerequisites

Ensure that you complete the Prerequisites.
2

Run the application

gst-opencv-transform.py --infile /etc/media/video_avc.mp4
To display all available options:
gst-opencv-transform.py -h

Expected output

The stream is displayed on the screen.Camera Transform Output

Pipeline flow

PluginDescription
filesrcReads the video data.
qtdemuxDemultiplexes the video data.
h264parseParses H.264 video streams.
v4l2h264decDecodes H.264 video streams.
qtivtransformTransforms the video data.
videoconvertConverts video frames from one format to another.
capsfilterEnforces constraints on the video data.
waylandsinkDisplays the video stream on the Wayland display.

Multi-camera streaming using Python

The gst-multi-camera-stream-example.py application streams from two camera sensors simultaneously, composing the feeds side by side or encoding to files. For information about the plugins used in this pipeline, see Pipeline flow. multi camera streaming pipeline Application: gst-multi-camera-stream-example.py
This application isn’t supported in the Config #1 of the QLI 2.0 RC3 release.
1

Complete prerequisites

Ensure that you complete the Prerequisites.
2

Run the application

  • Preview on display:
gst-multi-camera-stream-example.py -D 1 --width=1920 --height=1080
  • Encode to file:
gst-multi-camera-stream-example.py -D 0 --width=1920 --height=1080 --framerate=30/1
To display all available options:
gst-multi-camera-stream-example.py --help

Expected output

For the video composition pipeline, the output is displayed as a preview.Multi Camera Streaming Output

Pipeline flow

PipelineDescription
Preview on displayqticamsrc (cam0 + cam1) → capsfilter → qtivcomposerwaylandsink
Encoder dumpqticamsrc (cam0 + cam1) → capsfilter → v4l2h264ench264parsemp4muxfilesink

Decode JPEG images using Python

The gst-jpg-image-decode.py application decodes JPEG images and displays them on a screen. For information about the plugins used in this pipeline, see Pipeline flow. jpeg decode pipeline Application: gst-jpg-image-decode.py
1

Complete prerequisites

Ensure that you complete the Prerequisites.
2

Run the application

gst-jpg-image-decode.py -i /etc/media/imagefiles_%d.jpg
To display all available options:
gst-jpg-image-decode.py -h

Expected output

The decoded images are displayed on the screen.JPEG Decode Output

Pipeline flow

PluginDescription
multifilesrcReads video data from sequentially named files.
capsfilterEnforces constraints on the video data.
jpegdecDecodes the JPEG video stream.
videoconvertConverts video frames from one format to another.
waylandsinkDisplays the video stream on the Wayland display.

Transform and encode a camera stream

The gst-camera-rotate-downscale-file.py application rotates, downscales, and encodes a camera stream, saving the result to a file. For information about the plugins used in this pipeline, see Pipeline flow. camera transform encode pipeline Application: gst-camera-rotate-downscale-file.py
1

Complete prerequisites

Ensure that you complete the Prerequisites.
2

Run the application

gst-camera-rotate-downscale-file.py
To display all available options:
gst-camera-rotate-downscale-file.py -h

Expected output

The output is saved to a file at /etc/media/test.mp4.

Pipeline flow

PluginDescription
qticamsrcCaptures the video stream.
qtivtransformRotates and downscales the video stream.
v4l2h264encEncodes H.264 video.
h264parseParses the encoded H.264 video stream.
mp4muxMultiplexes the stream into an MP4 container.
filesinkWrites the video data to a file.

Troubleshooting

Download the model manually from IoT — Qualcomm AI Hub and push it to the device:
scp <model filename> root@<IP addr of the target device>:/etc/models
Remount the file system with read/write permissions:For Qualcomm Linux:
mount -o remount,rw /usr
For Ubuntu Server:
mount -o remount,rw /
ps -ef | grep cam-server
rm ~/.cache/gstreamer-1.0/registry.aarch64.bin
export GST_DEBUG=2
export GST_DEBUG=3,qticamsrc:5,qtimlvconverter:5,qtimltflite:5
export GST_DEBUG_FILE=/tmp/gst_debug.log