LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices



Reply
 
Search this Thread
Old 02-13-2005, 03:30 PM   #1
dexim
LQ Newbie
 
Registered: Jan 2005
Posts: 9

Rep: Reputation: 0
Convert avi to mp3


Anyone know a way to convert avi to mp3? Thank you in advance for any suggestions.
 
Old 02-13-2005, 04:13 PM   #2
mebrelith
Member
 
Registered: Nov 2004
Location: Torreón, Coahuila, México
Distribution: Gentoo
Posts: 342
Blog Entries: 1

Rep: Reputation: 30
Just to clarify, you want to convert AVI (a video format) to MP3 (an audio format)? Maybe you mean extract the audio from an AVI and save it as MP3? I don't have any clues as to how to di this, but your post looks confusing to me. Just wanting to verify.
 
Old 02-13-2005, 07:59 PM   #3
dexim
LQ Newbie
 
Registered: Jan 2005
Posts: 9

Original Poster
Rep: Reputation: 0
yes, I wish to extract audio from avi and save as mp3. http://www.google.com/search?hl=en&q...=Google+Search shows some Microsoft applications that do this. I have aprx 50 avi files totaling 5 GB in different directories. I want to run script or program from terminal to extract audio from files into mp3's, then move all of the mp3's into one directory. I can figure out how to write script to move files into new directory, im not sure how to get avi audio into mp3. any help will be greatly appreciated.
 
Old 02-13-2005, 08:57 PM   #4
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
I wrote a script which does just that. It needs mplayer and LAME:

Code:
#!/bin/bash

if [ -e "$1" ]
    then
    if ! mplayer -vo dummy -ao pcm -aofile any2wav.wav "$1"
	then
	echo "Couldn't decode $1."
	echo "Exiting."
	exit 1
    fi
    OUTFILE="$1.mp3"
    if ! lame --alt-preset standard any2wav.wav "$OUTFILE"
	then
	echo "Couldn't encode $OUTFILE."
	echo "Exiting."
	rm -f any2wav.wav
	exit 1
    fi
    rm -f any2wav.wav
else
    echo "$1 does not exist."
    echo "Exiting."
    exit 1
fi
Dave
 
Old 02-14-2005, 12:38 AM   #5
zippo85
Member
 
Registered: Dec 2004
Distribution: Fedora Core 3
Posts: 66

Rep: Reputation: 15
7
 
Old 02-16-2005, 12:20 AM   #6
dexim
LQ Newbie
 
Registered: Jan 2005
Posts: 9

Original Poster
Rep: Reputation: 0
Thumbs up

Thank you much Dave! very very helpful.
 
Old 10-05-2006, 12:02 AM   #7
JoseNeville
LQ Newbie
 
Registered: Jul 2005
Distribution: Fedora Core 4
Posts: 9

Rep: Reputation: 0
I have a file secret-world.mp4. How I can edit the script to work with it.
 
Old 10-05-2006, 03:37 AM   #8
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi.

No editing required. The file to be converted is just given as the argument to the script, e.g.
Code:
/path/to/the/saved/script secret-world.mp4
Dave
 
Old 10-05-2006, 08:25 AM   #9
JoseNeville
LQ Newbie
 
Registered: Jul 2005
Distribution: Fedora Core 4
Posts: 9

Rep: Reputation: 0
I received this message.

-aofile is deprecated. Use -ao pcm:file=<filename> instead.
Could not find "any2wav.wav".
Couldn't encode secret-world.avi.mp3.
Exiting.


Thanks
 
Old 10-05-2006, 12:55 PM   #10
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 3,513

Rep: Reputation: 64
Quote:
Originally Posted by JoseNeville
I received this message.

-aofile is deprecated. Use -ao pcm:file=<filename> instead.
Could not find "any2wav.wav".
Couldn't encode secret-world.avi.mp3.
Exiting.


Thanks
Try changing this line.

Code:
if ! mplayer -vo dummy -ao pcm -aofile any2wav.wav "$1"
To

Code:
if ! mplayer -vo dummy -ao pcm:file=any2wav.wav "$1"
Then see if it works.
 
Old 10-05-2006, 07:49 PM   #11
JoseNeville
LQ Newbie
 
Registered: Jul 2005
Distribution: Fedora Core 4
Posts: 9

Rep: Reputation: 0
This is the code

Quote:
#!/bin/bash

