LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
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 04-07-2007, 03:48 PM   #1
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
HOWTO convert .flac to .mp3


yes i know mp3 is not the "going rage" and OOC and FLAC are as good or better, but the issue is i need to convert the flac to mp3 so i can use it in video editing. Adobe Premiere 6.5 DOES not use flac sound files.

all of the converters for windows SUX0R big time and i just need to convert 1 bloody file so im not going to be paying $20-$100 for a converter under windows for it.

this is NOT for a DVD to be sold, just one i am making for my school, thanks.
 
Old 04-07-2007, 03:55 PM   #2
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

If you've got mplayer and lame installed, then:
Code:
#!/bin/bash
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License version 2 as published by
#the Free Software Foundation.

#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details:
#http://www.gnu.org/copyleft/gpl.html

#Any questions at all, email me at: dave@davidstark.name

if ! [ -e "$1" ]
then
    echo "$1 does not exist."
    echo "Exiting."
    exit 1
fi

INFILE="$1"

if file -L "$INFILE" | grep RIFF | grep PCM | grep "16 bit" | grep stereo | grep 48000 &> /dev/null
    then
    RAWFILE="$INFILE"
else
    if [ -e "$INFILE".wav ]
	then
	echo "Decode output file: $INFILE.wav already exists."
	echo "Exiting."
	exit 1
    fi
    if ! mplayer -vo null -vc null -af lavcresample=48000,channels=2,format=s16le -ao pcm:file="$INFILE".wav "$INFILE"
	then
	echo "Couldn't decode $INFILE"
	echo "Exiting."
	exit 1
    fi
    RAWFILE="$INFILE".wav
fi

OUTFILE="$INFILE".mp3

if ! lame --preset insane "$RAWFILE" "$OUTFILE"
    then
    echo "Couldn't encode $OUTFILE"
    echo "Exiting."
    if [ "$RAWFILE" != "$INFILE" ]
	then
	rm -f "$RAWFILE"
    fi
    exit 1
fi

if [ "$RAWFILE" != "$INFILE" ]
    then
    rm -f "$RAWFILE"
