# 摄像头编码

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

**gst-camera-encode-example** 应用程序可以记录和编码单个摄像头流。

Figure : 摄像头编码 pipeline
            
            <?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<!-- Generated by Microsoft Visio, SVG Export pipeline_camera_encoding.svg Layer_2 -->
<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.4717in" height="1.38195in" viewbox="0 0 753.962 99.5001" xml:space="preserve" color-interpolation-filters="sRGB" class="st11"><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: #2a2aea; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st4 { fill: #ffffff; font-family: Roboto; font-size: 1.00001em }
.svg-1 .st5 { fill: #007884; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st6 { stroke: #000000; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st7 { fill: #000000; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st8 { fill: none; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st9 { fill: #000000; font-family: Roboto; font-size: 0.874992em }
.svg-1 .st10 { fill: #000000; font-family: SimHei; font-size: 0.874992em }
.svg-1 .st11 { 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_2</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.375011,-0.375229)">		<title>Sheet.2</title>		<path d="M0 93.88 A5.62513 5.62513 -180 0 0 5.62 99.5 L747.59 99.5 A5.62513 5.62513 -180 0 0 753.21 93.88 L753.21 6.38					 A5.62513 5.62513 -180 0 0 747.59 0.75 L5.62 0.75 A5.62513 5.62513 -180 0 0 0 6.38 L0 93.88 Z" class="st1"></path>	</g>	<g id="shape3-3" v:mid="3" v:groupcontext="shape">		<title>Sheet.3</title>		<path d="M747.96 0.75 C750.86 0.75 753.21 3.11 753.21 6 L753.21 93.5 C753.21 96.39 750.86 98.75 747.96 98.75 L6 98.75					 C3.11 98.75 0.75 96.39 0.75 93.5 L0.75 6 C0.75 3.11 3.11 0.75 6 0.75 L747.96 0.75 ZM747.96 0 L6 0 C2.69					 0 0 2.69 0 6 L0 93.5 C0 96.81 2.69 99.5 6 99.5 L747.96 99.5 C751.28 99.5 753.96 96.81 753.96 93.5 L753.96					 6 C753.96 2.69 751.28 0 747.96 0 Z" class="st2"></path>	</g>	<g id="shape5-5" v:mid="5" v:groupcontext="shape" transform="translate(15,-42)">		<title>Sheet.5</title>		<desc>qtiqmmfsrc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="52.5" cy="78.25" width="105" height="42.5"></v:textrect>		<path d="M0 96.5 A3.00007 3.00007 -180 0 0 3 99.5 L102 99.5 A3.00007 3.00007 -180 0 0 105 96.5 L105 60 A3.00007 3.00007					 -180 0 0 102 57 L3 57 A3.00007 3.00007 -180 0 0 0 60 L0 96.5 Z" class="st3"></path>		<text x="21.4" y="81.85" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtiqmmfsrc</text>		</g>	<g id="shape7-8" v:mid="7" v:groupcontext="shape" transform="translate(138.126,-42)">		<title>Sheet.7</title>		<desc>capsfilter</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="52.5" cy="78.25" width="105" height="42.5"></v:textrect>		<path d="M0 96.5 A3.00007 3.00007 -180 0 0 3 99.5 L102 99.5 A3.00007 3.00007 -180 0 0 105 96.5 L105 60 A3.00007 3.00007					 -180 0 0 102 57 L3 57 A3.00007 3.00007 -180 0 0 0 60 L0 96.5 Z" class="st5"></path>		<text x="27.47" y="81.85" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>capsfilter</text>		</g>	<g id="shape8-11" v:mid="8" v:groupcontext="shape" transform="translate(262.343,-42)">		<title>Sheet.8</title>		<desc>v4l2h264enc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="52.5" cy="78.25" width="105" height="42.5"></v:textrect>		<path d="M0 96.5 A3.00007 3.00007 -180 0 0 3 99.5 L102 99.5 A3.00007 3.00007 -180 0 0 105 96.5 L105 60 A3.00007 3.00007					 -180 0 0 102 57 L3 57 A3.00007 3.00007 -180 0 0 -0 60 L0 96.5 Z" class="st5"></path>		<text x="18.36" y="81.85" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>v4l2h264enc</text>		</g>	<g id="shape9-14" v:mid="9" v:groupcontext="shape" transform="translate(633.962,-42)">		<title>Sheet.9</title>		<desc>filesink</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="52.5" cy="78.25" width="105.01" height="42.5"></v:textrect>		<path d="M0 96.5 A3.00007 3.00007 -180 0 0 3 99.5 L102 99.5 A3.00007 3.00007 -180 0 0 105 96.5 L105 60 A3.00007 3.00007					 -180 0 0 102 57 L3 57 A3.00007 3.00007 -180 0 0 0 60 L0 96.5 Z" class="st5"></path>		<text x="33.42" y="81.85" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>filesink</text>		</g>	<g id="shape12-17" v:mid="12" v:groupcontext="shape" transform="translate(386.241,-42)">		<title>Sheet.12</title>		<desc>h264parse</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="52.5" cy="78.25" width="105" height="42.5"></v:textrect>		<path d="M0 96.5 A3.00007 3.00007 -180 0 0 3 99.5 L102 99.5 A3.00007 3.00007 -180 0 0 105 96.5 L105 60 A3.00007 3.00007					 -180 0 0 102 57 L3 57 A3.00007 3.00007 -180 0 0 0 60 L0 96.5 Z" class="st5"></path>		<text x="24.15" y="81.85" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>h264parse</text>		</g>	<g id="shape14-20" v:mid="14" v:groupcontext="shape" transform="translate(510.072,-42)">		<title>Sheet.14</title>		<desc>mp4mux</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="52.5" cy="78.25" width="105" height="42.5"></v:textrect>		<path d="M0 96.5 A3.00007 3.00007 -180 0 0 3 99.5 L102 99.5 A3.00007 3.00007 -180 0 0 105 96.5 L105 60 A3.00007 3.00007					 -180 0 0 102 57 L3 57 A3.00007 3.00007 -180 0 0 0 60 L0 96.5 Z" class="st5"></path>		<text x="28.97" y="81.85" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>mp4mux</text>		</g>	<g id="shape18-23" v:mid="18" v:groupcontext="shape" transform="translate(243.829,-63.25)">		<title>Sheet.18</title>		<path d="M0 99.5 L13.19 99.5" class="st6"></path>	</g>	<g id="shape19-26" v:mid="19" v:groupcontext="shape" transform="translate(256.148,-60.2582)">		<title>Sheet.19</title>		<path d="M0 99.5 L5.18 96.51 L0 93.52 L0 99.5 Z" class="st7"></path>	</g>	<g id="shape21-28" v:mid="21" v:groupcontext="shape" transform="translate(120.626,-63.25)">		<title>Sheet.21</title>		<path d="M0 99.5 L13.19 99.5" class="st6"></path>	</g>	<g id="shape22-31" v:mid="22" v:groupcontext="shape" transform="translate(132.945,-60.2582)">		<title>Sheet.22</title>		<path d="M0 99.5 L5.18 96.51 L0 93.52 L0 99.5 Z" class="st7"></path>	</g>	<g id="shape24-33" v:mid="24" v:groupcontext="shape" transform="translate(368.05,-63.25)">		<title>Sheet.24</title>		<path d="M0 99.5 L13.19 99.5" class="st6"></path>	</g>	<g id="shape25-36" v:mid="25" v:groupcontext="shape" transform="translate(380.369,-60.2582)">		<title>Sheet.25</title>		<path d="M0 99.5 L5.18 96.51 L0 93.52 L0 99.5 Z" class="st7"></path>	</g>	<g id="shape27-38" v:mid="27" v:groupcontext="shape" transform="translate(491.876,-63.25)">		<title>Sheet.27</title>		<path d="M0 99.5 L13.19 99.5" class="st6"></path>	</g>	<g id="shape28-41" v:mid="28" v:groupcontext="shape" transform="translate(504.195,-60.2582)">		<title>Sheet.28</title>		<path d="M0 99.5 L5.18 96.51 L0 93.52 L0 99.5 Z" class="st7"></path>	</g>	<g id="shape30-43" v:mid="30" v:groupcontext="shape" transform="translate(615.789,-63.25)">		<title>Sheet.30</title>		<path d="M0 99.5 L13.19 99.5" class="st6"></path>	</g>	<g id="shape31-46" v:mid="31" v:groupcontext="shape" transform="translate(628.108,-60.2582)">		<title>Sheet.31</title>		<path d="M0 99.5 L5.18 96.51 L0 93.52 L0 99.5 Z" class="st7"></path>	</g>	<g id="group39-48" transform="translate(628.837,-14.7814)" v:mid="39" v:groupcontext="group">		<title>Sheet.39</title>		<g id="shape34-49" v:mid="34" v:groupcontext="shape" transform="translate(15.1883,1.42109E-14)">			<title>Sheet.34</title>			<desc>Qualcomm</desc>			<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>			<v:textrect cx="27.3956" cy="93.2001" width="54.8" height="12.6"></v:textrect>			<rect x="0" y="86.9001" width="54.7911" height="12.6" class="st8"></rect>			<text x="0" y="96.35" class="st9" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>Qualcomm  </text>			</g>		<g id="shape35-52" v:mid="35" v:groupcontext="shape" transform="translate(-9.99201E-16,-0.21863)">			<title>Sheet.35</title>			<path d="M0 98 A1.50003 1.50003 -180 0 0 1.5 99.5 L10.5 99.5 A1.50003 1.50003 -180 0 0 12 98 L12 89 A1.50003 1.50003						 -180 0 0 10.5 87.5 L1.5 87.5 A1.50003 1.50003 -180 0 0 0 89 L0 98 Z" class="st3"></path>		</g>		<g id="shape37-54" v:mid="37" v:groupcontext="shape" transform="translate(89.1246,1.42109E-14)">			<title>Sheet.37</title>			<desc>开源</desc>			<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>			<v:textrect cx="10.5" cy="93.2001" width="21" height="12.6"></v:textrect>			<rect x="0" y="86.9001" width="21" height="12.6" class="st8"></rect>			<text x="-0" y="96.69" class="st10" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>开源</text>			</g>		<g id="shape38-57" v:mid="38" v:groupcontext="shape" transform="translate(73.9363,-0.21863)">			<title>Sheet.38</title>			<path d="M0 98 A1.50003 1.50003 -180 0 0 1.5 99.5 L10.5 99.5 A1.50003 1.50003 -180 0 0 12 98 L12 89 A1.50003 1.50003						 -180 0 0 10.5 87.5 L1.5 87.5 A1.50003 1.50003 -180 0 0 0 89 L0 98 Z" class="st5"></path>		</g>	</g></g>
</svg>

有关该 pipeline 中使用的插件的信息，请参见 [Pipeline 流](https://docs.qualcomm.com/doc/80-70022-50SC/topic/camera-encode.html#camera-encode__section_nn5_cck_zcc)。

## 在目标设备上运行应用程序

1. 确保您已完成[前提条件](https://docs.qualcomm.com/doc/80-70022-50SC/topic/prerequisites-for-python-sample-applications.html)。
2. 运行摄像头编码脚本：

        gst-camera-encode.pyCopy to clipboard

要显示可用的帮助选项，请运行以下命令：

    gst-camera-encode.py -hCopy to clipboard

## 预期输出

输出保存在 /etc/media/recording.mp4 的文件中

## Pipeline 流

下表列出了摄像头编码 pipeline 中使用的插件：| 插件 | 说明 |
| :--- | :--- |
| [qtiqmmfsrc](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtiqmmfsrc.html) | <ul class="ul" id="camera-encode__ul_o43_szq_ndc"><br>                                    <li class="li">采集摄像头实时流。</li><br><br>                                    <li class="li">Capsfilter 用于对原始视频数据实施约束。</li><br><br>                                </ul> |
| [v4l2h264enc](https://docs.qualcomm.com/doc/80-70022-50SC/topic/v4l2h264enc.html) | 使用 H.264 格式对视频进行编码。 |
| H264parse | 渲染视频。 |
| Mp4mux | 将视频多路传输到 MP4 容器中。 |
| Filesink | 将视频写入文件。 |

**Parent Topic:** [运行基于 Python 的应用程序](https://docs.qualcomm.com/doc/80-70022-50SC/topic/python-sample-applications.html)

Last Published: Nov 05, 2025

[Previous Topic
前提条件](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/prerequisites-for-python-sample-applications.md) [Next Topic
使用 OpenCV 进行摄像头流传输](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/gst-camera-opencv-resize-py.md)