Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Transcode Opus file to MP3/AAC (Read 14236 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Transcode Opus file to MP3/AAC

I have a few hundred Opus encoded music files (not copyrighted) that I wish to transcode to MP3 or AAC.

Some preliminary remarks:
- I know that in principle lossy-to-lossy is not a great idea, and I risk to lose some quality;
- I know Opus is a very good/efficient codec, in particular for low bitrates, but it is currently not supported on the players I want to use (but I will keep the original Opus file, for future use);
- I understand AAC is more efficient than MP3 at lower bitrates, but I have a bias in favour of MP3 for a couple of reasons : I use ffmpeg/lame, and I don't have the skills/time to compile ffmpeg myself with libfdk_aac; I don't want to install fb2k convertor with the Apple AAC codec; lame really is very good, in particular at higher bitrates; MP3 still has wider support than AAC. But, if conversion from Opus to AAC would be better (more efficient, less artifacts, ...), happy to forego MP3 and go the AAC route;
- The music is not only for myself, but for kids & family as well, and I do not want to run an ABX test to find "lowest acceptable setting" for myself, as my own hearing/player might not be representative for other listeners or audio equipment. So while acknowledging that quality will always remain subjective, my aim is just to lose as little as possible.

So my question is what your recommended settings are to transcode the files.

Source files are Opus files with avg bitrate in the 125-135 kbs range, sourced from Youtube.

Some further considerations (or rather : where my doubts come from ;)

I think I fairly well understand the various options / settings when encoding a lossless file into a lossy format, but I just conceptually struggle with determining the best settings for transcoding such lossy file, while trying to keep all audio/quality information present in the source file.

Let's take an Opus source file of 3.6Mb file, so it is my understanding that the maximum amount of information in the file is not more than 3.6Mb. So I would assume that if I use the highest possible VBR setting (v0 for MP3), all (or as much as possible) audio information would be kept, but no new information can be "created" by the new codec, so the file size should not be much bigger.
However, I did some testing with various quality settings (using ffmpeg/lame), and this are the resulting file sizes (avg bitrate) : -q:a 0 gives a 7.1Mb file (242kbs), -q:a 1 6.3Mb (212kbs), -q:a 2 5.3Mb (181kbs). So even if Opus is more efficient in encoding, not sure that the file-size increases are reasonable ...

I understand that from lossless, -q:a 0/1/2 are virtually undistinguishable/transparent. But is this the same when transcoding from a lossy file?

The difference between -q:a 0 and -q:a 2 is 1.8Mb in filesize. When encoding from a, let's say, 60Mb file lossless wav, this would only be a 3% difference, so I can grasp that the difference is imperceptible because of the codec performance.
But if the codec only has 3.6Mb of information to work with, the 1.8Mb of difference in output file size is a massive 50% of the source file !

So should I just "take the hit" (and more than double the file size), and use -q:a 0 to avoid any quality loss?
Or is the recommendation that  -q:a 0/1/2 are "transparent" also true for encoding from a lossy file?
Or could I go even lower (-q:a 3/4?) without losing any quality?

Thanks !

Re: Transcode Opus file to MP3/AAC

Reply #1
You are wrong in more than one way... you don't understand anything of how compression works and need to learn more about information theory.

Compression is basically a way to encode the data in less size that its original size, the resulting size is dependent of the compressor and the time you want to spend finding the best way to encode the file.

Then lossy compression is a especial case where the compressor don't encode all the data, only encoding the one that mather based on a data model, but in place of this data when you decode the file is going to be noise and/or faked or reconstructed data. Even although this is a simplification you can basically tell that the amount of data don't change, what changes is the data itself and the amount of data is the same as the one present in the original file.

Re: Transcode Opus file to MP3/AAC

Reply #2
Source files are Opus files with avg bitrate in the 125-135 kbs range, sourced from Youtube.

Since one of the forum administrators recently mentioned youtube-dl, I guess that is within the Terms of Service: you can just redownload an AAC version, then?

Let's take an Opus source file of 3.6Mb file, so it is my understanding that the maximum amount of information in the file is not more than 3.6Mb.
[...]
The difference between -q:a 0 and -q:a 2 is 1.8Mb in filesize. When encoding from a, let's say, 60Mb file lossless wav, this would only be a 3% difference, so I can grasp that the difference is imperceptible because of the codec performance.
But if the codec only has 3.6Mb of information to work with, the 1.8Mb of difference in output file size is a massive 50% of the source file !
In principle, you got a point: it is patently possible to fit the information in 3.6 megabytes, and what is then the extra 1.8 ... ?
But in practice, it does not go that way. If you decode your 3.6 file to 60, you cannot compress it losslessly back to 3.6 - that would be, kinda, like "brute force password cracking": There is a 3.6 file that does it, but if you don't have it, you cannot just compute it.
Re-encoding introduces new lossiness. Luckily, it is not "double the loss" (as has been demonstrated by listening tests).

(By the way, filesizes are commonly given in "MB" for megabytes. Transfer speeds are commonly given in "Mb/s" for megabits per second.)


Re: Transcode Opus file to MP3/AAC

Reply #3
[...] when you decode the file is going to be noise and/or faked or reconstructed data.

Yes indeed, I am not an expert (not in coding, not in information theory, and not in audio), and it is the above part of what a codec does that I was not sure about. But still not clear why the decoding would add noise, instead of just "nothing" (zeroes, as most of it is un-audible data) by reconstructing the PCM stream, so the new encoder could just ignore it.

Or also, as transcoding does happen in real life, why there is not (among the myriad of options and switches of ffmpeg or other tools) a decoding setting that just decompresses the audio information of the encoded source file (without adding noise/fake data), so that the new encoder can take 100% of that raw (useful) data, and just apply its own compression algorithm into the new format.

Re: Transcode Opus file to MP3/AAC

Reply #4
[...] you can just redownload an AAC version, then?
Yes, that would be possible of course. But the best quality you can get from youtube is the opus encoded file, and the premise of the exercise is that by transcoding the opus file transparently into AAC or MP3, the result would be audibly better than just taking that lower quality AAC file from youtube. And my initial question was then what the recommended settings are for transparency in case of transcoding an opus file.

If you decode your 3.6 file to 60, you cannot compress it losslessly back to 3.6 - that would be, kinda, like "brute force password cracking": There is a 3.6 file that does it, but if you don't have it, you cannot just compute it.
Re-encoding introduces new lossiness.
Yes, I see the analogy, thanks for making it much clearer.
However, as I wrote in my previous reply, it seems quite curious that that in the process of handing information from decoder A to encoder B, the only way is to go through a re-composed PCM stream, and that there is not an option/setting that makes a difference between (i) the actual (real/important audio) information that encoder A has kept in the lossy file and (ii) the interpolation/noise introduced to arrive at a valid/audible PCM file, so that encoder B could take 100% of that valuable data for its encoding process.

Well, I guess that technically this would be possible, but maybe it would not be possible generically, and you would need a specific transcoder for each format pair (opus>MP3, opus>AAC, MP3>opus, etc.).

Re: Transcode Opus file to MP3/AAC

Reply #5
Well, I guess that technically this would be possible
I think that for Opus to MP3/AAC transcoding it's not even technically possible due to different frame sizes.

Re: Transcode Opus file to MP3/AAC

Reply #6
Well, I guess that technically this would be possible, but maybe it would not be possible generically, and you would need a specific transcoder for each format pair (opus>MP3, opus>AAC, MP3>opus, etc.).

Technically that is not possible unless special cases.

One clear example of this is of what happens betwen AAC and HE-AAC.

AAC view the audio spectrum full (A).
HE-AAC separates the audio spectrum in two one of lower frequencies (B) and other of high frequencies (C).

A and B are actually encoded exactly in the same way, then we can tell that A=B.
C is directly tossed, and some minimal data (D) is added to fake-recontruct C (this is called Spectral Band Replication or SBR)

Then HE-AAC = AAC+side data(D) , in other works HE-AAC is AAC+SBR

There are 3 ways to go from HE-AAC to AAC and their equivalents from AAC to HE-AAC:

One is to re-encode the data

Other is in  HE-AAC to AAC to toss the reconstruction data of the HF and lose those frequencies with the subsequent quality, or in the case of AAC to HE-AAC is to tell that the file is HE-AAC and add fake data as D that do nothing....

The 3rd option is the most interesting as in AAC to HE-AAC you can partially decode the AAC file up to the DCT blocks, then doing some magic (math hard to understand to the layman) on those blocks you toss those the high frequencies that form the C part and resample the file, then you use the original blocks to derive a reconstruction data (D) and finally generate the HE-AAC. For going HE-AAC to AAC is similar but in reverse (decode up to DCT blocks, magic to resample, fake the missing data, add the data to the blocs and generate the AAC file)

While this 3rd option is closer what you want  but the bitrate can't be the same due to the nature of the fake-recontruct data and not real equivalence betwen the codecs for all tools as you have an extra tool in HE-AAC, another thing is that process while theoretically possible with some demonstrations the quality is lower that to simply re-encode the files primarily due to the actual implementation of SBR as it was implemented as an add on instead of a extension in the core of AAC.

Also count that this HE-AAC and AAC example is a special case as most codecs are very diffrent, having even different transforms (mainly variation of the DCT transform but not compatible betwen them) making the only common part between them the full decodec audio.

Read this to know better how codecs work and for what what you want is not possible normally:
http://www.linkwitzlab.com/Brandenburg_mp3_aac.pdf
https://people.xiph.org/~xiphmont/demo/celt/demo.html (one of the 2 codeds merged in opus)
https://web.archive.org/web/20070316003615/http://www.ebu.ch/en/technical/trev/trev_305-moser.pdf

Even after reading this the HE-AAC and AAC example is not obvious and is in the realm of hard magic.

Re: Transcode Opus file to MP3/AAC

Reply #7
@lvqcl
@Phanton_13
Thanks for your insights. Very interesting, I learned a lot about codecs today !

And would you have any advice re: the original question, i.e. recommended settings to achieve a transparent transcoding from Opus (VBR 125-135 kbs encoded) to MP3 or AAC ?

Tx.

Re: Transcode Opus file to MP3/AAC

Reply #8
May i ask you question? Why not use Ogg Vorbis?
 Convert your music files to ogg Q7 - is about 192K VBR - file size less than mp3 file size and much more better quality than mp3...
And AAC... AAC just replicate your high freq is not the same as it was.... Its too much high freq sounds who sounded very weird..
But yours bass and mids freq sounded as it was...

Re: Transcode Opus file to MP3/AAC

Reply #9
May i ask you question? Why not use Ogg Vorbis?
Well, I aim for maximum compatibility, also for older players, car, windows, ios, itunes, android, DJ apps, etc. So I think MP3 currently just has the widest acceptance across the board.
And my music collection currently is exclusively MP3 and AAC, so I am just not very enthusiastic about adding a new format; I could just as well keep the original opus files then.
And thanks for not recommending AAC; so at least one choice discarded...

I made a test with ogg -q:a 7, and this gave a 6MB file with 240kb/s avg bitrate.
Closest in size was the -q:a 1 MP3, which gave a 6.3MB file with 212kb/s avg bitrate.

Re: Transcode Opus file to MP3/AAC

Reply #10
And would you have any advice re: the original question, i.e. recommended settings to achieve a transparent transcoding from Opus (VBR 125-135 kbs encoded) to MP3 or AAC ?
MP3 and AAC have been demonstrated to be transparent for most people for all but the most exceptional samples at 192 kbps.  Start with MP3 -V2 or AAC --tvbr 90 and adjust up from there if you hear artifacts.  The resulting files should be about 50% larger than your source files.  The 212 kbps MP3 file you already created is fine.

Re: Transcode Opus file to MP3/AAC

Reply #11
When you use mp3 for decode i just suggest you use 224k CBR or ABR its still can be nice for yours ears.
Somewhere on 192K and below 192k its can be like plastic and metallic sound. But its still acceptable for pop and dance music.
Not good for listening heavy metal, jazz and blues and chillout and classic music.

Re: Transcode Opus file to MP3/AAC

Reply #12
This thread begins to violate TOS8...  :-\

Re: Transcode Opus file to MP3/AAC

Reply #13
When you use mp3 for decode i just suggest you use 224k CBR or ABR its still can be nice for yours ears.

Interesting that you recommend CBR 224 kb/s and not VBR (with a high-quality setting). Is this because in my case the source file is already lossy, or do you in general prefer CBR over VBR? And if so, could you further explain why?
Thanks.

Re: Transcode Opus file to MP3/AAC

Reply #14
MP3 and AAC have been demonstrated to be transparent for most people for all but the most exceptional samples at 192 kbps.  Start with MP3 -V2 or AAC --tvbr 90 and adjust up from there if you hear artifacts.  The resulting files should be about 50% larger than your source files.  The 212 kbps MP3 file you already created is fine.

Thanks a lot. A very useful and concrete recommendation.
The 212kb/s file was actually -V1, and is 75% larger than the opus source file.
-V2 gave a 5.3MB file, i.e. 47% larger , with an avg. 181kb/s.
Giving in to my OCD tendencies, I probably will go for -V1 ...

I will do some further testing with qaac.

Re: Transcode Opus file to MP3/AAC

Reply #15
This thread begins to violate TOS8...  :-\

That was not my intention.
I wanted
(1) to know whether technically there is a difference whether the source file is lossy or lossless to choose encoding settings (i.e. do you need different settings to ensure transparency), and
(2) whether in the decoding/encoding process something could be done (with settings/switches) so that 100% of "useful" audio information would be passed through from the lossy source file to the lossy target file.

From various comments I understand that the answer is NO for both...

Re: Transcode Opus file to MP3/AAC

Reply #16
[...] you can just redownload an AAC version, then?
Yes, that would be possible of course. But the best quality you can get from youtube is the opus encoded file, and the premise of the exercise is that by transcoding the opus file transparently into AAC or MP3, the result would be audibly better than just taking that lower quality AAC file from youtube.

Hm. I just checked and found that a few YouTube audio streams reported as 192 kb/s AAC, are indeed "only" 125. So you have a theoretical point that Opus@ hundredandfiftysomething could be the safest option.
But how much bitrate must one have for upload -> Opus -> AAC to be (question I) transparent relative to Opus or (question II) a better solution than the AAC at 125? Too lazy to spend days on listening :-o

Re: Transcode Opus file to MP3/AAC

Reply #17
(1) to know whether technically there is a difference whether the source file is lossy or lossless to choose encoding settings (i.e. do you need different settings to ensure transparency), and
(2) whether in the decoding/encoding process something could be done (with settings/switches) so that 100% of "useful" audio information would be passed through from the lossy source file to the lossy target file.

From various comments I understand that the answer is NO for both...

Maybe the answer is "likely not much, nobody knows if at all, so you might as well ...".

Some codecs use noise substitution rather than highpass:
Instead of thinking "the highest frequencies take up too much space, you get more fidelity for the bits by filtering them off", the idea could be "replacing high frequency content by different high frequency content is less of a loss than just removing them, and with a built-in algorithm it need not take much space". Whether that means anything for transcoding ... dunno. I would be surprised if one cannot construct situations where it would, but we are not trying to construct those situations here: we take codecs that are already on the table, at a more or less given range of bitrates.

Re: Transcode Opus file to MP3/AAC

Reply #18
Hm. I just checked and found that a few YouTube audio streams reported as 192 kb/s AAC, are indeed "only" 125. So you have a theoretical point that Opus@ hundredandfiftysomething could be the safest option.
But how much bitrate must one have for upload -> Opus -> AAC to be (question I) transparent relative to Opus or (question II) a better solution than the AAC at 125? Too lazy to spend days on listening :-o

Yeah, and the opus that youtube lists as 160 is in reality "only" in the 125-135 range. It is of course all dependent on the quality of the source file uploaded to youtube. I assume uploaders will use highest quality that they have available and that youtube allows, but probably I am too optimistic  8)

