Ffmpeg Command Tutorial With Examples For Video and Audio

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/ffmpeg-command-tutorial-examples-video-audio/
PINTEREST
PINTEREST
INSTAGRAM

In today’s multimedia world there are a lot of different formats for video and audio. In order to use video and audio we generally need to convert and edit operations. There are different tools for this job but the most popular and useful tool is ffmpeg. Ffmpeg is used by a lot of different free and commercial software. It provide very large feature set. In this tutorial we will look most wanted and useful features like convert, resize,… of ffmpeg . Ffmpeg is a free video editing software which works from command line.

As we know ffmpeg is provided for Windows operating systems too. So following commands will work seamlessly in Windows operating systems to if ffmpeg is downloaded and setup correctly.

Display Video Information

Video files have different options about their structure. These information can be display with ffmpeg.

Display Video Information

Display Video Information

Ffmeg will display following information;

  • encoder shows video encoder of the video file
  • creation_time describes the create time as year,month,day, hour,minute,second
  • Duration describes the length of the video file in hour:minute:second format
  • Stream show video stream information. A video file like mkv, mp4 may have more than one stream for different purposes. In this example we have only one stream with index 0:0 . There is information about the video stream like video format resolution frame per second

Display Audio Information

We can also get audio information from video file or audio file.

Display Audio Information

Display Audio Information

There are following information

  • genre describes the musical type of mp3 as metadata
  • Duration describes the length of the video file in hour:minute:second format
  • Stream show audio information like format type, quality of the stream

Convert Mkv To Mp4

Now we can start converting files into different format. We will start converting Mkv video file into Mp4 format. In this example we will convert file named jellyfish.mkv into jellyfish.mp4

Convert Mkv To Mp4

Convert Mkv To Mp4

In the example the first thing is printing the source file information and than the convert operation starts. During the convert operation following statistical informations are provided as real time.

  • frame show currently processes frame count
  • fps show the count of frames processed in one second
  • Lsize shows the destination or new file size
  • time shows current position of the convert process in the video length in time
  • bitrate shows the bit size of a second length of the video
LEARN MORE  Linux Print History Command Without Line Numbers

Convert Flash and Flv To Mp4

Flash files can be converted to Mp4 like below.

Convert Flash and Flv To Mp4

Convert Flash and Flv To Mp4

Convert  Mp4 To Mp3

Mp4 files are mainly used for mobile media devices or smart phones. This type of video can be converted to the mp3 audio file with the following command.

Convert  Mp4 To Avi

Mp4 is a popular format as stated before. In the old time avi was the most popular advanced format.

Convert Mp4 To Avi

Convert Mp4 To Avi

Convert  Mp4 To Gif

Gif format is generally used to show simple, low size video to the user in the web pages without video players. Gif is a picture format that can store motions as different frames in pictures.

Convert Mp4 To Gif

Convert Mp4 To Gif

Convert  Avi To Mp4

We can convert avi to mp4 with the following command.

Extract Audio From Video File

We can extract audio stream from the video file and save audio as a separate file in formats like aac , mp3 , vorbis etc. We will provide -vn -ab 128 options. -ab 128 specifies the bitrate. The audio extraction will be done very little time.

Extract Audio From Video File

Extract Audio From Video File

Mute Audio

As we see previous example audio file is stored as separate stream. This gives the ability to mute audio of the video file. We will use -an option to mute audio.

LEARN MORE  How To Record Screen In Linux?

Mute Audio

Mute Audio

Resize Video Resolution

Video files can be resized. Scaling down the resolution will made the video file less in size. We will use -s with the new resoution x and y sizes. In the example we will resize the video as 640x480 .

Resize Video Resolution

Resize Video Resolution

Add Poster Image To Audio File

As audio files provides only sound the singers albums need some poster to show while playing the song. This poster image can be embedded into audio file as metadata like below.

Add Poster Image To Audio File

Add Poster Image To Audio File

Cut Video

We can cut video from specified time as specified time range. Original file will be kept without changing. We will specify the start time with -ss option and duration with -t option. In this example we will cut video from 20 seconds to 35 seconds.

Cut Video

Cut Video

Merge Video Files

Multiple video files can be concatenated into single video file. We will provide the video file list as a text file with -f concat and -c copy options. The video files are listed like below named videos.txt

videos.txt

Now we will join togather.

LEARN MORE  How To List Installed Packages In CentOS, Fedora?

Crop Audio File

We have previously cut the video file. There is also option to cut audio file. We will use same options with video file but the output will be an audio file. In this example we crop audio_crop.mp3

Crop Audio File

Crop Audio File

Set Bitrate Of Audio

Bitrate of a video effects the quality of the audio more bitrate means more quality but also more audio size. We can change the audio file bitrate -ab option. In the example we will change bitrate to 128k

Set Bitrate Of Audio

Set Bitrate Of Audio

Set Framerate Of Video

The framerate specifies the count of pictures in one second. High framerate means more fluid movie but costs more CPU and disk. We can change framerate with -r option. In the example we will set framerate 15

Set Framerate Of Video

Set Framerate Of Video

Set Bitrate Of Video

Bitrate of video provides color density about the frames. More bitrate means more detailed colors but more in size. We can set video bitrate with ffmpeg by using -b option. In the example we will change bitrate to 100k which means 100.000 bits

Set Bitrate Of Audio

Set Bitrate Of Audio

Extract Images From Video

As you know movie rippers generally provides some picture thumbnail about movies and video files. This picture thumbnail can be created with ffmpeg. We will use -r option to specify rate and -f option for the format. In the example we will create a thumbnail with rate 1.

Extract Images From Video

Extract Images From Video

RSS
EMAIL
FACEBOOK
FACEBOOK
GOOGLE
GOOGLE
https://www.poftut.com/ffmpeg-command-tutorial-examples-video-audio/
PINTEREST
PINTEREST
INSTAGRAM

You may also like...

Leave a Reply

Your email address will not be published.

Enjoy this blog? Please spread the word :)