ffmpeg - bunnyamin/bunnix GitHub Wiki

Analyze

Command Example Comment
Print all metadata ffprobe -v error -show_format -show_streams <FILE>
Print bitrate data without element (bit_rate=) from audio stream ffprobe -v error -show_entries stream=bit_rate -select_streams a -of default=noprint_wrappers=1:nokey=1 <FILE> Can return "N/A" for example weba; try format=bit_rate instead of stream=bit_rate.
Print bitrate data without element (bit_rate=) from audio stream, using format=bit_rate ffprobe -v error -show_entries format=bit_rate -select_streams a -of default=noprint_wrappers=1:nokey=1 <FILE>
Print bitrate data without element (bit_rate=) from audio stream, all files in directory for i in *.<FILE EXT>; do echo "$i"; ffprobe -v error -show_entries stream=bit_rate -select_streams a -of default=noprint_wrappers=1:nokey=1 "$i"; done;
Print bitrate data without element (bit_rate=) from audio stream, all files in directory if bitrate above 128Kb for i in *.<FILE EXT>; do br=$(ffprobe -v error -show_entries stream=bit_rate -select_streams a -of default=noprint_wrappers=1:nokey=1 "$i"); if [ "$br" -gt 128000 ]; then echo "$br $i"; fi; done;

Copy

Command Example Comment
Copy ffmpeg -i <FILE>.<EXT> -c copy <FILE>.<EXT>
Copy all files in a directory for i in *.<FILE EXT>; do ffmpeg -i "$i" -c copy "$(basename "${i/.<FILE EXT>}").<FILE EXT>"; done;

Crop, extract

Command Example
Crop, extract sound from sound and copy the stream ffmpeg -ss <00:00:00> -to <00:00:00> -i "<INPUT FILE>" -c copy <OUTPUT FILE>
Crop, extract sound from video and copy the stream ffmpeg -ss <00:00:00> -to <00:00:00> -i "<INPUT FILE>" -acodec copy <OUTPUT FILE>
Crop, extract specific sound encoding from video and copy the stream ffmpeg -ss <SECONDS> -to <SECONDS> -i "<INPUT FILE>" -acodec <ENCODING> -c copy <OUTPUT FILE>

Encode to MP3

  • FFmpeg MP3 Encoding Guide
  • Print expected file output for i in *.<FILE EXT>; do echo "$(basename "${i/.<FILE EXT>}").mp3"; done;
Command Example
VBR ffmpeg -i <INPUT FILE>.* -vn -codec:a libmp3lame -q:a 0 <OUTPUT FILE>.mp3
VBR, all files in a directory for i in *.<FILE EXT>; do ffmpeg -i "$i" -vn -codec:a libmp3lame -q:a 0 "$(basename "${i/.<FILE EXT>}").mp3"; done;
CBR, 128kb ffmpeg -i <INPUT FILE>.* -vn -codec:a libmp3lame -b:a 128k <OUTPUT FILE>.mp3
CBR, 128kb, all files in a directory for i in *.<FILE EXT>; do ffmpeg -i "$i" -vn -codec:a libmp3lame -b:a 128k "$(basename "${i/.<FILE EXT>}").mp3"; done;
CBR, preserve bitrate, all files in a directory for i in *.<FILE EXT>; do br=$(ffprobe -v error -show_entries stream=bit_rate -select_streams a -of default=noprint_wrappers=1:nokey=1 "$i"); ffmpeg -i "$i" -vn -codec:a libmp3lame -b:a $br "$(basename "${i/.<FILE EXT>}").mp3"; done;

Error, problem, troubleshoot

Event Error Cause Consequence Remedy
ffmpeg -ss ... -to ... -i ... -c copy ... [mp3 @ 0x5591eee4f140] Audio packet of size 557 (starting with 49443304...) is invalid, writing it anyway. Unknown Unknown
⚠️ **GitHub.com Fallback** ⚠️