LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (https://www.linuxquestions.org/questions/slackware-14/)
-   -   unable to extract audio from .flv (https://www.linuxquestions.org/questions/slackware-14/unable-to-extract-audio-from-flv-746059/)

adityavpratap 08-08-2009 11:37 AM

unable to extract audio from .flv
 
Hi,

Well, I don't know if this falls within the purview of this forum. However here it is -

I have downloaded a video from youtube which is saved as a .flv file. I am trying to extract the soundtrack as follows -

$ mplayer -dumpaudio infile.flv -dumpfile infile.mp3

However, the dumpfile doesn't seem to be an mp3 file as is evident from the output of -

$ file infile.mp3

which gives -

infile.mp3: \012- Assembler source

and this doesn't play in mplayer or any other audio player.

How can I set right this? Awaiting your valuable suggestions,

disturbed1 08-08-2009 01:54 PM

Is it really an mp3 file? Use mplayer -identify file.flv to check. Does mplayer play the flv file on its own?

Try -
mplayer -vo null -vc null -ao pcm:fast:file=audio.wav file.flv
This doesn't dump the stream, but decodes it to pcm wav file.

vanstra 08-08-2009 02:25 PM

I use the following 'flash2avi' script:

!#/bin/sh

if [ -z "$1" ]; then
echo "Usage: $0 {-divx|-xvid} list_of_flv_files"
exit 1
fi

# video encoding bit rate
V_BITRATE=1000

while [ "$1" ]; do
case "$1" in
-divx)
MENC_OPTS="-ovc lavc -lavcopts vcodec=mpeg4:vbitrate=$V_BITRATE:mbd=2:v4mv:autoaspect"
;;
-xvid)
MENC_OPTS="-ovc xvid -xvidencopts bitrate=$V_BITRATE:autoaspect"
;;
*)
if file "$1" | grep -q "Macromedia Flash Video"; then
mencoder "$1" $MENC_OPTS -vf pp=lb -oac mp3lame -lameopts fast:preset=standard -o "`basename $1 .flv`.avi"
else
echo "$1 is not Flash Video. Skipping"
fi
;;
esac
shift
done

justwantin 08-08-2009 04:10 PM

Nice little script!

adityavpratap 08-08-2009 11:24 PM

Hi,

Thanks for the prompt reply!

Quote:

$ mplayer -identify infile.flv
gives the following output -

Quote:

libavformat file format detected.
[flv @ 0x8e5da80]skipping flv packet: type 18, size 294, flags 0
ID_VIDEO_ID=0
[lavf] Video stream found, -vid 0
ID_AUDIO_ID=1
[lavf] Audio stream found, -aid 1
VIDEO: [H264] 208x142 0bpp 15.000 fps 0.0 kbps ( 0.0 kbyte/s)
ID_FILENAME=infile.flv
ID_DEMUXER=lavfpref
ID_VIDEO_FORMAT=H264
ID_VIDEO_BITRATE=0
ID_VIDEO_WIDTH=208
ID_VIDEO_HEIGHT=142
ID_VIDEO_FPS=15.000
ID_VIDEO_ASPECT=1.4648
ID_AUDIO_FORMAT=255
ID_AUDIO_BITRATE=0
ID_AUDIO_RATE=22050
ID_AUDIO_NCH=2
ID_LENGTH=214.69
ID_SEEKABLE=1
ID_CHAPTERS=0
and it plays the .flv file without any problem. However, the file audio.wav dumped by the following command,

Quote:

$ mplayer -vo null -vc null -ao pcm:fast:file=audio.wav infile.flv
is unplayable by mplayer. When I try to play the .wav file, I can only hear a short burst of sound as though the whole file has been played in a fraction of a second with the following output
Quote:

MPlayer UNKNOWN-4.2.4 (C) 2000-2009 MPlayer Team

Playing audio.wav.
Audio only file format detected.
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 44100 Hz, 2 ch, s16le, 1411.2 kbit/100.00% (ratio: 176400->176400)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
AO: [oss] 44100Hz 2ch s16le (2 bytes per sample)
Video: no video
Starting playback...
A: 0.0 (00.0) of 0.4 (00.3) ??,?%

