Skip to content

Instantly share code, notes, and snippets.

@alifeee
Last active October 28, 2024 16:13
Show Gist options
  • Save alifeee/9e968dbf9f380ab4b15cda8d05d2a89e to your computer and use it in GitHub Desktop.
Save alifeee/9e968dbf9f380ab4b15cda8d05d2a89e to your computer and use it in GitHub Desktop.
FFmpeg commands

FFmpeg Commands

see video information

# see all information
ffmpeg -i input.mp4
# format resolution nicely
ffprobe -v error -select_streams v:0 -show_entries stream=width,height -of csv=s=x:p=0 input.mp4

resize video

# limit height to 720px
ffmpeg -i input.mp4 -vf scale="trunc(oh*a/2)*2:720" out.mp4
# limit width to 720px
ffmpeg -i input.mp4 -vf scale="720:trunc(ow/a/2)*2" out.mp4

Turn mp4 into gif

Used here. From here.

ffmpeg -y -i input.mp4 -filter_complex "fps=5,scale=480:-1:flags=lanczos,split[s0][s1];[s0]palettegen=max_colors=32[p];[s1][p]paletteuse=dither=bayer" output.gif

Turn mp4 into webm

For webm videos, two passes should be made. on Windows, redirect to NUL instead of /dev/null

ffmpeg  -i input.mp4  -b:v 0  -crf 30  -pass 1  -an -f webm -y /dev/null
ffmpeg  -i input.mp4  -b:v 0  -crf 30  -pass 2  output.webm

Export frame from mp4

Select frame 34

ffmpeg -i <input> -vf "select=eq(n\,34)" -vframes 1 out.png

mute a video

ffmpeg -i $input_file -c copy -an $output_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment