You can use the following command to extract audio from a video file using VLC:
$ vlc "Source File" \
--sout #transcode{acodec=mp3}\
:duplicate{dst=std{access=file,\
mux=raw,dst="Output.mp3",select=novideo}}
(Important!: The argument of "--sout" must have no spaces in it (except for in the "dst" attribute).
To only extract a segment of audio use the following command:
$ vlc "Source File" \
--start-time=<start time (in seconds)> \
--stop-time=<stop time (in seconds)> \
--sout #transcode{acodec=mp3}\
:duplicate{dst=std{access=file,mux=raw,\
dst="Output.mp3",select=novideo}}