FFmpeg cmds collection

Brief

This article collected the common cmds of ffmpeg, it will continue to update, hope it is useful for you.

The common cmds of ffmpeg

ffmpeg -i input.avi -pix_fmt rgb24 output.tiff
ffmpeg -i input.mkv -vcodec h264 -b:v 1.5M -acodec aac -b:a 48K output.mp4
ffmpeg -i test.mp4 test.gif
ffmpeg -ss 00:00:10 -t 3 -i test.mp4 test.gif
ffmpeg -i test.mp4 -b:v 2048k test.gif
ffmpeg -f gif -i test.gif test.mp4
ffmpeg -f gif -i test.gif test.mkv
ffmpeg -i test.mp4 -r 10 %06d.jpg;

ffmpeg -i input.mp4 -vf subtitles=text.srt output.mp4
ffmpeg -i “C:\Users\Engine - Turboshaft.mp4” -vf subtitles='D:\input.ass' output.mp4
ffmpeg -i “C:\Users\Engine - Turboshaft.mp4” -vf “subtitles='D:\input.ass'“ output.mp4
ffmpeg -i “C:\Turboshaft.mp4” -filter_complex “subtitles='D:\input.ass'“ output.mp4
ffmpeg -i output.mkv -an -vn -bsf:s mov2textsub -scodec copy -f rawvideo sub.txt
ffmpeg -i output.mkv -an -vn -c:s copy -f rawvideo -map 0:s sub2.txt
ffmpeg -i output.mkv -an -vn -scodec copy sub3.ass
ffmpeg -ss 00:00:15 -t 00:00:05 -i input.mp4 -vcodec copy -acodec copy output.mp4
ffmpeg -i input.mp4 -b:v 2000k output.mp4
ffmpeg -i input.mp4 -b:v 2000k -bufsize 2000 output.mp4
ffmpeg -i input.mp4 -b:v 2000k -bufsize 2000k -maxrate 2500k -minrate 1500k output.mp4
ffmpeg -i input.mp4 -vcodec copy -an -f m4v output.h264
ffmpeg -i input.mp4 -vf scale=960:540 output.mp4
ffmpeg -i input.mp4 -vf scale=960:-1 output.mp4 // keep ratio of w/h264
ffmpeg -i test.mp4 -vf “transpose=1” out.mp4
ffmpeg -i input.mp4 -vf transpose=1 output.mp4
ffmpeg -i test.mp4 -vf “transpose=2” out.mp4
ffmpeg -i test.mp4 -vf “transpose=3” out.mp4
ffmpeg -i test.mp4 -vf “transpose=0” out.mp4
ffmpeg -i test.mp4 -vf hflip out.mp4
ffmpeg -i test.mp4 -vf vflip out.mp4
ffmpeg -i test.mp4 -i test.png -filter_complex “overlay=10:10” watermark.mp4
ffmpeg -i input.mp4 -i warter.png -filter_complex “[1:v]scale=120:120[s];[0:v][s]overlay=10:10” out.mp4
ffmpeg -i input.mp4 -i logo.png -filter_complex overlay output.mp4
ffmpeg -i input.mp4 -i logo.png -filter_complex overlay=W-w output.mp4
ffmpeg -i input.mp4 -i logo.png -filter_complex overlay=0:H-h output.mp4
ffmpeg -i input.mp4 -i logo.png -filter_complex overlay=W-w:H-h output.mp4

// -vf delogo=x:y:w:h[:show], x:y, Top left coordinates,w:h logo w/h,show setbox,default 0
ffmpeg -i input.mp4 -vf delogo=1:1:144:144:1 output.mp4
ffmpeg -i input.mp4 -i warter.png -filter_complex “[0:v][1:v]overlay[logo];[logo]subtitles=av1.srt[sub]” -map [sub] -map 0:a output.mp4
ffmpeg -i input.mp4 -i warter.png -filter_complex “[1:v]scale=120:120[simg];[0:v][simg]overlay[logo];[logo]subtitles=av1.srt[sub]” -map [sub] -map 0:a output.mp4

