Skip to content

Instantly share code, notes, and snippets.

@guoqiao
Last active December 8, 2022 23:02
Show Gist options
  • Save guoqiao/15f3bae286f58974cdbe2093a4ac9422 to your computer and use it in GitHub Desktop.
Save guoqiao/15f3bae286f58974cdbe2093a4ac9422 to your computer and use it in GitHub Desktop.
ffmpeg cheatsheet

usage syntax:

ffmpeg input(s) [codec options] output(s)

convert video format:

ffmpg -i input.mov -c copy output.mp4

RTMP stream to flv file, re-encode:

ffmpeg -i rtmp://IP:PORT/live/stream -c:a aac -strict -2 -c:v h264 output.flv

MP4 file input to RTMP stream, re-encode, and loop forever:

ffmpeg -re -stream_loop -1 -i input.mp4 -c:a aac -strict -2 -c:v h264 -f flv rtmp://IP:PORT/live/stream

HLS stream input to RTMP stream, re-encode:

ffmpeg -i http://IP:PORT/hls/streamname/index.m3u8 -c:a aac -strict -2 -c:v h264 -f flv rtmp://IP:PORT/live/streamname

concat/join/merge multiple videos:

cat input.txt
file '/path/to/file1'
file '/path/to/file2'
file '/path/to/file3'

ffmpeg -f concat -i input.txt -c copy output.mp4

remove the first 3s from the video:

ffmpeg -ss 00:00:03 -i input.mp4 -c copy output.mp4
# -ss: seek to position, must before -i
# not exactly, will seek to the closest point before position.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment