The way to Use FFmpeg Instructions for Audio and Video Processing on Linux

Virtually anybody who offers with movies could have heard of FFmpeg earlier than. For individuals who are unfamiliar, FFmpeg is a free and open-source program that may convert any video format to a different and alter its codecs.

FFmpeg helps almost all audio/video codecs (H.264, H.265, VP8, VP9, AAC, OPUS, and extra), file codecs (MP4, FLV, MKV, TS, WEBM, MP3, and so on.), and even streaming protocols (HTTP, RTMP, RTSP, HLS, and so on.).

This is how one can set up and use FFmpeg to course of audio and video information on Linux.

FFmpeg Set up on Linux

FFmpeg is a free and open-source software accessible within the default repositories of just about each main Linux distribution. You too can get its supply code at no cost in case you want to compile it your self.


sudo apt set up ffmpeg


sudo dnf set up https://download1.rpmfusion.org/free/fedora/rpmfusion-free-launch-$(rpm -E %fedora).noarch.rpm
sudo dnf -y set up ffmpeg


yum set up ffmpeg ffmpeg-devel


pacman -S ffmpeg

If every little thing goes properly throughout set up, it’s best to have the ability to see the FFmpeg model whenever you use the -version argument.

ffmpeg -version

Getting Video Data With FFmpeg

It’s doable to see the data of a video that you simply wish to edit with FFmpeg utilizing the -i flag:

ffmpeg -i example-video.mp4 -hide_banner

Right here, the -hide_banner parameter’s job is to cover pointless data. You’ll be able to take away this parameter and see the distinction within the output.

As you may see, it’s doable to get quite a lot of data resembling video codec sort, creation date, metadata, and encoder construction of the pattern video.

Changing Video or Audio Information to One other Format

Some of the helpful options of FFmpeg is that it may convert a video or audio to a different format. You are able to do this with easy one-liners.

MOV to MP4 With FFmpeg

You’ll be able to convert your MOV format video file to MP4 with FFmpeg utilizing the command under:

ffmpeg -i input-mov-video.mov output-video.mp4

First, use the -i parameter, which stands for enter video. Then, enter the file you wish to convert. Lastly, enter the format you wish to convert it to. You can provide your output any identify you need.

Whereas FFmpeg is operating, it’s going to present you the adjustments it has made on the command display screen. Your output file shall be saved in your current working listing.

WAV to MP3 With FFmpeg

Just like movies, you are able to do the identical conversions for audio information. For instance, you may convert a WAV audio file to MP3 as follows:

ffmpeg -i example-wav.wav -vn -ar 48000 -ac 2 -b:a 256 output.mp3

This command has extra parameters than the video conversion technique, however they aren’t obscure. To clarify these:

  • -vn: Typically the audio information you hearken to have photos. These pictures often originate from movies. If you don’t want such pictures within the output, you should use this parameter.
  • -ar: This parameter lets you set the audio frequency of the audio file you wish to convert. You’ll be able to regulate the sound high quality and frequency with values resembling 8kHz, 44.1kHz, or 48kHz.
  • -ac: You could have heard the phrases mono and stereo earlier than. This parameter can assist you set the variety of audio channels.
  • -b:a: This parameter lets you set the audio bitrate per second. The upper the kilobit, the upper the sound high quality.


Audio Operations With FFmpeg

FFmpeg may also separate audio from movies. For this, it’s enough to make use of the -vn parameter:

ffmpeg -i example-video.mp4 -vn output.mp3

In case you managed to separate the audio from the video, now you can attempt to take away the audio from the movies. The distinction right here is the -an parameter. You need to preserve this parameter in thoughts if you wish to disable any sound in a video:

ffmpeg -i example-video.mp4 -an output-mute.mp4

Video Dimension Processing With FFmpeg

Video sizes might be fairly annoying generally, particularly whenever you wish to add them someplace. You not must obtain applications to trim them as FFmpeg can do that for you. There are some parameters it is advisable to know for this, although:

  • -ss: Use this parameter to set the beginning time of the clip
  • -to: Means that you can specify the tip time of the clip
  • -c: Set the codec of your clip utilizing this parameter
  • -t: Use this parameter to set the length of the clip

You’ll be able to derive many examples utilizing these parameters. For instance, if you wish to trim a video, you should use one thing like:

