PDA

View Full Version : Ripping audio off a video



sameerdhar
21st February 2013, 07:08 PM
Greetings,

I am looking for a way to rip the audio off a video file. I had recorded a concert in my video camera but now want to only have the audio file. I have tried to delete the video stream using pitivi but that still saves it as a ogv file which does not serve the purpose.

Need to save it as an mp3 or even ogg will do.

Regards Sameer

smr54
21st February 2013, 08:35 PM
ffmpeg -i myvideo myaudio.mp3

should do it. If it's an flv, you might have to first do ffmpeg -i myfile.flv myfile.mp4 then do it.

More detailed explanation, though somewhat dated.

http://howto-pages.org/ffmpeg/#strip

assen
21st February 2013, 09:16 PM
Hi,


ffmpeg -i myvideo myaudio.mp3

should do it.

It will, but you won't like the result - default for ffmpeg is 2-channel, 64 kbps. Take a moment to examine what format the audio is in, then fun ffmpeg with 'acodec copy' and retrieve the audio in the same format.

WWell,

Ihatewindows
21st February 2013, 10:17 PM
PiTiVi should be able to do it, but the program itself is flaky...

gadgetwiz
22nd February 2013, 02:56 AM
VLC does a good job ripping audio from a video using the Media/Convert-Save menu option.

sameerdhar
22nd February 2013, 04:26 AM
Thanks guys will give it a shot and get back to you.

Regards Sameer

jbuckley2004
22nd February 2013, 05:31 PM
I've had good results using ffmpeg, but only when I use the "lame" libraries with it. You may want to try

$ ffmpeg -i "input-file" -acodec libmp3lame -ab 160k -ac 2 -ar 44100 "output-file.mp3"

where "input-file" is your video and the resultant, output type is .mp3. Also, youtube videos are easily downloaded using
$ youtube-dl theURLhere

Ihatewindows
22nd February 2013, 05:46 PM
I've had good results using ffmpeg, but only when I use the "lame" libraries with it. You may want to try

$ ffmpeg -i "input-file" -acodec libmp3lame -ab 160k -ac 2 -ar 44100 "output-file.mp3"

where "input-file" is your video and the resultant, output type is .mp3. Also, youtube videos are easily downloaded using
$ youtube-dl theURLhere

Yeah, but you can't select your video quality. Little stuff like that can get annoying.

smr54
22nd February 2013, 07:44 PM
Note that the OP isn't looking for video quality here, just wants to pull audio from the file.

Ihatewindows
22nd February 2013, 08:45 PM
He's not looking to pull it off of YouTube, either. :doh:

dobbi
2nd March 2013, 02:02 PM
What I do use for demuxing:

ProjectX (DVB streams, DVD)
Great to demux raw data from DVB streams(aka MPEG-2 PS/TS)
It also can fix missing PTS(aka wrong time showing, happens a lot with recording of digital TV streams and DVD raw dumps)
You can also fix PTS(Packet Time Stamps) with ffmpeg with the option -fflags genpts

FFMPEG

ffmpeg -i inpuvideohere -map 0 -c:a:0 copy ouputaudio.ac3
http://ffmpeg.org/trac/ffmpeg/wiki/How%20to%20use%20-map%20option

To know what format your audio is in, you can either play it on a video player like VLC and look at the video properties or right click on it and choose properties or you can just use ffmpeg like this:

ffmpeg -i inputvideohere.mpeg

And it will show you the mappings, so you can choose the audio streams to copy. There is also a "raw" option for ffmpeg.

Avidemux(freeworld).
Great for extracting anything it can read, it will just copy the streams, if it opens.

---------- Post added at 01:59 PM ---------- Previous post was at 01:21 PM ----------

Forgot mplayer.

mplayer originalfile -dumpaudio -dumpfile rawaudio.ac3

-dumpfile (destination file for the dump)
-dumpaudio (dumping audio only)
-dumpvideo (dumping video only)
-dumpstream (dumping all streams)

---------- Post added at 02:02 PM ---------- Previous post was at 01:59 PM ----------

Note: VLC doesn't copy data from the file, it reads the output of the system, if your system drops frames or skip part of the audio it will record that.

Dan
2nd March 2013, 03:40 PM
This works for me.


Save file locally
Run this from a terminal

$ mplayer -really-quiet -vc dummy -ao pcm:file=/dev/stdout video-file.mp4 2> /dev/null | oggenc -q 5 -o Audio-file.ogg -

Change the indicated file names accordingly.

FunkyRes
4th March 2013, 12:00 PM
I forget what the switches are but when I did this, I believe I did the demux with ffmpeg resulting in a 24-bit / 48kHz wav file.

Then I used audacity to remove background noise and normalize, and then I think sox to downsample to 16-bit 44.1kHz before encoding for mp3 player.

