LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Desktop (http://www.linuxquestions.org/questions/linux-desktop-74/)
-   -   copy-mode extract of audio from youtube flv video (http://www.linuxquestions.org/questions/linux-desktop-74/copy-mode-extract-of-audio-from-youtube-flv-video-508026/)

moob8 12-06-2006 07:27 PM

copy-mode extract of audio from youtube flv video
 
I would like to extract the audio from a youtube (.flv) file without re-encoding it. When I play the video with mplayer and watch the console (text) output I see that the audio is in mp3 form. Despite this, I cannot extract that to an mp3 file (attempts using mencoder and also with transcode). I can use transcode to extract the audio but only in a way converts it to PCM ... which is not what I want.

By the way, extracting just the video part (no sound) in copy-mode (not-re-encoding) is easy:
Code:

mencoder -of avi -nosound -ovc copy in.flv -o out_just_vid.avi

David the H. 12-07-2006 01:39 PM

Try this:

'ffmpeg -i inputfile.flv -f mp3 -vn -acodec copy ouputfile.mp3'

That should do it for most files.

Apparently there are some microphone-recorded .flv files that use a proprietary codec that doesn't have any open source support. I don't know how common those are in the wild.

osor 12-07-2006 06:12 PM

The easiest and most elegant (IMO) way is:
Code:

mplayer -dumpaudio in.flv
This should leave a file called stream.dump in the original audio format (perhaps mp3), just extracted from the flv container.

moob8 12-07-2006 08:23 PM

David The H. and osor, I tried both your methods and both worked! Not only that, the files produced by the two methods are identical. Most excellent! Thank you both! Yay! :D :D

fakie_flip 05-01-2008 01:58 AM

Quote:

Originally Posted by moob8 (Post 2534414)
David The H. and osor, I tried both your methods and both worked! Not only that, the files produced by the two methods are identical. Most excellent! Thank you both! Yay! :D :D

How come neither worked for me :(

Code:

[root@localhost tmp]# ffmpeg -i video.flv -f mp3 -vn -acodec copy carsounds2.mp3
FFmpeg version SVN-r10703, Copyright (c) 2000-2007 Fabrice Bellard, et al.
  configuration: --prefix=/usr --incdir=/usr/include/ffmpeg --libdir=/usr/lib64 --shlibdir=/usr/lib64 --mandir=/usr/share/man --arch=x86_64 --extra-cflags=-O2 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fexceptions -fstack-protector --param=ssp-buffer-size=4 -m64 -mtune=generic --enable-liba52 --enable-libfaac --enable-libfaad --enable-libgsm --enable-libmp3lame --enable-libogg --enable-libtheora --enable-libvorbis --enable-libxvid --enable-libx264 --enable-pp --enable-pthreads --disable-static --enable-shared --enable-gpl --disable-debug --disable-opts --disable-strip
  libavutil version: 49.5.0
  libavcodec version: 51.45.0
  libavformat version: 51.14.0
  built on Oct 18 2007 03:18:27, gcc: 4.1.2 20070925 (Red Hat 4.1.2-31)

Seems stream 0 codec frame rate differs from container frame rate: 1000.00 (1000/1) -> 25.00 (25/1)
Input #0, flv, from 'video.flv':
  Duration: 00:09:58.7, start: 0.000000, bitrate: 56 kb/s
  Stream #0.0: Video: flv, yuv420p, 320x240, 25.00 fps(r)
  Stream #0.1: Audio: mp3, 22050 Hz, mono, 56 kb/s
Output #0, mp3, to 'carsounds2.mp3':
  Stream #0.0: Audio: libmp3lame, 22050 Hz, mono, 56 kb/s
Stream mapping:
  Stream #0.1 -> #0.0
Press [q] to stop encoding
size=    4188kB time=598.8 bitrate=  57.3kbits/s   
video:0kB audio:4188kB global headers:0kB muxing overhead 0.000746%
[root@localhost tmp]#

Code:

[chris@localhost tmp]$ mplayer -dumpaudio video.flv
MPlayer 1.0rc2-4.1.2 (C) 2000-2007 MPlayer Team
CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ (Family: 15, Model: 43, Stepping: 1)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.
mplayer: could not connect to socket
mplayer: No such file or directory
Failed to open LIRC support. You will not be able to use your remote control.

Playing video.flv.
libavformat file format detected.
[lavf] Video stream found, -vid 0
[lavf] Audio stream found, -aid 1
VIDEO:  [FLV1]  320x240  0bpp  25.000 fps    0.0 kbps ( 0.0 kbyte/s)
Core dumped ;)

Exiting... (End of file)
[chris@localhost tmp]$

Dumping only the video has worked, but that's not what I want. Please help.

fakie_flip 05-01-2008 02:02 AM

I'm trying to get the audio only from here. I've already got the video.flv from that youtube site. Please help.

http://www.youtube.com/watch?v=Ejb8QOyjz-E&

I tried putting together some of my own commands just as a test. Here are the results.

Code:

[root@localhost tmp]# mencoder -novideo -ovc copy video.flv -o ultimatecarsounds2.mp3
MEncoder 1.0rc2-4.1.2 (C) 2000-2007 MPlayer Team
CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ (Family: 15, Model: 43, Stepping: 1)
CPUflags: Type: 15 MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled with runtime CPU detection.

WARNING: OUTPUT FILE FORMAT IS _AVI_. See -of help.
success: format: 0  data: 0x0 - 0x16ed37e
libavformat file format detected.
[lavf] Video stream found, -vid 0
[lavf] Audio stream found, -aid 1
Video stream is mandatory!

Exiting...
[root@localhost tmp]#

That indicates the audio is there!

fakie_flip 05-01-2008 03:03 AM

Nevermind, problem solved. I used Avidemux.

bruce384 06-23-2008 12:29 AM

extract audio from .flv files
 
To get the audio from a bunch of .flv files I use

for i in *.flv; do ffmpeg -i $i -f mp3 -vn -acodec copy $i.mp3 ;done

By the way; this linuxquestions format is a pain in the ass. Try to log in and then find the question you were trying to answer is nuts. The thread disappeared after I loged in.

bruce

David the H. 06-23-2008 02:45 AM

Quote:

Originally Posted by bruce384 (Post 3192275)
By the way; this linuxquestions format is a pain in the ass. Try to log in and then find the question you were trying to answer is nuts. The thread disappeared after I loged in.

Open up a new tab or window, log-in there, then go back to your original tab and hit refresh. Problem solved. :D

jschiwal 04-13-2009 01:35 AM

Fakie_Flip: The video you posted is an mp4 file and not a flash video. It uses aac codec rather than mp3.

I was able to extract the audio easily with: ffmpeg -i Ultimate_Car_Sounds__Part_II.mp4 -vn -acodec copy ucs.m4a

I could have transcoded it to another audio format/codec.

Generally I will first play the source with "ffmpeg -identify <video_file>" and study the text output for what make up the video and audio streams. You can't go by the extension. It just indicates the container.

nancy0903 07-17-2009 01:30 AM

but i usually chose Audio Recorder

David the H. 07-17-2009 03:14 AM

Edit: deleted.

I should've noticed this was an older thread. I'd already replied to this one. :(

bijukn 01-11-2010 07:23 AM

extract audio from flv
 
use winff

eay 02-14-2010 02:11 AM

Update: Solution
 
I know this is an old thread, but I found a solution over at UbuntuForums and thought I would post it here, too:

http://ubuntuforums.org/showpost.php...1&postcount=14

cheers,

ethan

random-tux 08-18-2011 05:23 PM

dump and convert audio from flv to wav using mplayer
 
This way seems to work well (and one can see fast video meanwile ;-) ):

mplayer -ao pcm input.flv -ao pcm:file="output.wav"


All times are GMT -5. The time now is 04:52 AM.