mirror of
https://github.com/foo-dogsquared/wiki.git
synced 2025-01-31 04:58:21 +00:00
41 lines
18 KiB
HTML
41 lines
18 KiB
HTML
|
<!DOCTYPE html><html><head><meta name="viewport" content="width=device-width"/><meta charSet="utf-8"/><title>Command line: FFmpeg</title><script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script><script id="MathJax-script" async="" src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script><script type="text/x-mathjax-config">
|
||
|
MathJax = {
|
||
|
tex: {
|
||
|
inlineMath: [ ['$','$'], ['\(','\)'] ],
|
||
|
displayMath: [ ['$$','$$'], ['[',']'] ]
|
||
|
},
|
||
|
options = {
|
||
|
processHtmlClass = "math"
|
||
|
}
|
||
|
}
|
||
|
</script><meta name="next-head-count" content="6"/><link rel="preload" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" as="style"/><link rel="stylesheet" href="/wiki/_next/static/css/52fc2ba29703df73922c.css" data-n-g=""/><noscript data-n-css=""></noscript><link rel="preload" href="/wiki/_next/static/chunks/main-ae4733327bd95c4ac325.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/webpack-50bee04d1dc61f8adf5b.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/framework.9d524150d48315f49e80.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/commons.0e1c3f9aa780c2dfe9f0.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/_app-8e3d0c58a60ec788aa69.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/940643274e605e7596ecea1f2ff8d83317a3fb76.4841a16762f602a59f00.js" as="script"/><link rel="preload" href="/wiki/_next/static/chunks/pages/%5B%5B...slug%5D%5D-1aa198f87ede1cd0e1dc.js" as="script"/></head><body><div id="__next"><main><h1>Command line: FFmpeg</h1><section class="post-metadata"><span>Date: <!-- -->2021-05-09 16:40:50 +08:00</span><span>Date modified: <!-- -->2021-07-20 23:30:49 +08:00</span></section><nav class="toc"><ol class="toc-level toc-level-1"><li class="toc-item toc-item-h1"><a href="/wiki/cli.ffmpeg#options" class="toc-link toc-link-h1">Options</a></li><li class="toc-item toc-item-h1"><a href="/wiki/cli.ffmpeg#examples" class="toc-link toc-link-h1">Examples</a><ol class="toc-level toc-level-2"><li class="toc-item toc-item-h2"><a href="/wiki/cli.ffmpeg#convert-an-mp3-to-ogg" class="toc-link toc-link-h2">Convert an MP3 to OGG</a></li><li class="toc-item toc-item-h2"><a href="/wiki/cli.ffmpeg#transrate-an-audio-file" class="toc-link toc-link-h2">Transrate an audio file</a></li><li class="toc-item toc-item-h2"><a href="/wiki/cli.ffmpeg#list-all-available-options" class="toc-link toc-link-h2">List all available options</a></li><li class="toc-item toc-item-h2"><a href="/wiki/cli.ffmpeg#capture-video-device" class="toc-link toc-link-h2">Capture video device</a></li><li class="toc-item toc-item-h2"><a href="/wiki/cli.ffmpeg#extract-a-segment-from-a-file" class="toc-link toc-link-h2">Extract a segment from a file</a></li></ol></li></ol></nav><p>The swiss army knife for interacting with multimedia files (except images because ImageMagick).
|
||
|
</p><h1 id="options">Options</h1><p>The FFmpeg command line interface is mostly picky because of order.
|
||
|
Whatever options are given will be processed with those options in order.
|
||
|
</p><ul><li><p><code class="inline-verbatim">-hide_banner</code> - hide the annoying banner
|
||
|
</p></li><li><p><code class="inline-verbatim">-loglevel [level] | -v [level]</code> - set the verbosity level
|
||
|
</p></li><li><p><code class="inline-verbatim">-codecs</code> - list all codecs
|
||
|
</p></li><li><p><code class="inline-verbatim">-devices</code> - list all devices
|
||
|
</p></li><li><p><code class="inline-verbatim">-i [file]</code> - the input file
|
||
|
</p></li><li><p><code class="inline-verbatim">c [codec]</code> - set the codec
|
||
|
</p></li><li><p><code class="inline-verbatim">-b [rate]</code> - set the bitrate
|
||
|
</p></li><li><p><code class="inline-verbatim">-o [file]</code> - set the output
|
||
|
</p></li></ul><p>Certain options have the option of specifying whether you're interacting with the audio or video track.
|
||
|
For example, <code class="inline-verbatim">-codec:audio</code> (<code class="inline-verbatim">-c:a</code>) to set the audio codec.
|
||
|
</p><h1 id="examples">Examples</h1><p>FFmpeg is comprehensive and so needs some specific examples to fill my monkey brain.
|
||
|
</p><h2 id="convert-an-mp3-to-ogg">Convert an MP3 to OGG</h2><pre class="src-block"><code class="language-shell">ffmpeg -i $INPUT.mp3 -o $OUTPUT.ogg
|
||
|
</code></pre><p>By default, FFmpeg will guess if certain things are missing.
|
||
|
In this case, it guessed the input file is an MP3 and wants to convert OGG.
|
||
|
Sometimes, it will also use default options for converting between two formats such as the default bitrate and codec.
|
||
|
</p><h2 id="transrate-an-audio-file">Transrate an audio file</h2><pre class="src-block"><code class="language-shell">ffmpeg -i $INPUT -c $CODE -b:a $BITRATE $OUTPUT
|
||
|
</code></pre><h2 id="list-all-available-options">List all available options</h2><p>FFmpeg has compile options, heaps of them.
|
||
|
You may want to know what codecs are available.
|
||
|
</p><pre class="src-block"><code class="language-shell">ffmpeg -codecs
|
||
|
</code></pre><p>It tends to be a large list so prepare to send it through a pager.
|
||
|
</p><p>You should also know FFmpeg can print out devices.
|
||
|
</p><pre class="src-block"><code class="language-shell">ffmpeg -devices
|
||
|
</code></pre><h2 id="capture-video-device">Capture video device</h2><pre class="src-block"><code class="language-shell"># Assuming /dev/video0 is your webcam.
|
||
|
ffmpeg -f video4linux2 -i /dev/video0 cringe-at-yourself.mpg
|
||
|
</code></pre><h2 id="extract-a-segment-from-a-file">Extract a segment from a file</h2><p>The timestamps are essentially seeking to a file.
|
||
|
For more information, see <a href="https://trac.ffmpeg.org/wiki/Seeking">FFmpeg documentation</a>.
|
||
|
</p><pre class="src-block"><code class="language-shell">ffmpeg -nostdin -i $INPUT -ss 00:05:22 -to 00:22:43 $OUTPUT
|
||
|
</code></pre></main></div><script id="__NEXT_DATA__" type="application/json">{"props":{"pageProps":{"metadata":{"date":"\"2021-05-09 16:40:50 +08:00\"","date_modified":"\"2021-07-20 23:30:49 +08:00\"","language":"en","source":""},"title":"Command line: FFmpeg","hast":{"type":"root","children":[{"type":"element","tagName":"nav","properties":{"className":"toc"},"children":[{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-1"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"options"},"children":[{"type":"text","value":"Options"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/cli.ffmpeg#options"},"children":[{"type":"text","value":"Options"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h1","properties":{"id":"examples"},"children":[{"type":"text","value":"Examples"}]}]},"properties":{"className":"toc-item toc-item-h1"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h1","href":"/cli.ffmpeg#examples"},"children":[{"type":"text","value":"Examples"}]},{"type":"element","tagName":"ol","properties":{"className":"toc-level toc-level-2"},"children":[{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"convert-an-mp3-to-ogg"},"children":[{"type":"text","value":"Convert an MP3 to OGG"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.ffmpeg#convert-an-mp3-to-ogg"},"children":[{"type":"text","value":"Convert an MP3 to OGG"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"transrate-an-audio-file"},"children":[{"type":"text","value":"Transrate an audio file"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.ffmpeg#transrate-an-audio-file"},"children":[{"type":"text","value":"Transrate an audio file"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"list-all-available-options"},"children":[{"type":"text","value":"List all available options"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.ffmpeg#list-all-available-options"},"children":[{"type":"text","value":"List all available options"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"capture-video-device"},"children":[{"type":"text","value":"Capture video device"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.ffmpeg#capture-video-device"},"children":[{"type":"text","value":"Capture video device"}]}]},{"type":"element","tagName":"li","data":{"hookArgs":[{"type":"element","tagName":"h2","properties":{"id":"extract-a-segment-from-a-file"},"children":[{"type":"text","value":"Extract a segment from a file"}]}]},"properties":{"className":"toc-item toc-item-h2"},"children":[{"type":"element","tagName":"a","properties":{"className":"toc-link toc-link-h2","href":"/cli.ffmpeg#extract-a-segment-from-a-file"},"children":[{"type":"text","value":"Extract a segment from a file"}]}]}]}]}]}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The swiss army knife for interacting with multimedia files (except images because ImageMagick).\n"}]},{"type":"element","tagName":"h1","properties":{"id":"options"},"children":[{"type":"text","value":"Options"}]},{"type":"element","tagName":"p","properties":{},"children":[{"type":"text","value":"The FFmpeg command line interface is mostly picky because of order.\nWhatever o
|