How to ffmpeg

Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.

Last updated: April 4, 2026

Quick Answer: FFmpeg is a powerful, open-source command-line tool used for handling multimedia files. You can use it to convert video and audio formats, resize media, extract audio, create GIFs, and much more, all by typing specific commands into your terminal.

Key Facts

What is FFmpeg?

FFmpeg is a free and open-source software project consisting of a vast suite of libraries and programs for handling video, audio, and other multimedia files and streams. It is widely used for converting, recording, and streaming digital multimedia. The core of FFmpeg is its command-line tool, also named ffmpeg, which is exceptionally versatile and can perform a multitude of tasks related to media manipulation.

Why Use FFmpeg?

The primary advantage of FFmpeg lies in its flexibility and power. While graphical user interfaces (GUIs) for video editing and conversion exist, they often have limitations or can be costly. FFmpeg, being a command-line tool, offers unparalleled control over the encoding and decoding process. This makes it indispensable for developers, system administrators, and power users who need to automate media tasks, batch process files, or achieve specific encoding parameters not easily accessible through GUI applications.

Common FFmpeg Commands and Use Cases

FFmpeg's syntax generally follows the pattern: ffmpeg [global_options] [input_file_options] -i input_file [output_file_options] output_file.

1. Converting Video Formats

One of the most common uses is converting a video file from one format to another. For example, to convert an MP4 file to AVI:

ffmpeg -i input.mp4 output.avi

FFmpeg automatically detects the input format and chooses appropriate codecs for the output, but you can also specify them:

ffmpeg -i input.mp4 -c:v libx264 -c:a aac output.mp4

Here, -c:v libx264 specifies the H.264 video codec, and -c:a aac specifies the AAC audio codec.

2. Converting Audio Formats

Similarly, you can convert audio files. To convert a WAV file to MP3:

ffmpeg -i input.wav output.mp3

To control the audio quality (bitrate), you can use the -b:a option:

ffmpeg -i input.wav -b:a 192k output.mp3

3. Resizing Videos

You can change the resolution of a video using the -vf scale (video filter scale) option:

ffmpeg -i input.mp4 -vf scale=640:360 output.mp4

To maintain the aspect ratio while resizing, you can specify one dimension and use -1 for the other:

ffmpeg -i input.mp4 -vf scale=640:-1 output.mp4

4. Extracting Audio from Video

To get just the audio track from a video file, you can specify no video output (-vn) and an audio codec:

ffmpeg -i input.mp4 -vn -acodec copy output.aac

Using -acodec copy (or -c:a copy) avoids re-encoding the audio, making it faster and preserving quality.

5. Creating GIFs from Videos

FFmpeg can generate animated GIFs from video clips. This often involves resizing and setting a frame rate:

ffmpeg -i input.mp4 -vf "fps=10,scale=320:-1:flags=lanczos,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" output.gif

This command is more complex, involving filters for frame rate (fps), scaling (scale), and color palette generation (palettegen and paletteuse) for better GIF quality.

6. Trimming Video/Audio

To cut a specific segment from a media file, you can use the -ss (start time) and -to (end time) or -t (duration) options:

ffmpeg -i input.mp4 -ss 00:00:10 -to 00:00:25 -c copy output_trimmed.mp4

-c copy is used here to avoid re-encoding, which is faster and lossless for trimming.

7. Muting Audio

To remove the audio track from a video:

ffmpeg -i input.mp4 -c copy -an output_no_audio.mp4

The -an option disables audio recording/output.

8. Changing Video Speed

You can alter the playback speed using the setpts (set presentation timestamp) filter:

ffmpeg -i input.mp4 -vf "setpts=0.5*PTS" output_faster.mp4

Multiplying PTS by 0.5 makes the video play twice as fast. For slower playback, use a value greater than 1.

Installation

FFmpeg is available for Windows, macOS, and Linux. Installation typically involves downloading the binaries from the official FFmpeg website or using a package manager (like Homebrew on macOS, apt/yum on Linux). Once installed, you can access the ffmpeg command from your terminal or command prompt.

Important Considerations

FFmpeg's power comes with a learning curve. The command-line interface requires understanding syntax and options. Always consult the official FFmpeg documentation for the most accurate and detailed information, as options and syntax can vary slightly between versions and specific use cases.

Sources

  1. FFmpeg DocumentationCC-BY-SA-4.0
  2. FFmpeg - WikipediaCC-BY-SA-3.0
  3. How to Use FFmpeg to Convert Videos and Audio on the Command Linefair-use

Missing an answer?

Suggest a question and we'll generate an answer for it.