Helpful FFmpeg instructions for working with audio and video recordsdata

FFmpeg is an especially highly effective and versatile command-line software for changing audio and video recordsdata. It’s free and out there for Home windows, Mac and Linux machines. Whether or not you wish to be a part of two video recordsdata, extract the audio element from a video file, convert your video into an animated GIF, FFmpeg can do all this and extra.

Extract audio from video file with this straightforward FFmpeg command.

Helpful FFmpeg Instructions

FFmpeg helps all fashionable audio and video codecs. or you’ll be able to run the command ./ffmpeg -formats to get a listing of every format supported by your FFmpeg set up. If you’re simply beginning out, listed here are some instructions that will provide you with a good suggestion of ​​the capabilities of this system.

1, Minimize video file into smaller clips

You should use the time offset parameter (-ss) to specify the beginning time stamp within the format whereas the -t parameter is to specify the precise period of the clip in seconds.

ffmpeg -i enter.mp4 -ss 00:00:50.0 -codec copy -t 20 output.mp4

2, Cut up a video into a number of components

If you wish to break up a big video into a number of smaller clips with out re-encoding, ffmpeg might help. This command will break up the supply video into 2 components – one begins at 50s and the opposite begins in 50s and ends on the finish of the enter video.

ffmpeg -i video.mp4 -t 00:00:50 -c copy small-1.mp4 -ss 00:00:50 -codec copy small-2.mp4

3, convert video from one format to a different

you should use -vcodec Parameter to specify the encoding format for use for output video. Encoding video takes time however you’ll be able to velocity up the method by forcing the presets, though this may degrade the standard of the output video.

ffmpeg -i youtube.flv -c:v libx264 filename.mp4

ffmpeg -i video.wmv -c:v libx264 -preset ultrafast video.mp4

4, Be a part of (insert) video recordsdata

In case you have a number of audio or video recordsdata encoded with the identical codec, you should use FFmpeg to hitch them into one file. Create an enter file with a listing of all of the supply recordsdata you wish to mix after which run this command.

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

5, Mute video (take away audio element)

Use -an Parameter for disabling the audio a part of the video stream.

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

-vn The change extracts the audio portion from a video and we’re utilizing the -ab change to avoid wasting the audio as a 256kbps MP3 audio file.

ffmpeg -i video.mp4 -vn -ab 256 audio.mp3

7, Convert Video to Animated GIF

FFmpeg is a superb software for changing movies to animated GIFs and the standard isn’t unhealthy both. Use the dimensions filter to specify the width of the GIF, the -t parameter specifies the period particular whereas -r specifies the body charge (fps).

ffmpeg -i video.mp4 -vf scale=500:-1 -t 10 -r 10 picture.gif

This command will extract the video body at mark 15 and put it aside as an 800px broad JPEG picture. It’s also possible to use the -s change (e.g. -s 400×300) to specify the precise dimensions of the picture file, though it would possible create an enlarged picture if the picture measurement doesn’t comply with the facet ratio of the unique video file. .

ffmpeg -ss 00:00:15 -i video.mp4 -vf scale=800:-1 -vframes 1 picture.jpg

9, convert video to picture

You should use FFmpeg to robotically extract picture frames from a video each ‘n’ seconds and the photographs are saved in a sequence. This command saves the picture body from the video after each 4 seconds.

ffmpeg -i film.mp4 -r 0.25 frames_percent04d.png

10, Merge an audio and video file

It’s also possible to specify -shortest Swap to finish encoding when the shortest clip is completed.

ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -strict experimental output.mp4

ffmpeg -i video.mp4 -i audio.mp3 -c:v copy -c:a aac -strict experimental -shortest output.mp4

1 1, resize video

Use the resize (-s) change with ffmpeg to resize the video whereas sustaining the facet ratio.

ffmpeg -i enter.mp4 -s 480x320 -c:a replica output.mp4

12, Create video slideshow from photos

This command creates a video slideshow utilizing a sequence of photos named img001.png, img002.png, and so forth. The period of every picture will probably be 5 seconds (-r 1/5).

ffmpeg -r 1/5 -i imgpercent03d.png -c:v libx264 -r 30 -pix_fmt yuv420p slideshow.mp4

13, add poster picture to audio

You’ll be able to add a canopy picture to an audio file and the size of the output video would be the similar because the enter audio stream. This will come in useful for importing MP3s to YouTube.

ffmpeg -loop 1 -i picture.jpg -i audio.mp3 -c:v libx264 -c:a aac -strict experimental -b:a 192k -shortest output.mp4

14, convert single picture to video

Use the -t parameter to specify the period of the video.

ffmpeg -loop 1 -i picture.png -c:v libx264 -t 30 -pix_fmt yuv420p video.mp4

15, Add Subtitles to Films

It would take subtitles from .srt file. FFmpeg can decode all widespread subtitle codecs.

ffmpeg -i film.mp4 -i -map 0 -map 1 -c copy -c:v libx264 -crf 23 -preset veryfast output.mkv

16, crop an audio file

It will create a 30 second audio file beginning at 90 seconds from the unique audio file with out transcoding.

ffmpeg -ss 00:01:30 -t 30 -acodec copy -i inputfile.mp3 outputfile.mp3

17, change audio quantity

You should use Quantity Filter to vary the quantity of a media file utilizing FFmpeg. This command will take half the quantity of the audio file.

ffmpeg -i enter.wav -af 'quantity=0.5' output.wav

18, rotate video

This command will rotate a video clip 90° clockwise. You’ll be able to set Transpose to 2 to rotate the video 90° counterclockwise.

ffmpeg -i enter.mp4 -filter:v 'transpose=1' rotated-video.mp4

It will rotate the video 180° clockwise.

ffmpeg -i enter.mp4 -filter:v 'transpose=2,transpose=2' rotated-video.mp4

19, velocity up or decelerate video

You’ll be able to change the velocity of your video through the use of setpts (set presentation time stamp) FFmpeg’s filter. This command will make the video 8x (1/8) sooner or use setpts=4*PTS To make the video 4x slower.

ffmpeg -i enter.mp4 -filter:v "setpts=0.125*PTS" output.mp4

20, velocity up or decelerate audio

To vary the velocity of the audio, use atempo audio filter. This command will double the velocity of the audio. You should use any worth between 0.5 and a pair of.0 for audio.

ffmpeg -i enter.mkv -filter:a "atempo=2.0" -vn output.mkv

Stack Change has an excellent overview to get you began with FFmpeg. You must also take a look at the official documentation on or the wiki at to study all of the attainable issues you are able to do with FFmpeg.

See additionally: Important Linux Instructions

Supply hyperlink