Skip to content

Instantly share code, notes, and snippets.

@bramanda48
Last active February 10, 2026 13:01
Show Gist options
  • Select an option

  • Save bramanda48/cb796eefb92c4ce05d44ea173f2fb37c to your computer and use it in GitHub Desktop.

Select an option

Save bramanda48/cb796eefb92c4ce05d44ea173f2fb37c to your computer and use it in GitHub Desktop.
List of frequently used FFmpeg commands

Convert mp4 video to mkv

ffmpeg -i "input.mp4" -vcodec copy -acodec copy output.mkv

Convert mp4 video to mkv with audio codec opus

ffmpeg -i "input.mp4" -vcodec copy -acodec libopus output.mkv

Cut video based on start time

ffmpeg -ss 00:42:59.984 -i "input.mp4" -vcodec copy -acodec copy output.mkv
ffmpeg -t 11:56 -i "input.mp4" -vcodec copy -acodec copy output.mkv

Make video size smaller

ffmpeg -i "input.mp4" -s 2304x1440 -crf 0 -vcodec h264_nvenc -acodec copy -stats output.mkv

Note: Change -s value with the input resolution

Extract video only

ffmpeg -i "input.mp4" -vcodec copy -an output.mkv

Extract audio only (opus)

ffmpeg -i "input.mp4" -vn -acodec copy output.opus

Merge audio and video

ffmpeg -i "input.mp4" -i audio.m4a -c copy output.mkv

Merge multiple video

  1. First, we need to create mylist.txt
file 'file1.mkv'
file 'file2.mkv'
file 'file3.mkv'
  1. Run the command
ffmpeg -f concat -i mylist.txt -c copy output.mkv

Increase or Decrease audio volume

  1. First, check the average dB volume
ffmpeg -i "input.m4a" -af "volumedetect" -vn -sn -dn -f null -
  1. Increate the volume
ffmpeg -i "input.m4a" -af "volume=30dB" output.m4a

Note: 30dB is the number of decibels volume, if decrease set with minus -30dB

Split video part by part for streaming (HLS Auto chunk)

ffmpeg -i "input.mp4" -c:v libx264 -crf 23 -preset fast -c:a aac -b:a 128k -f hls -hls_time 10 -hls_playlist_type vod -hls_segment_filename "seg_%03d.ts" playlist.m3u8

Note: -hls_time 10 split result duration

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