ffmpeg commands reminder

Convert video with x264 encoder

ffmpeg -i input -c:v libx264 -crf 23 -maxrate 1M -bufsize 2M output.mp4

0<crf<51 (default: 23) (lossless: 0)

To only change video bitrate/quality but keep audio :

ffmpeg -i input.avi -c:v libx264 -b:v 720k -crf 33 -c:a copy output.mkv

Easy way --> choose a preset

ffmpeg -i input.mp4 -c:v libx264 -preset superfast output.mp4

Optimize video for fast streaming :

ffmpeg -i INPUT.mp4 -c copy -movflags +faststart STREAMABLE_OUTPUT.mp4

Get video file informations

ffmpeg -i video.flv -hide_banner

Split video to images

ffmpeg -i video.flv image%d.jpg

Extract mp3 from video

ffmpeg -i video1.avi -vn -ar 44100 -ac 2 -ab 192 -f mp3 audio3.mp3

other links :

ffmpeg official website :

Using ffmpeg Filters

Doc: https://ffmpeg.org/ffmpeg-filters.html

Concatenate videos

For video only (w/o audio)

ffmpeg -i 1.mp4 -i 2.mp4 ---filter_complex "[0:0][1:0]concat=n=2:v=1:a=0" 1and2.mp4

For both, video and audio

ffmpeg -i 1.mp4 -i 2.mp4 ---filter_complex "[0][1]concat=n=2:v=1:a=1" 1and2.mp4

Sometimes it's necesary to change SAR to 1:1, just use setsar=1 filter.

Crop a rectangle inside a video

ffmpeg -i full.mp4 -filter:v 'crop=width:height:x:y' cropped.mp4

Transform a vertical video (smartphone) to horizontal video with blur

9:16 --> 16:9

Using ffmpeg filters. 1st, split videos, crop and blur the background from original, then overlay original and rescale

Dot notation :

 input --> split -------------------------------> overlay --> output
        │                                          ^
        │[copy]                           [blurred]│
        └──────> crop ──> scale ──> gblur ─────────┘

Source : https://stackoverflow.com/a/54618683

ffmpeg -i vertical.mp4 -vf 'split[original][copy];[copy]scale=ih*16/9:-1,crop=h=iw*9/16,gblur=sigma=20,eq=brightness=-0.1[blurred];[blurred][original]overlay=(W-w)/2:(H-h)/2,scale=1920:1080' horizontal.mp4

Note : CPU intensive !

view raw ffmpeg commands.md hosted with ❤ by GitHub

Example of vertical video to horizontal :


Laissez un commentaire

Votre adresse de messagerie ne sera pas publiée.

Generic filters
Exact matches only
Filter by Custom Post Type