Search code examples
audioffmpegmp3sox

How to extract audio in 8khz using ffmpeg


I am using ffmpeg to extract the audio from a video. Below code downlaods the audio from a video file. I'm not sure how efficient this program is but I do know that it downloaods it in 48KHZ.

How do I use this program to extract audio from a video in 8Khz because the file is getting too big.

ffmpeg -i video_link -vn output.wav

Solution

  • Use -ar option to change frequency rate

    ffmpeg -i video_link -vn -ar 8000 output.wav
    

    If you want to try different formats of audio check the available formats in ffmpeg using ffmpeg -formats and available codecs using ffmpeg -codecs

    Here's an example to extract to mp3 file

    ffmpeg -i video_link -vn -ar 8000 -f mp3 output.mp3
    

    Edit: as @llogan pointed out, -f option is not needed, ffmpeg automatically mux mp3 file.

    ffmpeg -i video_link -vn -ar 8000 output.mp3