LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Desktop
User Name
Password
Linux - Desktop This forum is for the discussion of all Linux Software used in a desktop context.

Notices

Reply
 
Search this Thread
Old 12-06-2006, 07:27 PM   #1
moob8
Member
 
Registered: Sep 2006
Distribution: slackware
Posts: 132

Rep: Reputation: 15
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
 
Old 12-07-2006, 01:39 PM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
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.
 
Old 12-07-2006, 06:12 PM   #3
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 70
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.
 
Old 12-07-2006, 08:23 PM   #4
moob8
Member
 
Registered: Sep 2006
Distribution: slackware
Posts: 132

Original Poster
Rep: Reputation: 15
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!
 
Old 05-01-2008, 01:58 AM   #5
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,441

Rep: Reputation: 80
Quote:
Originally Posted by moob8 View Post
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!
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.
 
Old 05-01-2008, 02:02 AM   #6
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,441

Rep: Reputation: 80
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!

Last edited by fakie_flip; 05-01-2008 at 02:06 AM.
 
Old 05-01-2008, 03:03 AM   #7
fakie_flip
Senior Member
 
Registered: Feb 2005
Location: san antonio, texas
Distribution: Fedora 64 bit RAID0 + LUKS, CentOS (server), Backtrack, Gentoo Hardened
Posts: 1,441

Rep: Reputation: 80
Nevermind, problem solved. I used Avidemux.
 
Old 06-23-2008, 12:29 AM   #8
bruce384
LQ Newbie
 
Registered: Jan 2006
Posts: 4

Rep: Reputation: 0
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
 
Old 06-23-2008, 02:45 AM   #9
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
Quote:
Originally Posted by bruce384 View Post
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.
 
Old 04-13-2009, 01:35 AM   #10
jschiwal
Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654Reputation: 654
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.

Last edited by jschiwal; 04-13-2009 at 03:46 AM.
 
Old 07-17-2009, 01:30 AM   #11
nancy0903
LQ Newbie
 
Registered: May 2009
Posts: 1

Rep: Reputation: 0
but i usually chose Audio Recorder
 
Old 07-17-2009, 03:14 AM   #12
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948Reputation: 1948
Edit: deleted.

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

Last edited by David the H.; 07-17-2009 at 03:50 AM.
 
Old 01-11-2010, 07:23 AM   #13
bijukn
LQ Newbie
 
Registered: Mar 2007
Location: india, kerala, trivandrum
Distribution: redhat, clarkconnect, ubuntu
Posts: 4

Rep: Reputation: 3
extract audio from flv

use winff
 
1 members found this post helpful.
Old 02-14-2010, 02:11 AM   #14
eay
LQ Newbie
 
Registered: Feb 2008
Posts: 2

Rep: Reputation: 1
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
 
1 members found this post helpful.
Old 08-18-2011, 05:23 PM   #15
random-tux
LQ Newbie
 
Registered: Dec 2006
Posts: 3

Rep: Reputation: 0
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"
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Canít get video from Youtube to play blastradius Ubuntu 4 10-29-2006 05:50 AM
Out of synch video and audio on Youtube.com? Corndaddy Linux - Newbie 1 08-16-2006 06:54 AM
Help embedding FLV flash video MicahCarrick Programming 3 07-24-2006 08:40 PM
Extract audio from .wmv $in Linux - Software 10 07-10-2005 05:31 PM
extract video audio Latem Linux - Software 0 02-05-2005 05:07 PM


All times are GMT -5. The time now is 05:40 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration