Skip to content

Instantly share code, notes, and snippets.

@psyburr
Last active April 7, 2024 03:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save psyburr/10fa63d954f774103be26584fd8c7cfd to your computer and use it in GitHub Desktop.
Save psyburr/10fa63d954f774103be26584fd8c7cfd to your computer and use it in GitHub Desktop.
useful ffmpeg examples difficult to remember
  • Increase/decrease audio tempo/speed this is represented as a percentage. ie: 1.5=1½× normal speed

atempo={0.5-100}

  • Remove logo in bottom right-hand corner

delogo=x=620:y=495:w=330:h=40

  • Fade in/out video (fade out is dependent on number of frames)

fade=in:0:500,fade=out:21500:400

  • Loop a stream N number of times (or infinitely if '-1')

-stream_loop -1 -i <inputfile> this must go BEFORE the stream you want to loop

  • Clip a video into segments quickly (bsf can be applied, but results are unreliable)

<inputfile> -segment_time <UNIX time, 00:00:00.00 or 00s> -f segment -reset_timestamps 1 <outfile>_%03d.<ext>

  • Fade in/out audio (these durations are in seconds, not in frames like video)

-af afade=t=in:ss=<start-time>:d=<duration>,afade=t=out:st=<fade-start>:d=<fade-duration>

  • Record monitor source audio in lossless format

ffmpeg -f pulse -i default output.wav or ffmpeg -i pulse -i default output.opus for compressed

  • Wipe all metadata from a media file. Use as an option to other ffmpeg command or by itself.

-map_metadata 1

Honerable Mentions

  • count the number of video frames in a file quickly

mediainfo --Output="Video;%FrameCount%" <inputfile>

  • Flip a video horizontally useful for avoiding contentid scans

-i input.mp4 -vf "hflip" output.mp4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment