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 03-28-2020, 12:15 PM   #1
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Question ffmpeg Encoding audio files - sound quality


I'm re-encoding mp3 files to a bit rate of 48k - it's only radio plays so no music as such.
Code:
ffmpeg -i 02241429.MP2 -acodec libmp3lame -b:a 48k 02241429.mp3
Works fine, but it can get a bit warberly (squeaky) sounding, are there any other parameters I can use to remove this affect?

I could just keep them as they are - dab radio seems to use two bit rate, 80k and 128k, so I'm only saving up to 2/3rds of disk space.
 
Old 03-29-2020, 10:03 AM   #2
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
grep'ing all of my scripts. i got a few different ways I've done it before.
Code:
ffmpeg -b 128k -xerror -i "$f" ""${ARTIST}-${TITLE}-${ALBUM}-192k-"${f%.mp3}.mp3"
I use LAME
Code:
  
    # if MP3 is out of limits then re-sample it if not then send it through
 if [[ "${ext1}" == 'mp3' ]] ; then
     # start bitrate       128        start bitrate       160
	if [[ "${rateis}" -gt "${LameCheckRate}" ]] ; then
		lame -V2 -b"${LameLowEnd}" -B "${LameHighEnd}" -F --vbr-new -m j -q2 "$FILENAME" "$newFile"
		else
			# if MP3 is within limits then skip resmapling then just make 
			# a copy to move it 
			# to new directory/folder
			## WORKING SCRIPT DIRECTORY !
			exiftool "${script_dir}"/"${newFile}"
			
			cp "$FILENAME" "$script_dir"/"$newFile"
	fi
 
 fi # end first if
	fi #END of if off of find working dir
http://wiki.hydrogenaud.io/index.php?title=LAME

Last edited by BW-userx; 03-29-2020 at 10:07 AM.
 
1 members found this post helpful.
Old 03-30-2020, 12:38 PM   #3
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026

Original Poster
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
So my script now uses -q:a 8 as the most obvios option. I use this script to re-encode and change the name of the file to be more readable:
Code:
#!/bin/bash
#
# DAB file name format is MMDDHHMM.MP2 03301414.MP" > 03-Mar-30-1414.mp3
#
MONTHS=(ZZZ Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
for FF in *.MP2; 
do
echo Processing  $FF to ${FF:0:2}-${MONTHS[10#${FF:0:2}]}-${FF:2:2}-${FF:4:2}${FF:6:2}.mp3;
  
  /usr/bin/ffmpeg -y -i "$FF" -acodec libmp3lame  -q:a 8  ${FF:0:2}-${MONTHS[10#${FF:0:2}]}-${FF:2:2}-${FF:4:2}${FF:6:2}.mp3; 

done;
exit
And you can find more here: https://trac.ffmpeg.org/wiki/Encode/MP3
 
Old 03-30-2020, 01:39 PM   #4
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
I use LAME
 
1 members found this post helpful.
Old 03-31-2020, 04:19 AM   #5
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026

Original Poster
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Quote:
Originally Posted by BW-userx View Post
I use LAME
Isn't ffmpeg using LAME when I include?
Code:
-acodec libmp3lame
Anyway I'll take your script and process a few with LAME directly, thanks for the tip.
 
Old 03-31-2020, 05:57 AM   #6
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026

Original Poster
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
Thumbs up

Just tried lame - seems a far better quality of re-encoding, so the files are from DAB radio, and the bit rates are ither 128kbps or 80kbps, no music just voice, plays and so on.

Lame has a number of presets and I've tried them all:
Code:
A few aliases are also available for ABR mode:
phone => 16kbps/mono        phon+/lw/mw-eu/sw => 24kbps/mono
mw-us => 40kbps/mono        voice => 56kbps/mono
fm/radio/tape => 112kbps    hifi => 160kbps
cd => 192kbps               studio => 256kbps
The original file is an MP2 wrapper size of 45MB 128kbps
I re-encoded using all options up to voice and this is what I found:
phone - acceptable, small file 6.2MB
sw - acceptable, file size 9.3MB
mw-us - okay, file size 15.2MB
voice - fine, file size 20.5MB

So I'm going to use sw or mw-us in future, great tip from BW-userx, cheers
 
1 members found this post helpful.
Old 03-31-2020, 09:54 AM   #7
BW-userx
LQ Guru
 
Registered: Sep 2013
Location: Somewhere in my head.
Distribution: Slackware (15 current), Slack15, Ubuntu studio, MX Linux, FreeBSD 13.1, WIn10
Posts: 10,342

Rep: Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242Reputation: 2242
Happy to have been of some help.
 
1 members found this post helpful.
Old 03-31-2020, 12:08 PM   #8
GPGAgent
Senior Member
 
Registered: Oct 2018
Location: Surrey UK
Distribution: Mint 20 xfce 64bit
Posts: 1,026

Original Poster
Blog Entries: 3

Rep: Reputation: 133Reputation: 133
I forgot to add the modified script
Code:
#!/bin/bash
#
# DAB file name format is MMDDHHMM.MP2 03301414.MP" converted to 03-Mar-30-1414.mp3
# This makes it a bit more legible and using the month number make sure it sorts correctly
#
# Usage: lame --preset mw-us --tt "Episode 4" --ta "Inspector West" 03310600.MP2 Ep04.mp3
#
# lame --preset help
#
## A few aliases are also available for ABR mode:
## phone => 16kbps/mono        phon+/lw/mw-eu/sw => 24kbps/mono
## mw-us => 40kbps/mono        voice => 56kbps/mono
## fm/radio/tape => 112kbps    hifi => 160kbps
## cd => 192kbps               studio => 256kbps
#
MONTHS=(ZZZ Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec);
##PRESET=sw;
PRESET=mw-us;
TT="Afternoon Play";
TA="BBC R4";
for FF in *.MP2; 
do
echo Processing  $FF to ${FF:0:2}-${MONTHS[10#${FF:0:2}]}-${FF:2:2}-${FF:4:2}${FF:6:2}.mp3;
  
lame --preset $PRESET --tt "$TT" --ta "$TA" $FF ${FF:0:2}-${MONTHS[10#${FF:0:2}]}-${FF:2:2}-${FF:4:2}${FF:6:2}.mp3;
done;
exit
 
  


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
[SOLVED] High quality batch ffmpeg video encoding propofol Linux - Software 6 11-22-2012 01:57 PM
Chinese encoding not encoding in kate linuxmandrake Linux - Software 1 12-12-2010 08:50 AM
ffmpeg encoding wmv3 audio+video to flv fylnq Linux - Software 15 02-24-2010 04:15 AM
ffmpeg - psp [] Need help encoding to mp4 nomb Linux - Software 7 01-08-2007 07:42 PM
Best video Encoding (compression Vs. Quality) mshahwan Linux - Software 11 06-23-2006 03:33 AM

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

All times are GMT -5. The time now is 06:06 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