fi
will do it for you (it'll convert any sound file that mplayer can play, even audio from video files). Just give the full path of the file as the argument.

It's set to produce 48000k sample rate and the highest possible quality which should be good for DVD.

Or you can just do:
Code:
flac -d /path/to/file.flac
Code:
lame --perset insane /path/to/decoded/file.wav
I happened to have the script handy, though.

Dave

Last edited by ilikejam; 04-07-2007 at 04:01 PM.
 
Old 04-07-2007, 03:57 PM   #3
uv256
Member
 
Registered: Feb 2007
Location: Israel
Distribution: openSuSE
Posts: 59

Rep: Reputation: 15
http://www.gurulabs.com/downloads/flac2mp3.pl

visit:
http://www.gurulabs.com/goodies/downloads.php

scroll down to flac2mp3

haven't tried myself so I don't know if it actually works

Last edited by uv256; 04-07-2007 at 04:00 PM.
 
Old 04-07-2007, 04:41 PM   #4
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
Quote:
you can just do:
Code:

flac -d /path/to/file.flac

Code:

lame --perset insane /path/to/decoded/file.wav

I happened to have the script handy, though.
with that, i just need lame installed, what about the flac stuff?
 
Old 04-07-2007, 04:55 PM   #5
ilikejam
Senior Member
 
Registered: Aug 2003
Location: Glasgow
Distribution: Fedora / Solaris
Posts: 3,109

Rep: Reputation: 97
Hi.

flac is probably installed. Can you run 'flac' from a shell?
 
Old 04-07-2007, 05:37 PM   #6
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
You could also use ffmpeg.

ffmpeg -i flacfile.flac -acodec mp3 -ab 128 mp3file.mp3

MP3 files are lossy, so I recommend convert the flac file into WAV or PCM.

There are better programs than Adobe Premiere that works in Linux. Cinelerra CVS is one of them. Another one is Jahshaka but the developers do not use good configure scripts to find the require libraries, so find pre-compiled versions for your distribution. Then the pathetic Kino. Like any program, you will have to learn how to use it.
 
Old 04-10-2007, 03:31 PM   #7
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
thanks all. sorry for the long delay in the thanks. my main box lost the PSU so i have been down trying to get that up and running again. top it off the new ram i picked up for it will not work with XP... so back to 2G instead of the 4G that MS claims XP can handle. system only reccognizes 2.5G out of the 4G installed that yes the BIOS sees and tells me is ok and ready to use.

bloody MS. sucks there is nothing as powerful or as easy to use as Adobe premiere 6.5 in Linux.
 
Old 04-10-2007, 07:10 PM   #8
Electro
LQ Guru
 
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
In order to use 4 GB of memory with out losing memory from virtual memory instructions, both the processor and the OS have to be 64-bit. A 32-bit OS and processor can handle more than 4 GB but PAE uses most of it for virtual addressing.

Kino is easy and quick. Cinelerra CVS is more powerful than Adobe Premiere. Adobe Premiere is a wimp compared to Cinelerra CVS. Cinelerra CVS compares to Avid. The hard thing to understand is both Cinelerra CVS and Kino can only handle a few formats, so the videos have to be re-encoded.

I suggest doing the following to use the desire video clip in Cinelerra CVS.

ffmpeg -i videoinput.avi -vcodec mjpeg -sameq -acodec u16_le videoutput.mov

You may need to double check the video codec and audio codec names if they are wrong.

Quicktime formats are better because they keep audio and video sync better than AVI.

BTW, you could have downloaded the flac codec for Windows. Adobe Premiere should be able to play back flac files with out any problems.
 
Old 04-10-2007, 11:37 PM   #9
lleb
Senior Member
 
Registered: Dec 2005
Location: Florida
Distribution: CentOS/Fedora/Pop!_OS
Posts: 2,983

Original Poster
Rep: Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551Reputation: 551
i didnt have more then 4G, just 4x1G PC3200 ram for this rig. my OS is not the 64bit vs, but according to MS, i dont need the 64bit vs for winXP Pro to access 4G of ram. i do have a 64bit CPU AMD 939chip 3800+

AVI allows for multi level video and audio when importing and working with data for editing.

IIRC a few years back i messed with Cinerlera, and it was just not very clean or easy to understand. very pore guides and things just were not easy to understand or follow the flow, plus it ONLY allowed for single line editing and not A/B editing.

again that was a few years ago. as for codec, i leave the video uncompressed and burn straight to DVD, or convert the AVI to a flash for web uploads.

some examples of the smaller edits i do for the web. also i do 10 - 60+min videos for display via DVD inside of my school.

http://www.ssma.us/media.html
 
Old 04-11-2007, 05:56 AM   #10
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 57
If you have kde you go on kde.org and download one of the audio converter addons.

Then open konqueror and right click, convert to (mp3,ogg,mpc,...)
 
Old 04-11-2007, 07:21 PM   #11
Pumalite
Member
 
Registered: Apr 2007
Location: All over
Distribution: Suse 10.2
Posts: 131

Rep: Reputation: 15
Quote:
Originally Posted by nx5000
If you have kde you go on kde.org and download one of the audio converter addons.

Then open konqueror and right click, convert to (mp3,ogg,mpc,...)

You could also try Audacity from Packman.
 
Old 09-24-2010, 12:58 PM   #12
hugogee
LQ Newbie
 
Registered: Sep 2010
Posts: 1

Rep: Reputation: 0
Or this

#!/bin/bash
##############
#Convert all files in directory into 128k mp3 files
# Using ffmpeg
###############

for FILE in *;
do ffmpeg -i "$FILE" -ab 128 "$FILE.mp3";
done
 
Old 02-12-2011, 08:55 AM   #13
imageintech
LQ Newbie
 
Registered: Feb 2011
Posts: 2

Rep: Reputation: 1
Taking out the Flac

@ hugogee. Excellent code thank you,
I found and edited the following to remove the ".flac" from "filename.flac.mp3" so the it becomes Only mp3

#find $1 -name '*.flac.mp3' | while read file; do
new=$(echo "$file" | sed s/'.flac.mp3/.mp3'/g)
mv "$file" "$new"
done

This works great recursive through directories, tested on Copied Directory numerous times

not sure if # is required when posting code in here, so i did

Thanks again hope this helps too :-)

Additional info on your code;

for FILE in *; will search directories for you if " */* " is used ( save selecting each dir )

Last edited by imageintech; 02-12-2011 at 06:49 PM. Reason: additional code
 
1 members found this post helpful.
Old 02-12-2011, 08:37 PM   #14
Zirbert
LQ Newbie
 
Registered: Oct 2010
Distribution: Ubuntu Studio
Posts: 13

Rep: Reputation: 0
I use a program called SoundConverter 1.4.4. It installed by default in Ubuntu Studio, but is probably available in other package managers. Easy to use, and does the job very well.
 
Old 12-29-2011, 03:36 AM   #15
igrowingbaby
LQ Newbie
 
Registered: Dec 2011
Posts: 2

Rep: Reputation: Disabled
Just google search Step-by-step Guide on How to Convert FLAC to MP3 using Windows or Mac

you will find a simple solution to convert flac to mp3, wma, wav, aiff, ogg, aac, mp2 and more

it even can help to convert ogg to mp3, ape to mp3, m4a to mp3, aiff to mp3, wav to mp3
 
  


Reply



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
Convert MP3, OGG, WAV, CDA or FLAC to WMA JerryP Linux - Software 12 03-02-2014 04:23 PM
quick bash script to convert flac to mp3 zuralin Programming 8 08-19-2011 03:50 AM
FLAC to MP3 General Linux - Software 3 12-28-2009 06:43 AM
flac to ogg and mp3 DJOtaku Linux - General 4 09-28-2005 05:24 PM
howto convert .flac to .mp3 Lleb_KCir Linux - Software 4 05-21-2005 06:07 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:39 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
Open Source Consulting | Domain Registration