# Smart codec

The **gst-smartcodec-example** application reduces bandwidth and storage resources based on scene change estimate thresholds.

The smart codec plugin, [qtismartvencbin](https://docs.qualcomm.com/doc/80-80022-50/topic/qtismartvencbin.html), uses smart fps, smart I-frame, smart bit rate, and smart ROI to do the following:

- Decrease the bit rate without compromising the quality.
- Enable efficient use of network and storage resources.

The following figure shows the pipeline flow for a two-stream use case. For more information, see [Pipeline flow](https://docs.qualcomm.com/doc/80-80022-55/topic/smart-codec.html#section-rcj-tl2-ncc).

<!--?xml version="1.0" encoding="UTF-8"?-->
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="1055.994903564454944" height="212.060546875" viewbox="0 0 1055.994903564454944 212.060546875" aria-label="../../_images/gst_smartcodec_example_pipeline_twostreams.svg">
  <g>
    <rect x=".499908447265625" y=".50006103515625" width="1054.9951171875" height="211.06005859375" rx="7.499999999999996" ry="7.499999999999996" style="fill: #fafafa;"></rect>
    <path d="M1047.994903564454944,1c3.85986328125,0,7,3.14013671875,7,7v196.060546875c0,3.85986328125-3.14013671875,7-7,7H8c-3.859866142272949,0-7-3.14013671875-7-7V8c0-3.85986328125,3.140133857727051-7,7-7h1039.994903564454944M1047.994903564454944,0H8C3.581733703613281,0,0,3.581726074219659,0,8v196.060546875c0,4.41827392578125,3.581733703613281,8,8,8h1039.994903564454944c4.418334960941138,0,8-3.58172607421875,8-8V8c0-4.418273925780341-3.581665039058862-8-8-8h0Z" style="fill: #d2d7e1;"></path>
  </g>
  <g>
    <rect x="20.000046053328333" y="58.260039199907624" width="120" height="60" rx="4" ry="4" style="fill: #2a2aea;"></rect>
    <text transform="translate(38.531082153320312 92.935684204101562)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">qtiqmmfsrc</tspan></text>
    <g>
      <polyline points="165.777725219726562 126.06048583984375 151.518707275390625 126.06048583984375 151.518707275390625 50.4595947265625 165.777725219726562 50.4595947265625" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></polyline>
      <polygon points="164.61053466796875 122.0714111328125 171.518707275390625 126.06048583984375 164.61053466796875 130.049530029296875 164.61053466796875 122.0714111328125"></polygon>
      <polygon points="164.61053466796875 54.448669433594659 171.518707275390625 50.4595947265625 164.61053466796875 46.470550537109375 164.61053466796875 54.448669433594659"></polygon>
    </g>
    <rect x="172.264756265165488" y="96.060474746349428" width="120" height="60" rx="4" ry="4" style="fill: #007884;"></rect>
    <text transform="translate(198.893451690673828 129.567169189453125)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">capsfilter</tspan></text>
    <g>
      <line x1="292.2647705078125" y1="126.06048583984375" x2="307.24139404296875" y2="126.06048583984375" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <polygon points="306.2200927734375 129.5509033203125 312.2647705078125 126.06048583984375 306.2200927734375 122.570037841796875 306.2200927734375 129.5509033203125"></polygon>
    </g>
    <rect x="313.010797855018609" y="96.060474746349428" width="160" height="60" rx="4" ry="4" style="fill: #2a2aea;"></rect>
    <text transform="translate(377.854595422744751 120.151851654052734)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Sink</tspan><tspan x="-52.1796875" y="19.2001953125">(qtismartvencabin)</tspan></text>
    <g>
      <line x1="473.01080322265625" y1="126.06048583984375" x2="487.9874267578125" y2="126.06048583984375" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <polygon points="486.966156005859375 129.5509033203125 493.01080322265625 126.06048583984375 486.966156005859375 122.570037841796875 486.966156005859375 129.5509033203125"></polygon>
    </g>
    <rect x="493.75683944487173" y="96.060474746349428" width="119.999999999998181" height="60" rx="4" ry="4" style="fill: #007884;"></rect>
    <text transform="translate(508.233184814453125 129.567169189453125)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">v4l2h264enc</tspan></text>
    <g>
      <line x1="613.756866455078125" y1="126.06048583984375" x2="628.733489990234375" y2="126.06048583984375" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <polygon points="627.712188720703125 129.5509033203125 633.756866455078125 126.06048583984375 627.712188720703125 122.570037841796875 627.712188720703125 129.5509033203125"></polygon>
    </g>
    <rect x="634.502881034723032" y="96.060474746349428" width="120" height="60" rx="4" ry="4" style="fill: #007884;"></rect>
    <text transform="translate(656.709686279296875 129.567169189453125)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">h264parse</tspan></text>
    <g>
      <line x1="754.502899169921875" y1="126.06048583984375" x2="769.479522705078125" y2="126.06048583984375" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <polygon points="768.458221435546875 129.5509033203125 774.502899169921875 126.06048583984375 768.458221435546875 122.570037841796875 768.458221435546875 129.5509033203125"></polygon>
    </g>
    <rect x="775.248922624576153" y="96.060474746349428" width="120" height="60" rx="4" ry="4" style="fill: #007884;"></rect>
    <text transform="translate(803.869842529296875 129.567169189453125)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">mp4mux</tspan></text>
    <g>
      <line x1="895.248931884765625" y1="126.06048583984375" x2="910.225555419921875" y2="126.06048583984375" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <polygon points="909.204254150390625 129.5509033203125 915.248931884765625 126.06048583984375 909.204254150390625 122.570037841796875 909.204254150390625 129.5509033203125"></polygon>
    </g>
    <rect x="915.994964214429274" y="96.060474746349428" width="119.999999999996362" height="60" rx="4" ry="4" style="fill: #007884;"></rect>
    <text transform="translate(950.561187744140625 129.567169189453125)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">filesink</tspan></text>
    <rect x="172.264756265165488" y="20.000062605433413" width="120" height="60" rx="4" ry="4" style="fill: #007884;"></rect>
    <text transform="translate(198.893451690673828 53.50677490234375)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">capsfilter</tspan></text>
    <g>
      <line x1="292.2647705078125" y1="50.00006103515625" x2="307.24139404296875" y2="50.00006103515625" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <polygon points="306.2200927734375 53.490478515625 312.2647705078125 50.00006103515625 306.2200927734375 46.5096435546875 306.2200927734375 53.490478515625"></polygon>
    </g>
    <rect x="313.010797855018609" y="20.000062605433413" width="160" height="60" rx="4" ry="4" style="fill: #2a2aea;"></rect>
    <text transform="translate(377.854595422744751 44.091442108154297)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Sink</tspan><tspan x="-52.1796875" y="19.2001953125">(qtismartvencabin)</tspan></text>
    <line x1="151.518714675312367" y1="88.260039199907624" x2="140.000046053328333" y2="88.260039199907624" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
  </g>
  <g>
    <g>
      <text transform="translate(858.92333984375 188.152046203613281)" style="font-family: Roboto-Regular, Roboto; font-size: 14px;"><tspan x="0" y="0">Qualcomm </tspan></text>
      <rect x="838.672330999992482" y="176.060546875" width="16" height="16" rx="2" ry="2" style="fill: #2a2aea;"></rect>
    </g>
    <g>
      <text transform="translate(957.505126953125 188.152046203613281)" style="font-family: Roboto-Regular, Roboto; font-size: 14px;"><tspan x="0" y="0">Open source</tspan></text>
      <rect x="937.254112412845643" y="176.060546875" width="16" height="16" rx="2" ry="2" style="fill: #007884;"></rect>
    </g>
  </g>
</svg>

**Figure : gst-smartcodec-example pipeline for two streams**

## Run the application

1. Ensure that you complete the [Prerequisites](https://docs.qualcomm.com/doc/80-80022-55/topic/mm_sample_apps_prerequisites.html).
2. To access the target device from your host computer, set up SSH. For instructions, see [Sign in using SSH](https://docs.qualcomm.com/bundle/publicresource/topics/80-80022-254/how_to.html#use-ssh).
3. In the terminal of the host computer, enter the SSH shell to:

    - Run the use cases:

ssh root@<ip-addr of the target device>
            Copy to clipboard
    - Push the files from host computer:

scp <filename> root@<IP address of target device>:/etc/media/
            Copy to clipboard
4. In the terminal of the target device, run the use case with a camera source:

gst-smartcodec-example -w 1920 -h 1080 -o video.mp4
        Copy to clipboard
5. To stop the use case, use **CTRL + C**.
6. In the terminal of the target device, run the following command in the SSH shell to display the available help options:

gst-smartcodec-example --help
        Copy to clipboard

## Expected output

The application generates the output as an encoded MP4 file.

The following table lists the file sizes of a 1080p video with and without smart codec.

Table:Smart codec–file sizes

| Smart codec | File size |
| --- | --- |
| Enabled | 3718 KB |
| Disabled | 17706 KB |

## Pipeline flow

The following table lists the plugins used in the smart codec pipeline:

| **Plugin** | **Description** |
| --- | --- |
| [qtiqmmfsrc](https://docs.qualcomm.com/doc/80-80022-50/topic/qtiqmmfsrc.html) | <ol class="arabic simple"><br><li><p>Captures the video stream.</p></li><br><li><p>Feeds the stream to capsfilter.</p></li><br></ol> |
| Capsfilter | Branches the source into two separate pipelines. In one pipeline, [qtismartvencbin](https://docs.qualcomm.com/doc/80-80022-50/topic/qtismartvencbin.html) processes the output. |
| Capsfilter | In the other pipeline, the video undergoes the following:<br><br><br><br>> <br>> <br>> <ol class="arabic simple"><br>> <li><p>Encoded using <a href="https://docs.qualcomm.com/doc/80-80022-50/topic/v4l2h264enc.html" rel="noopener noreferrer" target="_blank" class="xref cursorpointer" onclick="Window.BookmapComponent.navigateExternalFile('https://docs.qualcomm.com/doc/80-80022-50/topic/v4l2h264enc.html')">v4l2h264enc</a>.</p></li><br>> <li><p>Parsed with h264parse.</p></li><br>> <li><p>Multiplexed into an MP4 format with mp4mux.</p></li><br>> <li><p>Written to a file using filesink.</p></li><br>> </ol> |
|  |  |

## Related information

[AI smart codec](https://docs.qualcomm.com/doc/80-80022-55/topic/ai-smart-codec.html)

Last Published: May 17, 2026

[Previous Topic
Video wall](https://docs.qualcomm.com/bundle/publicresource/80-80022-55/topics/gst-concurrent-videoplay-composition.md) [Next Topic
Multi format decode](https://docs.qualcomm.com/bundle/publicresource/80-80022-55/topics/gst-videocodec-concurrent-playback.md)

Source: [https://docs.qualcomm.com/doc/80-80022-55/topic/smart-codec.html](https://docs.qualcomm.com/doc/80-80022-55/topic/smart-codec.html)