FFmpeg Commands

FFmpeg utility supports almost all major audio and video formats, if you want to check the ffmpeg supported available formats you can use ./ffmpeg -formats command to list all supported formats. If you are new to this tool, here are some handy commands that will give you a better idea about the capabilities of this powerful tool.

1. Get Video File Information

To get information about a file (say video.mp4), run the following command. Remember you have to specify an ouput file, but in this case we only want to get some information about the input file. Note: The -hide_banner option is used to hide a copyright notice shown my ffmpeg, such as build options and library versions. This option can be used to suppress printing this information. For example, if you run the above command without adding -hide_banner option it will print the all FFmpeg tools copyright information as shown.

2. Split a video into images

To turn a video to number of images, run the command below. The command generates the files named image1.jpg, image2.jpg and so on… Split Video into Images After successful execution of above command you can verify that the video turn into multiple images using following ls command.

3. Convert images into a video

Turn number of images to a video sequence, use the following command. This command will transform all the images from the current directory (named image1.jpg, image2.jpg, etc…) to a video file named imagestovideo.mpg. There are many other image formats (such as jpeg, png, jpg, etc) you can use.

4. Convert a video into mp3 format

To convert an .flv format video file to Mp3 format, run the following command. Description about the options used in above command:
  1. vn: helps to disable video recording during the conversion.
  2. ar: helps you set audio sampling rate in Hz.
  3. ab: set the audio bitrate.
  4. ac: to set the number of audio channels.
  5. -f: format.

5. Covert flv video file to mpg format

To convert a .flv video file to .mpg, use the following command.

6. Convert video into animated gif

To convert a .flv video file to animated, uncompressed gif file, use the command below.

7. Convert mpg video file to flv

To convert a .mpg file to .flv format, use the following command.

8. Convert avi video file to mpeg

To convert a .avi file to mpeg for dvd players, run the command below: Explanation about the options used in above command.
  1. target pal-dvd : Output format
  2. ps 2000000000 maximum size for the output file, in bits (here, 2 Gb).
  3. aspect 16:9 : Widescreen.

9. Convert a video to CD or DVD format

To create a video CD or DVD, FFmpeg makes it simple by letting you specify a target type and the format options required automatically. You can set a target type as follows: add -target type; type can of the following be vcd, svcd, dvd, dv, pal-vcd or ntsc-svcd on the command line. To create a VCD, you can run the following command:

10. Extract audio from video file

To extract sound from a video file, and save it as Mp3 file, use the following command: Explanation about the options used in above command.
  1. Source video : video.avi
  2. Audio bitrate : 192kb/s
  3. output format : mp3
  4. Generated sound : audio3.mp3

11. Mix a video and audio together

You can also mix a video with a sound file as follows:

12. Increase/Reduce Video Playback Speed

To increase video play back speed, run this command. The -vf option sets the video filters that helps to adjust the speed. You can also reduce video speed as follows:

13. Compare/Test Video and Audio Quality

To compare videos and audios after converting you can use the commands below. This helps you to test videos and audio quality. To test audio quality simply use the name of the audio file as follows: You can listen to them while they play and compare the qualities from the sound.

14. Add Photo or Banner to Audio

You can add a cover poster or image to an audio file using the following command, this comes very useful for uploading MP3s to YouTube.

15. Add subtitles to a Movie

If you have a separate subtitle file called subtitle.srt, you can use following command to add subtitle to a movie file:


That is all for now but these are just few examples of using FFmpeg, you can find more options for what you wish to accomplish. Remember to post a comment to provide information about how to use FFmpeg or if you have encountered errors while using it. Reference: https://ffmpeg.org/