# 转换和编码摄像头流

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

**gst-camera-rotate-downscale-file.py** 应用程序可旋转、缩小摄像头流并对其进行编码。然后将转换后的数据流保存到文件中。

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_video_transformation.svg pipeline_video_transformation -->
<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="11.9792in" height="1.3125in" viewbox="0 0 862.5 94.5" 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>pipeline_video_transformation</title>	<v:pageproperties v:drawingscale="1" v:pagescale="1" v:drawingunits="19" v:shadowoffsetx="9" v:shadowoffsety="-9"></v:pageproperties>	<g id="shape3-1" v:mid="3" v:groupcontext="shape" transform="translate(0.374908,-0.375057)">		<title>Sheet.3</title>		<path d="M0 88.87 A5.62513 5.62513 -180 0 0 5.62 94.5 L856.13 94.5 A5.62513 5.62513 -180 0 0 861.75 88.87 L861.75 6.38					 A5.62513 5.62513 -180 0 0 856.13 0.75 L5.62 0.75 A5.62513 5.62513 -180 0 0 -0 6.38 L0 88.87 Z" class="st1"></path>	</g>	<g id="shape4-3" v:mid="4" v:groupcontext="shape">		<title>Sheet.4</title>		<path d="M856.5 0.75 C859.39 0.75 861.75 3.11 861.75 6 L861.75 88.5 C861.75 91.39 859.39 93.75 856.5 93.75 L6 93.75 C3.11					 93.75 0.75 91.39 0.75 88.5 L0.75 6 C0.75 3.11 3.11 0.75 6 0.75 L856.5 0.75 ZM856.5 0 L6 0 C2.69 0 0 2.69					 0 6 L0 88.5 C0 91.81 2.69 94.5 6 94.5 L856.5 94.5 C859.81 94.5 862.5 91.81 862.5 88.5 L862.5 6 C862.5 2.69					 859.81 0 856.5 0 Z" class="st2"></path>	</g>	<g id="shape14-5" v:mid="14" v:groupcontext="shape" transform="translate(15,-42)">		<title>Sheet.14</title>		<desc>qtiqmmfsrc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="41.25" cy="75.75" width="82.5" height="37.5"></v:textrect>		<path d="M0 91.5 A3.00007 3.00007 -180 0 0 3 94.5 L79.5 94.5 A3.00007 3.00007 -180 0 0 82.5 91.5 L82.5 60 A3.00007 3.00007					 -180 0 0 79.5 57 L3 57 A3.00007 3.00007 -180 0 0 -0 60 L0 91.5 Z" class="st3"></path>		<text x="10.15" y="79.35" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtiqmmfsrc</text>		</g>	<g id="shape17-8" v:mid="17" v:groupcontext="shape" transform="translate(112.5,-42)">		<title>Sheet.17</title>		<desc>capsfilter</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="37.5" cy="75.75" width="75" height="37.5"></v:textrect>		<path d="M0 91.5 A3.00007 3.00007 -180 0 0 3 94.5 L72 94.5 A3.00007 3.00007 -180 0 0 75 91.5 L75 60 A3.00007 3.00007					 -180 0 0 72 57 L3 57 A3.00007 3.00007 -180 0 0 0 60 L0 91.5 Z" class="st5"></path>		<text x="12.47" y="79.35" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>capsfilter</text>		</g>	<g id="shape20-11" v:mid="20" v:groupcontext="shape" transform="translate(97.5,-60.75)">		<title>Sheet.20</title>		<path d="M0 94.5 L11.23 94.5" class="st6"></path>	</g>	<g id="shape21-14" v:mid="21" v:groupcontext="shape" transform="translate(107.967,-58.1322)">		<title>Sheet.21</title>		<path d="M0 94.5 L4.53 91.88 L0 89.26 L0 94.5 Z" class="st7"></path>	</g>	<g id="shape23-16" v:mid="23" v:groupcontext="shape" transform="translate(202.5,-42)">		<title>Sheet.23</title>		<desc>qtivtransform</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="75.75" width="90" height="37.5"></v:textrect>		<path d="M0 91.5 A3.00007 3.00007 -180 0 0 3 94.5 L87 94.5 A3.00007 3.00007 -180 0 0 90 91.5 L90 60 A3.00007 3.00007					 -180 0 0 87 57 L3 57 A3.00007 3.00007 -180 0 0 -0 60 L0 91.5 Z" class="st3"></path>		<text x="8.81" y="79.35" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtivtransform</text>		</g>	<g id="shape26-19" v:mid="26" v:groupcontext="shape" transform="translate(187.5,-60.75)">		<title>Sheet.26</title>		<path d="M0 94.5 L11.23 94.5" class="st6"></path>	</g>	<g id="shape27-22" v:mid="27" v:groupcontext="shape" transform="translate(197.967,-58.1322)">		<title>Sheet.27</title>		<path d="M0 94.5 L4.53 91.88 L0 89.26 L0 94.5 Z" class="st7"></path>	</g>	<g id="shape29-24" v:mid="29" v:groupcontext="shape" transform="translate(292.5,-60.75)">		<title>Sheet.29</title>		<path d="M0 94.5 L11.23 94.5" class="st6"></path>	</g>	<g id="shape30-27" v:mid="30" v:groupcontext="shape" transform="translate(302.967,-58.1322)">		<title>Sheet.30</title>		<path d="M0 94.5 L4.53 91.88 L0 89.26 L0 94.5 Z" class="st7"></path>	</g>	<g id="shape32-29" v:mid="32" v:groupcontext="shape" transform="translate(382.5,-60.75)">		<title>Sheet.32</title>		<path d="M0 94.5 L11.23 94.5" class="st6"></path>	</g>	<g id="shape33-32" v:mid="33" v:groupcontext="shape" transform="translate(392.967,-58.1322)">		<title>Sheet.33</title>		<path d="M0 94.5 L4.53 91.88 L0 89.26 L0 94.5 Z" class="st7"></path>	</g>	<g id="shape35-34" v:mid="35" v:groupcontext="shape" transform="translate(472.5,-60.75)">		<title>Sheet.35</title>		<path d="M0 94.5 L11.23 94.5" class="st6"></path>	</g>	<g id="shape36-37" v:mid="36" v:groupcontext="shape" transform="translate(482.967,-58.1322)">		<title>Sheet.36</title>		<path d="M0 94.5 L4.53 91.88 L0 89.26 L0 94.5 Z" class="st7"></path>	</g>	<g id="shape38-39" v:mid="38" v:groupcontext="shape" transform="translate(570,-60.75)">		<title>Sheet.38</title>		<path d="M0 94.5 L11.23 94.5" class="st6"></path>	</g>	<g id="shape39-42" v:mid="39" v:groupcontext="shape" transform="translate(580.467,-58.1322)">		<title>Sheet.39</title>		<path d="M0 94.5 L4.53 91.88 L0 89.26 L0 94.5 Z" class="st7"></path>	</g>	<g id="shape41-44" v:mid="41" v:groupcontext="shape" transform="translate(667.5,-60.75)">		<title>Sheet.41</title>		<path d="M0 94.5 L11.23 94.5" class="st6"></path>	</g>	<g id="shape42-47" v:mid="42" v:groupcontext="shape" transform="translate(677.967,-58.1322)">		<title>Sheet.42</title>		<path d="M0 94.5 L4.53 91.88 L0 89.26 L0 94.5 Z" class="st7"></path>	</g>	<g id="shape44-49" v:mid="44" v:groupcontext="shape" transform="translate(757.5,-60.75)">		<title>Sheet.44</title>		<path d="M0 94.5 L11.23 94.5" class="st6"></path>	</g>	<g id="shape45-52" v:mid="45" v:groupcontext="shape" transform="translate(767.967,-58.1322)">		<title>Sheet.45</title>		<path d="M0 94.5 L4.53 91.88 L0 89.26 L0 94.5 Z" class="st7"></path>	</g>	<g id="shape47-54" v:mid="47" v:groupcontext="shape" transform="translate(307.5,-42)">		<title>Sheet.47</title>		<desc>capsfilter</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="37.5" cy="75.75" width="75.01" height="37.5"></v:textrect>		<path d="M0 91.5 A3.00007 3.00007 -180 0 0 3 94.5 L72 94.5 A3.00007 3.00007 -180 0 0 75 91.5 L75 60 A3.00007 3.00007					 -180 0 0 72 57 L3 57 A3.00007 3.00007 -180 0 0 -0 60 L0 91.5 Z" class="st5"></path>		<text x="12.47" y="79.35" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>capsfilter</text>		</g>	<g id="shape50-57" v:mid="50" v:groupcontext="shape" transform="translate(397.5,-42)">		<title>Sheet.50</title>		<desc>tee</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="37.5" cy="75.75" width="75.01" height="37.5"></v:textrect>		<path d="M0 91.5 A3.00007 3.00007 -180 0 0 3 94.5 L72 94.5 A3.00007 3.00007 -180 0 0 75 91.5 L75 60 A3.00007 3.00007					 -180 0 0 72 57 L3 57 A3.00007 3.00007 -180 0 0 -0 60 L0 91.5 Z" class="st5"></path>		<text x="29.18" y="79.35" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>tee</text>		</g>	<g id="shape53-60" v:mid="53" v:groupcontext="shape" transform="translate(487.5,-42)">		<title>Sheet.53</title>		<desc>v4l2h264enc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="41.25" cy="75.75" width="82.51" height="37.5"></v:textrect>		<path d="M0 91.5 A3.00007 3.00007 -180 0 0 3 94.5 L79.5 94.5 A3.00007 3.00007 -180 0 0 82.5 91.5 L82.5 60 A3.00007 3.00007					 -180 0 0 79.5 57 L3 57 A3.00007 3.00007 -180 0 0 -0 60 L0 91.5 Z" class="st5"></path>		<text x="7.11" y="79.35" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>v4l2h264enc</text>		</g>	<g id="shape56-63" v:mid="56" v:groupcontext="shape" transform="translate(585,-42)">		<title>Sheet.56</title>		<desc>h264prase</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="41.25" cy="75.75" width="82.5" height="37.5"></v:textrect>		<path d="M0 91.5 A3.00007 3.00007 -180 0 0 3 94.5 L79.5 94.5 A3.00007 3.00007 -180 0 0 82.5 91.5 L82.5 60 A3.00007 3.00007					 -180 0 0 79.5 57 L3 57 A3.00007 3.00007 -180 0 0 0 60 L0 91.5 Z" class="st5"></path>		<text x="12.9" y="79.35" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>h264prase</text>		</g>	<g id="shape59-66" v:mid="59" v:groupcontext="shape" transform="translate(682.5,-42)">		<title>Sheet.59</title>		<desc>mp4mux</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="37.5" cy="75.75" width="75.01" height="37.5"></v:textrect>		<path d="M0 91.5 A3.00007 3.00007 -180 0 0 3 94.5 L72 94.5 A3.00007 3.00007 -180 0 0 75 91.5 L75 60 A3.00007 3.00007					 -180 0 0 72 57 L3 57 A3.00007 3.00007 -180 0 0 -0 60 L0 91.5 Z" class="st5"></path>		<text x="13.97" y="79.35" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>mp4mux</text>		</g>	<g id="shape62-69" v:mid="62" v:groupcontext="shape" transform="translate(772.5,-42)">		<title>Sheet.62</title>		<desc>filesink</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="37.5" cy="75.75" width="75.01" height="37.5"></v:textrect>		<path d="M0 91.5 A3.00007 3.00007 -180 0 0 3 94.5 L72 94.5 A3.00007 3.00007 -180 0 0 75 91.5 L75 60 A3.00007 3.00007					 -180 0 0 72 57 L3 57 A3.00007 3.00007 -180 0 0 0 60 L0 91.5 Z" class="st5"></path>		<text x="18.42" y="79.35" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>filesink</text>		</g>	<g id="group64-72" transform="translate(737.375,-14.7814)" v:mid="64" v:groupcontext="group">		<title>Sheet.64</title>		<g id="shape7-73" v:mid="7" v:groupcontext="shape" transform="translate(15.1882,0)">			<title>Sheet.7</title>			<desc>Qualcomm</desc>			<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>			<v:textrect cx="26.8152" cy="88.2" width="53.64" height="12.6"></v:textrect>			<rect x="0" y="81.9" width="53.6304" height="12.6" class="st8"></rect>			<text x="0" y="91.35" class="st9" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>Qualcomm  </text>			</g>		<g id="shape8-76" v:mid="8" v:groupcontext="shape" transform="translate(1.26898E-13,-0.21863)">			<title>Sheet.8</title>			<path d="M0 93 A1.50003 1.50003 -180 0 0 1.5 94.5 L10.5 94.5 A1.50003 1.50003 -180 0 0 12 93 L12 84 A1.50003 1.50003						 -180 0 0 10.5 82.5 L1.5 82.5 A1.50003 1.50003 -180 0 0 -0 84 L0 93 Z" class="st3"></path>		</g>		<g id="shape10-78" v:mid="10" v:groupcontext="shape" transform="translate(89.1246,0)">			<title>Sheet.10</title>			<desc>开源</desc>			<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>			<v:textrect cx="10.5" cy="88.2" width="21.01" height="12.6"></v:textrect>			<rect x="0" y="81.9" width="21" height="12.6" class="st8"></rect>			<text x="0" y="91.69" class="st10" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>开源</text>			</g>		<g id="shape11-81" v:mid="11" v:groupcontext="shape" transform="translate(73.9363,-0.21863)">			<title>Sheet.11</title>			<path d="M0 93 A1.50003 1.50003 -180 0 0 1.5 94.5 L10.5 94.5 A1.50003 1.50003 -180 0 0 12 93 L12 84 A1.50003 1.50003						 -180 0 0 10.5 82.5 L1.5 82.5 A1.50003 1.50003 -180 0 0 -0 84 L0 93 Z" class="st5"></path>		</g>	</g></g>
</svg>

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

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

