ShinChven's Blog

FFmpeg Frequently Used Commands

ffmpeg, bitrate2022-08-07 07:11:46

Compressing Video by Setting Bitrate

ffmpeg -i input.mp4 -c:v libx264 -b:v 1000k -b:a 192k output.mp4
  • -i: Input file
  • -c:v: Video codec
  • -b:v: Video bitrate
  • -b:a: Audio bitrate
  • output.mp4: Output file

Copy Audio Or Video Streams

ffmpeg -i input.mp4 -c:v copy -c:a copy output.mkv
  • -i: Input file
  • -c:v copy: Copy video codec
  • -c:a copy: Copy audio codec
  • output.mkv: Output file

Copy Audio out of a Video File

ffmpeg -i input.mp4 -vn -acodec copy output.aac
  • -i: Input file
  • -vn: Disable video
  • -acodec copy: Copy audio codec
  • output.aac: Output file

Merge Audio and Video Files

ffmpeg -i input.mp4 -i input.aac -c copy output.mkv
  • -i input.mp4: Input video file
  • -i input.aac: Input audio file
  • -c: Copy
  • output.mkv: Output file

Cut Video

ffmpeg -i input.mp4 -ss 00:00:00 -t 00:00:10 -c copy output.mp4
  • -i: Input file
  • -ss: Start time
  • -t: Duration
  • -c: Copy
  • output.mp4: Output file

Merge Files in Directory

ffmpeg -f concat -safe 0 -i <(for f in *.mp4; do echo "file '$f'"; done) -c copy output.mp4
  • -f: File format
  • -safe: Safe mode
  • -i: Input file
  • -c: Copy
  • output.mp4: Output file
  • *.mp4: Files in directory
  • -i <(for f in *.mp4; do echo "file '$f'"; done): Command to generate input file
  • -c copy: Command to copy
  • output.mp4: Output file