# Audio and video encode

Source: [https://docs.qualcomm.com/doc/80-70022-50/topic/gst-audio-video-encode.html](https://docs.qualcomm.com/doc/80-70022-50/topic/gst-audio-video-encode.html)

The **gst-audio-video-encode** application encodes audio and video data, which is
        stored in a user-specified output file. A few use cases for this application are streaming
        services, video conferencing, and surveillance systems.

The following figure shows the pipeline, which receives the video and audio feed,
            encodes, and parses the video stream. It then captures the audio stream and encodes it
            in MP3 format. Both streams are multiplexed and written to a file.

For information about the plugins used in the pipeline, see [Pipeline flow](https://docs.qualcomm.com/doc/80-70022-50/topic/gst-audio-video-encode.html#gst-audio-video-encode__section_mj1_yfn_4bc).

Figure : gst-audio-video-encode pipeline
            
            <?xml version="1.0" encoding="UTF-8"?>
<svg id="Layer_2" data-name="Layer 2" xmlns="http://www.w3.org/2000/svg" width="1289.3170166015625" height="405.068984985351562" viewbox="0 0 1289.3170166015625 405.068984985351562">
  <g>
    <rect x=".500244140625" y=".500198364257812" width="1288.31640625" height="404.068359375" rx="7.49999999999989" ry="7.49999999999989" style="fill: #fafafa;"></rect>
    <path d="M1281.3170166015625,1c3.85980224609375,0,7,3.140167236328125,7,7v389.068984985351562c0,3.85986328125-3.14019775390625,7-7,7H8c-3.859832763671875,0-7-3.14013671875-7-7V8c0-3.859832763671875,3.140167236328125-7,7-7h1273.3170166015625M1281.3170166015625,0H8C3.58184814453125,0,0,3.581832885742188,0,8v389.068984985351562c0,4.418182373046875,3.58184814453125,8,8,8h1273.3170166015625c4.41815185546875,0,8-3.581817626953125,8-8V8c0-4.418167114257812-3.58184814453125-8-8-8h0Z" style="fill: #d2d7e1;"></path>
  </g>
  <g>
    <text transform="translate(104.513801574707031 198.716869354248047)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">width</tspan><tspan x="-5.21875" y="21">height</tspan><tspan x="-36.2421875" y="42">output_file</tspan><tspan x="-85.6171875" y="63">input_videocodec</tspan></text>
    <text transform="translate(1209.1373291015625 174.468860626220703)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">MP4</tspan><tspan x="0" y="21">encoded</tspan><tspan x="0" y="42">file</tspan></text>
    <g>
      <rect x="196.019050352037084" y="109.014491939344225" width="120" height="59.999992741379174" rx="4.000000000000007" ry="4.000000000000007" style="fill: #2a2aea;"></rect>
      <text transform="translate(205.015035629272461 143.690397380385548)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Media capture</tspan></text>
      <text transform="translate(214.550191879272461 101.81681644776836)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">qtiqmmfsrc</tspan></text>
      <g>
        <line x1="316.019050598144531" y1="139.014495849609375" x2="330.278066635131836" y2="139.014495849609375" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="329.110874176025391 143.003555297851562 336.019050598144531 139.014495849609375 329.110874176025391 135.025421142578125 329.110874176025391 143.003555297851562"></polygon>
      </g>
      <line x1="455.909389490157992" y1="139.014488310034722" x2="467.065258279575573" y2="139.014488310034722" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <rect x="335.909389490157992" y="109.014491939344225" width="120" height="59.999992741379174" rx="3.999999516090611" ry="3.999999516090611" style="fill: #007884;"></rect>
      <text transform="translate(378.04595947265625 143.609914897475392)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Filter</tspan></text>
      <text transform="translate(362.53814697265625 101.81681644776836)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">capsfilter</tspan></text>
      <rect x="196.019050352037084" y="274.737442342457143" width="120" height="59.999992741379174" rx="4.000000000000007" ry="4.000000000000007" style="fill: #007884;"></rect>
      <text transform="translate(206.397968292236328 309.413332103285939)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Audio capture</tspan></text>
      <text transform="translate(225.796405792236328 267.539774058852345)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">pulsesrc</tspan></text>
      <g>
        <line x1="316.019050598144531" y1="304.737442016601562" x2="330.278066635131836" y2="304.737442016601562" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="329.110874176025391 308.726516723632812 336.019050598144531 304.737442016601562 329.110874176025391 300.748367309571222 329.110874176025391 308.726516723632812"></polygon>
      </g>
      <g>
        <line x1="455.909385681152344" y1="304.737442016601562" x2="479.966781616210938" y2="304.737442016601562" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="478.799591064453125 308.726516723632812 485.707778930664062 304.737442016601562 478.799591064453125 300.748367309571222 478.799591064453125 308.726516723632812"></polygon>
      </g>
      <rect x="335.909389490157992" y="274.737442342457143" width="120" height="59.999992741379174" rx="3.999999516090611" ry="3.999999516090611" style="fill: #007884;"></rect>
      <text transform="translate(378.04595947265625 309.332872508559376)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Filter</tspan></text>
      <text transform="translate(362.53814697265625 267.539774058852345)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">capsfilter</tspan></text>
      <g>
        <line x1="745.18719482421875" y1="77.16986083984375" x2="759.44622802734375" y2="77.16986083984375" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="758.279022216796875 81.158920288085938 765.18719482421875 77.16986083984375 758.279022216796875 73.180801391601562 758.279022216796875 81.158920288085938"></polygon>
      </g>
      <rect x="625.187209325576987" y="47.16986652365722" width="120" height="59.999992741378264" rx="4" ry="4" style="fill: #007884;"></rect>
      <text transform="translate(662.3902587890625 81.765272258315235)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Queue</tspan></text>
      <text transform="translate(787.3946533203125 39.972181438002735)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">h264parse</tspan></text>
      <rect x="765.187209325576987" y="47.16986652365722" width="120" height="59.999992741378264" rx="4" ry="4" style="fill: #007884;"></rect>
      <text transform="translate(804.71844482421875 81.845533488783985)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Parse</tspan></text>
      <g>
        <line x1="885.23028564453125" y1="77.16986083984375" x2="899.48931884765625" y2="77.16986083984375" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="898.3221435546875 81.158920288085938 905.23028564453125 77.16986083984375 898.3221435546875 73.180801391601562 898.3221435546875 81.158920288085938"></polygon>
      </g>
      <text transform="translate(934.53814697265625 39.972181438002735)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">mp4mux</tspan></text>
      <g>
        <line x1="745.18719482421875" y1="190.873489379882812" x2="759.44622802734375" y2="190.873489379882812" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="758.279022216796875 194.862533569335938 765.18719482421875 190.873489379882812 758.279022216796875 186.884414672851562 758.279022216796875 194.862533569335938"></polygon>
      </g>
      <rect x="625.187209325576987" y="160.87347980490722" width="120" height="59.999992741378264" rx="3.999999516090611" ry="3.999999516090611" style="fill: #007884;"></rect>
      <text transform="translate(662.3902587890625 195.468904613051564)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Queue</tspan></text>
      <text transform="translate(787.39422607421875 153.675802348647267)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">h265parse</tspan></text>
      <rect x="765.187209325576987" y="160.87347980490722" width="120" height="59.999992741378264" rx="3.999999516090611" ry="3.999999516090611" style="fill: #007884;"></rect>
      <text transform="translate(804.71844482421875 195.549154399428517)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Parse</tspan></text>
      <g>
        <line x1="885.23028564453125" y1="190.873489379882812" x2="899.48931884765625" y2="190.873489379882812" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="898.3221435546875 194.862533569335938 905.23028564453125 190.873489379882812 898.3221435546875 186.884414672851562 898.3221435546875 194.862533569335938"></polygon>
      </g>
      <g>
        <line x1="745.18719482421875" y1="304.577102661132812" x2="759.44622802734375" y2="304.577102661132812" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="758.279022216796875 308.566146850585938 765.18719482421875 304.577102661132812 758.279022216796875 300.588027954101562 758.279022216796875 308.566146850585938"></polygon>
      </g>
      <g>
        <line x1="605.707763671875" y1="77.16986083984375" x2="619.966796875" y2="77.16986083984375" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="618.799591064453125 81.158920288085938 625.707763671875 77.16986083984375 618.799591064453125 73.180801391601562 618.799591064453125 81.158920288085938"></polygon>
      </g>
      <g>
        <line x1="605.707763671875" y1="190.873489379882812" x2="619.966796875" y2="190.873489379882812" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="618.799591064453125 194.862533569335938 625.707763671875 190.873489379882812 618.799591064453125 186.884414672851562 618.799591064453125 194.862533569335938"></polygon>
      </g>
      <g>
        <line x1="605.707763671875" y1="304.577102661132812" x2="619.966796875" y2="304.577102661132812" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="618.799591064453125 308.566146850585938 625.707763671875 304.577102661132812 618.799591064453125 300.588027954101562 618.799591064453125 308.566146850585938"></polygon>
      </g>
      <rect x="625.187209325576987" y="274.57709308615722" width="120" height="59.999992741378264" rx="3.999999516090611" ry="3.999999516090611" style="fill: #007884;"></rect>
      <text transform="translate(662.3902587890625 309.172502635512501)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Queue</tspan></text>
      <text transform="translate(500.18426513671875 39.972181438002735)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">v4l2h264enc</tspan></text>
      <rect x="485.707771839821362" y="47.16986652365722" width="120" height="59.999992741378264" rx="4" ry="4" style="fill: #007884;"></rect>
      <text transform="translate(519.24676513671875 81.765272258315235)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Encode</tspan></text>
      <text transform="translate(500.18426513671875 153.675802348647267)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">v4l2h265enc</tspan></text>
      <rect x="485.707771839821362" y="160.87347980490722" width="120" height="59.999992741378264" rx="3.999999516090611" ry="3.999999516090611" style="fill: #007884;"></rect>
      <text transform="translate(519.24676513671875 195.468904613051564)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Encode</tspan></text>
      <text transform="translate(499.33270263671875 267.37940418580547)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">audioconvert</tspan></text>
      <rect x="485.707771839821362" y="274.57709308615722" width="120" height="59.999992741378264" rx="3.999999516090611" ry="3.999999516090611" style="fill: #007884;"></rect>
      <text transform="translate(518.09051513671875 309.172502635512501)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Convert</tspan></text>
      <text transform="translate(778.81219482421875 267.37940418580547)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">lamemp3enc</tspan></text>
      <rect x="765.187209325576987" y="274.57709308615722" width="120" height="59.999992741378264" rx="3.999999516090611" ry="3.999999516090611" style="fill: #007884;"></rect>
      <text transform="translate(780.53094482421875 309.252763865981251)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">MP3 encode</tspan></text>
      <g>
        <line x1="885.23028564453125" y1="304.577102661132812" x2="899.48931884765625" y2="304.577102661132812" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="898.3221435546875 308.566146850585938 905.23028564453125 304.577102661132812 898.3221435546875 300.588027954101562 898.3221435546875 308.566146850585938"></polygon>
      </g>
      <rect x="905.917055841848196" y="47.16986652365722" width="119.999999999996362" height="289.40721906192357" rx="4" ry="4" style="fill: #007884;"></rect>
      <text transform="translate(933.39349365234375 196.549352763686329)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Multiplex</tspan></text>
      <text transform="translate(1080.48345947265625 39.972181438002735)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">filesink</tspan></text>
      <g>
        <line x1="1025.91705322265625" y1="190.873489379882812" x2="1040.17608642578125" y2="190.873489379882812" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="1039.00885009765625 194.862533569335938 1045.91705322265625 190.873489379882812 1039.00885009765625 186.884414672851562 1039.00885009765625 194.862533569335938"></polygon>
      </g>
      <rect x="1045.917055841844558" y="47.16986652365722" width="119.999999999996362" height="289.40721906192357" rx="3.999999516090611" ry="3.999999516090611" style="fill: #007884;"></rect>
      <text transform="translate(1087.3193359375 196.549352763686329)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Write</tspan></text>
      <g>
        <polyline points="479.966781616210938 190.357437133789062 467.065261840820312 190.357437133789062 467.065261840820312 77.16986083984375 479.966781616210938 77.16986083984375" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></polyline>
        <polygon points="478.799591064453125 186.368392944335938 485.707778930664062 190.357437133789062 478.799591064453125 194.346511840821222 478.799591064453125 186.368392944335938"></polygon>
        <polygon points="478.799591064453125 81.158920288085938 485.707778930664062 77.16986083984375 478.799591064453125 73.180801391601562 478.799591064453125 81.158920288085938"></polygon>
      </g>
    </g>
    <g>
      <polyline points="196.019050352037084 139.014488310034722 165.957597349232856 139.014488310034722 165.957597349232856 309.172569258667863 196.019050352037084 309.172569258667863" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 3px;"></polyline>
      <g>
        <polyline points="190.278060913085938 139.014495849609375 165.957595825195312 139.014495849609375 165.957595825195312 309.172561645507812 190.278060913085938 309.172561645507812" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></polyline>
        <polygon points="189.110870361328125 135.025421142578125 196.01904296875 139.014495849609375 189.110870361328125 143.003555297851562 189.110870361328125 135.025421142578125"></polygon>
        <polygon points="189.110870361328125 313.161636352539062 196.01904296875 309.172561645507812 189.110870361328125 305.183517456054688 189.110870361328125 313.161636352539062"></polygon>
      </g>
    </g>
    <g>
      <line x1="1165.91705584184092" y1="190.873476175596807" x2="1205.91705584184092" y2="190.873476175596807" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 3px;"></line>
      <g>
        <line x1="1165.91705322265625" y1="190.873489379882812" x2="1200.17608642578125" y2="190.873489379882812" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="1199.00885009765625 194.862533569335938 1205.91705322265625 190.873489379882812 1199.00885009765625 186.884414672851562 1199.00885009765625 194.862533569335938"></polygon>
      </g>
    </g>
    <line x1="145.957597349232856" y1="224.093528784352202" x2="165.957597349232856" y2="224.093528784352202" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
  </g>
  <g>
    <g>
      <text transform="translate(1093.39312744140625 376.0892333984375)" style="font-family: Roboto-Regular, Roboto; font-size: 14px;"><tspan x="0" y="0">Qualcomm </tspan></text>
      <rect x="1073.142126556689618" y="363.997742434914471" width="16" height="16" rx="2" ry="2" style="fill: #2a2aea;"></rect>
    </g>
    <g>
      <text transform="translate(1191.97491455078125 376.0892333984375)" style="font-family: Roboto-Regular, Roboto; font-size: 14px;"><tspan x="0" y="0">Open source</tspan></text>
      <rect x="1171.723907969542779" y="363.997742434914471" width="16" height="16" rx="2" ry="2" style="fill: #007884;"></rect>
    </g>
  </g>
</svg>

## Run the application

The following table lists the actions that can be performed for the common use
                    cases of gst-audio-video-encode application:| Use case | Actions |
| --- | --- |
| Streaming services | Encode audio and video streams for live internet streaming. |
| Security camera | Invert or rotate the video image to compensate for situations<br>                                where the camera is improperly mounted. |
| Augmented reality | Scale or rotate the video feed to synchronize with the virtual<br>                                components. |

1. Ensure that you complete the [Prerequisites](https://docs.qualcomm.com/doc/80-70022-50/topic/mm_sample_apps_prerequisites.html).
2. In the terminal of the target device, run the use case:

        gst-audio-video-encode -w <width> -h <height> -c <input-codec> -o /etc/media/<output-file>.mp4Copy to clipboard

The following table provides a description of the command-line
                            parameters:    | Command-line parameter | Description |
    | --- | --- |
    | `-w` | Specifies the camera width. |
    | `-h` | Specifies the camera height. |
    | `-c` | Specifies the video codec of the input file:<ul class="ul" id="gst-audio-video-encode__ul_sm4_hpt_4bc"><br>                                            <li class="li"><code class="ph codeph">1</code> for AVC (H.264).</li><br><br>                                            <li class="li"><code class="ph codeph">2</code> for HEVC (H.265).</li><br><br>                                        </ul> |
    | `output-file` | Provides the absolute path to the output file. |

For example, use the following commands to run different video encode
                        use cases:
    - AVC:

            gst-audio-video-encode -w 1920 -h 1080 -c 1 -o /etc/media/audiovideo.mp4Copy to clipboard
    - HEVC:

            gst-audio-video-encode -w 1920 -h 1080 -c 2 -o /etc/media/audiovideo.mp4Copy to clipboard
3. To stop the use case, use CTRL +
                    C.
4. In the terminal of the target device, run the following command in the SSH shell
                    to display the available help
                    options:

        gst-audio-video-encode --helpCopy to clipboard
5. In the terminal of the host computer, run the following command to pull the
                    files from the target
                    device:

        scp root@<IP address of target device>:/etc/media/<destination directory>Copy to clipboard

## Expected output

The encoded audio and video streams multiplexed to an MP4 container and written to a
                file.

## Pipeline flow

The following table lists the plugins used to run the audio and video stream
                    encoding pipeline:| Plugin | Description |
| --- | --- |
| [qtiqmmfsrc](https://docs.qualcomm.com/doc/80-70022-50/topic/qtiqmmfsrc.html) and capsfilter | Captures the media stream. |
| [v4l2h264enc](https://docs.qualcomm.com/doc/80-70022-50/topic/v4l2h264enc.html) | Encodes the video for AVC (H.264) format. |
| [v4l2h265enc](https://docs.qualcomm.com/doc/80-70022-50/topic/v4l2h265enc.html) | Encodes the video for HEVC (H.265) format. |
| h264parse | Parses the H.264 video stream. |
| h265parse | Parses the H.265 video stream. |
| [pulsesrc](https://docs.qualcomm.com/doc/80-70022-50/topic/pulsesrc.html) | Captures the audio from the stream, which is filtered using<br>                                capsfilter. |
| audioconvert | Converts the audio for encoding. |
| lamemp3enc | Encodes the audio in MP3 format. |
| mp4mux | Multiplexes encoded video and audio into an MP4<br>                                container. |
| filesink | Writes the stream into a file. |

**Parent Topic:** [Run sample applications for video and audio](https://docs.qualcomm.com/doc/80-70022-50/topic/audio-sample-applications.html)

Last Published: Feb 20, 2026

[Previous Topic
Video playback](https://docs.qualcomm.com/bundle/publicresource/80-70022-50/topics/gst-video-playback-example.md) [Next Topic
Audio playback](https://docs.qualcomm.com/bundle/publicresource/80-70022-50/topics/gst-audio-decode-sample.md)