Skip to main content

Topic: how to compress 93gb speech mp3 files to opus files (Read 3337 times) previous topic - next topic

0 Members and 1 Guest are viewing this topic.
how to compress 93gb speech mp3 files to opus files
Hi I am Rupesh from India. I have a huge directory of size 93.5 gb with 8500 mp3 files and 2000 sub directories.

All these mp3s are speeches recorded by someone at 64 kbps. I want to compress these files recursively to opus using lame or another tool with 16 kbps bit rate and 11050 sample rate.

I have compressed the above huge directory with above options using ffmpeg and the resulted destination directory size was 29.5 gb and the quality was not good. Then I thought instead of compressing to mp3 it is better to compress and convert to opus.

I have compressed some mp3 files to opus recursively with foobar2000 and lamexp(a gui front end for lame) and the resulted opus files were satisfactory.

The quality of opus file generated is much higher than mp3 file generated using same bitrate and same sample rate. The quality I mean there are less sounds like shhh garrrr and other electronic sounds.

So I have decided to compress and convert all these mp3 speech files to opus.

I have examined some tools like ffmpeg,lame,foobar. lamexp tool is taking much time to convert and foobar is taking very much less time to convert. I want to maintain high quality in resulted opus files I mean I want a tool which can take maximum time and produce good opus file.

Can anyone of you suggest which is the best tool to convert and compress mp3 files recursively to opus. Please try to suggest 3 options I mean at 8kbps,16 kbps, 24 kbps with the corresponding sample rates which are perfectly suitable. Also suggest how to reduce noises if any in resulted opus files.

I think that there is no player for opus files in android and if you know any please suggest the best one possibly which can play files in folder view.


Regards,
Rupesh.

Re: how to compress 93gb speech mp3 files to opus files
Reply #1
First Opus only works at 48kHz even trough it can also work at others (8, 12, 16, 24) those are part of an extension and not waranted to work in all decoders and even opusenc don't support that extension. Also in mono it sounds a little better than stereo at the same bitrate specially at this low bitrates. For bitarte 14kbps mono is rougthly 16kbps stero and 18kbps mono is the same for 24kbps stereo. I recomend you to test in mono 14kbps 16kbps 18kbps and 24kbps.

For compression in mono I use:
sox --temp . imput.file -t .wav - gain -h channels 1 rate -v -s 48000 | opusenc --vbr --comp 10 --bitrate 18 - output.file

But it can be simplified to:

sox  imput.file -t .wav - gain -h channels 1 rate -v -s 48000 | opusenc  --bitrate 18 - output.file

both --vbr and --comp 10 are the default opusenc parameters
and if you change channels to 2 the encoding is in stereo


  • saratoga
  • [*][*][*][*][*]
Re: how to compress 93gb speech mp3 files to opus files
Reply #2
Use foobar2000 with the latest opus encoder.

Re: how to compress 93gb speech mp3 files to opus files
Reply #3
Use foobar2000 with the latest opus encoder.

Please review what Phanton_13 has suggested

  • saratoga
  • [*][*][*][*][*]
Re: how to compress 93gb speech mp3 files to opus files
Reply #4
Use foobar2000 with the latest opus encoder.

Please review what Phanton_13 has suggested

I read it before I posted.

Re: how to compress 93gb speech mp3 files to opus files
Reply #5
I can't understand what Phanton_13 suggested ie., does it mean input.file is input.mp3, and does it mean output.file is output.opus and also does it mean sox is the best decoder. Can we use 48khz with 16 kbps

Some of the requests made by me in first post were not answered
I want a tool or a set of tools which takes maximum time and produce a opus file with good quality and so please suggest.

I have examined foobar2000 which is taking less time and lamexp which is taking much time to convert and so does it mean foobar is worst and lamexp is the best.

Previously I have searched web to convert files recursively using ffmpeg and found a Windows batch script which I am providing below

Code: [Select]
@echo off
setlocal EnableExtensions DisableDelayedExpansion

rem // Define constants here:
set "_SOURCE=C:\Rupesh\to convert"
set "_TARGET=E:\Rupesh\ffmpeg out"

rem // Change to source directory temporarily:
pushd "%_SOURCE%" || exit /B 1
rem // Enumerate source files, return paths relative to the source directory:
for /F "delims=" %%F in ('xcopy /L /S /I ".\*.mp3" "%_TARGET%" ^| find ".\"') do (
    echo Currently converting "%%F"...
    rem // Create destination directory, suppress error if it aready exists:
    mkdir "%_TARGET%\%%F\.." 2> nul
    rem // Perform actual file conversion, using paths relative to target directory:
    ffmpeg -i  "%%F" -v quiet -codec:a libmp3lame -b:a 16k -ar 11025 -map_metadata 0 -id3v2_version 3 -write_id3v1 1 "%_TARGET%\%%F\..\%%~nF.mp3"
)
echo Completed.
popd