Moreover, my transcoding will be probably already be the 2nd or 3th one ... :
1) from whatever source (lossless or even lossy) to the actual file (lossy) that the uploader puts on youtube
2) the internal transcoding youtube does
3) my transcoding

But the AAC file will also already have been transcoded by youtube from the source, so this brings me back to my point that I think a 128kb/s opus file is higher quality to start with than a 128kb/s AAC, so my transparent -V1 encoding should not do any "damage" and approximate the opus quality that I get from youtube.

Quote
"likely not much, nobody knows if at all, so you might as well ...".

Yeah. So you corroborate that I should use -V1 and not -V2 ...  ;D


Re: Transcode Opus file to MP3/AAC

Reply #19
I would opt for OPUS >> MP3 CBR / ABR 160..224 depending on how the transcode sounds - go with the lowest bitrate possible.  VBR could be compromised from the addtional distortion in the source (the vbr psy model is more aggressive may make wrong assumptions etc.. )

Re: Transcode Opus file to MP3/AAC

Reply #20
I would opt for OPUS >> MP3 CBR / ABR 160..224 depending on how the transcode sounds - go with the lowest bitrate possible.  VBR could be compromised from the addtional distortion in the source (the vbr psy model is more aggressive may make wrong assumptions etc.. )

Thanks a lot. That is very useful, in particular your suggestion that the psy model used for VBR might actually do more harm than good for encoding an already lossy file.
I did some further searching, and this HA topic was also very useful in further explaining ABR vs VBR.