if [ -e "$1" ]
then
if ! mplayer -vo dummy -ao pcm:file=any2wav.wav "$1"
then
echo "Couldn't decode $1."
echo "Exiting."
exit 1
fi
OUTFILE="$1.mp3"
if ! lame --alt-preset standard any2wav.wav "$OUTFILE"
then
echo "Couldn't encode $OUTFILE."
echo "Exiting."
rm -f any2wav.wav
exit 1
fi
rm -f any2wav.wav
else
echo "$1 does not exist."
echo "Exiting."
exit 1
fi
this is the error now

Error opening/initializing the selected video_out (-vo) device.


Exiting... (End of file)
Could not find "any2wav.wav".
Couldn't encode secret-world.avi.mp3.
Exiting.
 
Old 10-05-2006, 07:51 PM   #12
JoseNeville
LQ Newbie
 
Registered: Jul 2005
Distribution: Fedora Core 4
Posts: 9

Rep: Reputation: 0
This is the code

Quote:
#!/bin/bash

if [ -e "$1" ]
then
if ! mplayer -vo dummy -ao pcm:file=any2wav.wav "$1"
then
echo "Couldn't decode $1."
echo "Exiting."
exit 1
fi
OUTFILE="$1.mp3"
if ! lame --alt-preset standard any2wav.wav "$OUTFILE"
then
echo "Couldn't encode $OUTFILE."
echo "Exiting."
rm -f any2wav.wav
exit 1
fi
rm -f any2wav.wav
else
echo "$1 does not exist."
echo "Exiting."
exit 1
fi
this is the error now

Error opening/initializing the selected video_out (-vo) device.


Exiting... (End of file)
Could not find "any2wav.wav".
Couldn't encode secret-world.avi.mp3.
Exiting.
 
Old 10-05-2006, 09:39 PM   #13
HappyTux
Senior Member
 
Registered: Mar 2003
Location: Nova Scotia, Canada
Distribution: Debian AMD64
Posts: 3,513

Rep: Reputation: 64
Quote:
Originally Posted by JoseNeville
This is the code



this is the error now

Error opening/initializing the selected video_out (-vo) device.


Exiting... (End of file)
Could not find "any2wav.wav".
Couldn't encode secret-world.avi.mp3.
Exiting.
Should have tried the command myself use this.

Code:
if ! mplayer -vo null -ao pcm:file=any2wav.wav "$1"
Or if wanting to do it faster.

Code:
if ! mplayer -vc null -vo null -ao pcm:fast:file=any2wav.wav "$1"
Now I just tried the actual command mplayer -vc null -vo null -ao pcm:fast:file=any2wav.wav file.avi not the script and it works fine this way.

Edit: Just tried the script it works with the line with the -vc null -vo null ... in it.

Code:
>$ ./avitomp3 dave\ chapelle\ -killing\ them\ softly.avi
MPlayer dev-SVN-rUNKNOWN-4.1.2 (C) 2000-2006 MPlayer Team
CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 3800+ (Family: 15, Model: 35, Stepping: 2)
CPUflags:  MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 1
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE SSE2
Opening joystick device /dev/input/js0
Can't open joystick device /dev/input/js0: Permission denied
Can't init input joystick
Setting up LIRC support...
mplayer: could not connect to socket
mplayer: Connection refused
Failed to open LIRC support.
You will not be able to use your remote control.

Playing dave chapelle -killing them softly.avi.
AVI file format detected.
VIDEO:  [MP43]  320x240  24bpp  14.993 fps  672.9 kbps (82.1 kbyte/s)
==========================================================================
Forced video codec: null
Opening video decoder: [null] Null video decoder
VDec: vo config request - 320 x 240 (preferred colorspace: BGR 24-bit)
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is undefined - no prescaling applied.
VO: [null] 320x240 => 320x240 Planar YV12
Selected video codec: [null] vfm: null (NULL codec (no decoding!))
==========================================================================
==========================================================================
Opening audio decoder: [pcm] Uncompressed PCM audio decoder
AUDIO: 22050 Hz, 1 ch, u8, 176.4 kbit/100.00% (ratio: 22050->22050)
Selected audio codec: [pcm] afm: pcm (Uncompressed PCM)
==========================================================================
[AO PCM] File: any2wav.wav (WAVE)
PCM: Samplerate: 22050Hz Channels: Mono Format u8
[AO PCM] Info: Faster dumping is achieved with -vc null -vo null -ao pcm:fast
[AO PCM] Info: To write WAVE files use -ao pcm:waveheader (default).
AO: [pcm] 22050Hz 1ch u8 (1 bytes per sample)
Starting playback...
A:   8.9 V:   3.3 A-V:  5.648 ct:  0.000  50/ 50  0%  0%  0.6% 50 0

           ************************************************
           **** Your system is too SLOW to play this!  ****
           ************************************************

