FFmpeg Basic Audio and Video Commands


FFmpeg is a very powerful and great command line tool used for performing various conversion operations on audio and video files. FFmpeg is absolutely free to use. It is available for Windows, Linux and Mac operating systems. In this post we will be running ffmpeg on Fedora 21 (Linux) to cover some basic commands.

Video specific commands

Extracting Video While Muting Audio

In the command written below, -an is used to remove the audio from the video file. The command should look like so:

$ ffmpeg -i yourvideo.mp4 -an mutevideo.mp4

Resize the Video File

In the command written below, -s is used to resize the video file.The command is:

$ ffmpeg -i yourvideo.mp4 -s 640×480 -c:a copy resizedvideo.mp4

Cut Video File into a Smaller Clip

The -ss defines the starting time stamp (here starting time is the 45th second) and -t tells the total time duration for the clip. So, -t 40 means 40 second duration. The command should like this:

$ ffmpeg -i yourvideo.mp4 -ss 00:00:45 -codec copy -t 40 outputclip.mp4

Split a Video File into Multiple Parts

Most of the hosting servers only allows for a specific size of file to be uploaded. To overcome this issue, you can use the split command to split a large video file into smaller parts, which is:

$ ffmpeg -i yourvideo.mp4 -t 00:00:59 -c copy part1.mp4 -ss 00:00:59 -codec copy part2.mp4

Here -t 00:00:59 represents a part that is created from the start of the video to the 59th second of video. -ss 00:00:59 shows the starting time stamp for the video. It means that the 2nd part will start from the 59th second and will continue up to the end of the original video file.

Convert a Video File from One Format to Another Format

You can see all of the formats supported by FFmpeg by using the following command:

$ ffmpeg -formats

To convert a video file from one format to another format, the following command is used: The command below is an example of when converting a .mp4 file into a .wmv file.

$ ffmpeg -i yourvideo.mp4 -c:v libx264 outputfilename.wmv

To encode a video with a 128kbps audio bitrate and 1,200kbps video stream, to be used for DVD creation we would issue the following command:

$ ffmpeg -i yourvideo.avi -ab 128 -b 1200 outputfilename.mpg

Join (merge) Video Files

FFmpeg can also join multiple video or audio files with the same codecs. Create a .txt file including a list of all the input video files that are supposed to be merged. The keyword file is followed by name, path and the format of the video files. Add all of the files in the same way in the created .txt file and save this .txt file in the bin folder.

Now type the following command to join the video files:

$ ffmpeg -f concat -i file-list.txt -c copy outputfile.mp4

Audio specific commands

Extracting Audio only From Video File

$ ffmpeg -i yourvideo.mp4 -vn -ab 128 outputaudio.mp3

Here -vn is used to extract audio and -ab is used to save audio as 128Kbps MP3 file. You can change the bit rate to 256Kbps or something else. Just change the value after -ab. All of the output files will be stored automatically in the folder you are running the command from and assumes the file you are running on is there as well.

Adding Poster Image to an Audio File

You can add a poster image to your audio file easily and the output would be a video file with an image being displayed in the front and audio in the background. This is really handy when uploading MP3 files to video hosting and sharing sites.

You must copy the image to the folder in which the mp3 file resides.

$ ffmpeg -loop 1 -i inputimage.jpg -i inputaudio.mp3 -c:v libx264 -c:a –strict experimental -b:a 192k -shortest outputfile.mp4

Cropping an Audio File

To crop part of an audio file, the following command can be utilized:

$ ffmpeg -ss 00:00:15 -t 45 -i sampleaudio.mp3 croppedaudio.mp3

Here, -ss 00:00:15 is the staring time and -t 45 is the duration of the cropped file.


As we have just seen FFmpeg is a very powerful tool and can be used for many operations. You can explore the rest of the commands via the help option of FFmpeg. Just type in ffmpeg -h in command line. This will list all the available options and commands for these options.

No Responses to “FFmpeg Basic Audio and Video Commands”


  1. Summary of FFmpeg processing audio and video commands • Artificial Intelligence and Cloud Computing - […] FFmpeg Basic Audio And Video Commands […]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.