add subtitle and water file at one time:
ffmpeg -i input.mp4 -i warter.png -filter_complex “[0:v][1:v]overlay[logo];[logo]subtitles=av1.srt[sub]” -map [sub] -map 0:a output.mp4 ffmpeg -i input.mp4 -i warter.png -filter_complex “[1:v]scale=120:120[simg];[0:v][simg]overlay[logo];[logo]subtitles=av1.srt[sub]” -map [sub] -map 0:a output.mp4
[1:v], 1 is the original video, 0 is the input.mp4, 1 is the warter.png,if there are secound water file , it will be 2,simg replace the first midle file of the first filter, self define。
[1:v]scale=120:120[simg],scale the warter file of number 1,[0:v][simg]overlay[logo] integrate the video and logo,overlay=0+t*10:0,move the logo based on time

ffmpeg -i input.mp4 -i warter.png -filter_complex “[1:v]scale=120:120[s];[0:v][s]overlay=x=’if(gte(t,0), 0+mod(t,5)*20, NAN)’:y=0[logo];[logo]subtitles=av1.srt[sub]” -map [sub] -map 0:a output.mp4

mac cmd:
ffmpeg -y -i 1.mp4 -vf “drawtext=fontfile=/System/Library/Fonts/PingFang.ttc: text=’mytest: myname ‘:x=10:y=10:fontsize=16:fontcolor=DarkGreen:shadowy=2” out.mp4
win10 cmd, copy one font,copy /c/Windows/Fonts/msyhbd.ttc

ffmpeg -y -i 1.mp4 -vf “drawtext=fontfile=msyhbd.ttc: text=’mytest: myname’:x=80:y=32:fontsize=18:fontcolor=White” out.mp4

ffmpeg -i input.mp4 -r 1 -q:v 2 -f image2 pic-%03d.jpeg
ffmpeg -i input.mp4 -ss 00:00:20 -t 10 -r 1 -q:v 2 -f image2 pic-%03d.jpeg
ffmpeg -i pic-001.jpeg -s 1440x1440 -pix_fmt yuv420p xxx3.yuv
ffmpeg -i 001.mp3 -i example.%d.jpg -s 1024x768 -vcodec mpeg4 rebuild.mp4
ffmpeg -i input.mp4 -profile:v baseline -level 3.0 output.mp4
ffmpeg -i input.mp4 -profile:v main -level 4.2 output.mp4
ffmpeg -i input.mp4 -profile:v high -level 5.1 output.mp4
ffmpeg -i input.mp4 -c:v libx264 -x264-params “profile=high:level=3.0” output.mp4
ffmpeg -i input_file.265 -vframes 100 output.yuv
ffmpeg -i input_file.yuv -vcodec h264 output_file.264
ffmpeg -i input -c:v libx264 -profile:v main -preset:v fast -level 3.1 -x264opts crf=18
ultrafast, superfast, veryfast, faster, fast, medium, slow, slower, veryslow and placebo.
CRF(Constant Rate Factor): range 0-51: 0: no lost, 23 is default, 51 worst。 normal: 18-28.

ffmpeg -i input_file -vcode hevc output.h265
ffmpeg -i input_file -vcodec h264 -s 1280x720 output_file
ffmpeg -i input_file -vcodec h264 -b:v 10M -b:a 128K output_file
ffmpeg -ss 0:05:00 -t 0:1:30 -i input_file -vcodec copy -acodec copy output_file
ffmpeg -ss 300 -t 90 -i input_file -vcodec copy -acodec copy output_file
ffmpeg -i input_file -vcodec copy -an output_file_video
ffmpeg -i input_file -acodec copy -vn output_file_audio
ffmpeg –i video_file –i audio_file –vcodec copy –acodec copy output_file
ffmpeg –i input_file –r 1 –f image2 image-%3d.jpeg
ffmpeg -i input_file -vcodec rawvideo -an output_file.yuv
ffmpeg -i input_file -vcodec rawvideo -an -pix_fmt yuv420p10le output_file.yuv
ffmpeg -ss 00:01:57 -t 1 -i in.mp4 -an -c:v rawvideo -pix_fmt yuv420p -vframes 3 out.yuv
ffmpeg -ss 00:01:57 -t 1 -i in.mp4 -an -c:v rawvideo -pix_fmt rgb24 -vframes 3 out.rgb
ffmpeg -ss 00:01:57 -t 1 -i in.mp4 -an -c:v rawvideo -pix_fmt gbrp10le -vframes 3 out.rgb
ffplay -s 1280x720 -pix_fmt yuv420p10le -i 10bit_720p.yuv
ffmpeg -s 1280x720 -i 8bit_720p.yuv -pix_fmt yuv420p10le 10bit_720p.yuv
ffmpeg –s w*h –pix_fmt yuv420p –i input.yuv –vcodec mpeg4 output.mp4
ffmpeg –i input_file –vcodec h264 –bf 0 –g 25 –s 854x480 –an –f m4v output_file
-bf: set the B frame count,-g control the frame interval -f control the file format