endlocal
exit /B

In the above code it is possible to delete ffmpeg code and substitute our own code.

I think that command line tools or a script which is a list of commands are better than guis. In foobar2000 it is possible to select custom encoder and decoder and so which is best foobar or a script like above.

  • saratoga
  • [*][*][*][*][*]
Re: how to compress 93gb speech mp3 files to opus files
Reply #6
There are only two opus encoders, and one is the incomplete one in ffmpeg that nothing uses yet, so everything should be using libopus.

If you want to encode opus with good quality, download the lastest encoder and pair it with whatever software you want. Foobar2000 is a good choice but you can use something else if you prefer.

Phanton_13 posted instructions on how to resample files using sox. You can use that instead of foobar if you want.

Re: how to compress 93gb speech mp3 files to opus files
Reply #7
In lame there is an option -q which stands for algorithmic quality and if we set it to 0 the produced mp3 file is of highest quality and so is there any similar quality option in opusenc.

Can I set decoder option in foobar2000 to sox.

Can I use 48 khz with 16 kbps during conversion.
  • Last Edit: 30 May, 2017, 11:53:54 PM by rupeshforu3

  • saratoga
  • [*][*][*][*][*]
Re: how to compress 93gb speech mp3 files to opus files
Reply #8
In lame there is an option -q which stands for algorithmic quality and if we set it to 0 the produced mp3 file is of highest quality

Fwiw the meaning of the q switches was changed over the years:

https://hydrogenaud.io/index.php/topic,101132.msg835819.html

Now zero is no different then the default, at least in vbr mode.

Opusenc has a similar option, but like lame the default is highest quality.

Re: how to compress 93gb speech mp3 files to opus files
Reply #9
Can we use 48 khz sample rate with 18 kbps in encoding to opus what Phanton_13 posted.

Can anyone of you suggest players for opus files in android. I have examined foobar for android and backdrop in it is it is scanning the whole media files and showing artists and albums which I don't want I just want to play a certain folder which contains opus files and discard everything else. The player called folder player has this feature but it can't play opus files. Can you suggest a player with simple interface for android to play opus files.
  • Last Edit: 31 May, 2017, 12:50:07 PM by rupeshforu3

Re: how to compress 93gb speech mp3 files to opus files
Reply #10
rupeshforu3, opus only works at 48khz it doesn't support any other samplerate in the official part of the standard. And for android opus player I recomend AIMP or MATERIAL PLAYER (this last one is an audiobook player), at least both support opus in my phone.
  • Last Edit: 31 May, 2017, 05:00:36 PM by Phanton_13

Re: how to compress 93gb speech mp3 files to opus files
Reply #11
Can you suggest how to maintain directory structure of source in foobar and also how to set channels to mono in foobar.

Re: how to compress 93gb speech mp3 files to opus files
Reply #12
I have used opusenc in foobar with 18 kbps and added resample option in others and configured it to 48 khz.

Files converted with foobar are also contaning lot of noise. I have choosen opus because there will be less noise compared to mp3 but my expectations are false. Please suggest how to reduce noise.

Re: how to compress 93gb speech mp3 files to opus files
Reply #13
The questions are: what noise? and: is the noise present in the original file?

Re: how to compress 93gb speech mp3 files to opus files
Reply #14
In some of the original mp3 files a person will be speaking and there are no other sounds like guitar, violin,harmonium etc. In other original mp3 files a person will be speaking and there are other sounds stated above.

Some I mean few of the original mp3 files are poor in quality.

When I try to convert an mp3 file containing other instruments and files with poor in quality the output opus file generated is too worse. When I try to play these poor quality opus files in AIMP player(android) I am unable to hear what the person is speaking and instead I am hearing noise like shhhh garrrr and other electronic sounds.

  • saratoga
  • [*][*][*][*][*]
Re: how to compress 93gb speech mp3 files to opus files
Reply #15
When I try to play these poor quality opus files in AIMP player(android) I am unable to hear what the person is speaking and instead I am hearing noise like shhhh garrrr and other electronic sounds.

Do they sound ok when played using a player like foobar2000?

Re: how to compress 93gb speech mp3 files to opus files
Reply #16
Playing the file in foobar is better than playing in AIMP. The same file converted to mp3 using ffmpeg is more worse.

I can't understand why the converted opus file is contained that much noise.

Please suggest how to reduce this noise.

  • sPeziFisH
  • [*][*][*][*]
