July 4, 2020


convert any video to mp4 (h264, AAC)

and adopt it for playing in browser
ffmpeg -i input.avi -movflags +faststart -pix_fmt yuv420p output.mp4

Option -movflags faststart moovs atom at the front of the file to allow video play in streaming mode

convert any video to mp4, resize to 720p and compreess it

ffmpeg -i input.avi -movflags +faststart -pix_fmt yuv420p -crf 30 -vf scale=-1:720 output.mp4 -crf 23 — default compression
-crf 25 — middle compression
-crf 35 — high compression

just remove audio and keep video untoched

ffmpeg -i input.avi -vcodec copy -an output.mp4

Remove iPhone HDR from video

-vf zscale=t=linear:npl=100,format=gbrpf32le,zscale=p=bt709,tonemap=tonemap=hable:desat=0,zscale=t=bt709:m=bt709:r=tv,format=yuv420p -colorspace bt709 -color_primaries bt709 -color_trc bt709

Convert all files in folder to fullHD

for i in *.mp4; do ffmpeg -i "$i" -movflags +faststart -pix_fmt yuv420p -crf 25 -vf scale=-1:1080 ~/Downloads/"${i%.*}.mp4"; done