1,4 KiB
1,4 KiB
Playing with ffmpeg
...to extrac, manipulate and reassmbly frames
Frames extraction
In running the command take note about original video fps
ffmpeg -i video.mp4 %05d.png
Video creation from frames
In running the command take note about original video fps
ffmpeg -framerate 30 -pattern_type glob -i '*.png' -c:v libx264 -pix_fmt yuv420p paint.mp4
Video warping from images
Using CUDA:
ffmpeg -y -fflags +genpts -r 30 -hwaccel cuda -hwaccel_output_format cuda -pattern_type glob -i '*.png' -vf "setpts=100*PTS,minterpolate=fps=24:scd=none" -pix_fmt yuv420p -c:v h264_nvenc "test01.mp4"
Add silent audio track to a video (with no audio tack)
ffmpeg -i "test.mp4" -f lavfi -i anullsrc=cl=stereo:r=48000 -shortest -y "test_silent.mp4"
Useful if you want to merge more than one *.mp4 video and some of these ave no audio track Make sure that audio rate for the silent track matches the one of file(s) you are going to merge with it
Crop a video to a well defined size
ffmpeg -i test_silent.mp4 -filter:v "crop=512:512:1200:200" -c:a copy te.mp4
Crop to size 512x512 starting from 1200,200 where 0,0 is the top left corner
Concatenation of two videos
Once you've performed tthe two steps above (same size and a silent audio if needed):
ffmpeg -i te.mp4 -i 20231104021840.mp4 -filter_complex "[0:v][0:a][1:v][1:a]concat=n=2:v=1:a=1" -vsync vfr output.mp4