1. 确保您已完成[前提条件](https://docs.qualcomm.com/doc/80-70022-50SC/topic/prerequisites-for-python-sample-applications.html)。
2. 在目标设备上运行转换脚本：

        gst-camera-rotate-downscale-file.pyCopy to clipboard
3. 如需显示可用的帮助选项，可运行以下命令：

        gst-camera-rotate-downscale-file.py -hCopy to clipboard

## 预期输出

输出保存到位于 /etc/media/test.mp4的文件中。

## Pipeline 流

下表列出了用于运行转换 pipeline 的插件：| 插件 | 说明 |
| --- | --- |
| [qtiqmmfsrc](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtiqmmfsrc.html) | 采集视频流。 |
| [qtivtransform](https://docs.qualcomm.com/doc/80-70022-50SC/topic/qtivtransform.html) | 转换视频流。 |
| [v4l2h264enc](https://docs.qualcomm.com/doc/80-70022-50SC/topic/v4l2h264enc.html) | 编码 H.264 视频。 |
| h264parse | 渲染编码的 H.264 视频流。 |
| mp4mux | 将流多路传输至 MP4 容器中。 |
| filesink | 将视频数据写入文件。 |

## 相关信息

[视频转换](https://docs.qualcomm.com/doc/80-70022-50SC/topic/gst-transform-example.html)

**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/camera-ai-detection-overlay-composer-display.md) [Next Topic
摄像头编码、目标检测和显示](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/camera-encode-file-detection-yolov8-overlay-display.md)