mirror of
https://github.com/jaywcjlove/reference.git
synced 2025-06-19 21:51:20 +08:00
doc: update ffmpeg.md
(#18). 75a0acfc5d
This commit is contained in:
@ -41,7 +41,7 @@
|
||||
<p>本备忘清单是 <a href="https://ffmpeg.org/">FFmpeg</a> 中常见视频处理操作的备忘清单</p>
|
||||
</div></header><div class="menu-tocs"><div class="menu-btn"><svg aria-hidden="true" fill="currentColor" height="1em" width="1em" viewBox="0 0 16 16" version="1.1" data-view-component="true">
|
||||
<path fill-rule="evenodd" d="M2 4a1 1 0 100-2 1 1 0 000 2zm3.75-1.5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zm0 5a.75.75 0 000 1.5h8.5a.75.75 0 000-1.5h-8.5zM3 8a1 1 0 11-2 0 1 1 0 012 0zm-1 6a1 1 0 100-2 1 1 0 000 2z"></path>
|
||||
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" href="#参数参考">参数参考</a><a aria-hidden="true" class="leve3 tocs-link" href="#常用开关">常用开关</a><a aria-hidden="true" class="leve3 tocs-link" href="#音频">音频</a><a aria-hidden="true" class="leve3 tocs-link" href="#比特率">比特率</a><a aria-hidden="true" class="leve4 tocs-link" href="#视频">视频</a><a aria-hidden="true" class="leve2 tocs-link" href="#视频编辑">视频编辑</a><a aria-hidden="true" class="leve3 tocs-link" href="#裁剪">裁剪</a><a aria-hidden="true" class="leve3 tocs-link" href="#缩放">缩放</a><a aria-hidden="true" class="leve3 tocs-link" href="#视频帧速率">视频帧速率</a><a aria-hidden="true" class="leve3 tocs-link" href="#剪切视频部分">剪切视频部分</a><a aria-hidden="true" class="leve3 tocs-link" href="#h265-2-pass-编码">H265 2-pass 编码</a><a aria-hidden="true" class="leve3 tocs-link" href="#视频比特率设置">视频比特率设置</a><a aria-hidden="true" class="leve3 tocs-link" href="#固定旋转">固定旋转</a><a aria-hidden="true" class="leve3 tocs-link" href="#放慢视频速度">放慢视频速度</a><a aria-hidden="true" class="leve3 tocs-link" href="#缩放到特定宽度">缩放到特定宽度</a><a aria-hidden="true" class="leve2 tocs-link" href="#重新包装">重新包装</a><a aria-hidden="true" class="leve3 tocs-link" href="#提取音频流">提取音频流</a><a aria-hidden="true" class="leve3 tocs-link" href="#创建缩略图">创建缩略图</a><a aria-hidden="true" class="leve3 tocs-link" href="#处理-id3-标签">处理 id3 标签</a><a aria-hidden="true" class="leve3 tocs-link" href="#重新采样转换音频">重新采样/转换音频</a><a aria-hidden="true" class="leve3 tocs-link" href="#切换容器转换类型">切换容器(转换类型)</a><a aria-hidden="true" class="leve3 tocs-link" href="#音视频同步">音视频同步</a><a aria-hidden="true" class="leve3 tocs-link" href="#图片中的视频">图片中的视频</a><a aria-hidden="true" class="leve3 tocs-link" href="#将视频拆分为图像">将视频拆分为图像</a><a aria-hidden="true" class="leve3 tocs-link" href="#转换为-gif">转换为 Gif</a><a aria-hidden="true" class="leve2 tocs-link" href="#另见">另见</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="参数参考"><a aria-hidden="true" tabindex="-1" href="#参数参考"><span class="icon icon-link"></span></a>参数参考</h2><div class="wrap-body">
|
||||
</svg></div><div class="menu-modal"><a aria-hidden="true" class="leve2 tocs-link" href="#参数参考">参数参考</a><a aria-hidden="true" class="leve3 tocs-link" href="#常用开关">常用开关</a><a aria-hidden="true" class="leve3 tocs-link" href="#音频">音频</a><a aria-hidden="true" class="leve3 tocs-link" href="#比特率">比特率</a><a aria-hidden="true" class="leve4 tocs-link" href="#视频">视频</a><a aria-hidden="true" class="leve2 tocs-link" href="#视频编辑">视频编辑</a><a aria-hidden="true" class="leve3 tocs-link" href="#裁剪">裁剪</a><a aria-hidden="true" class="leve3 tocs-link" href="#缩放">缩放</a><a aria-hidden="true" class="leve3 tocs-link" href="#视频帧速率">视频帧速率</a><a aria-hidden="true" class="leve3 tocs-link" href="#剪切视频部分">剪切视频部分</a><a aria-hidden="true" class="leve3 tocs-link" href="#h265-2-pass-编码">H265 2-pass 编码</a><a aria-hidden="true" class="leve3 tocs-link" href="#视频比特率设置">视频比特率设置</a><a aria-hidden="true" class="leve3 tocs-link" href="#固定旋转">固定旋转</a><a aria-hidden="true" class="leve3 tocs-link" href="#放慢视频速度">放慢视频速度</a><a aria-hidden="true" class="leve3 tocs-link" href="#缩放到特定宽度">缩放到特定宽度</a><a aria-hidden="true" class="leve2 tocs-link" href="#重新包装">重新包装</a><a aria-hidden="true" class="leve3 tocs-link" href="#提取音频流">提取音频流</a><a aria-hidden="true" class="leve3 tocs-link" href="#创建缩略图">创建缩略图</a><a aria-hidden="true" class="leve3 tocs-link" href="#处理-id3-标签">处理 id3 标签</a><a aria-hidden="true" class="leve3 tocs-link" href="#重新采样转换音频">重新采样/转换音频</a><a aria-hidden="true" class="leve3 tocs-link" href="#切换容器转换类型">切换容器(转换类型)</a><a aria-hidden="true" class="leve3 tocs-link" href="#音视频同步">音视频同步</a><a aria-hidden="true" class="leve3 tocs-link" href="#图片中的视频">图片中的视频</a><a aria-hidden="true" class="leve3 tocs-link" href="#将视频拆分为图像">将视频拆分为图像</a><a aria-hidden="true" class="leve3 tocs-link" href="#转换为-gif">转换为 Gif</a><a aria-hidden="true" class="leve3 tocs-link" href="#移除音频">移除音频</a><a aria-hidden="true" class="leve3 tocs-link" href="#字幕">字幕</a><a aria-hidden="true" class="leve3 tocs-link" href="#音量">音量</a><a aria-hidden="true" class="leve2 tocs-link" href="#另见">另见</a></div></div><div class="h1wrap-body"><div class="wrap h2body-exist"><div class="wrap-header h2wrap"><h2 id="参数参考"><a aria-hidden="true" tabindex="-1" href="#参数参考"><span class="icon icon-link"></span></a>参数参考</h2><div class="wrap-body">
|
||||
</div></div><div class="h2wrap-body"><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="常用开关"><a aria-hidden="true" tabindex="-1" href="#常用开关"><span class="icon icon-link"></span></a>常用开关</h3><div class="wrap-body">
|
||||
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line"><span class="token parameter variable">-codecs</span> <span class="token comment"># 列出编解码器</span>
|
||||
</span><span class="code-line"><span class="token parameter variable">-c:v</span> <span class="token comment"># 视频编解码器(-vcodec)-'copy'复制流</span>
|
||||
@ -187,19 +187,45 @@
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="将视频拆分为图像"><a aria-hidden="true" tabindex="-1" href="#将视频拆分为图像"><span class="icon icon-link"></span></a>将视频拆分为图像</h3><div class="wrap-body">
|
||||
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">$ ffmpeg <span class="token parameter variable">-i</span> video.mp4 image%d.jpg
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap h3body-not-exist col-span-3"><div class="wrap-header h3wrap"><h3 id="转换为-gif"><a aria-hidden="true" tabindex="-1" href="#转换为-gif"><span class="icon icon-link"></span></a>转换为 Gif</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-3-->
|
||||
<pre class="wrap-text "><code class="language-bash code-highlight"><span class="code-line">$ ffmpeg <span class="token parameter variable">-ss</span> <span class="token number">2</span> <span class="token parameter variable">-t</span> <span class="token number">28</span> <span class="token parameter variable">-i</span> input.mp4 <span class="token punctuation">\</span>
|
||||
</span><span class="code-line"> <span class="token parameter variable">-vf</span> <span class="token string">"fps=10,scale=1080:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse"</span> <span class="token punctuation">\</span>
|
||||
</span><span class="code-line"> <span class="token parameter variable">-loop</span> <span class="token number">0</span> output.gif
|
||||
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="转换为-gif"><a aria-hidden="true" tabindex="-1" href="#转换为-gif"><span class="icon icon-link"></span></a>转换为 Gif</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<pre class="wrap-text "><code class="language-bash code-highlight"><span class="code-line">$ ffmpeg <span class="token parameter variable">-ss</span> <span class="token number">2</span> <span class="token parameter variable">-t</span> <span class="token number">28</span> <span class="token parameter variable">-i</span> input.mp4 <span class="token parameter variable">-vf</span> <span class="token string">"fps=10,scale=1080:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse"</span> <span class="token parameter variable">-loop</span> <span class="token number">0</span> output.gif
|
||||
</span></code></pre>
|
||||
<!--rehype:className=wrap-text -->
|
||||
<p>有关更多信息,请参阅 <a href="https://superuser.com/a/556031">StackOverflow 问题</a></p>
|
||||
<p>上面有关更多信息,请参阅 <a href="https://superuser.com/a/556031">StackOverflow 问题</a></p>
|
||||
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line"><span class="token comment"># 转换为 GIF</span>
|
||||
</span><span class="code-line">$ ffmpeg <span class="token parameter variable">-i</span> input.mov output.gif
|
||||
</span><span class="code-line"><span class="token comment"># 从 GIF 转换</span>
|
||||
</span><span class="code-line">$ ffmpeg <span class="token parameter variable">-i</span> input.gif output.mov
|
||||
</span><span class="code-line"><span class="token comment"># 在非 GIF 格式之间转换</span>
|
||||
</span><span class="code-line">$ ffmpeg <span class="token parameter variable">-i</span> input.mov <span class="token parameter variable">-codec:v</span> copy <span class="token parameter variable">-codec:a</span> copy output.mp4
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap h3body-not-exist"><div class="wrap-header h3wrap"><h3 id="移除音频"><a aria-hidden="true" tabindex="-1" href="#移除音频"><span class="icon icon-link"></span></a>移除音频</h3><div class="wrap-body">
|
||||
<pre class="wrap-text "><code class="language-bash code-highlight"><span class="code-line">$ ffmpeg <span class="token parameter variable">-i</span> input.mov <span class="token parameter variable">-codec:v</span> copy <span class="token parameter variable">-an</span> output.mov
|
||||
</span></code></pre>
|
||||
<!--rehype:className=wrap-text -->
|
||||
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="字幕"><a aria-hidden="true" tabindex="-1" href="#字幕"><span class="icon icon-link"></span></a>字幕</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<p>将字幕写入视频</p>
|
||||
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">$ ffmpeg <span class="token parameter variable">-i</span> input.mov <span class="token parameter variable">-filter:v</span> <span class="token string">'subtitles=subtitles.srt'</span> <span class="token parameter variable">-codec:a</span> copy output.mov
|
||||
</span></code></pre>
|
||||
<p>将字幕写入视频,具有自定义字幕样式</p>
|
||||
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">$ ffmpeg <span class="token parameter variable">-i</span> input.mov <span class="token parameter variable">-filter:v</span> <span class="token string">"subtitles=subtitles.srt:force_style='FontName=Menlo Bold,Fontsize=18'"</span> <span class="token parameter variable">-codec:a</span> copy output.mov
|
||||
</span></code></pre>
|
||||
</div></div></div><div class="wrap h3body-not-exist col-span-2"><div class="wrap-header h3wrap"><h3 id="音量"><a aria-hidden="true" tabindex="-1" href="#音量"><span class="icon icon-link"></span></a>音量</h3><div class="wrap-body">
|
||||
<!--rehype:wrap-class=col-span-2-->
|
||||
<p>将音量减半</p>
|
||||
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">$ ffmpeg <span class="token parameter variable">-i</span> input.mov <span class="token parameter variable">-codec:v</span> copy <span class="token parameter variable">-filter:a</span> <span class="token string">'volume=0.5'</span> output.mov
|
||||
</span></code></pre>
|
||||
<p>音量加倍</p>
|
||||
<pre class="language-bash"><code class="language-bash code-highlight"><span class="code-line">$ ffmpeg <span class="token parameter variable">-i</span> input.mov <span class="token parameter variable">-codec:v</span> copy <span class="token parameter variable">-filter:a</span> <span class="token string">'volume=2'</span> output.mov
|
||||
</span></code></pre>
|
||||
</div></div></div></div></div><div class="wrap h2body-not-exist"><div class="wrap-header h2wrap"><h2 id="另见"><a aria-hidden="true" tabindex="-1" href="#另见"><span class="icon icon-link"></span></a>另见</h2><div class="wrap-body">
|
||||
<ul>
|
||||
<li><a href="https://ffmpeg.org/">FFmpeg 官网地址</a> <em>(ffmpeg.org)</em></li>
|
||||
<li><a href="https://lzone.de/cheat-sheet/ffmpeg">FFmpeg Cheat Sheet</a> <em>(lzone.de)</em></li>
|
||||
<li><a href="https://devhints.io/ffmpeg">FFmpeg Cheat Sheet</a> <em>(devhints.io)</em></li>
|
||||
<li><a href="https://github.com/yuanqing/ffmpeg-cheatsheet">FFmpeg Cheat Sheet</a> <em>(github.com)</em></li>
|
||||
</ul>
|
||||
</div></div></div></div></div><footer class="footer-wrap"><footer class="max-container">© 2022 Kenny Wang, All rights reserved.</footer></footer><script>
|
||||
if(('onhashchange' in window) && ((typeof document.documentMode==='undefined') || document.documentMode==8)) {
|
||||
|
Reference in New Issue
Block a user