# 视频转码

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

**gst-video-transcode-example** 应用程序支持 AVC 到 HEVC 或 HEVC 到 AVC 格式的视频转码。其中一些用例是视频编辑、安全摄像头和增强现实。

下图展示了一个 pipeline，其读取输入流，对其进行解码和编码，并在屏幕上显示转码后的输出，或保存到文件中。有关该 pipeline 中使用的插件的信息，请参见 [Pipeline 流](https://docs.qualcomm.com/doc/80-70022-50SC/topic/gst-video-transcode-example.html#gst-video-transcode-example__section_rdl_ysg_4bc)。

Figure : gst-video-transcode-example 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 gst_video_transcode_example.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.9375in" height="1.45833in" viewbox="0 0 787.5 105" xml:space="preserve" color-interpolation-filters="sRGB" class="st10"><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: #007884; stroke: none; stroke-linecap: butt; stroke-width: 0.75 }
.svg-1 .st4 { fill: #ffffff; font-family: Roboto; font-size: 1.00001em }
.svg-1 .st5 { font-size: 1em }
.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: SimHei; font-size: 0.874992em }
.svg-1 .st10 { 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.375,-0.375092)">		<title>Sheet.2</title>		<path d="M0 99.37 A5.62513 5.62513 -180 0 0 5.62 105 L781.13 105 A5.62513 5.62513 -180 0 0 786.75 99.37 L786.75 6.38					 A5.62513 5.62513 -180 0 0 781.13 0.75 L5.62 0.75 A5.62513 5.62513 -180 0 0 -0 6.38 L0 99.37 Z" class="st1"></path>	</g>	<g id="shape3-3" v:mid="3" v:groupcontext="shape">		<title>Sheet.3</title>		<path d="M781.5 0.75 C784.39 0.75 786.75 3.11 786.75 6 L786.75 99 C786.75 101.89 784.39 104.25 781.5 104.25 L6 104.25					 C3.11 104.25 0.75 101.89 0.75 99 L0.75 6 C0.75 3.11 3.11 0.75 6 0.75 L781.5 0.75 ZM781.5 0 L6 0 C2.69 0					 0 2.69 0 6 L0 99 C0 102.31 2.69 105 6 105 L781.5 105 C784.81 105 787.5 102.31 787.5 99 L787.5 6 C787.5 2.69					 784.81 0 781.5 0 Z" class="st2"></path>	</g>	<g id="shape6-5" v:mid="6" v:groupcontext="shape" transform="translate(11.25,-44.6969)">		<title>Sheet.6</title>		<desc>filesrc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="37.5" cy="83.75" width="75" height="42.5"></v:textrect>		<path d="M0 102 A3.00007 3.00007 -180 0 0 3 105 L72 105 A3.00007 3.00007 -180 0 0 75 102 L75 65.5 A3.00007 3.00007 -180					 0 0 72 62.5 L3 62.5 A3.00007 3.00007 -180 0 0 0 65.5 L0 102 Z" class="st3"></path>		<text x="21.06" y="87.35" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>filesrc</text>		</g>	<g id="shape8-8" v:mid="8" v:groupcontext="shape" transform="translate(191.25,-44.6969)">		<title>Sheet.8</title>		<desc>h264parse/h265parse</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="83.75" width="90.01" height="42.5"></v:textrect>		<path d="M0 102 A3.00007 3.00007 -180 0 0 3 105 L87 105 A3.00007 3.00007 -180 0 0 90 102 L90 65.5 A3.00007 3.00007 -180					 0 0 87 62.5 L3 62.5 A3.00007 3.00007 -180 0 0 -0 65.5 L0 102 Z" class="st3"></path>		<text x="14.18" y="80.15" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>h264parse/<tspan x="16.65" dy="1.2em" class="st5">h265parse</tspan></text>		</g>	<g id="shape9-12" v:mid="9" v:groupcontext="shape" transform="translate(101.25,-44.6969)">		<title>Sheet.9</title>		<desc>qtdemux</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="37.5" cy="83.75" width="75" height="42.5"></v:textrect>		<path d="M0 102 A3.00007 3.00007 -180 0 0 3 105 L72 105 A3.00007 3.00007 -180 0 0 75 102 L75 65.5 A3.00007 3.00007 -180					 0 0 72 62.5 L3 62.5 A3.00007 3.00007 -180 0 0 -0 65.5 L0 102 Z" class="st3"></path>		<text x="14.03" y="87.35" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>qtdemux</text>		</g>	<g id="group10-15" transform="translate(176.25,-63.3291)" v:mid="10" v:groupcontext="group">		<title>Sheet.10</title>		<g id="shape11-16" v:mid="11" v:groupcontext="shape" transform="translate(0,-2.61782)">			<title>Sheet.11</title>			<path d="M0 105 L11.23 105" class="st6"></path>		</g>		<g id="shape12-19" v:mid="12" v:groupcontext="shape" transform="translate(10.4665,-2.84217E-14)">			<title>Sheet.12</title>			<path d="M0 105 L4.53 102.38 L0 99.76 L0 105 Z" class="st7"></path>		</g>	</g>	<g id="group13-21" transform="translate(86.25,-63.3291)" v:mid="13" v:groupcontext="group">		<title>Sheet.13</title>		<g id="shape14-22" v:mid="14" v:groupcontext="shape" transform="translate(0,-2.61782)">			<title>Sheet.14</title>			<path d="M0 105 L11.23 105" class="st6"></path>		</g>		<g id="shape15-25" v:mid="15" v:groupcontext="shape" transform="translate(10.4665,-2.84217E-14)">			<title>Sheet.15</title>			<path d="M0 105 L4.53 102.38 L0 99.76 L0 105 Z" class="st7"></path>		</g>	</g>	<g id="group17-27" transform="translate(281.25,-63.3291)" v:mid="17" v:groupcontext="group">		<title>Sheet.17</title>		<g id="shape18-28" v:mid="18" v:groupcontext="shape" transform="translate(0,-2.61782)">			<title>Sheet.18</title>			<path d="M0 105 L11.23 105" class="st6"></path>		</g>		<g id="shape19-31" v:mid="19" v:groupcontext="shape" transform="translate(10.4665,-2.84217E-14)">			<title>Sheet.19</title>			<path d="M0 105 L4.53 102.38 L0 99.76 L0 105 Z" class="st7"></path>		</g>	</g>	<g id="shape21-33" v:mid="21" v:groupcontext="shape" transform="translate(296.25,-44.6969)">		<title>Sheet.21</title>		<desc>vl2h264dec/v4l2h65dec</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="83.75" width="90" height="42.5"></v:textrect>		<path d="M0 102 A3.00007 3.00007 -180 0 0 3 105 L87 105 A3.00007 3.00007 -180 0 0 90 102 L90 65.5 A3.00007 3.00007 -180					 0 0 87 62.5 L3 62.5 A3.00007 3.00007 -180 0 0 -0 65.5 L0 102 Z" class="st3"></path>		<text x="11.68" y="80.15" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>vl2h264dec/<tspan x="14.15" dy="1.2em" class="st5">v4l2h65dec</tspan></text>		</g>	<g id="group23-37" transform="translate(386.25,-63.3291)" v:mid="23" v:groupcontext="group">		<title>Sheet.23</title>		<g id="shape24-38" v:mid="24" v:groupcontext="shape" transform="translate(0,-2.61782)">			<title>Sheet.24</title>			<path d="M0 105 L11.23 105" class="st6"></path>		</g>		<g id="shape25-41" v:mid="25" v:groupcontext="shape" transform="translate(10.4665,-2.84217E-14)">			<title>Sheet.25</title>			<path d="M0 105 L4.53 102.38 L0 99.76 L0 105 Z" class="st7"></path>		</g>	</g>	<g id="group26-43" transform="translate(491.25,-63.3291)" v:mid="26" v:groupcontext="group">		<title>Sheet.26</title>		<g id="shape27-44" v:mid="27" v:groupcontext="shape" transform="translate(0,-2.61782)">			<title>Sheet.27</title>			<path d="M0 105 L11.23 105" class="st6"></path>		</g>		<g id="shape28-47" v:mid="28" v:groupcontext="shape" transform="translate(10.4665,-2.84217E-14)">			<title>Sheet.28</title>			<path d="M0 105 L4.53 102.38 L0 99.76 L0 105 Z" class="st7"></path>		</g>	</g>	<g id="group29-49" transform="translate(596.25,-63.3291)" v:mid="29" v:groupcontext="group">		<title>Sheet.29</title>		<g id="shape30-50" v:mid="30" v:groupcontext="shape" transform="translate(0,-2.61782)">			<title>Sheet.30</title>			<path d="M0 105 L11.23 105" class="st6"></path>		</g>		<g id="shape31-53" v:mid="31" v:groupcontext="shape" transform="translate(10.4665,-2.84217E-14)">			<title>Sheet.31</title>			<path d="M0 105 L4.53 102.38 L0 99.76 L0 105 Z" class="st7"></path>		</g>	</g>	<g id="group32-55" transform="translate(686.25,-63.3291)" v:mid="32" v:groupcontext="group">		<title>Sheet.32</title>		<g id="shape33-56" v:mid="33" v:groupcontext="shape" transform="translate(0,-2.61782)">			<title>Sheet.33</title>			<path d="M0 105 L11.23 105" class="st6"></path>		</g>		<g id="shape34-59" v:mid="34" v:groupcontext="shape" transform="translate(10.4665,-2.84217E-14)">			<title>Sheet.34</title>			<path d="M0 105 L4.53 102.38 L0 99.76 L0 105 Z" class="st7"></path>		</g>	</g>	<g id="shape36-61" v:mid="36" v:groupcontext="shape" transform="translate(401.25,-44.6969)">		<title>Sheet.36</title>		<desc>v4l2h265enc/v4l2h64enc</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="83.75" width="90.01" height="42.5"></v:textrect>		<path d="M0 102 A3.00007 3.00007 -180 0 0 3 105 L87 105 A3.00007 3.00007 -180 0 0 90 102 L90 65.5 A3.00007 3.00007 -180					 0 0 87 62.5 L3 62.5 A3.00007 3.00007 -180 0 0 -0 65.5 L0 102 Z" class="st3"></path>		<text x="8.38" y="80.15" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>v4l2h265enc/<tspan x="14.23" dy="1.2em" class="st5">v4l2h64enc</tspan></text>		</g>	<g id="shape38-65" v:mid="38" v:groupcontext="shape" transform="translate(506.25,-44.6969)">		<title>Sheet.38</title>		<desc>h265parse/h264parse</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="45" cy="83.75" width="90.01" height="42.5"></v:textrect>		<path d="M0 102 A3.00007 3.00007 -180 0 0 3 105 L87 105 A3.00007 3.00007 -180 0 0 90 102 L90 65.5 A3.00007 3.00007 -180					 0 0 87 62.5 L3 62.5 A3.00007 3.00007 -180 0 0 -0 65.5 L0 102 Z" class="st3"></path>		<text x="14.18" y="80.15" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>h265parse/<tspan x="16.65" dy="1.2em" class="st5">h264parse</tspan></text>		</g>	<g id="shape41-69" v:mid="41" v:groupcontext="shape" transform="translate(611.25,-44.6969)">		<title>Sheet.41</title>		<desc>mp4mux</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="37.5" cy="83.75" width="75.01" height="42.5"></v:textrect>		<path d="M-0 102 A3.00007 3.00007 -180 0 0 3 105 L72 105 A3.00007 3.00007 -180 0 0 75 102 L75 65.5 A3.00007 3.00007 -180					 0 0 72 62.5 L3 62.5 A3.00007 3.00007 -180 0 0 -0 65.5 L0 102 Z" class="st3"></path>		<text x="13.97" y="87.35" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>mp4mux</text>		</g>	<g id="shape43-72" v:mid="43" v:groupcontext="shape" transform="translate(701.25,-44.6969)">		<title>Sheet.43</title>		<desc>filesink</desc>		<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>		<v:textrect cx="37.5" cy="83.75" width="75" height="42.5"></v:textrect>		<path d="M-0 102 A3.00007 3.00007 -180 0 0 3 105 L72 105 A3.00007 3.00007 -180 0 0 75 102 L75 65.5 A3.00007 3.00007 -180					 0 0 72 62.5 L3 62.5 A3.00007 3.00007 -180 0 0 -0 65.5 L0 102 Z" class="st3"></path>		<text x="18.42" y="87.35" class="st4" v:langid="1033"><v:paragraph v:horizalign="1"></v:paragraph><v:tablist></v:tablist>filesink</text>		</g>	<g id="group49-75" transform="translate(740.062,-17.5844)" v:mid="49" v:groupcontext="group">		<title>Sheet.49</title>		<g id="shape47-76" v:mid="47" v:groupcontext="shape" transform="translate(15.1883,1.42109E-14)">			<title>Sheet.47</title>			<desc>开源</desc>			<v:textblock v:margins="rect(0,0,0,0)"></v:textblock>			<v:textrect cx="10.5" cy="98.7" width="21" height="12.6"></v:textrect>			<rect x="0" y="92.4" width="21" height="12.6" class="st8"></rect>			<text x="0" y="102.19" class="st9" v:langid="1033"><v:paragraph></v:paragraph><v:tablist></v:tablist>开源</text>			</g>		<g id="shape48-79" v:mid="48" v:groupcontext="shape" transform="translate(6.29496E-14,-0.218626)">			<title>Sheet.48</title>			<path d="M0 103.5 A1.50003 1.50003 -180 0 0 1.5 105 L10.5 105 A1.50003 1.50003 -180 0 0 12 103.5 L12 94.5 A1.50003						 1.50003 -180 0 0 10.5 93 L1.5 93 A1.50003 1.50003 -180 0 0 0 94.5 L0 103.5 Z" class="st3"></path>		</g>	</g></g>
</svg>

## 运行应用程序

下表列出了 gst-video-transcode-example 应用程序的常见用例及其可以执行的操作：| 用例 | 操作 |
| --- | --- |
| 视频编辑 | 旋转、翻转或调整视频大小 |
| 安全摄像头 | 对视频图像进行翻转或旋转，以弥补摄像头安装不当的情况。 |
| 增强现实 | 缩放或旋转视频源以与虚拟组件同步。 |

要运行转码用例，请执行以下操作：

1. 确保您已完成[前提条件](https://docs.qualcomm.com/doc/80-70022-50SC/topic/mm_sample_apps_prerequisites.html)。
2. 在目标设备上输入 `AVC.mp4` 和 `HEVC.mp4` 视频文件。
3. 在目标设备的终端中，对视频文件进行转码：

        gst-video-transcode-example -i /etc/media/<input-file>.mp4 -c <format> -o /etc/media/<output-file>.mp4    Copy to clipboard

下表提供了命令行参数的说明：    | 命令行参数 | 说明 |
    | --- | --- |
    | `-1` | 指定 MP4 输入文件的绝对路径 |
    | `-c` | 指定*输入*文件的视频 codec。<ul class="ul" id="gst-video-transcode-example__ul_wrj_d5g_4bc"><br>                                            <li class="li"><code class="ph codeph">1</code>= AVC (H.264)</li><br><br>                                            <li class="li"><code class="ph codeph">2</code>= HEVC (H.265)</li><br><br>                                        </ul> |
    | `-o` | 指定保存转码后的 MP4 文件的绝对路径。 |
4. 运行不同视频格式的用例：
    - 从 AVC 转码到 HEVC：

            gst-video-transcode-example -i /etc/media/<avc>.mp4 -c 1 -o /etc/media/<hevc>.mp4Copy to clipboard
    - 从 HEVC 转码到 AVC：

            gst-video-transcode-example -i /etc/media/<hevc>.mp4 -c 2 -o /etc/media/<avc>.mp4Copy to clipboard
5. 要停止用例，请使用 CTRL +
                    C。
6. 在目标设备的终端中，在 SSH shell 中运行以下命令以显示可用的帮助选项：

        gst-video-transcode-example --helpCopy to clipboard

## 预期输出

将视频流从 H.264 转码为 H.265，然后再转回 H.264 格式。

## Pipeline 流

下表列出了视频转码 pipeline 中使用的插件： | 插件 | 说明 |
| --- | --- |
| filesrc | 读取视频流。 |
| qtdemux | 将流解复用为单独的音频和视频流。 |
| h264parse | 渲染 H.264 视频流。 |
| h265parse | 渲染 H.265 视频流。 |
| [v4l2h264dec](https://docs.qualcomm.com/doc/80-70022-50SC/topic/v4l2h264dec.html) | 使用 Video4Linux 解码 H.264 视频流。 |
| [v4l2h265dec](https://docs.qualcomm.com/doc/80-70022-50SC/topic/v4l2h265dec.html) | 使用 Video4Linux 解码 H.265 视频流。 |
| [Waylandsink](https://docs.qualcomm.com/doc/80-70022-50SC/topic/waylandsink.html) | 在 Wayland 显示器上显示 H.264 视频流。 |
| filesink | 将 H.265 视频写入 YUV 文件进行播放。 |

下表提供了有关如何处理解码的视频流以生成转码输出的信息：| 视频格式 | 说明 |
| --- | --- |
| H.264 | <ol class="ol" id="gst-video-transcode-example__ol_nk2_bwh_4bc"><br>                                        <li class="li"><a href="https://docs.qualcomm.com/doc/80-70022-50SC/topic/v4l2h265enc.html">v4l2h265enc</a> 将解码后的 H.264 视频编码为 H.265 格式。</li><br><br>                                        <li class="li">h265parse 渲染 H.265 视频流。</li><br><br>                                        <li class="li">mp4mux 将流复用到 MP4 容器中。</li><br><br>                                        <li class="li">filesink 将流数据写入文件。</li><br><br>                                    </ol><br><br>                                    <br>AVC (H.264)视频转码为HEVC (H.265)格式。 |
| H.265 | <ol class="ol" id="gst-video-transcode-example__ol_zfg_fwh_4bc"><br>                                        <li class="li"><a href="https://docs.qualcomm.com/doc/80-70022-50SC/topic/v4l2h264enc.html">v4l2h264enc</a> 将解码的 H.265 视频编码为 H.264 格式。</li><br><br>                                        <li class="li">h264parse 渲染 H.264 视频流。</li><br><br>                                        <li class="li">mp4mux 将流复用到 MP4 容器中。</li><br><br>                                        <li class="li">filesink 将流数据写入文件。</li><br><br>                                    </ol><br><br>                                    <br>HEVC（H.265）视频转码为 AVC（H.264）格式。 |

## 相关信息

[转换和转码用例](https://docs.qualcomm.com/doc/80-70022-50SC/topic/transform-and-transcode-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-video-playback.md) [Next Topic
视频播放](https://docs.qualcomm.com/bundle/publicresource/80-70022-50SC/topics/gst-video-playback-example.md)