ffmpeg Question

So I use the following to rip audio from one .mp4 file and then generate one .mp3 file.

caleb@linux-vmp1:~> ffmpeg -i a -ab 128000 -ar 44100 01.mp3

Obviously, this takes a file named a and makes a file named 01 that is an mp3. It works great and I have used it many times. The problem is, I would like to rip the audio from several files all at once. I am sure there is a way to do it but I haven’t stumbled upon the way to do it.

For example, if I could rip the audio from every file in a certain directory then that would be great!

Does anyone know how to do something like this?

Create a test directory with 4 or 5 files in it you wish to test, … hence if we mess up there is no harm done.

Then try something like this (assuming your input file extension is “.avi” in my example):

for i in *.avi; do ffmpeg -i "$i" -ab 128000 -ar 44100 output${i/%avi/mp3}; done 

I did a brief, but not thorough test of that, so you may wish to check it further.

Here is my reference thread for this where I was taught how to do it: process multiple files from one command line??

Thanks, I will give it a try.

OK, so this is what I get.

for i in *.mp4; do ffmpeg -i "$i" -ab 128000 -ar 44100 output${i/%mp4/mp3}; done

and I get the following…

FFmpeg version UNKNOWN, Copyright (c) 2000-2010 the FFmpeg developers
  built on Nov 15 2010 19:54:35 with gcc 4.5.0 20100604 [gcc-4_5-branch revision 160292]
  configuration: --prefix=/usr --mandir=/usr/share/man --libdir=/usr/lib64 --shlibdir=/usr/lib64 --enable-pthreads --enable-shared --enable-avfilter --disable-static --enable-libmp3lame --enable-libxvid --enable-libx264 --enable-postproc --enable-shared --enable-libdc1394 --enable-libtheora --enable-libschroedinger --enable-libvpx --enable-gpl --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3
  libavutil     50.32. 6 / 50.32. 6
  libavcore      0.12. 0 /  0.12. 0
  libavcodec    52.94. 3 / 52.94. 3
  libavformat   52.84. 0 / 52.84. 0
  libavdevice   52. 2. 2 / 52. 2. 2
  libavfilter    1.56. 0 /  1.56. 0
  libswscale     0.12. 0 /  0.12. 0
  libpostproc   51. 2. 0 / 51. 2. 0
*.mp4: No such file or directory

Ok … are there any files in that directory with the extension mp4 ? Are you in the correct directory with your terminal session ?

This is what the files are that I am trying to rip the audio from. I thought they were .mp4. Maybe they aren’t?

This is what it says for file properties…


Hmmm … how familiar are you with a terminal ? I’m begining to think not very familiar.

Just navigate to the terminal and look at the name of a sample file !! What is an EXACT name of one of the files that you want to convert ?

NOTE the command you attempted, assumed an extension of .mp4. The file ‘test’ that you created has NO extension. Change that file name to test.mp4 and you may find a different result.

But this is all incredibly basic … which makes me think you are very new to this. …

Hey thanks for the help. And yes, I am new to this. But, I am learning quickly. I have 95% of my system running how I want it so I am patting myself on the back for that. Slowly, I will learn the terminal. But for now I am bugging you folks. Thanks again!


You might want to try this application zak, it is in the packman repo:

Zak allows you to select one or more MP3 files and convert them into a single MP3 or MP4/M4A/M4B file The primary use for Zak is audio books. Most audio books are distributed in several files, usually one per chapter. Converting these files into a single .m4b allows one to take advantage of the iPod’s bookmarking features.

I have never tried it myself though.