Difference between revisions of "FFMPEG Commands"

From Hawk Wiki
Jump to: navigation, search
(use ffpreset in windows)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 +
=== General ===
 +
-y :overwrite<br>
 +
-s 1920x1080 : width x height. output size
 +
----
 
=== Extracting images (jpeg) from a video: ===
 
=== Extracting images (jpeg) from a video: ===
 
ffmpeg -i foo.avi -f image2 f%03d.jpg<br>
 
ffmpeg -i foo.avi -f image2 f%03d.jpg<br>
Line 20: Line 24:
 
//padding 90px top and bottom<br>
 
//padding 90px top and bottom<br>
 
ffmpeg -i image.%04d.jpg -vcodec libx264 -b 15M -f mov -g 30 -bf 3 -b_strategy 1 -coder 1 -qmin 20 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 1 -flags2 +fastpskip -dts_delta_threshold 1 -acodec libfaac -ab 192k -y -vf "[in]pad=1280:900:0:90:black[pd];movie=o.png, scale=1280:900 [mask];[pd][mask] overlay=0:0:1 [out]" -s 1280x720 output_padding90.mov
 
ffmpeg -i image.%04d.jpg -vcodec libx264 -b 15M -f mov -g 30 -bf 3 -b_strategy 1 -coder 1 -qmin 20 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 1 -flags2 +fastpskip -dts_delta_threshold 1 -acodec libfaac -ab 192k -y -vf "[in]pad=1280:900:0:90:black[pd];movie=o.png, scale=1280:900 [mask];[pd][mask] overlay=0:0:1 [out]" -s 1280x720 output_padding90.mov
 +
----
 +
=== Convert to ipad ===
 +
ffmpeg -y -i input.avi -acodec aac -ar 48000 -ab 128k -ac 2 -s 1024x768 -vcodec libx264 -b:v 1200k -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -subq 7 -trellis 1 -refs 5 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 1200k -maxrate 1200k -bufsize 1200k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 16:9 -r 30 -g 90 -async 2 output.mp4
 +
----
 +
 +
=== Convert to wmv ===
 +
ffmpeg -i winter_clip.mov -vcodec wmv2 -b 12000k -ar 44100 -ab 192k -ac 2 -y -s 720x406 output.wmv
 +
===use ffpreset in windows===
 +
ffmpeg -i "d:\inputfile.avi"  -vcodec libx264 -crf 25 -s 1600x900 -vpre "d:\ffmpeg\ffpresets\libx264-veryslow.ffpreset" -acodec libmp3lame -ar 44100 -ab 128k -f flv tmp.mp4
 +
===convert m4a to mp3 in batch===
 +
for f in *.m4a; do ffmpeg -i "$f" -codec:a libmp3lame -q:a 2 mp3s/"${f%.m4a}.mp3"; done

Latest revision as of 02:16, 12 September 2019

General

-y :overwrite
-s 1920x1080 : width x height. output size


Extracting images (jpeg) from a video:

ffmpeg -i foo.avi -f image2 f%03d.jpg


ffmpeg convert to photo-jpeg

ffmpeg -i input.mov -pix_fmt yuv420p -vcodec mjpeg -qscale 1 output.mov
ffmpeg -i f%03d.jpg -pix_fmt yuv420p -vcodec mjpeg -qscale 1 output.mov


Add Watermark/Overlay & H264 output

ffmpeg -i image.%04d.jpg -vcodec libx264 -b 15M -f mov -g 30 -bf 3 -b_strategy 1 -coder 1 -qmin 20 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 1 -flags2 +fastpskip -dts_delta_threshold 1 -acodec libfaac -ab 192k -y -vf "movie=0:png:o.png, scale=1280x720 [wm];[in][wm] overlay=0:0:1 [out]" -s 1280x720 output_watermark.mov

Another version. For windows build and newer version of ffmpeg
ffmpeg -i image.%04d.jpg -vcodec libx264 -b 15M -f mov -g 30 -bf 3 -b_strategy 1 -coder 1 -qmin 20 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 1 -flags2 +fastpskip -dts_delta_threshold 1 -acodec libfaac -ab 192k -y -vf "movie=o.png, scale=1280:720 [mask];[in][mask] overlay=0:0:1 [out]" -s 1280x720 output_watermark.mov


Split video

use -ss 00:00:01.000 #start position
-t 00:00:30.000 #duration


Padding & Overlay

//padding 90px top and bottom
ffmpeg -i image.%04d.jpg -vcodec libx264 -b 15M -f mov -g 30 -bf 3 -b_strategy 1 -coder 1 -qmin 20 -qmax 51 -sc_threshold 40 -flags +loop -cmp +chroma -me_range 16 -me_method hex -subq 5 -i_qfactor 0.71 -qcomp 0.6 -qdiff 4 -directpred 1 -flags2 +fastpskip -dts_delta_threshold 1 -acodec libfaac -ab 192k -y -vf "[in]pad=1280:900:0:90:black[pd];movie=o.png, scale=1280:900 [mask];[pd][mask] overlay=0:0:1 [out]" -s 1280x720 output_padding90.mov


Convert to ipad

ffmpeg -y -i input.avi -acodec aac -ar 48000 -ab 128k -ac 2 -s 1024x768 -vcodec libx264 -b:v 1200k -flags +loop+mv4 -cmp 256 -partitions +parti4x4+partp8x8+partb8x8 -subq 7 -trellis 1 -refs 5 -coder 0 -me_range 16 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -bt 1200k -maxrate 1200k -bufsize 1200k -rc_eq 'blurCplx^(1-qComp)' -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -level 30 -aspect 16:9 -r 30 -g 90 -async 2 output.mp4


Convert to wmv

ffmpeg -i winter_clip.mov -vcodec wmv2 -b 12000k -ar 44100 -ab 192k -ac 2 -y -s 720x406 output.wmv

use ffpreset in windows

ffmpeg -i "d:\inputfile.avi" -vcodec libx264 -crf 25 -s 1600x900 -vpre "d:\ffmpeg\ffpresets\libx264-veryslow.ffpreset" -acodec libmp3lame -ar 44100 -ab 128k -f flv tmp.mp4

convert m4a to mp3 in batch

for f in *.m4a; do ffmpeg -i "$f" -codec:a libmp3lame -q:a 2 mp3s/"${f%.m4a}.mp3"; done