Possible reasons, problems, workarounds:
- Most common: broken/buggy _audio_ driver
  - Try -ao sdl or use the OSS emulation of ALSA.
  - Experiment with different values for -autosync, 30 is a good start.
- Slow video output
  - Try a different -vo driver (-vo help for a list) or try -framedrop!
- Slow CPU
  - Don't try to play a big DVD/DivX on a slow CPU! Try some of the lavdopts,
    e.g. -vfm ffmpeg -lavdopts lowres=1:fast:skiploopfilter=all.
- Broken file
  - Try various combinations of -nobps -ni -forceidx -mc 0.
- Slow media (NFS/SMB mounts, DVD, VCD etc)
  - Try -cache 8192.
- Are you using -cache to play a non-interleaved AVI file?
  - Try -nocache.
Read DOCS/HTML/en/video.html for tuning/speedup tips.
If none of this helps you, read DOCS/HTML/en/bugreports.html.

A:3413.2 V:3413.2 A-V:  0.067 ct:  0.140 51175/51175  0%  0%  0.3% 47139 0

Exiting... (End of file)
LAME 3.97 64bits (http://www.mp3dev.org/)
Using polyphase lowpass filter, transition band: 10758 Hz - 11025 Hz
Encoding any2wav.wav to dave chapelle -killing them softly.avi.mp3
Encoding as 22.05 kHz VBR(q=2) single-ch MPEG-2 Layer III (ca. 7.3x) qval=3
    Frame          |  CPU time/estim | REAL time/estim | play/CPU |    ETA
130666/130666(100%)|    1:48/    1:48|    1:50/    1:50|   31.367x|    0:00
  8 [     2] *
 16 [     0]
 24 [     0]
 32 [     1] *
 40 [   338] *
 48 [ 19225] *****************
 56 [ 79033] *********************************************************************
 64 [ 27069] ************************
 80 [  4015] ****
 96 [   839] *
112 [   120] *
128 [    14] *
144 [    10] *
160 [     0]
----------------------------------------------------------------------------------
   kbps       mono %     long switch short %
   57.5      100.0        96.4   2.1   1.5
Writing LAME Tag...done
ReplayGain: -5.1dB

>$  ll *.mp3
-rw-r--r-- 1 stephen stephen 24M 2006-10-05 22:50 dave chapelle -killing them softly.avi.mp3

Last edited by HappyTux; 10-05-2006 at 09:51 PM.
 
Old 10-06-2006, 04:30 AM   #14
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 96
Hi all.

This is what I'm using at the moment (with the new-ish mplayer syntax)
Code:
#!/bin/bash

if [ -e "$1" ]
    then
    if ! mplayer -vo null -vc null -af lavcresample=44100,channels=2,format=s16le -ao pcm:file="$1".wav "$1"
        then
        echo "Couldn't decode $1."
        echo "Exiting."
        exit 1
    fi
    OUTFILE="$1.mp3"
    if ! lame --alt-preset standard "$1".wav "$OUTFILE"
        then
        echo "Couldn't encode $OUTFILE."
        echo "Exiting."
        rm -f "$1".wav
        exit 1
    fi
    rm -f "$1".wav
else
    echo "$1 does not exist."
    echo "Exiting."
    exit 1
fi
It makes sure everything's resampled to 2 channel 44.1kHz 16 bit little endian (CD format), using the high quality resampler before mp3ing.

Dave
 
  


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
How to convert an AVI file to a VCD? jon_k Linux - Software 4 03-07-2006 02:56 PM
Convert AVI to MPEG? mrgrieves Linux - Software 1 07-10-2004 04:04 PM
Convert avi to svcd skon Linux - General 2 12-29-2003 12:18 AM
convert avi to mpg jbogins Linux - Software 1 12-28-2003 10:30 AM
convert avi to mpeg xgreen Linux - Software 7 11-30-2003 10:45 AM


All times are GMT -5. The time now is 07:19 AM.

Main Menu
Advertisement
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