CronoCloud
4th March 2013, 07:10 PM
ffmpeg -i video.foo (tells you what the audio type is for the next step

ffmpeg -i video.foo -vn -ac 2 -acodec copy audio.foo (change .foo to whichever type the audio is)

CronoCloud

jbuckley2004
4th March 2013, 07:48 PM
Chrono, I'm having a hard time seeing that this is correct.

First of all, I assume you meant "video.foo" in both cases? That's always the input file name, including the extension, I believe.

Second, when I tried $ffmpeg -i <my file here>, I get a long list of configuration options, an error message that says an output file must *always* been included, and yes, somewhere in between, some information about both the video and audio types.

But the only audio information is that the format is vorbis, which is correct, but not usable in your second line. When I try, ffmpeg complains thusly:


Unable to find a suitable output format for 'Outputfile.vorbis'
Outputfile.vorbis: Invalid argument

I'll be researching the -acodec copy option, though. That's new to me.

BTW, ffmpeg was working fine for me yesterday. Today, after installing the linux 3.8 kernel, I can't seem to convert anything! Is this a coincidence, or has something more dastardly occurred with source of my input videos? Hum?

I keep getting "Protocol not found" errors now.

smr54
4th March 2013, 09:07 PM
I think what he means is that doing ffmpeg -i video.foo (I'm also assuming typo) gives you, along with the error message, a lot of information. You can also use ffprobe to get pretty much the same information sans error message.

---------- Post added at 03:07 PM ---------- Previous post was at 03:05 PM ----------

-acodec copy only works if it's a usable format. If not, you get an error. Do you have libvorbis installed?

jbuckley2004
4th March 2013, 09:22 PM
Yes, I have libvorbis installed.

The surprising thing is that I can't find libmp3lame anywhere now. Doesn't seem to be in the repos either.

I'm still playing with it, but I'm not sure I understand what the error message means by "protocol". I understand codec in this context, but not protocol.

----

Wait! The fire is out. I rebooted and now it's clear that 1) it's working 2) ffmpeg is recognizing the audio as vorbis and 3) ffmpeg is using the libmp3lame codecs now. All I can think is that couldn't find the vorbis information before, and needed a reboot after I re-installed the lib this morning (duh!).

Thanks for everyone's help. But since I didn't post the original problem (just something I thought was very related), I'm leaving this thread unmarked (not solved).

CronoCloud
4th March 2013, 09:32 PM
But the only audio information is that the format is vorbis, which is correct, but not usable in your second line. When I try, ffmpeg complains thusly:


Unable to find a suitable output format for 'Outputfile.vorbis'
Outputfile.vorbis: Invalid argumentI'll be researching the -acodec copy option, though. That's new to me.

It should be outputfile.ogg vorbis audio uses ogg containers. -acodec copy gives you the exact same audio as was in the video with no conversion applied, so it's fast and you don't have to muck around with ffmpeg audio settings....it's keeps the command simpler.


BTW, ffmpeg was working fine for me yesterday. Today, after installing the linux 3.8 kernel, I can't seem to convert anything! Is this a coincidence, or has something more dastardly occurred with source of my input videos? Hum?


Was an ffmpeg update in there too? It seems like the command line options change with every update.


I think what he means is that doing ffmpeg -i video.foo (I'm also assuming typo) gives you, along with the error message, a lot of information.

Yep that's what I meant.


You can also use ffprobe to get pretty much the same information sans error message.

Oh thanks I didn't know about ffprobe. That's even better.[/quote]


-acodec copy only works if it's a usable format. If not, you get an error.

Yep.

CronoCloud

jbuckley2004
4th March 2013, 09:47 PM
@Crono

Was an ffmpeg update in there too? It seems like the command line options change with every update.

I didn't think so, but there were quite a few updates. I may have missed it. As it was, I re-installed ffmpeg specifically also, but after I knew the kernel update was up and working for me.

But like I said, it's working now the way I've been using it. Thanks for the tip on the copy argument. That's going to be a big help.

dobbi
5th March 2013, 02:48 PM
Suppose you want the French audio of an mpeg file of a backup movie for some reason(e.g. making funny cat videos)

Issuing:
ffmpeg -i "movie.mpeg"

You will see this.

Stream #0:0[0x1e0]: Video: mpeg2video (Main), yuv420p, 720x480 [SAR 32:27 DAR 16:9], 9800 kb/s, 23.98 fps, 59.94 tbr, 90k tbn, 59.94 tbc
Stream #0:1[0x20]: Subtitle: dvd_subtitle
Stream #0:2[0x21]: Subtitle: dvd_subtitle
Stream #0:3[0x22]: Subtitle: dvd_subtitle
Stream #0:4[0x23]: Subtitle: dvd_subtitle
Stream #0:5[0x24]: Subtitle: dvd_subtitle
Stream #0:6[0x25]: Subtitle: dvd_subtitle
Stream #0:7[0x26]: Subtitle: dvd_subtitle
Stream #0:8[0x27]: Subtitle: dvd_subtitle
Stream #0:9[0x80]: Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s
Stream #0:10[0x81]: Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s
Stream #0:11[0x82]: Audio: ac3, 48000 Hz, stereo, s16, 192 kb/s

suppose you want the second audio in mp3 format.

This is the second audio stream
Stream #0:10[0x81]: Audio: ac3, 48000 Hz, 5.1(side), s16, 448 kb/s

Extracting and encoding it is just a matter of selecting that stream.

ffmpeg \
-i "video.mpeg" \
-map 0:10 \
-metadata:s:a:1 language="French" \
-metadata title="video audio" \
"audio.mp3"

That is the shortest way, if you don't count the metadata.

s = stream
a = audio
1 = stream index aka position of the audio in the ffmpeg provided list, note that is not 10 since there is only 3 audio streams and it counts from zero.
http://ffmpeg.org/ffmpeg.html#Audio-Options

---------- Post added at 02:48 PM ---------- Previous post was at 10:24 AM ----------

Found a bunch of GUI's for FFMpeg.

Open source GUI's for FFMpeg.
http://sourceforge.net/projects/tencoder/ (not in the repo)
https://code.google.com/p/ffmpegyag/ (not in the repo)
https://code.google.com/p/winff/ (Fedora rpm available, not in the repo)
http://sourceforge.net/projects/hypervideoconve/ (not in the repo)

Command line tool:
ffmpeg2theora (RPM Fusion for Fedora 18 - Free)

Found most of it looking around in here.
http://www.videohelp.com/tools/sections/linux-video-tools