How to rip a specific audio segment from a video file using ffmpeg on Linux
I wanted to grab the last "Have you tried turning it off and on again?" quote as a WAV file from BBC's ill-fated The IT Crowd sitcom (you can grab the torrents - get the package with all 6 episodes using Azureus, and only download those you want - easy to do).
ffmpeg made quick work of it.
The full command:
ffmpeg -i input_file.avi -f mp3 -ss "00:02:40:" -t 20 outputfile.wav
The explanation:
- -i input_file.avi
- the input file
- -f wav
- format output as wav (other formats & codecs: ffmpeg -formats)
- -ss "00:02:40"
- start at that position; can also take seconds from the start
- -t 20
- 20 second duration
- outputfile.wav
- the output file
Thanks to jtpratt's Converting video in linux using ffmpeg and mencoder.