Last active
December 2, 2019 14:21
-
-
Save drmats/65b4d0695720f1e401ec733dae6cf2b5 to your computer and use it in GitHub Desktop.
FFmpeg commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# linux screengrab | |
ffmpeg -f x11grab -video_size 1024x768 -i $DISPLAY -s 1024x768 -r 25 -preset ultrafast -b:v 10M output.mp4 | |
# windows screengrab | |
ffmpeg -f gdigrab -video_size 1920x1200 -i desktop -s 1920x1200 -r 30 -preset ultrafast -b:v 10M wingrab.mp4 | |
# screengrab with visible region | |
ffmpeg -f x11grab -video_size 1080x608 -show_region 1 -grab_x 100 -grab_y 100 -i $DISPLAY -s 1080x608 -r 25 -preset ultrafast -b:v 10M output.mp4 | |
# video cut (no rerender) | |
ffmpeg -ss 00:00:00.00 -i input.mp4 -c copy -t 01:01:00.00 output.mp4 | |
# animated gif | |
ffmpeg -ss 00:00:43.5 -i input.mp4 -t 00:00:02.00 -r 15 -s 480x270 output.gif | |
# double the speed of the video | |
ffmpeg -i input.mp4 -filter:v "setpts=0.5*PTS" output.mp4 | |
# h265 encode | |
ffmpeg -i input.mp4 -c:v libx265 -crf 28 -c:a aac -b:a 128k output.mp4 |
Fade in and out (audio and video) for a 16-seconds video:
ffmpeg -i input.mp4 -filter_complex "[0:v]fade=type=in:duration=1,fade=type=out:duration=1:start_time=15[v];[0:a]afade=type=in:duration=1,afade=type=out:duration=1:start_time=15[a]" -map "[v]" -map "[a]" output.mp4
DnxHD:
fmpeg -i input.mp4 -vcodec dnxhd -acodec pcm_s16le -s 1920x1080 -r 30000/1001 -b:v 36M -pix_fmt yuv422p -f mov output.mov
Davinci output to MP4:
ffmpeg -i input.mov -vf yadif -codec:v libx264 -crf 1 -bf 2 -flags +cgop -pix_fmt yuv420p -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart output.mp4
hardware transcoding (nvidia)
h264/AAC -> DNxHR/PCM (with hardware decoding, deinterlace and clip-cut)
ffmpeg -ss 00:03:50.00 -c:v h264_cuvid -i ./CLIP.MTS -vf bwdif -c:v dnxhd -c:a pcm_s16le -profile:v dnxhr_sq -pix_fmt yuv422p -f mov -t 00:00:15.00 ./clip.mov
h264/AAC -> DNxHR/PCM (with hardware decoding and clip-cut)
ffmpeg -ss 00:04:45.00 -c:v h264_cuvid -i ./CLIP.MP4 -c:v dnxhd -c:a pcm_s16le -profile:v dnxhr_sq -pix_fmt yuv422p -f mov -t 00:00:10.00 ./clip.mov
DNxHR/PCM -> h264/AAC (yt)
ffmpeg -i clip.mov -codec:v h264_nvenc -bf 2 -flags +cgop -pix_fmt yuv420p -b:v 12M -codec:a aac -strict -2 -b:a 384k -r:a 48000 -movflags faststart clip.mp4
DNxHR/PCM -> h265/AAC (hq)
ffmpeg -i ./clip.mov -c:v hevc_nvenc -preset slow -rc cbr_hq -cbr 1 -2pass 1 -b:v 20M -c:a aac -b:a 384k ./clip.mp4
DNxHR/PCM -> h265/AAC (yt)
ffmpeg -i ./clip.mov -c:v hevc_nvenc -preset slow -rc vbr_hq -b:v 12M -c:a aac -b:a 384k ./clip.mp4
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://trac.ffmpeg.org/wiki/How%20to%20speed%20up%20/%20slow%20down%20a%20video