Difference between revisions of "FFmpeg"

From TSG Doc
Jump to navigation Jump to search
(Created page with "{{Infobox software | name = FFmpeg | logo = Ffmpeg_logo.jpg | screenshot = | caption = | discontinued...")
 
Line 50: Line 50:
  
 
<code>-af "pan=mono|c0=c0"</code> extracts a single channel from the file. Use <code>c0=c0</code> for left channel, <code>c0=c1</code> for right channel.
 
<code>-af "pan=mono|c0=c0"</code> extracts a single channel from the file. Use <code>c0=c0</code> for left channel, <code>c0=c1</code> for right channel.
 +
 +
===Add audio to video===
 +
{{cmdline|ffmpeg -i inputvideo.mp4 -i inputaudio.wav -vcodec copy  -map 0:v -map 1:a output.mp4}}

Revision as of 15:36, 7 March 2024

FFmpeg
Ffmpeg logo.jpg
Installed version6.1.1
Development statusActive
Operating systemMicrosoft Windows, Linux, MacOSX
LicenseGNU LGPL 2.1
Websiteffmpeg.org

FFmpeg is an open-source command-line tool to convert audio and video files.


Installation

Windows 10

  1. Download the latest ffmpeg-release-full build on https://ffmpeg.org/download.html
  2. Unpack the 7z/zip file anywhere you like
  3. Add ffmpeg to Windows' Environment Variables:
    1. Open the start menu and start typing "Environment Variables"
    2. Select "Edit the system environment variables"
    3. Click "Environment Variables"
    4. Select "Path" and click "Edit"
    5. Click "Browse" and go to the folder where you unpacked your FFmpeg files. Select the 'bin' folder inside (e.g. "C:\ffmpeg\bin")
    6. Click OK on all previously opened windows.
  4. To test, go to the command line (Windows+R -> cmd) and type ffmpeg. It should tell you the installed ffmpeg version.

Usage

FFmpeg needs to be run from the command line, but you can create batch scripts to automate the process for multiple files. You can also set up FFmpeg for Python: https://www.bannerbear.com/blog/how-to-use-ffmpeg-in-python-with-examples/ The following are examples of conversions that we commonly use.

Basic Format Conversion

ffmpeg -i input.mp4 output.avi

Remove audio from video file

ffmpeg -i input.mp4 -vcodec copy -an output.mp4

-vcodec copy means the video won't be re-encoded, preserving the quality.

-an strips the audio

Extract single audio channel from video file

ffmpeg -i input.mp4 -af "pan=mono|c0=c0" output.wav

-af "pan=mono|c0=c0" extracts a single channel from the file. Use c0=c0 for left channel, c0=c1 for right channel.

Add audio to video

ffmpeg -i inputvideo.mp4 -i inputaudio.wav -vcodec copy -map 0:v -map 1:a output.mp4