Convert MP4 video to MP3 audio with FFmpeg

ffmpeg -i filename.mp4 filename.mp3

fixed bit rate :

ffmpeg -i video.mp4 -b:a 192K -vn music.mp3

variable bit rate :

ffmpeg -i in.mp4 -q:a 0 -map a out.mp3

variable bit rate of 165 with libmp3lame encoder :

ffmpeg -vn -sn -dn -i input.mp4 -codec:a libmp3lame -qscale:a 4 output.mp3
  • -vn disables all video-streams from the input
  • -sn disables all subtitle-streams from the input
  • -dn disables all data-streams from the input
  • -i specifies the input file
  • -codec:a libmp3lame specifies the encoder
  • -qscale:a 4 specifies the quality target for libmp3lame
  • The last argument is the output-file. Note that the file-extension might be used to infer additional information.

References
https://superuser.com/questions/332347/how-can-i-convert-mp4-video-to-mp3-audio-with-ffmpeg
https://superuser.com/questions/1463710/convert-mp4-to-mp3-with-ffmpeg