20+ FFmpeg Instructions For Novices


Get real time updates directly on you device, subscribe now.

On this information, I might be explaining learn how to use FFmpeg multimedia framework to do numerous audio, video transcoding and conversion operations with examples. I’ve compiled mostly and steadily used 20+ FFmpeg instructions for novices. I’ll preserve updating this information by including extra examples every so often. Please bookmark this information and are available again shortly to test for the updates. Allow us to get began, we could? If you happen to haven’t put in FFmpeg in your Linux system but, refer the next information.

20+ FFmpeg Instructions For Novices

The standard syntax of the FFmpeg command is:

ffmpeg [global_options] …
[output_file_options] output_url …

We at the moment are going to see some necessary and helpful FFmpeg instructions.

1. Getting audio/video file data

To show your media file particulars, run:

$ ffmpeg -i video.mp4

Pattern output:

ffmpeg model n4.1.three Copyright (c) 2000-2019 the FFmpeg builders
constructed with gcc eight.2.1 (GCC) 20181127
configuration: –prefix=/usr –disable-debug –disable-static –disable-stripping –enable-fontconfig –enable-gmp –enable-gnutls –enable-gpl –enable-ladspa –enable-libaom –enable-libass –enable-libbluray –enable-libdrm –enable-libfreetype –enable-libfribidi –enable-libgsm –enable-libiec61883 –enable-libjack –enable-libmodplug –enable-libmp3lame –enable-libopencore_amrnb –enable-libopencore_amrwb –enable-libopenjpeg –enable-libopus –enable-libpulse –enable-libsoxr –enable-libspeex –enable-libssh –enable-libtheora –enable-libv4l2 –enable-libvidstab –enable-libvorbis –enable-libvpx –enable-libwebp –enable-libx264 –enable-libx265 –enable-libxcb –enable-libxml2 –enable-libxvid –enable-nvdec –enable-nvenc –enable-omx –enable-shared –enable-version3
libavutil 56. 22.100 / 56. 22.100
libavcodec 58. 35.100 / 58. 35.100
libavformat 58. 20.100 / 58. 20.100
libavdevice 58. 5.100 / 58. 5.100
libavfilter 7. 40.101 / 7. 40.101
libswscale 5. three.100 / 5. three.100
libswresample three. three.100 / three. three.100
libpostproc 55. three.100 / 55. three.100
Enter #Zero, mov,mp4,m4a,3gp,3g2,mj2, from ‘video.mp4’:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.20.100
Period: 00:00:28.79, begin: Zero.000000, bitrate: 454 kb/s
Stream #Zero:Zero(und): Video: h264 (Excessive) (avc1 / 0x31637661), yuv420p(television, smpte170m/bt470bg/smpte170m), 1920×1080 [SAR 1:1 DAR 16:9], 318 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
handler_name : ISO Media file produced by Google Inc. Created on: 04/08/2019.
Stream #Zero:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
handler_name : ISO Media file produced by Google Inc. Created on: 04/08/2019.
No less than one output file have to be specified

As you see within the above output, FFmpeg shows the media file data together with FFmpeg particulars similar to model, configuration particulars, copyright discover, construct and library choices and so on.

If you happen to don’t need to see the FFmpeg banner and different particulars, however solely the media file data, use -hide_banner flag like under.

$ ffmpeg -i video.mp4 -hide_banner

Pattern output:

View audio, video file information using FFMpeg

View audio, video file data utilizing FFMpeg

See? Now, it shows solely the media file particulars.

2. Changing video information to completely different codecs

FFmpeg is highly effective audio and video converter, so It’s doable to transform media information between completely different codecs. Say for instance, to transform mp4 file to avi file, run:

$ ffmpeg -i video.mp4 video.avi

Equally, you may convert media information to any format of your selection.

For instance, to transform youtube flv format movies to mpeg format, run:

$ ffmpeg -i video.flv video.mpeg

If you need to protect the standard of your supply video file, use ‘-qscale Zero’ parameter:

$ ffmpeg -i enter.webm -qscale Zero output.mp4

To test record of supported codecs by FFmpeg, run:

$ ffmpeg -formats

three. Changing video information to audio information

To transform a video file to audio file, simply specify the output format as .mp3, or .ogg, or another audio codecs.

The above command will convert enter.mp4 video file to output.mp3 audio file.

$ ffmpeg -i enter.mp4 -vn output.mp3

Additionally, you should utilize numerous audio transcoding choices to the output file as proven under.

$ ffmpeg -i enter.mp4 -vn -ar 44100 -ac 2 -ab 320 -f mp3 output.mp3

Right here,

-vn – Signifies that we have now disabled video recording within the output file.
-ar – Set the audio frequency of the output file. The widespread values used are  22050, 44100, 48000 Hz.
-ac – Set the variety of audio channels.
-ab – Signifies the audio bitrate.
-f – Output file format. In our case, it’s mp3 format.