Exiting... (End of file)
The script flash2avi outputs the following message -

Quote:

MEncoder UNKNOWN-4.2.4 (C) 2000-2009 MPlayer Team
Option lameopts: Unknown suboption fastreset
Error parsing option on the command line: -lameopts

Exiting... (error parsing command line)

adityavpratap 08-08-2009 11:31 PM

Quote:

Originally Posted by vanstra (Post 3636020)
I use the following 'flash2avi' script:

!#/bin/sh

should this be -

Quote:

#!/bin/sh

disturbed1 08-09-2009 12:14 AM

The script posted above wasn't wrapped in code tags and had bbcode enabled.

It should read -
Code:

mencoder "$1" $MENC_OPTS -vf pp=lb -oac mp3lame -lameopts fast:preset=standard -o "`basename $1 .flv`.avi"
AUDIO_FORMAT=255 I believe is aac audio. According to http://www2.mplayerhq.hu/DOCS/codecs-status.html#ac you need either libfaad2 or ffmpeg with aac support.
http://slackbuilds.org/repository/12.2/audio/faad2/

I find it quite strange that mplayer can play the original flv file with sound, but can not do a simple dump. As using dumpaudio, and -ao pcm:fast:file=audio.wav is actually no different than playing the file back. Playing the file back it has to be decoded, dumpaudio demuxes without decoding, -ao pcm:$ dumps the decoded stream. If mplayer can play the file, it should be able to dump it.

vdemuth 08-09-2009 12:57 AM

Why not just grab video downloader helper for FF from this link -> https://addons.mozilla.org/en-US/firefox/addon/3006 This will download and convert files from youtube with a couple of mouse clicks

chuckie 08-09-2009 01:34 AM

from MPlayer.SlackBuild

"The Slackware package is built with "USE_PATENTS=NO" i.e. without using
the lame mp3, faac, AMR and dvdcss libraries."

rkirk 08-09-2009 01:56 AM

Maybe you could use this:
Code:

$ ffmpeg -i infile.flv outfile.wav
That would seem the simplest way unless you want to use mplayer for a specific reason (I've never done this with mplayer, but I use ffmpeg all the time).

Ilgar 08-09-2009 02:18 AM

When the old -dumpaudio failed to work for the .mp4 files, I started using the following script to extract their audio; it seems to work for .flv files as well:

Code:

mplayer -quiet $1 -ao pcm:fast:file=$2  -vc dummy -vo null -channels 2
Here $1 is the .flv file and $2 is the output filename.

adityavpratap 08-09-2009 05:53 AM

Quote:

Originally Posted by Ilgar (Post 3636372)
When the old -dumpaudio failed to work for the .mp4 files, I started using the following script to extract their audio; it seems to work for .flv files as well:

Code:

mplayer -quiet $1 -ao pcm:fast:file=$2  -vc dummy -vo null -channels 2
Here $1 is the .flv file and $2 is the output filename.


Ok! Now this command works and I am getting mplayer-playable .mp3 files. That's a major achievement. Thanks Ilgar!

However, I want to upload these mp3s to my Samsung Ultra Touch S8300 mobile. When I do this, and try to play them using the music player app in my mobile, I get the following message -

Quote:

File has incorrect data
Any suggestions?

dwr1 08-09-2009 06:23 AM

I'm pretty sure mplayer outputs audio to raw pcm format. I've ripped audio from flv like that. I then use some mp3 encoder to turn it into an mp3.

adityavpratap 08-09-2009 06:30 AM

Quote:

Originally Posted by dwr1 (Post 3636524)
I'm pretty sure mplayer outputs audio to raw pcm format. I've ripped audio from flv like that. I then use some mp3 encoder to turn it into an mp3.

Yes I think so,

Quote:

file infile.mp3
gives the following output -

Quote:

Ennenno.mp3: RIFF (little-endian) data, WAVE audio, Microsoft PCM, 16 bit, stereo 44100 Hz

Ilgar 08-09-2009 07:00 AM

Oops yes, I forgot to add, you'll get a wav file that way (as you'll notice from the file size).


All times are GMT -5. The time now is 08:56 PM.