> ## Documentation Index
> Fetch the complete documentation index at: https://imsdkdocs.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Multimedia

> Ready-to-run Python multimedia applications demonstrating QIM SDK camera, video, and streaming capabilities

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

***

<h2 id="prerequisites">
  Prerequisites
</h2>

See the [Prerequisites](/sample-application/python-ai-sample-applications#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**](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/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-encoding-py-pipeline).

<img src="https://mintcdn.com/qimsdk/LUzi1SsU-yLionE6/sample-application/python-images/camera-encode-pipeline.svg?fit=max&auto=format&n=LUzi1SsU-yLionE6&q=85&s=6f32c6ee24fcb687b1f327fe35e8c9da" alt="camera encode pipeline" width="906" height="201" data-path="sample-application/python-images/camera-encode-pipeline.svg" />

**Application:** [`gst-camera-encode.py`](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/gst-camera-encode.py)

<Accordion title="Try me">
  <Steps>
    <Step title="Complete prerequisites">
      Ensure that you complete the [Prerequisites](#prerequisites).
    </Step>

    <Step title="Run the application">
      ```bash theme={null}
      gst-camera-encode.py
      ```

      To display all available options:

      ```bash theme={null}
      gst-camera-encode.py -h
      ```
    </Step>

    <Step title="Pull output from device">
      ```bash theme={null}
      scp root@<IP address of target device>:/etc/media/recording.mp4 .
      ```
    </Step>
  </Steps>

  ### Expected output

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

  <h3 id="camera-encoding-py-pipeline">
    Pipeline flow
  </h3>

  | Plugin        | Description                                                                         |
  | ------------- | ----------------------------------------------------------------------------------- |
  | `qticamsrc`   | Captures the camera live stream. Capsfilter enforces constraints on raw video data. |
  | `v4l2h264enc` | Encodes the video using H.264 format.                                               |
  | `h264parse`   | Parses the encoded video.                                                           |
  | `mp4mux`      | Multiplexes the video into an MP4 container.                                        |
  | `filesink`    | Writes the video to a file.                                                         |
</Accordion>

***

### Camera Streaming using OpenCV

The [**gst-camera-opencv-resize.py**](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/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-py-pipeline).

<img src="https://mintcdn.com/qimsdk/LUzi1SsU-yLionE6/sample-application/python-images/camera-resize-pipeline.svg?fit=max&auto=format&n=LUzi1SsU-yLionE6&q=85&s=3da628d1160fd3510023569c6428d3fe" alt="camera resize pipeline" width="1123" height="187" data-path="sample-application/python-images/camera-resize-pipeline.svg" />

**Application:** [`gst-camera-opencv-resize.py`](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/gst-camera-opencv-resize.py)

<Accordion title="Try me">
  <Steps>
    <Step title="Complete prerequisites">
      Ensure that you complete the [Prerequisites](#prerequisites).
    </Step>

    <Step title="Run the application">
      ```bash theme={null}
      gst-camera-opencv-resize.py --inwidth 1280 --inheight 720 --outwidth 640 --outheight 480
      ```

      To display all available options:

      ```bash theme={null}
      gst-camera-opencv-resize.py -h
      ```
    </Step>
  </Steps>

  ### Expected output

  The stream is displayed on the screen.

  <img src="https://mintcdn.com/qimsdk/LUzi1SsU-yLionE6/sample-application/python-images/camera-resize-output.jpg?fit=max&auto=format&n=LUzi1SsU-yLionE6&q=85&s=d6a9934e2072409c0c39e557f905766d" alt="Camera Resize Output" width="624" height="496" data-path="sample-application/python-images/camera-resize-output.jpg" />

  ### 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:

  ```bash theme={null}
  ```

  <h3 id="camera-resize-py-pipeline">
    Pipeline flow
  </h3>

  | Plugin          | Description                                                 |
  | --------------- | ----------------------------------------------------------- |
  | `qticamsrc`     | Captures the video stream and feeds it into the capsfilter. |
  | `capsfilter`    | Enforces constraints on the raw video data.                 |
  | `queue`         | Buffers video data.                                         |
  | `qtivtransform` | Transforms the video data.                                  |
  | `waylandsink`   | Displays the video stream on the Wayland display.           |
</Accordion>

***

### Concurrent video playback (video wall) using Python

The [**gst-concurrent-videoplay-composition.py**](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/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-py-pipeline).

<img src="https://mintcdn.com/qimsdk/LUzi1SsU-yLionE6/sample-application/python-images/concurrent-playback-pipeline.svg?fit=max&auto=format&n=LUzi1SsU-yLionE6&q=85&s=554b575045e611be309333c640e0f894" alt="concurrent playback pipeline" width="1200" height="391" data-path="sample-application/python-images/concurrent-playback-pipeline.svg" />

**Application:** [`gst-concurrent-videoplay-composition.py`](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/gst-concurrent-videoplay-composition.py)

<Accordion title="Try me">
  <Steps>
    <Step title="Complete prerequisites">
      Ensure that you complete the [Prerequisites](#prerequisites).
    </Step>

    <Step title="Run the application">
      ```bash theme={null}
      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:

      ```bash theme={null}
      gst-concurrent-videoplay-composition.py -h
      ```
    </Step>
  </Steps>

  ### Expected output

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

  <img src="https://mintcdn.com/qimsdk/LUzi1SsU-yLionE6/sample-application/python-images/concurrent-playback-output.png?fit=max&auto=format&n=LUzi1SsU-yLionE6&q=85&s=6bbc4fb5d921bc2e946dbe17bcecbcda" alt="Concurrent Playback Output" width="975" height="370" data-path="sample-application/python-images/concurrent-playback-output.png" />

  <h3 id="concurrent-playback-py-pipeline">
    Pipeline flow
  </h3>

  | Plugin         | Description                                       |
  | -------------- | ------------------------------------------------- |
  | `filesrc`      | Reads the video data.                             |
  | `qtdemux`      | Demultiplexes the video data.                     |
  | `h264parse`    | Parses H.264 video streams.                       |
  | `v4l2h264dec`  | Decodes H.264 video streams.                      |
  | `qtivcomposer` | Composes decoded streams and sends to display.    |
  | `waylandsink`  | Displays the video stream on the Wayland display. |
</Accordion>

***

### Video transformation using OpenCV

The [**gst-opencv-transform.py**](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/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-py-pipeline).

<img src="https://mintcdn.com/qimsdk/LUzi1SsU-yLionE6/sample-application/python-images/camera-transform-pipeline.svg?fit=max&auto=format&n=LUzi1SsU-yLionE6&q=85&s=3b646ecd5874a32d662d0369b5710dea" alt="camera transform pipeline" width="1070" height="98" data-path="sample-application/python-images/camera-transform-pipeline.svg" />

**Application:** [`gst-opencv-transform.py`](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/gst-opencv-transform.py)

<Accordion title="Try me">
  <Steps>
    <Step title="Complete prerequisites">
      Ensure that you complete the [Prerequisites](#prerequisites).
    </Step>

    <Step title="Run the application">
      ```bash theme={null}
      gst-opencv-transform.py --infile /etc/media/video_avc.mp4
      ```

      To display all available options:

      ```bash theme={null}
      gst-opencv-transform.py -h
      ```
    </Step>
  </Steps>

  ### Expected output

  The stream is displayed on the screen.

  <img src="https://mintcdn.com/qimsdk/LUzi1SsU-yLionE6/sample-application/python-images/camera-transform-output.png?fit=max&auto=format&n=LUzi1SsU-yLionE6&q=85&s=ddb3edfb8c33e65f6234445e45ad9031" alt="Camera Transform Output" width="975" height="496" data-path="sample-application/python-images/camera-transform-output.png" />

  <h3 id="camera-transform-py-pipeline">
    Pipeline flow
  </h3>

  | Plugin          | Description                                       |
  | --------------- | ------------------------------------------------- |
  | `filesrc`       | Reads the video data.                             |
  | `qtdemux`       | Demultiplexes the video data.                     |
  | `h264parse`     | Parses H.264 video streams.                       |
  | `v4l2h264dec`   | Decodes H.264 video streams.                      |
  | `qtivtransform` | Transforms the video data.                        |
  | `videoconvert`  | Converts video frames from one format to another. |
  | `capsfilter`    | Enforces constraints on the video data.           |
  | `waylandsink`   | Displays the video stream on the Wayland display. |
</Accordion>

***

### Multi-camera streaming using Python

The [**gst-multi-camera-stream-example.py**](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/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-py-pipeline).

<img src="https://mintcdn.com/qimsdk/LUzi1SsU-yLionE6/sample-application/python-images/multi-camera-streaming-pipeline.svg?fit=max&auto=format&n=LUzi1SsU-yLionE6&q=85&s=2f644af49c0a9abe9cdebdc56b34df77" alt="multi camera streaming pipeline" width="1080" height="382" data-path="sample-application/python-images/multi-camera-streaming-pipeline.svg" />

**Application:** [`gst-multi-camera-stream-example.py`](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/gst-multi-camera-stream-example.py)

<Note>
  This application isn't supported in the Config #1 of the QLI 2.0 RC3 release.
</Note>

<Accordion title="Try me">
  <Steps>
    <Step title="Complete prerequisites">
      Ensure that you complete the [Prerequisites](#prerequisites).
    </Step>

    <Step title="Run the application">
      * Preview on display:

      ```bash theme={null}
      gst-multi-camera-stream-example.py -D 1 --width=1920 --height=1080
      ```

      * Encode to file:

      ```bash theme={null}
      gst-multi-camera-stream-example.py -D 0 --width=1920 --height=1080 --framerate=30/1
      ```

      To display all available options:

      ```bash theme={null}
      gst-multi-camera-stream-example.py --help
      ```
    </Step>
  </Steps>

  ### Expected output

  For the video composition pipeline, the output is displayed as a preview.

  <img src="https://mintcdn.com/qimsdk/LUzi1SsU-yLionE6/sample-application/python-images/multi-camera-streaming-output.png?fit=max&auto=format&n=LUzi1SsU-yLionE6&q=85&s=bc5eec28d0d2b71a7f2b924defd09eeb" alt="Multi Camera Streaming Output" width="975" height="400" data-path="sample-application/python-images/multi-camera-streaming-output.png" />

  <h3 id="multi-camera-streaming-py-pipeline">
    Pipeline flow
  </h3>

  | Pipeline           | Description                                                                                  |
  | ------------------ | -------------------------------------------------------------------------------------------- |
  | Preview on display | `qticamsrc` (cam0 + cam1) → capsfilter → `qtivcomposer` → `waylandsink`                      |
  | Encoder dump       | `qticamsrc` (cam0 + cam1) → capsfilter → `v4l2h264enc` → `h264parse` → `mp4mux` → `filesink` |
</Accordion>

***

### Decode JPEG images using Python

The [**gst-jpg-image-decode.py**](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/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-py-pipeline).

<img src="https://mintcdn.com/qimsdk/LUzi1SsU-yLionE6/sample-application/python-images/jpeg-decode-py-pipeline.svg?fit=max&auto=format&n=LUzi1SsU-yLionE6&q=85&s=63e94fdaa68af699582d483034aa8ca2" alt="jpeg decode pipeline" width="860" height="97" data-path="sample-application/python-images/jpeg-decode-py-pipeline.svg" />

**Application:** [`gst-jpg-image-decode.py`](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/gst-jpg-image-decode.py)

<Accordion title="Try me">
  <Steps>
    <Step title="Complete prerequisites">
      Ensure that you complete the [Prerequisites](#prerequisites).
    </Step>

    <Step title="Run the application">
      ```bash theme={null}
      gst-jpg-image-decode.py -i /etc/media/imagefiles_%d.jpg
      ```

      To display all available options:

      ```bash theme={null}
      gst-jpg-image-decode.py -h
      ```
    </Step>
  </Steps>

  ### Expected output

  The decoded images are displayed on the screen.

  <img src="https://mintcdn.com/qimsdk/LUzi1SsU-yLionE6/sample-application/python-images/jpeg-decode-py-output.png?fit=max&auto=format&n=LUzi1SsU-yLionE6&q=85&s=6fa8994d6356a1deda6b4b0893c27e1e" alt="JPEG Decode Output" width="1029" height="143" data-path="sample-application/python-images/jpeg-decode-py-output.png" />

  <h3 id="jpeg-decode-py-pipeline">
    Pipeline flow
  </h3>

  | Plugin         | Description                                       |
  | -------------- | ------------------------------------------------- |
  | `multifilesrc` | Reads video data from sequentially named files.   |
  | `capsfilter`   | Enforces constraints on the video data.           |
  | `jpegdec`      | Decodes the JPEG video stream.                    |
  | `videoconvert` | Converts video frames from one format to another. |
  | `waylandsink`  | Displays the video stream on the Wayland display. |
</Accordion>

***

### Transform and encode a camera stream

The [**gst-camera-rotate-downscale-file.py**](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/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](#transform-encode-py-pipeline).

<img src="https://mintcdn.com/qimsdk/LUzi1SsU-yLionE6/sample-application/python-images/transform-encode-py-pipeline.svg?fit=max&auto=format&n=LUzi1SsU-yLionE6&q=85&s=fc058290974d76839fb334bbebd946e6" alt="camera transform encode pipeline" width="793" height="207" data-path="sample-application/python-images/transform-encode-py-pipeline.svg" />

**Application:** [`gst-camera-rotate-downscale-file.py`](https://github.com/qualcomm/gst-plugins-imsdk/blob/main/gst-python-examples/gst-camera-rotate-downscale-file.py)

<Accordion title="Try me">
  <Steps>
    <Step title="Complete prerequisites">
      Ensure that you complete the [Prerequisites](#prerequisites).
    </Step>

    <Step title="Run the application">
      ```bash theme={null}
      gst-camera-rotate-downscale-file.py
      ```

      To display all available options:

      ```bash theme={null}
      gst-camera-rotate-downscale-file.py -h
      ```
    </Step>
  </Steps>

  ### Expected output

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

  <h3 id="transform-encode-py-pipeline">
    Pipeline flow
  </h3>

  | Plugin          | Description                                   |
  | --------------- | --------------------------------------------- |
  | `qticamsrc`     | Captures the video stream.                    |
  | `qtivtransform` | Rotates and downscales the video stream.      |
  | `v4l2h264enc`   | Encodes H.264 video.                          |
  | `h264parse`     | Parses the encoded H.264 video stream.        |
  | `mp4mux`        | Multiplexes the stream into an MP4 container. |
  | `filesink`      | Writes the video data to a file.              |
</Accordion>

***

## Troubleshooting

<AccordionGroup>
  <Accordion title="Model not available after running the download script?">
    Download the model manually from [IoT — Qualcomm AI Hub](https://aihub.qualcomm.com) and push it to the device:

    ```bash theme={null}
    scp <model filename> root@<IP addr of the target device>:/etc/models
    ```
  </Accordion>

  <Accordion title="Running sample applications from the UART shell">
    Remount the file system with read/write permissions:

    For Qualcomm Linux:

    ```bash theme={null}
    mount -o remount,rw /usr
    ```

    For Ubuntu Server:

    ```bash theme={null}
    mount -o remount,rw /
    ```
  </Accordion>

  <Accordion title="Cannot locate the qticamsrc plugin?">
    ```bash theme={null}
    ps -ef | grep cam-server
    rm ~/.cache/gstreamer-1.0/registry.aarch64.bin
    ```
  </Accordion>

  <Accordion title="GStreamer logging and debugging">
    ```bash theme={null}
    export GST_DEBUG=2
    export GST_DEBUG=3,qticamsrc:5,qtimlvconverter:5,qtimltflite:5
    export GST_DEBUG_FILE=/tmp/gst_debug.log
    ```
  </Accordion>
</AccordionGroup>
