# Transform and encode a camera stream

Source: [https://docs.qualcomm.com/doc/80-70022-50/topic/camera-transform-downscale-and-rotate-encode.html](https://docs.qualcomm.com/doc/80-70022-50/topic/camera-transform-downscale-and-rotate-encode.html)

The **gst-camera-rotate-downscale-file.py** application  rotates, downscales, and
        encodes a camera stream. The transformed stream is then saved to a file.

Figure : Pipeline for video transformation
            
            <?xml version="1.0" encoding="UTF-8"?>
<svg xmlns="http://www.w3.org/2000/svg" width="1149.999999999998181" height="126" viewbox="0 0 1149.999999999998181 126">
  <g id="Layer_1" data-name="Layer 1">
    <g>
      <rect x=".4998779296875" y=".499923706054688" width="1149.00048828125" height="125" rx="7.499999999999943" ry="7.499999999999943" style="fill: #fafafa;"></rect>
      <path d="M1141.999999999998181,1c3.85986328125,0,7,3.140144348144531,7,7v110c0,3.85986328125-3.14013671875,7-7,7H8c-3.859857559204102,0-7-3.14013671875-7-7V8c0-3.859855651855469,3.140142440795898-7,7-7h1133.999999999998181M1141.999999999998181,0H8C3.581714630126953,0,0,3.581714630126953,0,8v110c0,4.418289184570312,3.581714630126953,8,8,8h1133.999999999998181c4.418334960939319,0,8-3.581710815429688,8-8V8c0-4.418285369873047-3.581665039060681-8-8-8h0Z" style="fill: #d2d7e1;"></path>
    </g>
    <g>
      <g>
        <text transform="translate(960.49273681640625 102.091506958007812)" style="font-family: Roboto-Regular, Roboto; font-size: 14px;"><tspan x="0" y="0">Qualcomm </tspan></text>
        <rect x="940.241769385746011" y="90" width="16" height="16" rx="2" ry="2" style="fill: #2a2aea;"></rect>
      </g>
      <g>
        <text transform="translate(1059.0745849609375 102.091506958007812)" style="font-family: Roboto-Regular, Roboto; font-size: 14px;"><tspan x="0" y="0">Open source</tspan></text>
        <rect x="1038.823550798597353" y="90" width="16" height="16" rx="2" ry="2" style="fill: #007884;"></rect>
      </g>
    </g>
  </g>
  <g id="Layer_2" data-name="Layer 2">
    <g>
      <g>
        <rect x="20.00004069010447" y="20" width="110" height="50" rx="4" ry="4" style="fill: #2a2aea;"></rect>
        <text transform="translate(33.53106689453125 48.506710052490234)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">qtiqmmfsrc</tspan></text>
      </g>
      <g>
        <rect x="150.00004069010447" y="20" width="100" height="50" rx="4" ry="4" style="fill: #007884;"></rect>
        <text transform="translate(166.62896728515625 48.506710052490234)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">capsfilter</tspan></text>
      </g>
      <g>
        <line x1="130.000038146972656" y1="45" x2="144.976676940917059" y2="45" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="143.95538330078125 48.490432739257812 150.000038146972656 45 143.95538330078125 41.509567260742188 143.95538330078125 48.490432739257812"></polygon>
      </g>
      <g>
        <rect x="270.00004069010447" y="20" width="120" height="50" rx="4" ry="4" style="fill: #2a2aea;"></rect>
        <text transform="translate(281.754020690917969 48.506710052490234)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">qtivtransform</tspan></text>
      </g>
      <g>
        <line x1="250.000045776367188" y1="45" x2="264.9766845703125" y2="45" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="263.95538330078125 48.490432739257812 270.000045776367188 45 263.95538330078125 41.509567260742188 263.95538330078125 48.490432739257812"></polygon>
      </g>
      <g>
        <line x1="390.000030517578125" y1="45" x2="404.9766845703125" y2="45" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="403.95538330078125 48.490432739257812 410.000030517578125 45 403.95538330078125 41.509567260742188 403.95538330078125 48.490432739257812"></polygon>
      </g>
      <g>
        <line x1="510.000030517578125" y1="45" x2="524.9766845703125" y2="45" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="523.95538330078125 48.490432739257812 530.000030517578125 45 523.95538330078125 41.509567260742188 523.95538330078125 48.490432739257812"></polygon>
      </g>
      <g>
        <line x1="630.00006103515625" y1="45" x2="644.9766845703125" y2="45" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="643.95538330078125 48.490432739257812 650.00006103515625 45 643.95538330078125 41.509567260742188 643.95538330078125 48.490432739257812"></polygon>
      </g>
      <g>
        <line x1="760.00006103515625" y1="45" x2="774.9766845703125" y2="45" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="773.95538330078125 48.490432739257812 780.00006103515625 45 773.95538330078125 41.509567260742188 773.95538330078125 48.490432739257812"></polygon>
      </g>
      <g>
        <line x1="890.00006103515625" y1="45" x2="904.9766845703125" y2="45" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="903.95538330078125 48.490432739257812 910.00006103515625 45 903.95538330078125 41.509567260742188 903.95538330078125 48.490432739257812"></polygon>
      </g>
      <g>
        <line x1="1010.00006103515625" y1="45" x2="1024.9766845703125" y2="45" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="1023.95538330078125 48.490432739257812 1030.00006103515625 45 1023.95538330078125 41.509567260742188 1023.95538330078125 48.490432739257812"></polygon>
      </g>
      <g>
        <rect x="410.00004069010447" y="20" width="100" height="50" rx="4" ry="4" style="fill: #007884;"></rect>
        <text transform="translate(426.628929138183594 48.506710052490234)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">capsfilter</tspan></text>
      </g>
      <g>
        <rect x="530.00004069010447" y="20" width="100" height="50" rx="4" ry="4" style="fill: #007884;"></rect>
        <text transform="translate(568.910171508789062 48.506710052490234)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">tee</tspan></text>
      </g>
      <g>
        <rect x="650.000040690105379" y="20" width="110" height="50" rx="4" ry="4" style="fill: #007884;"></rect>
        <text transform="translate(659.476654052734375 48.506710052490234)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">v4l2h264enc</tspan></text>
      </g>
      <g>
        <rect x="780.000077328117186" y="20" width="110" height="50" rx="4" ry="4" style="fill: #007884;"></rect>
        <text transform="translate(797.207061767578125 48.506710052490234)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">h264prase</tspan></text>
      </g>
      <g>
        <rect x="910.000040690105379" y="20" width="100" height="50" rx="4" ry="4" style="fill: #007884;"></rect>
        <text transform="translate(928.62115478515625 48.506710052490234)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">mp4mux</tspan></text>
      </g>
      <g>
        <rect x="1030.000040690105379" y="20" width="100.000000000001819" height="50" rx="4" ry="4" style="fill: #007884;"></rect>
        <text transform="translate(1054.56646728515625 48.506710052490234)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">filesink</tspan></text>
      </g>
    </g>
  </g>
</svg>

For information about the plugins used in this pipeline, see [Pipeline flow](https://docs.qualcomm.com/doc/80-70022-50/topic/camera-transform-downscale-and-rotate-encode.html#camera-transform-downscale-and-rotate-encode__section_uk5_f5k_bdc).

## Run the application on the target device

1. Ensure that you complete the [Prerequisites](https://docs.qualcomm.com/doc/80-70022-50/topic/prerequisites-for-python-sample-applications.html).
2. Run the transformation script on the target
                    device:

        gst-camera-rotate-downscale-file.pyCopy to clipboard
3. To display the available help options, run the following
                    command:

        gst-camera-rotate-downscale-file.py -hCopy to clipboard

## Expected output

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

## Pipeline flow

The following table lists the plugins used to run the transformation
                    pipeline:| Plugin | Description |
| --- | --- |
| [qtiqmmfsrc](https://docs.qualcomm.com/doc/80-70022-50/topic/qtiqmmfsrc.html) | Captures the video stream. |
| [qtivtransform](https://docs.qualcomm.com/doc/80-70022-50/topic/qtivtransform.html) | Transforms the video stream. |
| [v4l2h264enc](https://docs.qualcomm.com/doc/80-70022-50/topic/v4l2h264enc.html) | 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. |

## Related information

[Video transformation](https://docs.qualcomm.com/doc/80-70022-50/topic/gst-transform-example.html)

**Parent Topic:** [Run Python-based applications](https://docs.qualcomm.com/doc/80-70022-50/topic/python-sample-applications.html)

Last Published: Feb 20, 2026

[Previous Topic
Object detection and classification](https://docs.qualcomm.com/bundle/publicresource/80-70022-50/topics/camera-ai-detection-overlay-composer-display.md) [Next Topic
Camera encode, object detection, and display](https://docs.qualcomm.com/bundle/publicresource/80-70022-50/topics/camera-encode-file-detection-yolov8-overlay-display.md)