|
|
|
|
|
by paol
1903 days ago
|
|
Gladly. There's even some relatively advanced stuff in there: # Save a RTSP stream to file
ffmpeg -i rtps://someserver/somevideo -c copy out.mp4
# encoding quality settings examples
# H264
ffmpeg -i input.mp4 -a:c copy -c:v libx264 -crf 22 -preset slower -tune film -profile:v high -level 4.1 output.mp4
# H264 10bit (must switch to a different libx264 version)
LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu/x264-10bit ffmpeg -i input.mp4 -a:c copy -c:v libx264 -crf 22 -preset slower -tune film -pix_fmt yuv420p10le -profile:v high10 -level 5.0 output.mp4
# resize
ffmpeg -i in.mp4 -s 480x270 -c:v libx264 out.mp4
# change source fps
ffmpeg -r 10 -i in.mp4 out.mp4
# resample fps
ffmpeg -i in.mp4 -r 10 out.mp4
# extract the audio from a video
ffmpeg -i inputfile.mp4 -vn -codec:a copy outputfile.m4a
# merge audio and video files
ffmpeg -i inputfile.mp4 -i inputfile.m4a -codec copy outputfile.mp4
# cut (reencoding)
# set the start time and duration as HH:MM:SS
ffmpeg -ss 00:00:40.000 -i input.mp4 -t 00:00:10 -c:v libx264 output.mp4
# set the start time and duration as seconds
ffmpeg -ss 40.0 -i input.mp4 -t 10.0 -c:v libx264 output.mp4
# skip an exact number of frames at the start (100)
ffmpeg -i input.mp4 -vf 'select=gte(n\,100)' -c:v libx264 output.mp4
# cut (w/o reencoding - cut times will be approximate)
ffmpeg -ss 40.0 -i input.mp4 -t 10.0 -c copy output.mp4
# save all keyframes to images
ffmpeg -i video.mp4 -vf "select=eq(pict_type\,I)" -vsync vfr video-%03d.png
# encode video from images (image numbering must be sequential)
ffmpeg -r 25 -i image_%04d.jpg -vcodec libx264 timelapse.mp4
# flip image horizontally
ffmpeg -i input.mp4 -vf hflip -c:v libx264 output.mp4
# crop and concatenate 3 videos vertically
ffmpeg -i cam_4.mp4 -i cam_5.mp4 -i cam_6.mp4 -filter_complex "[0:v]crop=1296:432:0:200[c0];[1:v]crop=1296:432:0:200[c1];[2:v]crop=1296:432:0:230[c2];[c0][c1][c2]vstack=inputs=3[out]" -map "[out]" out.mp4
# 2x2 mosaic (all inputs must be same size)
ffmpeg -i video1.mp4 -i video2.mp4 -i video3.mp4 -i video4.mp4 -filter_complex "[0:v][1:v]hstack=inputs=2[row1];[2:v][3:v]hstack=inputs=2[row2];[row1][row2]vstack=inputs=2[out]" -map "[out]" out.mp4
# picture-in-picture
ffmpeg -i video1.mp4 -i video2.mp4 -filter_complex "[1:v]scale=iw/3:ih/3[pip];[0:v][pip]overlay=main_w-overlay_w-20:main_h-overlay_h-20[out]" -map "[out]" out.mp4
# print framerate of every file in dir
for f in *.mp4; do echo $f; mediainfo $f|grep "Frame rate"; done
# print selected info of every file in dir in CSV format
for f in *.mp4; do echo -n $f,; mediainfo --Inform="Video;%Duration%,%FrameCount%,%FrameRate%" $f; done
|
|
Wow, I didn't know there was a "keyframes" feature on Ffmpeg. This is awesome, thanks for sharing.