connect two video file: create: concat.txt:
file ‘orig_20160616113303_0.avi’
file ‘orig_20160616113303_1.avi’
run cmd:
ffmpeg -f concat -i concat.txt -c copy orig_20160616113303_merge.avi

ffmpeg -pix_fmts
ffmpeg -pix_fmt yuv420p -s 176x144 -i carphone_qcif.yuv -pix_fmt nv12 carphone_qcif_nv12.yuv
ffmpeg -s:v 1920x1080 -r 25 -i input.yuv -vf scale=960:540 -c:v rawvideo -pix_fmt yuv420p out.yuv
ffmpeg -i 720P.264 -s 1280x720 -pix_fmt yuv422p 720P-out.yuv
ffmpeg -i 720P.264 -vframes 300 720P-out.yuv
ffmpeg -i 720P.264 720P-out.yuv
ffmpeg -s wxh -pix_fmt yuv420p -i input.yuv -vcodec mpeg4 output.avi
ffmpeg -s wxh -pix_fmt yuv420p -i input.yuv -vcodec h264 output.avi
ffmpeg -f h264 -i source.264 -c:v libx264 -an dest.avi
Use -c:v copy instead to copy the source stream without re-encoding

ffmpeg.exe -i BQSquare_416x240_37.avi -f rawvideo -vcodec copy xx.264
ffmpeg.exe -i BQSquare_416x240_37.avi -f rawvideo -vcodec copy -vframes 100 xx.264

if you want to extract 260frames while the fps is 26, than set : -ss 10.0, 10.0=260/26
Extract some YUV frames from large yuv File

ffmpeg -s widthxheight -i input.yuv -c:v rawvideo -filter:v “select=’gt(n, -1)’” -vframes 30 out30.yuv
ffmpeg -s widthxheight -i input.yuv -c:v rawvideo -filter:v “select=’between(n, 0, 29)’” out30.yuv
ffmpeg -r 1 -ss 0 -i input.yuv -vcodec copy -vframes 30 output.yuv
ffmpeg -s widthxheight -i input.yuv -c:v rawvideo -filter:v “select=’between(n, 30, 100)’” out.yuv

//Select only frames contained in the 10-20 time interval: //select=between(t,10,20)
ffmpeg -s widthxheight -i input.yuv -c:v rawvideo -filter:v “select=’between(t, 10, 20)’” out.yuv
ffmpeg -i killer.mp4 -an -c:v rawvideo -pix_fmt yuv420p ouy.yuv
ffmpeg -i killer.mp4 -vn -ar 44100 -ac 2 -f s16le out.pcm
ffplay -ar 44100 -ac 2 -f s16le out.pcm
ffmpeg -re -i 1.mp4 -vcodec copy -acodec copy -b:v 800k -b:a 32k -f flv rtmp://localhost/live

change the speed of video playing
ffmpeg -i input.mp4 -vf “setpts=0.5PTS” output.mp4
ffmpeg -i input.mp4 -vf “setpts=4.0
PTS” output.mp4 //reduce the speed

ffmpeg -i input.avi -pix_fmt rgb24 output.tiff //compressed file
ffmpeg -i input -compression_algo raw -pix_fmt rgb24 output.tiff // uncompressed file
ffmpeg -v error -h encoder=tiff

ffmpeg -vsync 0 -hwaccel cuda -init_hw_device opencl=ocl -filter_hw_device ocl -extra_hw_frames 3 -threads 16 -c:v hevc_cuvid -i inputhdr.mp4 -vf “format=p010,hwupload,tonemap_opencl=tonemap=mobius:param=0.01:desat=0:r=tv:p=bt709:t=bt709:m=bt709:format=nv12,hwdownload,format=nv12” -c:a copy -c:s copy -c:v hevc_nvenc -max_muxing_queue_size 8192 outputsdr.mp4

(Continue update…)

© 2024 Color Image Video Technology All Rights Reserved. Site UV times Site PV times
Theme by hiero