⬆️ ⬇️

19 ffmpeg commands for every need

From the translator :

Many people know that ffmpeg is a force, but not everyone knows which one. It is multifaceted and limitless, and its man is obscure and in places obscure, only a few have comprehended the dao of professional work with it. Nevertheless, this tool can be useful to almost everyone who at least sometimes works with video and sound, even at the household level. Some useful ffmpeg console commands will be discussed in the article. In some places I took the liberty to insert links to explanatory articles.



ffmpeg is a cross-platform open-source library for processing video and audio files. I gathered 19 useful and amazing commands covering almost all needs: video conversion, audio track extraction, iPod or PSP conversion, and more.



1. Getting information about the video file


ffmpeg -i video.avi 


2. Turn a set of pictures into video


 ffmpeg -f image2 -i image%d.jpg video.mpg 


This command converts all images from the current directory (named image1.jpg, image2.jpg, etc.) into the video file video.mpg

')

(translator's note: I prefer this format:

 ffmpeg -r 12 -y -i "image_%010d.png" output.mpg 


here the frame rate (12) for the video is set, the format “image_% 010d.png” means that the pictures will be searched as image_0000000001.png, image_0000000002.png, etc., that is, in printf format)



3. Cut the video into pictures


 ffmpeg -i video.mpg image%d.jpg 


This command will create files image1.jpg, image2.jpg, etc., the formats PGM, PPM, PAM, PGMYUV, JPEG, GIF, PNG, TIFF, SGI are also supported.



4. Convert video to iPod / iPhone format


 ffmpeg -i source_video.avi input -acodec aac -ab 128kb -vcodec mpeg4 -b 1200kb -mbd 2 -flags +4mv+trell -aic 2 -cmp 2 -subcmp 2 -s 320x180 -title X final_video.mp4 


Explanations:





5. Convert video to PSP format


 ffmpeg -i source_video.avi -b 300 -s 320x240 -vcodec xvid -ab 32 -ar 24000 -acodec aac final_video.mp4 


Explanations:





6. Extract audio track from video and save to mp3


 ffmpeg -i source_video.avi -vn -ar 44100 -ac 2 -ab 192K -f mp3 sound.mp3 


Explanations:





7. Convert wav to mp3


 ffmpeg -i son_origine.wav -vn -ar 44100 -ac 2 -ab 192 -f mp3 son_final.mp3 


8. Convert .avi to .mpg


 ffmpeg -i video_origine.avi video_finale.mpg 


9. Convert .mpg to .avi


 ffmpeg -i video_origine.mpg video_finale.avi 


10. Convert .avi to .gif (without compression)


 ffmpeg -i video_origine.avi gif_anime.gif 


11. Add sound to the video


 ffmpeg -i son.wav -i video_origine.avi video_finale.mpg 


12. Convert .avi to .flv


 ffmpeg -i video_origine.avi -ab 56 -ar 44100 -b 200 -r 15 -s 320x240 -f flv video_finale.flv 


13. Convert .avi to .dv


 ffmpeg -i video_origine.avi -s pal -r pal -aspect 4:3 -ar 48000 -ac 2 video_finale.dv 


or



 ffmpeg -i video_origine.avi -target pal-dv video_finale.dv 


14. Convert .avi to mpeg for DVD players


 ffmpeg -i source_video.avi -target pal-dvd -ps 2000000000 -aspect 16:9 finale_video.mpeg 


Explanations:





15. Compress .avi to DivX


 ffmpeg -i video_origine.avi -s 320x240 -vcodec msmpeg4v2 video_finale.avi 


16. Compress OGG Theora to mpeg DVD


 ffmpeg -i film_sortie_cinelerra.ogm -s 720x576 -vcodec mpeg2video -acodec mp3 film_termin.mpg 


17. Compress .avi to SVCD mpeg2


NTSC format:



 ffmpeg -i video_origine.avi -target ntsc-svcd video_finale.mpg 


PAL format:



 ffmpeg -i video_origine.avi -target pal-svcd video_finale.mpg 


18. Compress .avi to VCD mpeg2


NTSC format:



 ffmpeg -i video_origine.avi -target ntsc-vcd video_finale.mpg 


PAL format:



 ffmpeg -i video_origine.avi -target pal-vcd video_finale.mpg 


19. Multi-pass encoding with ffmpeg


 ffmpeg -i fichierentree -pass 2 -passlogfile ffmpeg2pass fichiersortie-2 


Translator's Note :

I suggest in the comments to bring other useful ffmpeg commands, there are much more of them than 19.;)

Source: https://habr.com/ru/post/171213/



All Articles