Re: how to compress 93gb speech mp3 files to opus files
Reply #17
rupeshforu3, it makes sense to clean up your 1st post and link to the other thread you opended and people supported you, this makes things clearer.
Further compressing already compressed files, also ones which contain naturally-harmonic instruments even though there is simple speech, while "maintaining" quality mostly means trade-offs, 64kbit/s isn't ultra-much.

For batch-conversion I suggest Foobar2000, which is the weapon of choice of most of here at HA, superb at all disiplines, or check out e.g. https://github.com/wieslawsoltes/BatchEncoder
(last one is like the good ol' batch-frontends used in the past, e.g. Speek's Multi Frontend, Boereck's (Max Bureck) UniversalFront or mdati00's (Mattias Dahlberg) Frontah)
  • Last Edit: 02 June, 2017, 05:57:43 AM by sPeziFisH

Re: how to compress 93gb speech mp3 files to opus files
Reply #18
In opus documentation I have read that opus is the best choice for speech files at lower bitrates and they have compared it with mp3 and declared that opus is far superior.

Upon examining the opus files I have noticed that they are not superior not even equal to mp3 files.

I have also noticed that 50% of the mp3 files compressed to 32 kbps are having very less noise. Inorder to save more hard disk space I have decided to compress to 16 kbps opus or mp3.
  • Last Edit: 02 June, 2017, 06:51:06 AM by rupeshforu3

  • sPeziFisH
  • [*][*][*][*]
Re: how to compress 93gb speech mp3 files to opus files
Reply #19
1st - speech with sound is not pure speech anymore, so low bitrates might come with hearable artifacts
2nd - most statements of quality are made with clean input, input with artifacts as base (due to lossy sources) is a different situation- this should be considered properly while evaluating
3rd - you'll get your personal compression and your personal quality, so you'll be fine at all - but..
4th - lost quality and sources once thrown away, irreversibel, means lost at all

Re: how to compress 93gb speech mp3 files to opus files
Reply #20
Upon performing a number of experiments I came to conclusion that opus is the best codec for speech.

I have tried foobar and dbpowerAMP to convert mp3 to opus and they produced good quality files but they are unable to produce directory structure same as source. After that I have downloaded lamexp latest version ie., lamexp 2017 and installed it and tried it. Lamexp is a open source software which combined binaries of latest encoders like lame, opusenc,sox etc.,

Lamexp produced high quality opus files and maintained directory structure of source and also added meta data to the produced files.

In lamexp there is an option to specify mono or stereo and I selected mono but when I have examined the output files I am able to see stereo instead of mono. Phanton_13 suggested to use mono for listening quality.

I have followed what phanton_13 suggested ie., using 48000 sample rate for all bitrates and I have choosen 16 kbps to quality source files and 24 kbps to poor quality sources.

In lamexp I have selected options for 16 bit abr encoding as and similar to 24 kbps
--cvbr --comp 10 --framesize 20 --bitrate 16

The noise is less now compared to before I mean when I have used 24000 sample rate.

In lamexp there are ways to pass additional parameters via command line and so I am requesting phanton_13 how to force mono instead of stereo. Almost I have converted all mp3 speech files to opus and so is there any way to downgrade from stereo to mono.

Thanks to phanton_13 for giving valuable suggestions.
  • Last Edit: 16 June, 2017, 11:02:07 AM by rupeshforu3

  • spoon
  • [*][*][*][*][*]
  • Administrator
Re: how to compress 93gb speech mp3 files to opus files
Reply #21
>dbpowerAMP to convert mp3 to opus and they produced good quality files but they are unable to produce directory structure same as source.

For your naming string set:

[origpath]\[origfilename]

Re: how to compress 93gb speech mp3 files to opus files
Reply #22
Suppose source directory is d:\dir1\dir2\dir3\file.mp3 and I try to convert using your option I am getting output file as e:\dir1\file.opus or as e:\dir2\file.opus.

In foobar or dbpowerAMP we have several options as artist name, album name etc., and we can combine these to produce destination directory structure but none produce the same structure as source and even we have similar problems in writing meta data but in lamexp none of these problems exist and even it is easy to configure lamexp.

  • spoon
  • [*][*][*][*][*]
  • Administrator
Re: how to compress 93gb speech mp3 files to opus files
Reply #23
[origpath] in your example would give:

dir1\dir2\dir3

What is your naming string set to exactly? The [origpath] has been well tested over 10 years, I have not known it to fail as you describe.

Re: how to compress 93gb speech mp3 files to opus files
Reply #24
rupeshforu3 you can add "--downmix-mono" to the opus encoder in lamexp, it appears that lameXP don't downmix to mono and it can be a bug. Another option is TAudioConverter it also maintains the folder structure and transfer the tags, is less updated but you can update the encoders and decoders manually.