Skip to content

Videos

Create mp4 w/ fade effects from images

ffmpeg \
-loop 1 -t 5 -i image1.png \
-loop 1 -t 5 -i image2.png \
-loop 1 -t 5 -i image3.png \
-filter_complex \
"[0:v]fade=t=out:st=4:d=1[v0]; \
[1:v]fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v1]; \
[2:v]fade=t=in:st=0:d=1,fade=t=out:st=4:d=1[v2]; \
[v0][v1][v2]concat=n=3:v=1:a=0,format=yuv420p[v]" -map "[v]" video.mp4

ref

Create gif from mp4 w/ ffmpeg ::ref::

ffmpeg -ss 641 -t 39 -i video.mp4 -f gif video.gif

Save still images from mp4

ffmpeg -i video.mp4 -vf scale=1920:-1:flags=lanczos,fps=10 ffout%03d.png
ffmpeg -ss 00:00:05.01 -i myvideo.avi -frames:v 1 myimage.jpg

Create gif from images

convert -resize 640x360 -delay 10x100 -loop 0 ffout*.png output.gif

Create mp4 from images

ffmpeg -framerate 10 -s 1920x1080 -i images/image-%d.png -c:v libx264 -pix_fmt yuv420p -crf 28 video.mp4

Resize gif

convert input.gif -coalesce temp.gif
convert -size [orig-size-of-input-gif] temp.gif -resize [target-size] resized.gif

Trim video

ffmpeg -i movie.mp4 -ss 00:00:03 -t 00:00:08 -async 1 cut.mp4

Convert mov to mp4

ffmpeg -i input.mov -q:v 0 output.mp4

Download video from YouTube

youtube-dl -F <video_url>    # get format
youtube-dl -f 37 <video_url> # download specific format

ref

Speed up or slow down video

ffmpeg -i normal.mp4 -vf "setpts=4*PTS" -an  slow.mp4

Download from m3u8 and rename

note: curl www > tmp.m3u8 if needed

yt-dlp -a tmp.m3u8 -o "%(id)s.%(ext)s"

Download from m4s segments

replace .json?base64_init=1 with .mpd and use yt-dlp

Stabilize video (2-pass)

ffmpeg -i video.mp4 -vf vidstabdetect -f null -
ffmpeg -i video.mp4 -vf vidstabtransform stabilized.mp4

Resize video

ffmpeg -i input.mp4 -vf scale=480:-1 output.mp4

Remove audio

ffmpeg -i input.mp4 -c copy -an output.mp4