four. Change decision of video information

If you wish to set a selected decision to a video file, you should utilize following command:

$ ffmpeg -i enter.mp4 -filter:v scale=1280:720 -c:a replica output.mp4


$ ffmpeg -i enter.mp4 -s 1280×720 -c:a replica output.mp4

The above command will set the decision of the given video file to 1280×720.

Equally, to transform the above file to 640×480 measurement, run:

$ ffmpeg -i enter.mp4 -filter:v scale=640:480 -c:a replica output.mp4


$ ffmpeg -i enter.mp4 -s 640×480 -c:a replica output.mp4

This trick will assist you to scale your video information to smaller show units similar to tablets and mobiles.

5. Compressing video information

It’s all the time an good thought to cut back the media information measurement to decrease measurement to avoid wasting the harddrive’s house.

The next command will compress and scale back the output file’s measurement.

$ ffmpeg -i enter.mp4 -vf scale=1280:-1 -c:v libx264 -preset veryslow -crf 24 output.mp4

Please notice that you’ll lose the standard when you attempt to scale back the video file measurement. You’ll be able to decrease that crf worth to 23 or decrease if 24 is simply too aggressive.

You may additionally transcode the audio down a bit and make it stereo to cut back the scale by together with the next choices.

-ac 2 -c:a aac -strict -2 -b:a 128ok

6. Compressing Audio information

Identical to compressing video information, you too can compress audio information utilizing -ab flag so as to avoid wasting disk house.

Allow us to say you’ve an audio file of 320 kbps bitrate. You need to compress it by altering the bitrate to any decrease worth like under.

$ ffmpeg -i enter.mp3 -ab 128 output.mp3

The record of varied out there audio bitrates are:


7. Eradicating audio stream from a video file

If you happen to don’t need to a audio from a video file, use -an flag.

$ ffmpeg -i enter.mp4 -an output.mp4

Right here, ‘an’ signifies no audio recording.

The above command will undo all audio associated flags, as a result of we don’t audio from the enter.mp4.

eight. Eradicating video stream from a media file

Equally, when you don’t need video stream, you can simply take away it from the media file utilizing ‘vn’ flag. vn stands for no video recording. In different phrases, this command converts the given media file into audio file.

The next command will take away the video from the given media file.

$ ffmpeg -i enter.mp4 -vn output.mp3

You too can point out the output file’s bitrate utilizing ‘-ab’ flag as proven within the following instance.

$ ffmpeg -i enter.mp4 -vn -ab 320 output.mp3

9. Extracting photos from the video 

One other helpful characteristic of FFmpeg is we will simply extract photos from a video file. This could possibly be very helpful, if you wish to create a photograph album from a video file.

To extract photos from a video file, use the next command:

$ ffmpeg -i enter.mp4 -r 1 -f image2 image-%2nd.png

Right here,

-r – Set the body price. I.e the variety of frames to be extracted into photos per second. The default worth is 25.
-f – Signifies the output format i.e picture format in our case.
image-%2nd.png – Signifies how we need to title the extracted photos. On this case, the names ought to begin like image-01.png, image-02.png, image-03.png and so forth. If you happen to use %3d, then the title of photos will begin like image-001.png, image-Zero02.png and so forth.

10. Cropping movies

FFMpeg permits to crop a given media file in any dimension of our selection.

The syntax to crop a vide ofile is given under:

ffmpeg -i enter.mp4 -filter:v “crop=w:h:x:y” output.mp4

Right here,

enter.mp4 – supply video file.
-filter:v – Signifies the video filter.
crop – Signifies crop filter.
wWidth of the rectangle that we need to crop from the supply video.
h – Top of the rectangle.
xx coordinate of the rectangle that we need to crop from the supply video.
y – y coordinate of the rectangle.

Allow us to say you need to a video with a width of 640 pixels and a top of 480 pixels, from the place (200,150), the command can be:

$ ffmpeg -i enter.mp4 -filter:v “crop=640:480:200:150” output.mp4

Please notice that cropping movies will have an effect on the standard. Don’t do that until it’s needed.

11. Convert a selected portion of a video

Typically, you may need to convert solely a selected portion of the video file to completely different format. Say for instance, the next command will convert the first 50 seconds of given video.mp4 file to video.avi format.

$ ffmpeg -i enter.mp4 -t 10 output.avi

Right here, we specify the the time in seconds. Additionally, it’s doable to specify the time in hh.mm.ss format.

12. Set the side ratio to video

You’ll be able to set the side ration to a video file utilizing -aspect flag like under.

$ ffmpeg -i enter.mp4 -aspect 16:9 output.mp4

The generally used side ratios are:


13. Including poster picture to audio information

You’ll be able to add the poster photos to your information, in order that the photographs might be displayed whereas enjoying the audio information. This could possibly be helpful to host audio information in Video internet hosting or sharing web sites.

$ ffmpeg -loop 1 -i inputimage.jpg -i inputaudio.mp3 -c:v libx264 -c:a aac -strict experimental -b:a 192ok -shortest output.mp4

14. Trim a media file utilizing begin and cease occasions

To trim down a video to smaller clip utilizing begin and cease occasions, we will use the next command.

$ ffmpeg -i enter.mp4 -ss 00:00:50 -codec copy -t 50 output.mp4

Right here,

–s – Signifies the beginning time of the video clip. In our instance, beginning time is the 50th second.
-t – Signifies the overall time length.

That is very useful whenever you need to lower an element from an audio or video file utilizing beginning and ending time.

Equally, we will trim down the audio file like under.

$ ffmpeg -i audio.mp3 -ss 00:01:54 -to 00:06:53 -c copy output.mp3

15. Break up video information into a number of components

Some web sites will can help you add solely a selected measurement of video. In such circumstances, you may break up the big video information into a number of smaller components like under.

$ ffmpeg -i enter.mp4 -t 00:00:30 -c copy part1.mp4 -ss 00:00:30 -codec copy part2.mp4

Right here, -t 00:00:30 signifies an element that’s created from the beginning of the video to the 30th second of video. -ss 00:00:30 exhibits the beginning time stamp for the subsequent a part of video. It implies that the 2nd half will begin from the 30th second and can proceed as much as the top of the unique video file.

16. Becoming a member of or merging a number of video components into one

FFmpeg can even be part of the a number of video components and create a single video file.

Create be part of.txt file that comprises the precise paths of the information that you simply need to be part of. All information ought to be similar format (similar codec). The trail title of all information ought to be talked about one after the other like under.

file /house/sk/myvideos/part1.mp4
file /house/sk/myvideos/part2.mp4
file /house/sk/myvideos/part3.mp4
file /house/sk/myvideos/part4.mp4

Now, be part of all information utilizing command:

$ ffmpeg -f concat -i be part of.txt -c copy output.mp4

If you happen to get an error one thing like under;

[concat @ 0x555fed174cc0] Unsafe file title ‘/path/to/mp4’
be part of.txt: Operation not permitted

Add “-safe Zero”:

$ ffmpeg -f concat -safe Zero -i be part of.txt -c copy output.mp4

The above command will be part of part1.mp4, part2.mp4, part3.mp4, and part4.mp4 information right into a single file known as “output.mp4”.

17. Add subtitles to a video file

We will additionally add subtitles to a video file utilizing FFmpeg. Obtain the proper subtitle on your video and add it your video as proven under.

$ fmpeg -i enter.mp4 -i subtitle.srt -map Zero -map 1 -c copy -c:v libx264 -crf 23 -preset veryfast output.mp4

18. Preview or check video or audio information

You may need to preview to confirm or check whether or not the output file has been correctly transcoded or not. To take action, you may play it out of your Terminal with command:

$ ffplay video.mp4

Equally, you may check the audio information as proven under.

$ ffplay audio.mp3

19. Improve/lower video playback velocity

FFmpeg permits you to alter the video playback velocity.

To extend the video playback velocity, run:

$ ffmpeg -i enter.mp4 -vf “setpts=Zero.5*PTS” output.mp4

The command will double the velocity of the video.

To decelerate your video, it’s good to use a multiplier larger than 1.  To lower playback velocity, run:

$ ffmpeg -i enter.mp4 -vf “setpts=four.Zero*PTS” output.mp4

20. Create Animated GIF

We use GIF photos on nearly all social networks for numerous functions. Utilizing FFmpeg, we will simply and rapidly create animated video information. The next information explains learn how to create an animated GIF file utilizing FFmpeg and ImageMagick in Unix-like programs.

21. Create movies from PDF information

I collected many PDF information, largely Linux tutorials, through the years and saved in my Pill PC. Typically I really feel too lazy to learn them from the pill. So, I made a decision to create a video from PDF information and watch it in an enormous display units like a TV or a Laptop. If you happen to ever puzzled learn how to make a film file from a group of PDF information, the next information will assist.

22. Getting assist

On this information, I’ve coated probably the most generally used FFmpeg instructions. It has much more completely different choices to do numerous superior capabilities. To study extra about it, refer the person web page.

$ man ffmpeg

And, that’s all. I hope this information will assist you to getting began with FFmpeg. If you happen to discover this information helpful, please share it in your social, networks. Extra good stuffs to return. Keep tuned!


Thanks for stopping by!

Assist us that will help you:

Have a Good day!!

Source link

Leave A Reply

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More