Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extract audio from MPEG-4 file using ffmpeg [closed]

Tags:

ffmpeg

How can we extract audio from video file (MPEG-4 format)?

What is convenient form of storing the extracted audio data for further analysis? (edit: In other words: is it better to use PCM format or something like WAV if I want to get audio sound level?)

From other questions about this topic I learned that ffmpeg is a right tool to do this.

like image 245
SteveS Avatar asked Oct 24 '25 12:10

SteveS


2 Answers

Regarding your first question:

You can indeed do this with ffmpeg, but I can only give you the command line form. You might want to fiddle with the output format, but have a look at the man page at http://linux.die.net/man/1/ffmpeg, or the official ffmpeg (audio) documentation at https://www.ffmpeg.org/ffmpeg.html#Audio-Options

ffmpeg -i mpeg-4videofilename -vn -ac 2 -ar 44100 -ab 320k -f mp3 output.mp3

Explanation of the command line options:

  • -i input file
  • -vn no video
  • -ac audio channel
  • -ar audio sample rate
  • -ab audio bitrate
  • -f output format
like image 192
sanderr Avatar answered Oct 26 '25 03:10

sanderr


You can use the following command:

ffmpeg -i input.mp4 -vn -acodec pcm_s16le -ac 2 -ar 44100 out.wav

-vn: no video

-acodec: audio codec selection.

pcm_sl6le: 2 bytes samples in little endian format

-ac: number of audio channels

-ar: audio sample rate

out.wav output wav file

like image 20
sourabh gupta Avatar answered Oct 26 '25 03:10

sourabh gupta



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!