# 音频录制

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

**gst-audio-encode-example** 应用程序以 FLAC 或 WAV 格式对音频进行编码。

此应用程序的常见用例是编码实时音频数据，以便进行流传输或存储。

下图展示了一个 pipeline：采集音频，将流转换为 FLAC 或 WAV 格式，对流进行编码，并将其存储在文件中。有关 pipeline 中使用的插件的更多信息，请参见 [Pipeline 流](https://docs.qualcomm.com/doc/80-70022-50SC/topic/gst-audio-encode-example-without-flac.html#gst-audio-encode-example-without-flac__section_uj5_4v5_4bc)。

Figure : gst-audio-encode-example pipeline
            
            <!--?xml version="1.0" encoding="UTF-8" standalone="no"?-->

<!-- Generated by Microsoft Visio, SVG Export gst_audio_encode_example_pipeline.svg Layer_1 -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ev="http://www.w3.org/2001/xml-events" xmlns:v="http://schemas.microsoft.com/visio/2003/SVGExtensions/" width="10.1042in" height="2.60417in" viewbox="0 0 727.5 187.5" xml:space="preserve" color-interpolation-filters="sRGB" class="st13"><v:documentproperties v:langid="1033" v:viewmarkup="false"></v:documentproperties>
<style>.svg-1 .st1 { fill: #fafafa; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st2 { fill: #d2d7e1; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st3 { fill: none; stroke: #7c8aa3; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st4 { fill: #007884; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st5 { fill: #ffffff; font-family: SimHei; font-size: 1.00001em }
.svg-1 .st6 { fill: none; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st7 { fill: #000000; font-family: Roboto; font-size: 1.00001em }
.svg-1 .st8 { stroke: #ffffff; stroke-linecap: butt; stroke-width: 2.25 }
.svg-1 .st9 { stroke: #000000; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st10 { fill: #000000; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st11 { fill: #000000; font-family: SimHei; font-size: 1.00001em }
.svg-1 .st12 { fill: #000000; font-family: SimHei; font-size: 0.874992em }
.svg-1 .st13 { fill: none; fill-rule: evenodd; font-size: 12px; overflow: visible; stroke-linecap: square; stroke-miterlimit: 3 }</style>
<g v:mid="0" v:index="1" v:groupcontext="foregroundPage">	<title>Layer_1</title>	<v:pageproperties v:drawingscale="1" v:pagescale="1" v:drawingunits="19" v:shadowoffsetx="9" v:shadowoffsety="-9"></v:pageproperties>	<g id="shape2-1" v:mid="2" v:groupcontext="shape" transform="translate(0.374835,-0.37468)">		<title>Sheet.2</title>		<path d="M0 181.88 A5.62513 5.62513 -180 0 0 5.62 187.5 L721.13 187.5 A5.62513 5.62513 -180 0 0 726.75 181.88 L726.75					 6.37 A5.62513 5.62513 -180 0 0 721.13 0.75 L5.62 0.75 A5.62513 5.62513 -180 0 0 0 6.37 L0 181.88 Z" class="st1"></path>	</g>	<g id="shape3-3" v:mid="3" v:groupcontext="shape" transform="translate(-2.78056E-05,8.52651E-14)">		<title>Sheet.3</title>		<path d="M721.5 0.75 C724.39 0.75 726.75 3.11 726.75 6 L726.75 181.5 C726.75 184.39 724.39 186.75 721.5 186.75 L6 186.75					 C3.11 186.75 0.75 184.39 0.75 181.5 L0.75 6 C0.75 3.11 3.11 0.75 6 0.75 L721.5 0.75 ZM721.5 0 L6 0 C2.69					 0 0 2.69 0 6 L0 181.5 C0 184.81 2.69 187.5 6 187.5 L721.5 187.5 C724.81 187.5 727.5 184.81 727.5 181.5 L727.5					 6 C727.5 2.69 724.81 0 721.5 0 Z" class="st2"></path>	</g>	<g id="shape5-5" v:mid="5" v:groupcontext="shape" transform="translate(57.7545,-27.6458)">		<title>Sheet.5</title>		<path d="M0 184.5 A3.00007 3.00007 -180 0 0 3 187.5 L110.52 187.5 A3.00007 3.00007 -180 0 0 113.52 184.5 L113.52 46.29					 A3.00007 3.00007 -180 0 0 110.52 43.29 L3 43.29 A3.00007 3.00007 -180 0 0 -0 46.29 L0 184.5 Z" class="st3"></path>	</g>	<g id="shape6-7" v:mid="6" v:groupcontext="shape" transform="translate(69.5166,-104.42)">		<title>Sheet.6</title>		<desc>音频采集</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="165" width="90.01" height="45"></v:textrect>		<path d="M0 184.5 A3.00007 3.00007 -180 0 0 3 187.5 L87 187.5 A3.00007 3.00007 -180 0 0 90 184.5 L90 145.5 A3.00007 3.00007					 -180 0 0 87 142.5 L3 142.5 A3.00007 3.00007 -180 0 0 -0 145.5 L0 184.5 Z" class="st4"></path>		<text x="21" y="168.99" class="st5" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>音频采集</text>		</g>	<g id="shape8-10" v:mid="8" v:groupcontext="shape" transform="translate(69.5166,-151.218)">		<title>Sheet.8</title>		<desc>pulsesrc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="180.3" width="90" height="14.4"></v:textrect>		<rect x="0" y="173.1" width="90" height="14.4" class="st6"></rect>		<text x="22.33" y="183.9" class="st7" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>pulsesrc</text>		</g>	<g id="shape9-13" v:mid="9" v:groupcontext="shape" transform="translate(197.017,-151.218)">		<title>Sheet.9</title>		<desc>capsfilter</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="180.3" width="90" height="14.4"></v:textrect>		<rect x="0" y="173.1" width="90" height="14.4" class="st6"></rect>		<text x="19.97" y="183.9" class="st7" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>capsfilter</text>		</g>	<g id="shape10-16" v:mid="10" v:groupcontext="shape" transform="translate(312.59,-27.6458)">		<title>Sheet.10</title>		<path d="M0 184.5 A3.00007 3.00007 -180 0 0 3 187.5 L110.52 187.5 A3.00007 3.00007 -180 0 0 113.52 184.5 L113.52 46.29					 A3.00007 3.00007 -180 0 0 110.52 43.29 L3 43.29 A3.00007 3.00007 -180 0 0 -0 46.29 L0 184.5 Z" class="st3"></path>	</g>	<g id="shape11-18" v:mid="11" v:groupcontext="shape" transform="translate(324.352,-153.653)">		<title>Sheet.11</title>		<desc>audioconvert</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="180.3" width="90" height="14.4"></v:textrect>		<rect x="0" y="173.1" width="90" height="14.4" class="st6"></rect>		<text x="10.22" y="183.9" class="st7" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>audioconvert</text>		</g>	<g id="shape12-21" v:mid="12" v:groupcontext="shape" transform="translate(454.5,-151.218)">		<title>Sheet.12</title>		<desc>flacenc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="42.75" cy="180.3" width="85.51" height="14.4"></v:textrect>		<rect x="0" y="173.1" width="85.5" height="14.4" class="st6"></rect>		<text x="23.18" y="183.9" class="st7" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>flacenc</text>		</g>	<g id="shape13-24" v:mid="13" v:groupcontext="shape" transform="translate(454.5,-83.8665)">		<title>Sheet.13</title>		<desc>wavenc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="42.75" cy="180.3" width="85.51" height="14.4"></v:textrect>		<rect x="0" y="173.1" width="85.5" height="14.4" class="st6"></rect>		<text x="22.44" y="183.9" class="st7" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>wavenc</text>		</g>	<g id="shape14-27" v:mid="14" v:groupcontext="shape" transform="translate(580.5,-151.218)">		<title>Sheet.14</title>		<desc>filesink</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="180.3" width="90.01" height="14.4"></v:textrect>		<rect x="0" y="173.1" width="90" height="14.4" class="st6"></rect>		<text x="25.92" y="183.9" class="st7" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>filesink</text>		</g>	<g id="group15-30" transform="translate(39.5988,-123.928)" v:mid="15" v:groupcontext="group">		<title>Sheet.15</title>		<g id="shape16-31" v:mid="16" v:groupcontext="shape" transform="translate(0,-2.99179)">			<title>Sheet.16</title>			<path d="M0 187.5 L30 187.5" class="st8"></path>		</g>		<g id="group17-34" transform="translate(2.86806E-07,0)" v:mid="17" v:groupcontext="group">			<title>Sheet.17</title>			<g id="shape18-35" v:mid="18" v:groupcontext="shape" transform="translate(0,-2.99178)">				<title>Sheet.18</title>				<path d="M0 187.5 L25.69 187.5" class="st9"></path>			</g>			<g id="shape19-38" v:mid="19" v:groupcontext="shape" transform="translate(24.8189,0)">				<title>Sheet.19</title>				<path d="M0 187.5 L5.18 184.51 L0 181.52 L0 187.5 Z" class="st10"></path>			</g>		</g>	</g>	<g id="shape20-40" v:mid="20" v:groupcontext="shape" transform="translate(197.017,-104.42)">		<title>Sheet.20</title>		<desc>过滤器</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="165" width="90.01" height="45"></v:textrect>		<path d="M0 184.5 A3.00007 3.00007 -180 0 0 3 187.5 L87 187.5 A3.00007 3.00007 -180 0 0 90 184.5 L90 145.5 A3.00007 3.00007					 -180 0 0 87 142.5 L3 142.5 A3.00007 3.00007 -180 0 0 -0 145.5 L0 184.5 Z" class="st4"></path>		<text x="27" y="168.99" class="st5" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>过滤器</text>		</g>	<g id="shape22-43" v:mid="22" v:groupcontext="shape" transform="translate(16.0428,-119.873)">		<title>Sheet.22</title>		<desc>flac</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="11.8609" cy="180.3" width="23.73" height="14.4"></v:textrect>		<rect x="0" y="173.1" width="23.7218" height="14.4" class="st6"></rect>		<text x="0" y="183.9" class="st7" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>flac</text>		</g>	<g id="shape23-46" v:mid="23" v:groupcontext="shape" transform="translate(16.0428,-53.8598)">		<title>Sheet.23</title>		<desc>wav</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="12.2286" cy="180.3" width="24.46" height="14.4"></v:textrect>		<rect x="0" y="173.1" width="24.4572" height="14.4" class="st6"></rect>		<text x="0" y="183.9" class="st7" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>wav</text>		</g>	<g id="group24-49" transform="translate(159.517,-123.928)" v:mid="24" v:groupcontext="group">		<title>Sheet.24</title>		<g id="shape25-50" v:mid="25" v:groupcontext="shape" transform="translate(0,-2.99178)">			<title>Sheet.25</title>			<path d="M0 187.5 L33.19 187.5" class="st9"></path>		</g>		<g id="shape26-53" v:mid="26" v:groupcontext="shape" transform="translate(32.3189,0)">			<title>Sheet.26</title>			<path d="M0 187.5 L5.18 184.51 L0 181.52 L0 187.5 Z" class="st10"></path>		</g>	</g>	<g id="shape27-55" v:mid="27" v:groupcontext="shape" transform="translate(324.352,-104.42)">		<title>Sheet.27</title>		<desc>转换</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="165" width="90.01" height="45"></v:textrect>		<path d="M0 184.5 A3.00007 3.00007 -180 0 0 3 187.5 L87 187.5 A3.00007 3.00007 -180 0 0 90 184.5 L90 145.5 A3.00007 3.00007					 -180 0 0 87 142.5 L3 142.5 A3.00007 3.00007 -180 0 0 -0 145.5 L0 184.5 Z" class="st4"></path>		<text x="33" y="168.99" class="st5" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>转换</text>		</g>	<g id="group29-58" transform="translate(286.934,-123.928)" v:mid="29" v:groupcontext="group">		<title>Sheet.29</title>		<g id="shape30-59" v:mid="30" v:groupcontext="shape" transform="translate(0,-2.99178)">			<title>Sheet.30</title>			<path d="M0 187.5 L33.19 187.5" class="st9"></path>		</g>		<g id="shape31-62" v:mid="31" v:groupcontext="shape" transform="translate(32.3189,0)">			<title>Sheet.31</title>			<path d="M0 187.5 L5.18 184.51 L0 181.52 L0 187.5 Z" class="st10"></path>		</g>	</g>	<g id="shape32-64" v:mid="32" v:groupcontext="shape" transform="translate(451.783,-104.42)">		<title>Sheet.32</title>		<desc>编码</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="165" width="90.01" height="45"></v:textrect>		<path d="M0 184.5 A3.00007 3.00007 -180 0 0 3 187.5 L87 187.5 A3.00007 3.00007 -180 0 0 90 184.5 L90 145.5 A3.00007 3.00007					 -180 0 0 87 142.5 L3 142.5 A3.00007 3.00007 -180 0 0 0 145.5 L0 184.5 Z" class="st4"></path>		<text x="33" y="168.99" class="st5" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>编码</text>		</g>	<g id="group34-67" transform="translate(414.365,-123.928)" v:mid="34" v:groupcontext="group">		<title>Sheet.34</title>		<g id="shape35-68" v:mid="35" v:groupcontext="shape" transform="translate(0,-2.99178)">			<title>Sheet.35</title>			<path d="M0 187.5 L33.19 187.5" class="st9"></path>		</g>		<g id="shape36-71" v:mid="36" v:groupcontext="shape" transform="translate(32.3189,0)">			<title>Sheet.36</title>			<path d="M0 187.5 L5.18 184.51 L0 181.52 L0 187.5 Z" class="st10"></path>		</g>	</g>	<g id="group38-73" transform="translate(541.783,-123.928)" v:mid="38" v:groupcontext="group">		<title>Sheet.38</title>		<g id="shape39-74" v:mid="39" v:groupcontext="shape" transform="translate(0,-2.99178)">			<title>Sheet.39</title>			<path d="M0 187.5 L33.19 187.5" class="st9"></path>		</g>		<g id="shape40-77" v:mid="40" v:groupcontext="shape" transform="translate(32.3188,0)">			<title>Sheet.40</title>			<path d="M0 187.5 L5.18 184.51 L0 181.52 L0 187.5 Z" class="st10"></path>		</g>	</g>	<g id="shape41-79" v:mid="41" v:groupcontext="shape" transform="translate(69.5166,-38.4065)">		<title>Sheet.41</title>		<desc>音频采集</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="165" width="90.01" height="45"></v:textrect>		<path d="M0 184.5 A3.00007 3.00007 -180 0 0 3 187.5 L87 187.5 A3.00007 3.00007 -180 0 0 90 184.5 L90 145.5 A3.00007 3.00007					 -180 0 0 87 142.5 L3 142.5 A3.00007 3.00007 -180 0 0 -0 145.5 L0 184.5 Z" class="st4"></path>		<text x="21" y="168.99" class="st5" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>音频采集</text>		</g>	<g id="group43-82" transform="translate(39.5988,-57.9147)" v:mid="43" v:groupcontext="group">		<title>Sheet.43</title>		<g id="shape44-83" v:mid="44" v:groupcontext="shape" transform="translate(0,-2.9918)">			<title>Sheet.44</title>			<path d="M0 187.5 L30 187.5" class="st8"></path>		</g>		<g id="group45-86" transform="translate(2.86806E-07,-2.84217E-14)" v:mid="45" v:groupcontext="group">			<title>Sheet.45</title>			<g id="shape46-87" v:mid="46" v:groupcontext="shape" transform="translate(0,-2.99181)">				<title>Sheet.46</title>				<path d="M0 187.5 L25.69 187.5" class="st9"></path>			</g>			<g id="shape47-90" v:mid="47" v:groupcontext="shape" transform="translate(24.8189,-2.84217E-14)">				<title>Sheet.47</title>				<path d="M0 187.5 L5.18 184.51 L0 181.52 L0 187.5 Z" class="st10"></path>			</g>		</g>	</g>	<g id="group48-92" transform="translate(159.517,-57.9147)" v:mid="48" v:groupcontext="group">		<title>Sheet.48</title>		<g id="shape49-93" v:mid="49" v:groupcontext="shape" transform="translate(0,-2.99181)">			<title>Sheet.49</title>			<path d="M0 187.5 L160.53 187.5" class="st9"></path>		</g>		<g id="shape50-96" v:mid="50" v:groupcontext="shape" transform="translate(159.654,-2.84217E-14)">			<title>Sheet.50</title>			<path d="M0 187.5 L5.18 184.51 L0 181.52 L0 187.5 Z" class="st10"></path>		</g>	</g>	<g id="shape51-98" v:mid="51" v:groupcontext="shape" transform="translate(324.352,-38.4065)">		<title>Sheet.51</title>		<desc>转换</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="165" width="90.01" height="45"></v:textrect>		<path d="M0 184.5 A3.00007 3.00007 -180 0 0 3 187.5 L87 187.5 A3.00007 3.00007 -180 0 0 90 184.5 L90 145.5 A3.00007 3.00007					 -180 0 0 87 142.5 L3 142.5 A3.00007 3.00007 -180 0 0 -0 145.5 L0 184.5 Z" class="st4"></path>		<text x="33" y="168.99" class="st5" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>转换</text>		</g>	<g id="shape53-101" v:mid="53" v:groupcontext="shape" transform="translate(451.783,-38.4065)">		<title>Sheet.53</title>		<desc>编码</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="165" width="90.01" height="45"></v:textrect>		<path d="M0 184.5 A3.00007 3.00007 -180 0 0 3 187.5 L87 187.5 A3.00007 3.00007 -180 0 0 90 184.5 L90 145.5 A3.00007 3.00007					 -180 0 0 87 142.5 L3 142.5 A3.00007 3.00007 -180 0 0 -0 145.5 L0 184.5 Z" class="st4"></path>		<text x="33" y="168.99" class="st5" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>编码</text>		</g>	<g id="group55-104" transform="translate(414.365,-57.9147)" v:mid="55" v:groupcontext="group">		<title>Sheet.55</title>		<g id="shape56-105" v:mid="56" v:groupcontext="shape" transform="translate(0,-2.99181)">			<title>Sheet.56</title>			<path d="M0 187.5 L33.19 187.5" class="st9"></path>		</g>		<g id="shape57-108" v:mid="57" v:groupcontext="shape" transform="translate(32.3189,-2.84217E-14)">			<title>Sheet.57</title>			<path d="M0 187.5 L5.18 184.51 L0 181.52 L0 187.5 Z" class="st10"></path>		</g>	</g>	<g id="group58-110" transform="translate(541.783,-57.9147)" v:mid="58" v:groupcontext="group">		<title>Sheet.58</title>		<g id="shape59-111" v:mid="59" v:groupcontext="shape" transform="translate(0,-2.99181)">			<title>Sheet.59</title>			<path d="M0 187.5 L33.19 187.5" class="st9"></path>		</g>		<g id="shape60-114" v:mid="60" v:groupcontext="shape" transform="translate(32.3188,-2.84217E-14)">			<title>Sheet.60</title>			<path d="M0 187.5 L5.18 184.51 L0 181.52 L0 187.5 Z" class="st10"></path>		</g>	</g>	<g id="group61-116" transform="translate(669.201,-93.9212)" v:mid="61" v:groupcontext="group">		<title>Sheet.61</title>		<g id="shape62-117" v:mid="62" v:groupcontext="shape" transform="translate(6.62312E-07,-2.99181)">			<title>Sheet.62</title>			<path d="M0 187.5 L22.5 187.5" class="st8"></path>		</g>		<g id="group63-120" v:mid="63" v:groupcontext="group">			<title>Sheet.63</title>			<g id="shape64-121" v:mid="64" v:groupcontext="shape" transform="translate(0,-2.99181)">				<title>Sheet.64</title>				<path d="M0 187.5 L18.19 187.5" class="st9"></path>			</g>			<g id="shape65-124" v:mid="65" v:groupcontext="shape" transform="translate(17.3188,0)">				<title>Sheet.65</title>				<path d="M0 187.5 L5.18 184.51 L0 181.52 L0 187.5 Z" class="st10"></path>			</g>		</g>	</g>	<g id="shape67-126" v:mid="67" v:groupcontext="shape" transform="translate(695.065,-89.713)">		<title>Sheet.67</title>		<desc>文件</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="12.4674" cy="180.3" width="24.94" height="14.4"></v:textrect>		<rect x="0" y="173.1" width="24.9349" height="14.4" class="st6"></rect>		<text x="0" y="184.29" class="st11" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>文件</text>		</g>	<g id="shape37-129" v:mid="37" v:groupcontext="shape" transform="translate(579.201,-44.4065)">		<title>Sheet.37</title>		<desc>写入</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="134.993" width="90.01" height="105.013"></v:textrect>		<path d="M-0 184.5 A3.00007 3.00007 -180 0 0 3 187.5 L87 187.5 A3.00007 3.00007 -180 0 0 90 184.5 L90 85.49 A3.00007					 3.00007 -180 0 0 87 82.49 L3 82.49 A3.00007 3.00007 -180 0 0 0 85.49 L0 184.5 Z" class="st4"></path>		<text x="33" y="138.99" class="st5" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>写入</text>		</g>	<g id="group89-132" transform="translate(683.812,-15.4272)" v:mid="89" v:groupcontext="group">		<title>Sheet.89</title>		<g id="shape69-133" v:mid="69" v:groupcontext="shape" transform="translate(15.1882,0)">			<title>Sheet.69</title>			<desc>开源</desc>			<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>			<v:textrect cx="10.5" cy="181.2" width="21" height="12.6"></v:textrect>			<rect x="0" y="174.9" width="21" height="12.6" class="st6"></rect>			<text x="0" y="184.69" class="st12" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>开源</text>			</g>		<g id="shape70-136" v:mid="70" v:groupcontext="shape" transform="translate(6.29496E-14,-0.218622)">			<title>Sheet.70</title>			<path d="M0 186 A1.50003 1.50003 -180 0 0 1.5 187.5 L10.5 187.5 A1.50003 1.50003 -180 0 0 12 186 L12 177 A1.50003						 1.50003 -180 0 0 10.5 175.5 L1.5 175.5 A1.50003 1.50003 -180 0 0 -0 177 L0 186 Z" class="st4"></path>		</g>	</g></g>
</svg>

## 运行应用程序

对于此用例，如果您有实时音频源（如麦克风或互联网广播流），则可以将此音频数据编码为更紧凑或标准化的格式，以实现高效传输或存储。

1. 确保您已完成[前提条件](https://docs.qualcomm.com/doc/80-70022-50SC/topic/mm_sample_apps_prerequisites.html)。
2. 在目标设备的终端中，针对不同音频格式运行以下命令：
    `gst-audio-encode-example -o <path-file>
                            --audio_format=<format>`

下表提供了命令行参数的说明：

    | 命令行参数 | 说明 |
    | --- | --- |
    | `-o` | 指定输出音频文件的绝对路径。 |
    | `-format` | 指定音频文件的格式：<ul class="ul" id="gst-audio-encode-example-without-flac__ul_vhx_vw5_4bc"><br>                                            <li class="li"><code class="ph codeph">1</code>= FLAC</li><br><br>                                            <li class="li"><code class="ph codeph">2</code>= WAV</li><br><br>                                        </ul> |

例如，使用以下命令为 FLAC 和 WAV 音频格式运行应用程序：
    - 对 FLAC 音频进行编码：

            gst-audio-encode-example -o /etc/media/<filename>.flac --audio_format=1Copy to clipboard
    - 编码 WAV 音频：

            gst-audio-encode-example -o /etc/media/<filename>.wav --audio_format=2Copy to clipboard
3. 要停止用例，请使用 CTRL +
                    C。
4. 在目标设备的终端中，在 SSH shell 中运行以下命令以显示可用的帮助选项：

        gst-audio-encode-example --helpCopy to clipboard
5. 在主机的终端中，运行以下命令从目标设备中拉取文件：

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

## 预期输出

采集的音频根据所选格式（FLAC 或 WAV）进行编码并写入文件。

## Pipeline 流

在音频编码中，pipeline 根据编码格式略有不同。

下表列出了用于运行音频录制 pipeline 的插件：

| 插件 | FLAC | WAV |
| --- | --- | --- |
| pulsesrc | 从系统声音设备采集音频。 | 从系统声音设备采集音频。 |
| capsfilter | 确保音频采用适合 FLAC 编码器的格式。 | – |
| audioconvert | 将音频转换为所需的格式。 | 将音频转换为所需的格式。 |
| <ul class="ul" id="gst-audio-encode-example-without-flac__ul_n35_vy5_4bc"><br>                                    <li class="li">flacenc</li><br><br>                                    <li class="li">wavenc</li><br><br>                                </ul> | flacenc 将音频编码为 FLAC 格式。 | wavenc 将音频编码为 WAV 格式。 |
| filesink | 将编码的音频写入文件。 | 将编码的音频写入文件。 |

## 相关信息

[音频用例](https://docs.qualcomm.com/doc/80-70022-50SC/topic/audio-use-cases.html)

**Parent Topic:** [运行视频和音频的示例应用程序](https://docs.qualcomm.com/doc/80-70022-50SC/topic/audio-sample-applications.html)

Last Published: Nov 05, 2025

[Previous Topic
音频播放](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/gst-audio-decode-sample.md) [Next Topic
视频转换](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/gst-transform-example.md)