LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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 11-10-2008, 02:23 PM   #1
djeikyb
Member
 
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Rep: Reputation: 33
Trouble with lame: unsupported audio format


I'm trying to convert some flac files to mp3. Normally I rip a cd to wav, convert to flac, and if its something I want on my ipod, use lame to transcode a copy. This last bit is failing after upgrading from hardy to intrepid. I checked synaptic, and made sure the libmp3lame0 package was installed. I also tried transcoding some flacs I'd done already, without success.

Code:
$ lame 01-track.flac 01-track.mp3
Warning: unsupported audio format
Any ideas what might be wrong?
 
Old 11-10-2008, 04:12 PM   #2
rjwilmsi
Member
 
Registered: Mar 2005
Location: UK
Distribution: opensuse 12.2 x86_64
Posts: 563

Rep: Reputation: 38
Well surely you have to convert the FLAC back into a wav file before lame can transcode it, using flac -d?
 
Old 11-12-2008, 10:09 PM   #3
djeikyb
Member
 
Registered: Nov 2005
Location: California
Distribution: ubuntu 10
Posts: 162

Original Poster
Rep: Reputation: 33
Hmm. Definitely don't remember having to do that. Most of my flac conversions have been done with a gui like Foobar2000. I guess all have, since you appear to be right. Anyhow, I found a nifty cli one-liner that converts flac to mp3. Much cleaner than what I was trying with xargs.
Code:
for file in *.flac; do $(flac -cd "$file" | lame -h - "${file%.flac}.mp3"); done
http://www.linuxtutorialblog.com/pos...ng-flac-to-mp3
 
Old 09-17-2023, 03:01 AM   #4
shaysah6
LQ Newbie
 
Registered: Sep 2023
Posts: 1

Rep: Reputation: 0
convert file with right click script in mac

this script takes a list of file arguments, checks if each file is a FLAC file, and if so, it converts it to MP3 with a bitrate of 320 kbps using flac and lame. For non-FLAC files, it directly converts them to MP3 with the same bitrate using lame.
Code:
#!/bin/bash

for file in "$@"; do
    if [[ "$file" == *.flac ]]; then
        /usr/local/bin/flac -cd "$file" | /usr/local/bin/lame -b 320 - "${file%.flac}.mp3"
    else
        /usr/local/bin/lame -b 320 "$file"
    fi
done
remeber to install:
Code:
brew install lame
Code:
brew install flac
explaination of each part of the Bash script:

1. `#!/bin/bash`: This is called a shebang line, and it's the very first line in your script. It tells the operating system which interpreter should be used to execute the script. In this case, `#!/bin/bash` indicates that the script should be run using the Bash shell.

2. `for file in "$@"; do`: This line starts a `for` loop that iterates over the arguments passed to the script (`"$@"`). The `"$@"` is a special variable that represents all the command-line arguments passed to the script.

3. `if [[ "$file" == *.flac ]]; then`: This is an `if` statement that checks if the current value of the `file` variable (which represents each argument) matches the pattern `*.flac`. The double square brackets `[[ ... ]]` are used for conditional tests in Bash.

4. `/usr/local/bin/flac -cd "$file" | /usr/local/bin/lame -b 320 - "${file%.flac}.mp3"`: If the condition in the `if` statement is true (i.e., the file is a FLAC file), this line is executed. It does the following:
- `/usr/local/bin/flac -cd "$file"`: This command uses the `flac` utility to decode the input FLAC file specified by `"$file"` and sends the output to the standard output (stdout) with the `-c` option.
- `|`: This is a pipe operator that takes the output of the `flac` command and passes it as input to the `lame` command.
- `/usr/local/bin/lame -b 320 - "${file%.flac}.mp3"`: This part uses the `lame` utility to encode the audio data received from `flac` and save it as an MP3 file. Here's what each part does:
- `-b 320`: This specifies a bitrate of 320 kbps for the MP3 encoding.
- `"${file%.flac}.mp3"`: This part specifies the name of the output MP3 file. It uses parameter expansion to remove the `.flac` extension from the input file (`"${file%.flac}"`) and appends `.mp3` to it to create the output file name.

5. `else`: If the condition in the `if` statement is not true (i.e., the file is not a FLAC file), this line is executed.

6. `/usr/local/bin/lame -b 320 "$file"`: This command uses the `lame` utility to encode the input audio file specified by `"$file"` to MP3 format with a bitrate of 320 kbps.

7. `fi`: This marks the end of the `if` statement.

8. `done`: This marks the end of the `for` loop.

In summary, your script takes a list of file arguments, checks if each file is a FLAC file, and if so, it converts it to MP3 with a bitrate of 320 kbps using `flac` and `lame`. For non-FLAC files, it directly converts them to MP3 with the same bitrate using `lame`.

Last edited by shaysah6; 09-17-2023 at 03:02 AM.
 
Old 09-17-2023, 10:49 AM   #5
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Old thread. But if anyone is converting one format to another. ffmpeg.

Code:
curl https://getsamplefiles.com/download/flac/sample-3.flac -o Samp1.flac

ffprobe Samp1.flac
...
Input #0, flac, from 'Samp1.flac':
  Metadata:
    ENCODER         : Lavf58.29.100
  Duration: 00:00:13.84, start: 0.000000, bitrate: 1148 kb/s
  Stream #0:0: Audio: flac, 32000 Hz, stereo, s32 (24 bit
  
file Samp1.flac
Samp1.flac: FLAC audio bitstream data, 24 bit, stereo, 32 kHz, 442851 samples

du -c Samp1.flac
1944    Samp1.flac
1944    total  
  

ffmpeg -i Samp1.flac -vn -c:a libmp3lame -b:a 128k Samp1.mp3


ffprobe Samp1.mp3
...
Input #0, mp3, from 'Samp1.mp3':
  Metadata:
    encoder         : Lavf60.3.100
  Duration: 00:00:13.90, start: 0.034531, bitrate: 128 kb/s
  Stream #0:0: Audio: mp3, 32000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc60.3.
      
file Samp1.mp3
Samp1.mp3: Audio file with ID3 version 2.4.0, contains: MPEG ADTS, layer III, v1, 128 kbps, 32 kHz, Stereo

du -c Samp1.mp3
220     Samp1.mp3
220     total
 
  


Reply

Tags
flac, lame, ubuntu



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
Unsupported format 'application/postscript'! seeism Linux - Hardware 3 08-14-2008 08:44 AM
Unsupported DVD Format with latest k9copy and 2.6.20.7 Vincent_Vega Linux - Software 8 11-25-2007 08:52 PM
Unsupported tif format arubin Linux - Software 3 02-18-2007 11:40 AM
Error 13 : Invalid or unsupported Executed Format. linuxnewbie82 Linux - Newbie 1 08-01-2006 07:19 AM
Unsupported wav format arubin Linux - Software 2 03-28-2005 02:12 AM

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

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

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