# Audio recording

The **gst-audio-encode-example** application encodes audio in FLAC or WAV formats.

A common use case for this application can be to encode live audio data for streaming or storage.

The following figure shows the pipeline, which captures the audio, converts the stream into FLAC or WAV formats, encodes the stream, and stores it in a file. For more information about the plugins used in the pipeline, see [Pipeline flow](https://docs.qualcomm.com/doc/80-70029-50/topic/gst-audio-encode-example-without-flac.html#section-uj5-4v5-4bc).

<!--?xml version="1.0" encoding="UTF-8"?-->
<svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" width="970.000000000000909" height="250" viewbox="0 0 970.000000000000909 250" aria-label="../../_images/gst_audio_encode_example_pipeline.svg">
  <g>
    <rect x=".499779820443109" y=".49993896484375" width="969.00048828125" height="249.00048828125" rx="7.499999999999996" ry="7.499999999999996" style="fill: #fafafa;"></rect>
    <path d="M961.999962925911859,1c3.85986328125,0,7,3.14013671875,7,7v234c0,3.85986328125-3.14013671875,7-7,7H7.999962925911859c-3.859874725341797,0-7-3.14013671875-7-7V8C.999962925911859,4.14013671875,4.140088200570062,1,7.999962925911859,1h954M961.999962925911859,0H7.999962925911859C3.581713795662836,0-.000037074088141,3.581756591796875-.000037074088141,8v234C-.000037074088141,246.41827392578125,3.581713795662836,250,7.999962925911859,250h954c4.41827392578125,0,8-3.58172607421875,8-8V8c0-4.418243408203125-3.58172607421875-8-8-8h0Z" style="fill: #d2d7e1;"></path>
  </g>
  <g>
    <rect x="77.005939236685663" y="20.861073501757346" width="151.365694494367744" height="192.277852996485308" rx="3.99999951609243" ry="3.99999951609243" style="fill: none; stroke: #7c8aa3; stroke-miterlimit: 10;"></rect>
    <rect x="92.688786483870899" y="50.773947833142302" width="120" height="59.999992741379174" rx="4" ry="4" style="fill: #007884;"></rect>
    <text transform="translate(103.067559361458734 85.369354365859181)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Audio capture</tspan></text>
    <text transform="translate(122.465996861458734 43.576273082289845)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">pulsesrc</tspan></text>
    <text transform="translate(289.317803502083734 43.576273082289845)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">capsfilter</tspan></text>
    <rect x="416.786617512930206" y="20.861073501757346" width="151.365694494365016" height="192.277852996485308" rx="3.99999951609243" ry="3.99999951609243" style="fill: none; stroke: #7c8aa3; stroke-miterlimit: 10;"></rect>
    <text transform="translate(446.094353795052484 40.328712581191212)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">audioconvert</tspan></text>
    <text transform="translate(636.279687047005609 43.576273082289845)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">flacenc</tspan></text>
    <text transform="translate(635.299218297005609 133.37803470948711)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">wavenc</tspan></text>
    <text transform="translate(806.834435582161859 43.576574443373829)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">filesink</tspan></text>
    <g>
      <line x1="52.798447345749992" y1="80.773944203832798" x2="92.798447345749992" y2="80.773944203832798" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 3px;"></line>
      <g>
        <line x1="52.798447728157953" y1="80.773956298828125" x2="87.05746567249389" y2="80.773956298828125" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="85.890275120736078 84.763000488282159 92.798447728157953 80.773956298828125 85.890275120736078 76.784881591796875 85.890275120736078 84.763000488282159"></polygon>
      </g>
    </g>
    <rect x="262.688786483870899" y="50.773947833142302" width="120" height="59.999992741379174" rx="3.999999516089702" ry="3.999999516089702" style="fill: #007884;"></rect>
    <text transform="translate(304.825310826302484 85.369354365859181)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Filter</tspan></text>
    <text transform="translate(22.370904088021234 85.369354365859181)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">flac</tspan></text>
    <text transform="translate(21.390435338021234 173.386930583510548)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">wav</tspan></text>
    <g>
      <line x1="212.688790440560297" y1="80.773956298828125" x2="256.947808384896234" y2="80.773956298828125" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <polygon points="255.780602574349359 84.763000488282159 262.688775181771234 80.773956298828125 255.780602574349359 76.784881591796875 255.780602574349359 84.763000488282159"></polygon>
    </g>
    <rect x="432.469464760112714" y="50.773947833142302" width="120" height="59.999992741379174" rx="3.999999516089702" ry="3.999999516089702" style="fill: #007884;"></rect>
    <text transform="translate(464.852166295052484 85.369354365859181)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Convert</tspan></text>
    <g>
      <line x1="382.579125523568109" y1="80.773956298828125" x2="426.838128209114984" y2="80.773956298828125" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <polygon points="425.670952916146234 84.763000488282159 432.579125523568109 80.773956298828125 425.670952916146234 76.784881591796875 425.670952916146234 84.763000488282159"></polygon>
    </g>
    <rect x="602.377507971653358" y="50.773947833142302" width="120.000000000001819" height="59.999992741379174" rx="3.999999516089702" ry="3.999999516089702" style="fill: #007884;"></rect>
    <text transform="translate(635.916466832161859 85.369354365859181)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Encode</tspan></text>
    <g>
      <line x1="552.487145543099359" y1="80.773956298828125" x2="596.746178746224359" y2="80.773956298828125" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <polygon points="595.579003453255609 84.763000488282159 602.487145543099359 80.773956298828125 595.579003453255609 76.784881591796875 595.579003453255609 84.763000488282159"></polygon>
    </g>
    <rect x="772.267847109776085" y="50.773947833142302" width="120" height="140.01737594878432" rx="4" ry="4" style="fill: #007884;"></rect>
    <g>
      <line x1="722.377526402474359" y1="80.773956298828125" x2="766.636498570443109" y2="80.773956298828125" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <polygon points="765.469323277474359 84.763000488282159 772.377526402474359 80.773956298828125 765.469323277474359 76.784881591796875 765.469323277474359 84.763000488282159"></polygon>
    </g>
    <rect x="92.688786483870899" y="138.791330072730489" width="120" height="59.999992741380993" rx="3.99999951609243" ry="3.99999951609243" style="fill: #007884;"></rect>
    <text transform="translate(103.067559361458734 173.386755107436329)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Audio capture</tspan></text>
    <g>
      <line x1="52.798447345749992" y1="168.791326443419166" x2="92.798447345749992" y2="168.791326443419166" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 3px;"></line>
      <g>
        <line x1="52.798447728157953" y1="168.79132080078125" x2="87.05746567249389" y2="168.79132080078125" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="85.890275120736078 172.7803955078125 92.798447728157953 168.79132080078125 85.890275120736078 164.802276611328125 85.890275120736078 172.7803955078125"></polygon>
      </g>
    </g>
    <g>
      <line x1="212.688790440560297" y1="168.79132080078125" x2="426.728478550911859" y2="168.79132080078125" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <polygon points="425.561303257943109 172.7803955078125 432.469475865364984 168.79132080078125 425.561303257943109 164.802276611328125 425.561303257943109 172.7803955078125"></polygon>
    </g>
    <rect x="432.469464760112714" y="138.791330072730489" width="120" height="59.999992741380993" rx="3.99999951609243" ry="3.99999951609243" style="fill: #007884;"></rect>
    <text transform="translate(464.852166295052484 173.386755107436329)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Convert</tspan></text>
    <rect x="602.377507971653358" y="138.791330072730489" width="120.000000000001819" height="59.999992741380993" rx="3.99999951609243" ry="3.99999951609243" style="fill: #007884;"></rect>
    <text transform="translate(635.916466832161859 173.386755107436329)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Encode</tspan></text>
    <g>
      <line x1="552.487145543099359" y1="168.79132080078125" x2="596.746178746224359" y2="168.79132080078125" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <polygon points="595.579003453255609 172.7803955078125 602.487145543099359 168.79132080078125 595.579003453255609 164.802276611328125 595.579003453255609 172.7803955078125"></polygon>
    </g>
    <g>
      <line x1="722.377526402474359" y1="168.79132080078125" x2="766.636498570443109" y2="168.79132080078125" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
      <polygon points="765.469323277474359 172.7803955078125 772.377526402474359 168.79132080078125 765.469323277474359 164.802276611328125 765.469323277474359 172.7803955078125"></polygon>
    </g>
    <g>
      <line x1="892.267847109776085" y1="114.000000362932042" x2="922.267847109776085" y2="114.000000362932042" style="fill: none; stroke: #fff; stroke-miterlimit: 10; stroke-width: 3px;"></line>
      <g>
        <line x1="892.267846226693109" y1="114" x2="916.526879429818109" y2="114" style="fill: none; stroke: #000; stroke-miterlimit: 10;"></line>
        <polygon points="915.359643101693109 117.989074707032159 922.267846226693109 114 915.359643101693109 110.01092529296875 915.359643101693109 117.989074707032159"></polygon>
      </g>
    </g>
    <text transform="translate(813.670128941536859 125.378214000258595)" style="fill: #fff; font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">Write</tspan></text>
    <text transform="translate(926.753502964974359 119.519693492446095)" style="font-family: Roboto-Regular, Roboto; font-size: 16px;"><tspan x="0" y="0">file</tspan></text>
    <g>
      <text transform="translate(870.060265660286859 225.230422973632812)" style="font-family: Roboto-Regular, Roboto; font-size: 14px;"><tspan x="0" y="0">Open source</tspan></text>
      <rect x="849.80930098997942" y="213.138926498242654" width="16" height="16" rx="2" ry="2" style="fill: #007884;"></rect>
    </g>
  </g>
</svg>
**Figure : gst-audio-encode-example pipeline**

## Run the application

For this use case, if you have a live audio source (such as a microphone or an internet radio stream), you can encode this audio data into a more compact or standardized format for efficient transmission or storage.

1. Ensure that you complete the [Prerequisites](https://docs.qualcomm.com/doc/80-70029-50/topic/mm_sample_apps_prerequisites.html).
2. In the terminal of the target device, run the following command for different audio formats:

    `gst-audio-encode-example -o <path-file> --audio_format=<format>`

| Command-line parameter | Description |
| --- | --- |
| `-o` | Specifies the absolute path to the output audio file. |
| `-format` | Specifies the format of the audio file:<br><ul class="simple"><br><li><p><code class="docutils literal notranslate"><span class="pre">1</span></code> = FLAC</p></li><br><li><p><code class="docutils literal notranslate"><span class="pre">2</span></code> = WAV</p></li><br></ul> |

For example, use the following commands to run the application for FLAC and WAV audio formats:
    
    -   Encode FLAC audio:
    
        ``` {#codeblock_nrb_gm3_y1c}
        gst-audio-encode-example -o /etc/media/<filename>.flac --audio_format=1
        ```
    
    -   Encode WAV audio:
    
        ``` {#codeblock_lhk_gm3_y1c}
        gst-audio-encode-example -o /etc/media/<filename>.wav --audio_format=2
        ```
    Copy 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-encode-example --help
        Copy 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 captured audio is encoded and written to a file based on the chosen format (FLAC or WAV).

## Pipeline flow

In the audio encoding, the pipeline differs slightly based on the encoding format.

| **Plugin** | **FLAC** | **WAV** |
| --- | --- | --- |
| pulsesrc | Captures audio from the system sound device. | Captures audio from the system sound device. |
| capsfilter | Ensures that the audio is in a format suitable for the FLAC encoder. | – |
| audioconvert | Converts the audio to the required format. | Converts the audio to the required format. |
| <ul class="simple"><br><li><p>flacenc</p></li><br><li><p>wavenc</p></li><br></ul> | flacenc encodes the audio into FLAC format. | wavenc encodes the audio into WAV format. |
| filesink | Writes the encoded audio to a file. | Writes the encoded audio to a file. |

## Related information

[Audio use cases](https://docs.qualcomm.com/doc/80-70029-50/topic/audio-use-cases.html)

Last Published: Apr 02, 2026

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

Source: [https://docs.qualcomm.com/doc/80-70029-50/topic/gst-audio-encode-example-without-flac.html](https://docs.qualcomm.com/doc/80-70029-50/topic/gst-audio-encode-example-without-flac.html)