Skip to content

FFMPEG

Basic commands

Install FFMPEG

sh
brew install ffmpeg

Convert formats

sh
ffmpeg -i input.wav output.flac
ffmpeg -i input.avi output.mp4
convert -density 300 input.pdf output.jpg

Compress files

sh
ffmpeg -i input.mp4 -b 800k output.mp4
convert -density 20x20 -quality 60 -compress jpeg photo.jpeg output.jpeg

Combine jpegs in a pdf

sh
convert *.jpg output.pdf

Scale video

sh
ffmpeg -i input.mp4 -vf scale=1280:720 -preset slow -crf 18 output.mp4

Scale images

sh
ffmpeg -i screen.png -vf scale=320:132 output_320x240.png

Change playback speed

sh
ffmpeg -i toggle.mov -filter:v "setpts=PTS/5" output.mov

To concate all audios First create a file, in this case mylist.txt, and then add all audio file names For example - file 'A Journey Within.wav' Then, run this to concate all audio files together in one file

sh
ffmpeg -f concat -safe 0 -i mylist.txt -c copy output.wav

Create a video from a static image with an audio

sh
ffmpeg -loop 1 -i image.jpg -i audio.wav -shortest output.mp4

Replace audio in a video

sh
ffmpeg -i video.mp4 -i replace.mp3 -c:v copy -map 0:v:0 -map 1:a:0 output.mp4

Combine all videos into one

Create a txt file first and add all files in it by using echo

sh
echo file input1.mov >> mylist.txt
echo file input2.mov >> mylist.txt
echo file input3.mov >> mylist.txt

Then, to combine all videos into one

sh
ffmpeg -f concat -i mylist.txt -c copy output.mp4