# Image segmentation and encode with LiteRT The use case implements the `deeplabv3_resnet50` LiteRT model to compose the semantic segmentations and original video stream, encode this stream, and then multiplex it in an MP4 container. Run the use case on the target device: gst-launch-1.0 -e --gst-debug=2 \ qtiqmmfsrc name=camsrc ! video/x-raw,format=NV12_Q08C,width=1280,height=720,framerate=30/1 ! queue ! tee name=split \ split. ! queue ! qtivcomposer name=mixer sink_1::dimensions="<1920,1080>" sink_1::alpha=0.5 ! queue ! \ video/x-raw,format=NV12,width=1920,height=1080,interlace-mode=progressive,colorimetry=bt601 ! \ v4l2h264enc capture-io-mode=4 output-io-mode=5 ! h264parse ! queue ! mp4mux ! queue ! filesink location=/etc/media/output_video.mp4 \ split. ! queue ! qtimlvconverter ! queue ! qtimltflite delegate=external external-delegate-path=libQnnTFLiteDelegate.so \ external-delegate-options="QNNExternalDelegate,backend_type=htp;" model=/etc/models/deeplabv3_plus_mobilenet_quantized.tflite ! queue ! \ qtimlpostprocess module=deeplab-argmax labels=/etc/labels/dv3-argmax.json ! video/x-raw,width=256,height=144 ! queue ! mixer. Copy to clipboard To stop the use case, use **CTRL + C**. The following figure shows the flow of the use case execution: 1. Identify the scenes from a video stream coming through a camera source. 2. Compose the semantic segmentation and video stream using qtivcomposer. 3. Encode the stream as a H.264 bit stream and multiplex the stream in an MP4 container. Qualcomm Open source camsrc tee qtimlvconverter qtivcomposer v4l2h264enc h264parse mp4mux filesink qtimltflite qtimlpostprocess **Figure : Pipeline for segmentation and encode with qtivcomposer** The following table provides the sequential processing stages of the pipeline execution: | Process | Description | | --- | --- | | [qtiqmmfsrc](https://docs.qualcomm.com/doc/80-80021-50/topic/qtiqmmfsrc.html) |

  1. Collects the video stream (source) and creates two copies of the source:




    • One stream is sent to the qtivcomposer plugin to retain the video stream.


    • The other stream is sent to an ML inferencing branch in the pipeline.





| | **Preprocessing** | **Preprocessing** | | [qtimlvconverter](https://docs.qualcomm.com/doc/80-80021-50/topic/qtimlvconverter.html) |

  1. Receives the video stream on its sink pad.



  2. Performs preprocessing:

    • Color conversion


    • Scaling down/up


    • Normalization on the stream data when the model expects the floating point values as an input






  3. Converts the video stream to a tensor stream on its source pad.


    The segmentation model uses this tensor stream for inferencing.



| | **Inferencing** | **Inferencing** | | [qtimltflite](https://docs.qualcomm.com/doc/80-80021-50/topic/qtimltflite.html) |

  1. Loads the segmentation model.


  2. Modifies the graph for the chosen delegate.


  3. Receives the tensor stream on its sinkpad.


  4. Runs the inference and produces a tensor stream with the segmentation results on its source pad.


| | **Postprocessing** | **Postprocessing** | | [qtimlpostprocess](https://docs.qualcomm.com/doc/80-80021-50/topic/qtimlpostprocess.html) |

  1. Receives the inference tensors on its sinkpad.


  2. Converts the inference tensors into video formats that the multimedia plugins can process later.


  3. Produces the semantic segmentations for the frame.


  4. Loads the corresponding modules for the segmentation models.


    In this use case, qtimlpostprocess does the following:




    1. Loads the deeplab-argmax submodule.


    2. Produces video frames with segmentation masks.


    3. Sends them to the sinkpad of qtivcomposer.





| | [qtivcomposer](https://docs.qualcomm.com/doc/80-80021-50/topic/qtivcomposer.html) |

  1. Receives the original video stream with segmentation mask on its sinkpads.


  2. Produces on its sourcepad GST buffers with contents composed of video streams from its sinkpads.


| | [v4l2h264enc](https://docs.qualcomm.com/doc/80-80021-50/topic/v4l2h264enc.html) |

  1. Applies parameters to each frame of the video stream it's receiving on its sinkpad.


  2. Encodes it into bit stream and sends it over its sourcepad.


| | h264parse | Adds more information about the bit stream to the GStreamer buffer meta. | | mp4mux | Receives these buffers and creates the container format specification buffers. | | **Output** | **Output** | | Filesink | Stores the resulting stream in a `/etc/media/output_video.mp4` file. | | Playback | Pull *output\_video.mp4* from the host computer and play it on a media player: `scp root@\:/etc/media/output_video.mp4 ` | Last Published: Mar 26, 2026 [Previous Topic Image segmentation and display with LiteRT](https://docs.qualcomm.com/bundle/publicresource/80-80021-50/topics/single-camera-stream-with-image-segmentation-and-display.md) [Next Topic Pose estimation and display with LiteRT](https://docs.qualcomm.com/bundle/publicresource/80-80021-50/topics/single-camera-stream-with-pose-estimation-and-display.md) Source: [https://docs.qualcomm.com/doc/80-80021-50/topic/single-camera-stream-with-image-segmentation-and-encode.html](https://docs.qualcomm.com/doc/80-80021-50/topic/single-camera-stream-with-image-segmentation-and-encode.html)