Skip to content

Instantly share code, notes, and snippets.

@TommyPKeane
Last active September 12, 2023 00:50
Show Gist options
  • Save TommyPKeane/81d012eee309e3a0a403dba73f67b494 to your computer and use it in GitHub Desktop.
Save TommyPKeane/81d012eee309e3a0a403dba73f67b494 to your computer and use it in GitHub Desktop.
ffmpeg Syntax and Examples in bash as a commandline utility for Video and Image Parsing, Conversion, Creation, and Editing (https://ffmpeg.org/ffmpeg.html)
# Create looping (infinite) GIF (filename.gif) from a given MP4 Video (filename.mp4)
ffmpeg -i filename.mp4 -loop 0 filename.gif
# Create looping (infinite) GIF (filename.gif) from a given MP4 Video (filename.mp4)
# that is resized to a fixed height of 240 [px] while preserving the original
# aspect-ratio of the input video
ffmpeg -i filename.mp4 -vf "scale=-1:240" -loop 0 filename.gif
# Create looping (infinite) GIF (filename.gif) from a given MP4 Video (filename.mp4)
# that is resized to a fixed width of 300 [px] while preserving the original
# aspect-ratio of the input video
ffmpeg -i filename.mp4 -vf "scale=300:-1" -loop 0 filename.gif
# Create an MP4 Clip from an MKV Video while also scaling to 640 [px] width,
# preserving the original aspect ratio. Here we start at 19min 57sec and we
# create a 47sec clip offset from that starting timestamp.
#
# - `-ss`: Give the start timestamp for the clip in MM:SS.sss
# - `-t`: Give the total duration of the clip (offset from `-ss`) in MM:SS.sss
# - `-vf`: Video Filter string of valid commands for processing the video file
ffmpeg -ss 19:57.000 -i "/path/to/input_filename.mkv" -t 00:47.000 -vf "scale=640:-1" "/path/to/output_filename.mp4"
# Create a 3.45 second OggVorbis Audio Clip from an M4A Audio File
#
# - `-ss`: Give the start timestamp for the clip in SS.sss
# - `-t`: Give the total duration of the clip (offset from `-ss`) in SS.sss
ffmpeg -i "/path/to/input_filename.m4a" -ss 0 -t 3.45 "/path/to/output_filename.ogg"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment