The 28 most useful ffmpeg commands

Share

FFmpeg is a very powerful, free software tool, it can be used to record, convert and stream audio and video. This software includes a library of codecs, libavcodec. FFmpeg is developed in GNU / Linux but can be compiled in most Operating Systems including Windows. FFmpeg is a very simple and very easy-to-use program, targeting both people with advanced knowledge and new users.

You can download FFmpeg from its official site easily from the link given below. Link

Some useful commands from FFmpeg.

1- Get information about a video

<br />
 $ ffmpeg -i video.mp4<br />

2- Convert video formats

– From AVI to MP4

<br />
$ ffmpeg -i video_original.avi video_final.mp4<br />

 – From Matroshka to Avi

<br />
$ ffmpeg -i video_source.mkv video_final.avi<br />

 – From m4V to mp4

<br />
$ ffmpeg -i video_souce.m4v -codec copy video_final.mp4<br />

3- Convert images to video
It changes 0.3 to give faster, when higher  faster, it formats mp4 and avi

<br />
$ cat *.JPG | ffmpeg -f image2pipe -r 0.3 -vcodec mjpeg -i - -vcodec libx264 out4.mp4<br />
$ cat *.JPG | ffmpeg -f image2pipe -r 0.3 -vcodec mjpeg -i - -vcodec libx264 out4.avi<br />

4- Extract audio from a video

<br />
$ ffmpeg -i video.mp4 -vn audio.mp3<br />

5- Mute the audio of a video

<br />
$ ffmpeg -i video.mp4 -an video_mute.mp4<br />

6- Upload the volume of a video

<br />
$ ffmpeg -i video.mp4 -vol 512 video_final.mp4 ffmpeg -i video.mp4 -af volume=2<br />

7- Rotate a video

<br />
$ ffmpeg -i video.mp4 -vf transpose=clock video_rotado_90.mp4<br />
$ ffmpeg -i video.mp4 -vf transpose=clock,transpose=clock video_rotado_180.mp4<br />
$ ffmpeg -i video.mp4 -vf hflip video_invertido_horizontalmente.mp4<br />
$ ffmpeg -i video.mp4 -vf vflip video_invertido_verticalmente.mp4<br />

8- Resize a video

<br />
$ ffmpeg -i video.mp4 -vf scale=320:240 video_320x240.mp4<br />
$ ffmpeg -i video.mp4 -vf scale=320:-1 video_320x180.mp4<br />
$ ffmpeg -i video.mp4 -vf scale=iw/2:ih/2 video_x.mp4<br />
 

9- Cut fragments of a video

<br />
$ ffmpeg -i video.mp4 -ss 35 -t 30 fragmento.mp4<br />
$ ffmpeg -i video.mp4 -ss 00:35 -to 01:05 fragmento.mp4<br />

10- Add or remove audio tracks

</p>
<p>$ ffmpeg -i video.mp4 -i audio_es.mp3 -map 0:v -map 0:a -map 1:a -vcodec copy video_final.mp4<br />
$ ffmpeg -i video.mp4 -map 0:0 -map 0:2 solo_canal1_audio.mp4</p>
<p>

11- Mix audio tracks

<br />
$ ffmpeg -i audio1.mp3 -i audio2.mp3 -filter_complex amerge audio_mezclado.mp3<br />

12- Cut areas of the video

<br />
$ ffmpeg -i screencast.mp4 -ss 00:30 -to 03:50 -vf crop=640:480:500:250 video_final.mp4<br />

13- Apply bulleted to the video

<br />
$ ffmpeg -i video.mp4 -vf vignette=PI/4 video_vignette.mp4<br />
$ ffmpeg -i video.mp4 -vf vignette='PI/4+random(1)*PI/50':eval=frame<br />

14- Create a fade-in,fade-out

<br />
$ ffmpeg -i video.mp4 -vf fade=t=in:st=0:d=5 video-fadein.mp4<br />
$ ffmpeg -i video.mp4 -vf fade=t=in:st=0:d=5,fade=t=out:st=25:d=5 video-fadeout.mp4<br />

15- Audio fade

</p>
<p>$ ffmpeg -i true.mp4 -vf fade=t=in:st=0:d=5,fade=t=out:st=25:d=5 -af afade=t=in:ss=0:d=5,afade=t=out:st=25:d=5 truefade.mp4<br />

16- Extract frames from a video

<br />
$ ffmpeg -i video.mp4 image%d.jpg<br />

17- Extract frames from a video, one image per second

<br />
$ ffmpeg -i video.mp4 -vf fps=1 image%d.png<br />

18- Create video from a series of images

<br />
$ ffmpeg -f image2 -i image%d.jpg video.mp4<br />

19- Put a logo or watermark on the video

<br />
$ ffmpeg -i video.mp4 -i logo.png -filter_complex overlay=10:10 final.mp4<br />
$ ffmpeg -i video.mp4 -i logo.png -filter_complex overlay=x=(main_w-overlay_w):y=(main_h-overlay_h) final.mp4<br />

20- Join audio and video

<br />
$ ffmpeg -i audio.mp3 -i video.avi video_audio_mix.mpg<br />

21- Make a gif from a video

<br />
$ ffmpeg -i video.mp4 -vf scale=300:-1 -t 10 -r 10 image.gif<br />

22- Convert video to audio files

<br />
$ ffmpeg -i video.flv -vn -ar 44100 -ac 2 -ab 192 -f mp3 audio.mp3<br />

23- Make a video to watch on the PSP

<br />
$ ffmpeg -i carpeta/video.mov -b300 -s 320X240 -vcodec xvid -ab 12 -ar 24000 -acodec aac video_final.mp4<br />

24- Make a 5 sec video from an image and an audio

<br />
$ ffmpeg -loop 1 -y -i imagen.jpg -i audio.mp3 -shortest video.mp4<br />

25- Join videos

<br />
$ ffmpeg -i &quot;concat:video1.mp4|video2.mp4|video3.mp4&quot; -c copy videounido.mp4<br />

26- Record the main monitor

<br />
$ ffmpeg -framerate 25 -video_size 1920x1080 -f x11grab -draw_mouse 1 -show_region 1 -region_border 3 -i :0.0 -f alsa -ac 2 -i pulse -vcodec libx264 -crf 0 -preset medium -acodec libmp3lame output.mp4<br />

27- Record secondary monitor

<br />
$ ffmpeg -framerate 25 -video_size 1280x1024 -f x11grab -i :0.0+1920,0 -f alsa -ac 2 -i pulse -vcodec libx264 -crf 0 -preset medium -acodec libmp3lame output.mp4<br />

28- Extract audio from any video

<br />
$ ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 audio.mp3<br />

On the last command we can say:

-vn: Disables the understanding / recording of the video
-ar: audio rate
-ac: audio canals
-ab: bitrate d’ audio
-f: output format

lluis

Author: lluis

Leave a Reply

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