ffmpeg -i example-video.mp4 -ss 00:02:25 -to 00:03:50 -c copy output-trim.mp4

It’s also doable to crop solely the picture contained in the video and never the entire video. For this, you may resort to one thing like:

ffmpeg -i example-video.mp4 -filter:v "crop=w:h:x:y" output-crop.mp4

Listed below are the parameters used within the aforementioned command:

  • -filter:v: This parameter specifies the filtering course of you’ll apply to the video
  • crop: This parameter is for specifying {that a} clipping operation shall be carried out
  • w:h:x:y: As you would possibly’ve guessed already, the w, h, x, and y variables denote width, peak, and place of the crop field, respectively

Enhancing Movies on Linux With FFmpeg

Enhancing movies would not finish with simply trimming and reducing. Typically you additionally want to alter the dimensions of the video. The next command will resize the video to a measurement you need:

ffmpeg -i example-video.mp4 -vf scale=1920:1080 output-scale.mp4
  • -vf: This parameter works the identical because the -filter:v argument seen above
  • scale: You’ll be able to specify the dimensions sizes you need in your output with this parameter

FFmpeg additionally lets you mix a number of movies. Think about you’ve got a number of clips encoded with the identical codec. Enter the checklist of movies you wish to merge right into a .txt file. Then, run the next command:

ffmpeg -f concat -i my-video-list.txt -c copy sum-output.mp4

The concat parameter right here combines your information. It’s also doable to rotate movies with FFmpeg:

ffmpeg -i example-video.mp4 -vf "transpose=2" output-rotate.mp4
  • transpose=0: Flip vertically (default)
  • transpose=1: Rotate 90 levels clockwise
  • transpose=2: Rotate 90 levels counterclockwise
  • transpose=3: Flip vertically


To rotate movies 180 levels clockwise, it is advisable to specify the transpose parameter twice:

ffmpeg -i example-video.mp4 -vf "transpose=2,transpose=2" output-rotate.mp4

FPS and GOP Operations

As , FPS means frames per second. GOP (group of images) is the gap between two keyframes. FFmpeg can be helpful for altering some parameters, together with FPS and GOP. In case you use the command under, FFmpeg will change the unique FPS to the worth you set:

ffmpeg -i example-video.mp4 -vf "fps=60" output-fps.mp4

For GOP, you should use the -g parameter and set its worth to no matter you need. Observe that forcing too many keyframes might be dangerous to some encoders’ ahead algorithms.

ffmpeg -i example-video.mp4 -g 200 output-gop.mp4

Create Animated GIFs With FFmpeg

FFmpeg can be excellent for changing a video to animated GIFs. You should use a easy convert command to do that:

ffmpeg -i example-video.mp4 output-gif.gif

However generally, you could wish to customise the GIF. You should use the assorted parameters mentioned above to attain this:

ffmpeg -ss 00:01:15 -i example-video.mp4 -to 10 -r 10 -vf scale=250:-1 output-gif.gif

The -r parameter right here means the body charge. As you may see, many alternative customizations are doable in a single line command.

Other than changing one or many pictures to video, you too can extract frames from a video. The next command will extract one body each second out of your enter video. Additionally, these extracted pictures may have two-digit names like 01.jpeg, 02.jpeg, and so on. If you want, you too can add different parameters you’ve got realized.

ffmpeg -i example-video.mp4 -r 1 image-%02d.jpeg

You too can use different codecs resembling PNG and BMP for the extracted pictures.

Why Ought to You Use FFmpeg on Linux?

As you may see, FFmpeg could be very advantageous in some ways. You don’t want to have any technical information or skilled Linux expertise for this. You’ll be able to carry out numerous media-processing capabilities with only a few parameters. If you will make edits that aren’t very lengthy, you do not want costly laptop applications and on-line premium memberships. Furthermore, FFmpeg works very properly even on low-end gadgets.

Additionally, the options of FFmpeg should not restricted to the above. While you learn the documentation and consumer guide, you may see how highly effective the software program really is. Even utilizing the –help parameter and the man command, you will get extra detailed details about utilizing FFmpeg. There are additionally different nice converters for Linux to rival FFmpeg.

Leave a Reply

Get Your FREE Mix Template for Pro Tools

X