Although in many posts ABR seems to be considered the "ugly duckling", I have the impression that in my case, ABR would be the best solution: as you said, less reliance on the psy model that might give undesired results if input file is lossy, but still giving the encoder the flexibility to adapt bitrate in function of complexity of the file. As I understand from the HO wiki on LAME ABR, ABR is actually a VBR variant that uses a less-aggressive method and is less error prone if source is not reliable/lossless/clean (my interpretation/re-phrasing...).

The command I will be using (I choose 220k, as this gives a similar file size than V1, and seems high enough to satisfy my "let's just take some additional margin" attitude  8)  ) :
Code: [Select]
ffmpeg -i input.opus -c:a libmp3lame -abr 1 -b:a 220k outputabr220.mp3

Re: Transcode Opus file to MP3/AAC

Reply #21
Also you can experiment with -f switch (or -q7) + CBR / ABR to enable a less aggresive noise shaping while STILL using the psy model  That does help some problem samples and may be an addtional help for transcoding.

Re: Transcode Opus file to MP3/AAC

Reply #22
Also you can experiment with -f switch (or -q7) + CBR / ABR to enable a less aggresive noise shaping while STILL using the psy model  That does help some problem samples and may be an addtional help for transcoding.

Thanks for the suggestion. I will give it a try and see whether I can hear a difference. But I think the files have no specific problems, so I guess I will just trust the default ABR encoding with a sufficient hight bitrate.


Re: Transcode Opus file to MP3/AAC

Reply #24
When you use mp3 for decode i just suggest you use 224k CBR or ABR its still can be nice for yours ears.

Interesting that you recommend CBR 224 kb/s and not VBR (with a high-quality setting). Is this because in my case the source file is already lossy, or do you in general prefer CBR over VBR? And if so, could you further explain why?
Thanks.


VBR its sound better than CBR because VBR use variable bitrate bandwindth and this this is eco mode that saves your hdd space and compress the bandwindth in realtime (if your bandwindth dropped to 16k and going up 320k) and CBR mode use everytime constant bitrate (320k) even when its unecassary.