Recommended settings to convert Opus to AAC
I am downloading some music from Youtube, and it seems that in most cases (popular videos), the best quality audio is an opus file.
I know that (1) Opus is the newest and more efficient codec, and (2) converting from one lossy codec to another is not recommended.
However, as I want to use the same file, i.e. using same container, across Windows/iOs/car, I want to convert to AAC or MP3.
I have read here that you can mitigate the generation loss to a certain extent by using a higher bitrate for the target codec.
So what settings (e.g. ffmpeg) would you recommend to convert an opus file to AAC to keep same audio quality (I know this is subjective ...)?
According to the youtube-dl -F
data it is 160kbs, but when downloaded, MediaInfo gives 127Kbps overall bitrate and 48Khz sampling rate.
Would 192kbs be a good choice for the AAC file? (I presume AAC is in any case a better choice than MP3?)
I know that from CD or lossless, VBR is most recommended, but for transcoding from Opus, would CBR be better?
And should I keep the 48khz sample rate from the opus file, or downsample to the usual 44.1khz of AAC?
And finally, youtube-dl also can download an AAC file of 128 kbs.
Given that opus is more efficient/better, quality will be higher at the same bitrate. But would transcoding the opus to AAC (e.g. at 192kbs/212kbs) maintain that quality difference, or would the transcoding (even to a higher bitrate) induce artefacts so that the audio quality of the 192kbs AAC file would actually be worse than the AAC 128kbs file ?
EDIT
Let me explain why I “conceptually” struggle with understanding how to determine optimized settings for transcoding.
In most cases, you start with lossless file (e.g. a 50Mb wav), and you choose encoder settings for quality (VBR) or desired bitrate (CBR/ABR). The encoder then does its hocus pocus (discard inaudible info, compression, etc.), which then give you a smaller lossy file, based on the settings you choose. For arguments sake, let’s say maybe 3Mb for a 128kbs MP3, 5-6Mb for a top quality VBR ( i.e. highest settings for lame or qaac), and 7-8Mb for a 320kbs CBR).
But in this case, the source file is a 5Mb 128kbs opus file. The first step in transcoding is to first decode the file (to a PCM stream?), and then encode again in the new format.
So is my understanding correct that the maximum information in the file is not more than 5Mb, so to encode (and if it is not a requirement to reduce file size) I should just use the highest possible quality VBR, or possibly a high CBR (256 or 320) to capture virtually all information still present in the opus file. The resulting file would in any case not be larger than the 5Mb, as I assume no new information can be invented/generated in the process (I will do some experimenting over the weekend to test this).
The first answer given seems to suggest this.
audio ffmpeg codec aac youtube-dl
add a comment |
I am downloading some music from Youtube, and it seems that in most cases (popular videos), the best quality audio is an opus file.
I know that (1) Opus is the newest and more efficient codec, and (2) converting from one lossy codec to another is not recommended.
However, as I want to use the same file, i.e. using same container, across Windows/iOs/car, I want to convert to AAC or MP3.
I have read here that you can mitigate the generation loss to a certain extent by using a higher bitrate for the target codec.
So what settings (e.g. ffmpeg) would you recommend to convert an opus file to AAC to keep same audio quality (I know this is subjective ...)?
According to the youtube-dl -F
data it is 160kbs, but when downloaded, MediaInfo gives 127Kbps overall bitrate and 48Khz sampling rate.
Would 192kbs be a good choice for the AAC file? (I presume AAC is in any case a better choice than MP3?)
I know that from CD or lossless, VBR is most recommended, but for transcoding from Opus, would CBR be better?
And should I keep the 48khz sample rate from the opus file, or downsample to the usual 44.1khz of AAC?
And finally, youtube-dl also can download an AAC file of 128 kbs.
Given that opus is more efficient/better, quality will be higher at the same bitrate. But would transcoding the opus to AAC (e.g. at 192kbs/212kbs) maintain that quality difference, or would the transcoding (even to a higher bitrate) induce artefacts so that the audio quality of the 192kbs AAC file would actually be worse than the AAC 128kbs file ?
EDIT
Let me explain why I “conceptually” struggle with understanding how to determine optimized settings for transcoding.
In most cases, you start with lossless file (e.g. a 50Mb wav), and you choose encoder settings for quality (VBR) or desired bitrate (CBR/ABR). The encoder then does its hocus pocus (discard inaudible info, compression, etc.), which then give you a smaller lossy file, based on the settings you choose. For arguments sake, let’s say maybe 3Mb for a 128kbs MP3, 5-6Mb for a top quality VBR ( i.e. highest settings for lame or qaac), and 7-8Mb for a 320kbs CBR).
But in this case, the source file is a 5Mb 128kbs opus file. The first step in transcoding is to first decode the file (to a PCM stream?), and then encode again in the new format.
So is my understanding correct that the maximum information in the file is not more than 5Mb, so to encode (and if it is not a requirement to reduce file size) I should just use the highest possible quality VBR, or possibly a high CBR (256 or 320) to capture virtually all information still present in the opus file. The resulting file would in any case not be larger than the 5Mb, as I assume no new information can be invented/generated in the process (I will do some experimenting over the weekend to test this).
The first answer given seems to suggest this.
audio ffmpeg codec aac youtube-dl
Heh, nice that you found this old answer of mine. I updated it with some new information. Back when I wrote it in 2013, Opus was relatively new, but now it's much more commonly used.
– slhck
May 24 '18 at 18:25
@slhck Your answer was quite useful indeed ! But opus probably has "matured" less than anticipated in 2013. Not in respect to browser support, but with regards to usage in stand-alone music files (no commonly / across platforms accepted container format -- well, at least according to wikipedia ...).
– Peter K.
May 25 '18 at 6:51
Yes, it's more used in YouTube and VoIP implementations.
– slhck
May 25 '18 at 8:42
add a comment |
I am downloading some music from Youtube, and it seems that in most cases (popular videos), the best quality audio is an opus file.
I know that (1) Opus is the newest and more efficient codec, and (2) converting from one lossy codec to another is not recommended.
However, as I want to use the same file, i.e. using same container, across Windows/iOs/car, I want to convert to AAC or MP3.
I have read here that you can mitigate the generation loss to a certain extent by using a higher bitrate for the target codec.
So what settings (e.g. ffmpeg) would you recommend to convert an opus file to AAC to keep same audio quality (I know this is subjective ...)?
According to the youtube-dl -F
data it is 160kbs, but when downloaded, MediaInfo gives 127Kbps overall bitrate and 48Khz sampling rate.
Would 192kbs be a good choice for the AAC file? (I presume AAC is in any case a better choice than MP3?)
I know that from CD or lossless, VBR is most recommended, but for transcoding from Opus, would CBR be better?
And should I keep the 48khz sample rate from the opus file, or downsample to the usual 44.1khz of AAC?
And finally, youtube-dl also can download an AAC file of 128 kbs.
Given that opus is more efficient/better, quality will be higher at the same bitrate. But would transcoding the opus to AAC (e.g. at 192kbs/212kbs) maintain that quality difference, or would the transcoding (even to a higher bitrate) induce artefacts so that the audio quality of the 192kbs AAC file would actually be worse than the AAC 128kbs file ?
EDIT
Let me explain why I “conceptually” struggle with understanding how to determine optimized settings for transcoding.
In most cases, you start with lossless file (e.g. a 50Mb wav), and you choose encoder settings for quality (VBR) or desired bitrate (CBR/ABR). The encoder then does its hocus pocus (discard inaudible info, compression, etc.), which then give you a smaller lossy file, based on the settings you choose. For arguments sake, let’s say maybe 3Mb for a 128kbs MP3, 5-6Mb for a top quality VBR ( i.e. highest settings for lame or qaac), and 7-8Mb for a 320kbs CBR).
But in this case, the source file is a 5Mb 128kbs opus file. The first step in transcoding is to first decode the file (to a PCM stream?), and then encode again in the new format.
So is my understanding correct that the maximum information in the file is not more than 5Mb, so to encode (and if it is not a requirement to reduce file size) I should just use the highest possible quality VBR, or possibly a high CBR (256 or 320) to capture virtually all information still present in the opus file. The resulting file would in any case not be larger than the 5Mb, as I assume no new information can be invented/generated in the process (I will do some experimenting over the weekend to test this).
The first answer given seems to suggest this.
audio ffmpeg codec aac youtube-dl
I am downloading some music from Youtube, and it seems that in most cases (popular videos), the best quality audio is an opus file.
I know that (1) Opus is the newest and more efficient codec, and (2) converting from one lossy codec to another is not recommended.
However, as I want to use the same file, i.e. using same container, across Windows/iOs/car, I want to convert to AAC or MP3.
I have read here that you can mitigate the generation loss to a certain extent by using a higher bitrate for the target codec.
So what settings (e.g. ffmpeg) would you recommend to convert an opus file to AAC to keep same audio quality (I know this is subjective ...)?
According to the youtube-dl -F
data it is 160kbs, but when downloaded, MediaInfo gives 127Kbps overall bitrate and 48Khz sampling rate.
Would 192kbs be a good choice for the AAC file? (I presume AAC is in any case a better choice than MP3?)
I know that from CD or lossless, VBR is most recommended, but for transcoding from Opus, would CBR be better?
And should I keep the 48khz sample rate from the opus file, or downsample to the usual 44.1khz of AAC?
And finally, youtube-dl also can download an AAC file of 128 kbs.
Given that opus is more efficient/better, quality will be higher at the same bitrate. But would transcoding the opus to AAC (e.g. at 192kbs/212kbs) maintain that quality difference, or would the transcoding (even to a higher bitrate) induce artefacts so that the audio quality of the 192kbs AAC file would actually be worse than the AAC 128kbs file ?
EDIT
Let me explain why I “conceptually” struggle with understanding how to determine optimized settings for transcoding.
In most cases, you start with lossless file (e.g. a 50Mb wav), and you choose encoder settings for quality (VBR) or desired bitrate (CBR/ABR). The encoder then does its hocus pocus (discard inaudible info, compression, etc.), which then give you a smaller lossy file, based on the settings you choose. For arguments sake, let’s say maybe 3Mb for a 128kbs MP3, 5-6Mb for a top quality VBR ( i.e. highest settings for lame or qaac), and 7-8Mb for a 320kbs CBR).
But in this case, the source file is a 5Mb 128kbs opus file. The first step in transcoding is to first decode the file (to a PCM stream?), and then encode again in the new format.
So is my understanding correct that the maximum information in the file is not more than 5Mb, so to encode (and if it is not a requirement to reduce file size) I should just use the highest possible quality VBR, or possibly a high CBR (256 or 320) to capture virtually all information still present in the opus file. The resulting file would in any case not be larger than the 5Mb, as I assume no new information can be invented/generated in the process (I will do some experimenting over the weekend to test this).
The first answer given seems to suggest this.
audio ffmpeg codec aac youtube-dl
audio ffmpeg codec aac youtube-dl
edited May 25 '18 at 14:32
Peter K.
asked May 24 '18 at 16:47
Peter K.Peter K.
232110
232110
Heh, nice that you found this old answer of mine. I updated it with some new information. Back when I wrote it in 2013, Opus was relatively new, but now it's much more commonly used.
– slhck
May 24 '18 at 18:25
@slhck Your answer was quite useful indeed ! But opus probably has "matured" less than anticipated in 2013. Not in respect to browser support, but with regards to usage in stand-alone music files (no commonly / across platforms accepted container format -- well, at least according to wikipedia ...).
– Peter K.
May 25 '18 at 6:51
Yes, it's more used in YouTube and VoIP implementations.
– slhck
May 25 '18 at 8:42
add a comment |
Heh, nice that you found this old answer of mine. I updated it with some new information. Back when I wrote it in 2013, Opus was relatively new, but now it's much more commonly used.
– slhck
May 24 '18 at 18:25
@slhck Your answer was quite useful indeed ! But opus probably has "matured" less than anticipated in 2013. Not in respect to browser support, but with regards to usage in stand-alone music files (no commonly / across platforms accepted container format -- well, at least according to wikipedia ...).
– Peter K.
May 25 '18 at 6:51
Yes, it's more used in YouTube and VoIP implementations.
– slhck
May 25 '18 at 8:42
Heh, nice that you found this old answer of mine. I updated it with some new information. Back when I wrote it in 2013, Opus was relatively new, but now it's much more commonly used.
– slhck
May 24 '18 at 18:25
Heh, nice that you found this old answer of mine. I updated it with some new information. Back when I wrote it in 2013, Opus was relatively new, but now it's much more commonly used.
– slhck
May 24 '18 at 18:25
@slhck Your answer was quite useful indeed ! But opus probably has "matured" less than anticipated in 2013. Not in respect to browser support, but with regards to usage in stand-alone music files (no commonly / across platforms accepted container format -- well, at least according to wikipedia ...).
– Peter K.
May 25 '18 at 6:51
@slhck Your answer was quite useful indeed ! But opus probably has "matured" less than anticipated in 2013. Not in respect to browser support, but with regards to usage in stand-alone music files (no commonly / across platforms accepted container format -- well, at least according to wikipedia ...).
– Peter K.
May 25 '18 at 6:51
Yes, it's more used in YouTube and VoIP implementations.
– slhck
May 25 '18 at 8:42
Yes, it's more used in YouTube and VoIP implementations.
– slhck
May 25 '18 at 8:42
add a comment |
2 Answers
2
active
oldest
votes
More generally, I would recommend to have a look at the FFmpeg Wiki page on AAC encoding. Here you will find tips on how to achieve the best quality, which involves:
- using the
libfdk_aac
encoder instead of the built-in one (the encoder can make a huge difference in quality!) - using VBR — there is no need to constrain the rate or waste bits
- turning off the high pass filter, as by default some high frequencies are lost during conversion
Thus, the following would work:
ffmpeg -i input.opus -c:a libfdk_aac -vbr 5 -cutoff 18000 output.m4a
This should be absolutely transparent to anyone's ears. You may even use -vbr 4
and check whether you can detect the difference. I guess you won't.
More specifically, you ask:
And finally, youtube-dl also can download an AAC file of 128 kbs. (…) But would transcoding the opus to AAC (…) maintain that quality difference, or would the transcoding (…) induce artefacts so that the audio quality (…) would actually be worse?
Great question that I don't know how to answer without conducting a formal listening test.
However, if you assume that stereo AAC at 128 kbps is at least good quality (but not excellent), you may forgo any conversion and use that directly if it sounds good to you. I think I would listen to the original Opus and AAC samples that you directly downloaded and try to do a blind test — can you reliably detect the difference? If no, then just use AAC and save yourself the conversion.
PS: I listened to a few music clips from YouTube with both the Opus and AAC variants and I personally liked Opus better — it seemed to have a bit more high-frequency spatiality to it. But don't consider that a scientifically sound conclusion!
Finally, there is a thread discussing a similar issue, and here, one user thinks that there is more aggressive psycho-acoustic shaping in VBR encoding, which may enhance already present artifacts when encoding a lossy file again. He concludes that ABR at a high bitrate may be better suited for such tasks.
If anyone wants to know their frequency limit for customized low-pass filter-cutoff
value (at arbitrary 44100 Hz sample rate):ffplay -f lavfi -i sine=f=18000
. Decrease until "shrieking bat call" is audible or until your ears bleed. In a noisy office with open headphones mine is ~16100.
– llogan
May 24 '18 at 19:08
@LordNeckbeard There's a popping noise when you start the command (at least on my Mac), which I guess is due to the sudden onset. It can be avoided withsine=f=18000,afade=d=0.1
.
– slhck
May 24 '18 at 19:21
@slhck Thanks for your contribution. So by using presets (e.g. -vbr 5), the encoder will "find" optimal avg bitrate to preserve quality? I do use presets when ripping from source (CD), but I thought that when source is lossy (opus 128kbs), setting parameters manually would be better. And what about sample rate? Set 48Khz manually as in the opus file, or keep default (which implies resampling at 44.1Khz I assume)?
– Peter K.
May 25 '18 at 7:40
@PeterK Yes, VBR will ensure optimal rate and quality. The sample rate should stay at 48 kHz unless you specify a different one.
– slhck
May 25 '18 at 8:41
@slhck I have been looking atlibfdk_aac
, but I do not think I have the skills/time to make a custom ffmpeg build with libfdk_aac included. I assume I could useqaac
as an alternative (either command line or with fb2k) ? But then I still have to find out the recommended settings. Also forqaac
, there is much info for encoding from source (CD or lossless), but not much info for recommended settings based on various lossy input files.
– Peter K.
May 25 '18 at 8:46
|
show 13 more comments
Not so much an answer as a bit of 'expert' opinion, for what it's worth [I'm a sound engineer, but not a coding/algorithm guy]
For iOS/car you just get iTunes to resample at 128k AAC - the option is in iTunes itself, it will make new versions just for your devices - you'll never hear the difference, certainly in the car, & from mobiles only in silent surroundings with seriously expensive headphones.
Window crushed down to save space...
If you want to archive at "maximum" use Apple lossless [ALAC].
It won't get back anything already gone, but it won't lose any more.
btw, iOS itself can now play Opus files [since iOS 11] - but I don't know whether that's via iTunes or if only as a streamed format.
AAC cannot be lossless, do you mean ALAC?
– slhck
May 24 '18 at 18:33
I mean "Apple Lossless Encoder", so yes I probably do mean ALAC. [Told you I wasn't a tech ;-) Fixed.
– Tetsujin
May 24 '18 at 18:35
Heh! Using ALAC though would not give you much compatibility other than macOS (and maybe iOS? I don't even know…)
– slhck
May 24 '18 at 18:38
I assumed windows/ios/car would essentially be an iTunes environment. I guess FLAC would work too, but as iTunes doesn't like it, it would be the same issue in reverse. tbh, I usually work & archive in WAV & drop to whatever I need as required - but I start from scratch, not from someone else's source material ;-))
– Tetsujin
May 24 '18 at 18:44
@Tetsujin Thanks! I do try to keep my music library free from having various versions of a file for different players (and for the car, I have to manually select the music files and copy these directly from my library). If I would go the lossless route, I would rather go for FLAC than for ALAC. But preference (for filesize and universal playability) is to use AAC (or MP3).
– Peter K.
May 25 '18 at 7:50
add a comment |
protected by Ramhound Jan 21 at 19:01
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
More generally, I would recommend to have a look at the FFmpeg Wiki page on AAC encoding. Here you will find tips on how to achieve the best quality, which involves:
- using the
libfdk_aac
encoder instead of the built-in one (the encoder can make a huge difference in quality!) - using VBR — there is no need to constrain the rate or waste bits
- turning off the high pass filter, as by default some high frequencies are lost during conversion
Thus, the following would work:
ffmpeg -i input.opus -c:a libfdk_aac -vbr 5 -cutoff 18000 output.m4a
This should be absolutely transparent to anyone's ears. You may even use -vbr 4
and check whether you can detect the difference. I guess you won't.
More specifically, you ask:
And finally, youtube-dl also can download an AAC file of 128 kbs. (…) But would transcoding the opus to AAC (…) maintain that quality difference, or would the transcoding (…) induce artefacts so that the audio quality (…) would actually be worse?
Great question that I don't know how to answer without conducting a formal listening test.
However, if you assume that stereo AAC at 128 kbps is at least good quality (but not excellent), you may forgo any conversion and use that directly if it sounds good to you. I think I would listen to the original Opus and AAC samples that you directly downloaded and try to do a blind test — can you reliably detect the difference? If no, then just use AAC and save yourself the conversion.
PS: I listened to a few music clips from YouTube with both the Opus and AAC variants and I personally liked Opus better — it seemed to have a bit more high-frequency spatiality to it. But don't consider that a scientifically sound conclusion!
Finally, there is a thread discussing a similar issue, and here, one user thinks that there is more aggressive psycho-acoustic shaping in VBR encoding, which may enhance already present artifacts when encoding a lossy file again. He concludes that ABR at a high bitrate may be better suited for such tasks.
If anyone wants to know their frequency limit for customized low-pass filter-cutoff
value (at arbitrary 44100 Hz sample rate):ffplay -f lavfi -i sine=f=18000
. Decrease until "shrieking bat call" is audible or until your ears bleed. In a noisy office with open headphones mine is ~16100.
– llogan
May 24 '18 at 19:08
@LordNeckbeard There's a popping noise when you start the command (at least on my Mac), which I guess is due to the sudden onset. It can be avoided withsine=f=18000,afade=d=0.1
.
– slhck
May 24 '18 at 19:21
@slhck Thanks for your contribution. So by using presets (e.g. -vbr 5), the encoder will "find" optimal avg bitrate to preserve quality? I do use presets when ripping from source (CD), but I thought that when source is lossy (opus 128kbs), setting parameters manually would be better. And what about sample rate? Set 48Khz manually as in the opus file, or keep default (which implies resampling at 44.1Khz I assume)?
– Peter K.
May 25 '18 at 7:40
@PeterK Yes, VBR will ensure optimal rate and quality. The sample rate should stay at 48 kHz unless you specify a different one.
– slhck
May 25 '18 at 8:41
@slhck I have been looking atlibfdk_aac
, but I do not think I have the skills/time to make a custom ffmpeg build with libfdk_aac included. I assume I could useqaac
as an alternative (either command line or with fb2k) ? But then I still have to find out the recommended settings. Also forqaac
, there is much info for encoding from source (CD or lossless), but not much info for recommended settings based on various lossy input files.
– Peter K.
May 25 '18 at 8:46
|
show 13 more comments
More generally, I would recommend to have a look at the FFmpeg Wiki page on AAC encoding. Here you will find tips on how to achieve the best quality, which involves:
- using the
libfdk_aac
encoder instead of the built-in one (the encoder can make a huge difference in quality!) - using VBR — there is no need to constrain the rate or waste bits
- turning off the high pass filter, as by default some high frequencies are lost during conversion
Thus, the following would work:
ffmpeg -i input.opus -c:a libfdk_aac -vbr 5 -cutoff 18000 output.m4a
This should be absolutely transparent to anyone's ears. You may even use -vbr 4
and check whether you can detect the difference. I guess you won't.
More specifically, you ask:
And finally, youtube-dl also can download an AAC file of 128 kbs. (…) But would transcoding the opus to AAC (…) maintain that quality difference, or would the transcoding (…) induce artefacts so that the audio quality (…) would actually be worse?
Great question that I don't know how to answer without conducting a formal listening test.
However, if you assume that stereo AAC at 128 kbps is at least good quality (but not excellent), you may forgo any conversion and use that directly if it sounds good to you. I think I would listen to the original Opus and AAC samples that you directly downloaded and try to do a blind test — can you reliably detect the difference? If no, then just use AAC and save yourself the conversion.
PS: I listened to a few music clips from YouTube with both the Opus and AAC variants and I personally liked Opus better — it seemed to have a bit more high-frequency spatiality to it. But don't consider that a scientifically sound conclusion!
Finally, there is a thread discussing a similar issue, and here, one user thinks that there is more aggressive psycho-acoustic shaping in VBR encoding, which may enhance already present artifacts when encoding a lossy file again. He concludes that ABR at a high bitrate may be better suited for such tasks.
If anyone wants to know their frequency limit for customized low-pass filter-cutoff
value (at arbitrary 44100 Hz sample rate):ffplay -f lavfi -i sine=f=18000
. Decrease until "shrieking bat call" is audible or until your ears bleed. In a noisy office with open headphones mine is ~16100.
– llogan
May 24 '18 at 19:08
@LordNeckbeard There's a popping noise when you start the command (at least on my Mac), which I guess is due to the sudden onset. It can be avoided withsine=f=18000,afade=d=0.1
.
– slhck
May 24 '18 at 19:21
@slhck Thanks for your contribution. So by using presets (e.g. -vbr 5), the encoder will "find" optimal avg bitrate to preserve quality? I do use presets when ripping from source (CD), but I thought that when source is lossy (opus 128kbs), setting parameters manually would be better. And what about sample rate? Set 48Khz manually as in the opus file, or keep default (which implies resampling at 44.1Khz I assume)?
– Peter K.
May 25 '18 at 7:40
@PeterK Yes, VBR will ensure optimal rate and quality. The sample rate should stay at 48 kHz unless you specify a different one.
– slhck
May 25 '18 at 8:41
@slhck I have been looking atlibfdk_aac
, but I do not think I have the skills/time to make a custom ffmpeg build with libfdk_aac included. I assume I could useqaac
as an alternative (either command line or with fb2k) ? But then I still have to find out the recommended settings. Also forqaac
, there is much info for encoding from source (CD or lossless), but not much info for recommended settings based on various lossy input files.
– Peter K.
May 25 '18 at 8:46
|
show 13 more comments
More generally, I would recommend to have a look at the FFmpeg Wiki page on AAC encoding. Here you will find tips on how to achieve the best quality, which involves:
- using the
libfdk_aac
encoder instead of the built-in one (the encoder can make a huge difference in quality!) - using VBR — there is no need to constrain the rate or waste bits
- turning off the high pass filter, as by default some high frequencies are lost during conversion
Thus, the following would work:
ffmpeg -i input.opus -c:a libfdk_aac -vbr 5 -cutoff 18000 output.m4a
This should be absolutely transparent to anyone's ears. You may even use -vbr 4
and check whether you can detect the difference. I guess you won't.
More specifically, you ask:
And finally, youtube-dl also can download an AAC file of 128 kbs. (…) But would transcoding the opus to AAC (…) maintain that quality difference, or would the transcoding (…) induce artefacts so that the audio quality (…) would actually be worse?
Great question that I don't know how to answer without conducting a formal listening test.
However, if you assume that stereo AAC at 128 kbps is at least good quality (but not excellent), you may forgo any conversion and use that directly if it sounds good to you. I think I would listen to the original Opus and AAC samples that you directly downloaded and try to do a blind test — can you reliably detect the difference? If no, then just use AAC and save yourself the conversion.
PS: I listened to a few music clips from YouTube with both the Opus and AAC variants and I personally liked Opus better — it seemed to have a bit more high-frequency spatiality to it. But don't consider that a scientifically sound conclusion!
Finally, there is a thread discussing a similar issue, and here, one user thinks that there is more aggressive psycho-acoustic shaping in VBR encoding, which may enhance already present artifacts when encoding a lossy file again. He concludes that ABR at a high bitrate may be better suited for such tasks.
More generally, I would recommend to have a look at the FFmpeg Wiki page on AAC encoding. Here you will find tips on how to achieve the best quality, which involves:
- using the
libfdk_aac
encoder instead of the built-in one (the encoder can make a huge difference in quality!) - using VBR — there is no need to constrain the rate or waste bits
- turning off the high pass filter, as by default some high frequencies are lost during conversion
Thus, the following would work:
ffmpeg -i input.opus -c:a libfdk_aac -vbr 5 -cutoff 18000 output.m4a
This should be absolutely transparent to anyone's ears. You may even use -vbr 4
and check whether you can detect the difference. I guess you won't.
More specifically, you ask:
And finally, youtube-dl also can download an AAC file of 128 kbs. (…) But would transcoding the opus to AAC (…) maintain that quality difference, or would the transcoding (…) induce artefacts so that the audio quality (…) would actually be worse?
Great question that I don't know how to answer without conducting a formal listening test.
However, if you assume that stereo AAC at 128 kbps is at least good quality (but not excellent), you may forgo any conversion and use that directly if it sounds good to you. I think I would listen to the original Opus and AAC samples that you directly downloaded and try to do a blind test — can you reliably detect the difference? If no, then just use AAC and save yourself the conversion.
PS: I listened to a few music clips from YouTube with both the Opus and AAC variants and I personally liked Opus better — it seemed to have a bit more high-frequency spatiality to it. But don't consider that a scientifically sound conclusion!
Finally, there is a thread discussing a similar issue, and here, one user thinks that there is more aggressive psycho-acoustic shaping in VBR encoding, which may enhance already present artifacts when encoding a lossy file again. He concludes that ABR at a high bitrate may be better suited for such tasks.
edited Jun 4 '18 at 11:50
answered May 24 '18 at 18:31
slhckslhck
161k47447470
161k47447470
If anyone wants to know their frequency limit for customized low-pass filter-cutoff
value (at arbitrary 44100 Hz sample rate):ffplay -f lavfi -i sine=f=18000
. Decrease until "shrieking bat call" is audible or until your ears bleed. In a noisy office with open headphones mine is ~16100.
– llogan
May 24 '18 at 19:08
@LordNeckbeard There's a popping noise when you start the command (at least on my Mac), which I guess is due to the sudden onset. It can be avoided withsine=f=18000,afade=d=0.1
.
– slhck
May 24 '18 at 19:21
@slhck Thanks for your contribution. So by using presets (e.g. -vbr 5), the encoder will "find" optimal avg bitrate to preserve quality? I do use presets when ripping from source (CD), but I thought that when source is lossy (opus 128kbs), setting parameters manually would be better. And what about sample rate? Set 48Khz manually as in the opus file, or keep default (which implies resampling at 44.1Khz I assume)?
– Peter K.
May 25 '18 at 7:40
@PeterK Yes, VBR will ensure optimal rate and quality. The sample rate should stay at 48 kHz unless you specify a different one.
– slhck
May 25 '18 at 8:41
@slhck I have been looking atlibfdk_aac
, but I do not think I have the skills/time to make a custom ffmpeg build with libfdk_aac included. I assume I could useqaac
as an alternative (either command line or with fb2k) ? But then I still have to find out the recommended settings. Also forqaac
, there is much info for encoding from source (CD or lossless), but not much info for recommended settings based on various lossy input files.
– Peter K.
May 25 '18 at 8:46
|
show 13 more comments
If anyone wants to know their frequency limit for customized low-pass filter-cutoff
value (at arbitrary 44100 Hz sample rate):ffplay -f lavfi -i sine=f=18000
. Decrease until "shrieking bat call" is audible or until your ears bleed. In a noisy office with open headphones mine is ~16100.
– llogan
May 24 '18 at 19:08
@LordNeckbeard There's a popping noise when you start the command (at least on my Mac), which I guess is due to the sudden onset. It can be avoided withsine=f=18000,afade=d=0.1
.
– slhck
May 24 '18 at 19:21
@slhck Thanks for your contribution. So by using presets (e.g. -vbr 5), the encoder will "find" optimal avg bitrate to preserve quality? I do use presets when ripping from source (CD), but I thought that when source is lossy (opus 128kbs), setting parameters manually would be better. And what about sample rate? Set 48Khz manually as in the opus file, or keep default (which implies resampling at 44.1Khz I assume)?
– Peter K.
May 25 '18 at 7:40
@PeterK Yes, VBR will ensure optimal rate and quality. The sample rate should stay at 48 kHz unless you specify a different one.
– slhck
May 25 '18 at 8:41
@slhck I have been looking atlibfdk_aac
, but I do not think I have the skills/time to make a custom ffmpeg build with libfdk_aac included. I assume I could useqaac
as an alternative (either command line or with fb2k) ? But then I still have to find out the recommended settings. Also forqaac
, there is much info for encoding from source (CD or lossless), but not much info for recommended settings based on various lossy input files.
– Peter K.
May 25 '18 at 8:46
If anyone wants to know their frequency limit for customized low-pass filter
-cutoff
value (at arbitrary 44100 Hz sample rate): ffplay -f lavfi -i sine=f=18000
. Decrease until "shrieking bat call" is audible or until your ears bleed. In a noisy office with open headphones mine is ~16100.– llogan
May 24 '18 at 19:08
If anyone wants to know their frequency limit for customized low-pass filter
-cutoff
value (at arbitrary 44100 Hz sample rate): ffplay -f lavfi -i sine=f=18000
. Decrease until "shrieking bat call" is audible or until your ears bleed. In a noisy office with open headphones mine is ~16100.– llogan
May 24 '18 at 19:08
@LordNeckbeard There's a popping noise when you start the command (at least on my Mac), which I guess is due to the sudden onset. It can be avoided with
sine=f=18000,afade=d=0.1
.– slhck
May 24 '18 at 19:21
@LordNeckbeard There's a popping noise when you start the command (at least on my Mac), which I guess is due to the sudden onset. It can be avoided with
sine=f=18000,afade=d=0.1
.– slhck
May 24 '18 at 19:21
@slhck Thanks for your contribution. So by using presets (e.g. -vbr 5), the encoder will "find" optimal avg bitrate to preserve quality? I do use presets when ripping from source (CD), but I thought that when source is lossy (opus 128kbs), setting parameters manually would be better. And what about sample rate? Set 48Khz manually as in the opus file, or keep default (which implies resampling at 44.1Khz I assume)?
– Peter K.
May 25 '18 at 7:40
@slhck Thanks for your contribution. So by using presets (e.g. -vbr 5), the encoder will "find" optimal avg bitrate to preserve quality? I do use presets when ripping from source (CD), but I thought that when source is lossy (opus 128kbs), setting parameters manually would be better. And what about sample rate? Set 48Khz manually as in the opus file, or keep default (which implies resampling at 44.1Khz I assume)?
– Peter K.
May 25 '18 at 7:40
@PeterK Yes, VBR will ensure optimal rate and quality. The sample rate should stay at 48 kHz unless you specify a different one.
– slhck
May 25 '18 at 8:41
@PeterK Yes, VBR will ensure optimal rate and quality. The sample rate should stay at 48 kHz unless you specify a different one.
– slhck
May 25 '18 at 8:41
@slhck I have been looking at
libfdk_aac
, but I do not think I have the skills/time to make a custom ffmpeg build with libfdk_aac included. I assume I could use qaac
as an alternative (either command line or with fb2k) ? But then I still have to find out the recommended settings. Also for qaac
, there is much info for encoding from source (CD or lossless), but not much info for recommended settings based on various lossy input files.– Peter K.
May 25 '18 at 8:46
@slhck I have been looking at
libfdk_aac
, but I do not think I have the skills/time to make a custom ffmpeg build with libfdk_aac included. I assume I could use qaac
as an alternative (either command line or with fb2k) ? But then I still have to find out the recommended settings. Also for qaac
, there is much info for encoding from source (CD or lossless), but not much info for recommended settings based on various lossy input files.– Peter K.
May 25 '18 at 8:46
|
show 13 more comments
Not so much an answer as a bit of 'expert' opinion, for what it's worth [I'm a sound engineer, but not a coding/algorithm guy]
For iOS/car you just get iTunes to resample at 128k AAC - the option is in iTunes itself, it will make new versions just for your devices - you'll never hear the difference, certainly in the car, & from mobiles only in silent surroundings with seriously expensive headphones.
Window crushed down to save space...
If you want to archive at "maximum" use Apple lossless [ALAC].
It won't get back anything already gone, but it won't lose any more.
btw, iOS itself can now play Opus files [since iOS 11] - but I don't know whether that's via iTunes or if only as a streamed format.
AAC cannot be lossless, do you mean ALAC?
– slhck
May 24 '18 at 18:33
I mean "Apple Lossless Encoder", so yes I probably do mean ALAC. [Told you I wasn't a tech ;-) Fixed.
– Tetsujin
May 24 '18 at 18:35
Heh! Using ALAC though would not give you much compatibility other than macOS (and maybe iOS? I don't even know…)
– slhck
May 24 '18 at 18:38
I assumed windows/ios/car would essentially be an iTunes environment. I guess FLAC would work too, but as iTunes doesn't like it, it would be the same issue in reverse. tbh, I usually work & archive in WAV & drop to whatever I need as required - but I start from scratch, not from someone else's source material ;-))
– Tetsujin
May 24 '18 at 18:44
@Tetsujin Thanks! I do try to keep my music library free from having various versions of a file for different players (and for the car, I have to manually select the music files and copy these directly from my library). If I would go the lossless route, I would rather go for FLAC than for ALAC. But preference (for filesize and universal playability) is to use AAC (or MP3).
– Peter K.
May 25 '18 at 7:50
add a comment |
Not so much an answer as a bit of 'expert' opinion, for what it's worth [I'm a sound engineer, but not a coding/algorithm guy]
For iOS/car you just get iTunes to resample at 128k AAC - the option is in iTunes itself, it will make new versions just for your devices - you'll never hear the difference, certainly in the car, & from mobiles only in silent surroundings with seriously expensive headphones.
Window crushed down to save space...
If you want to archive at "maximum" use Apple lossless [ALAC].
It won't get back anything already gone, but it won't lose any more.
btw, iOS itself can now play Opus files [since iOS 11] - but I don't know whether that's via iTunes or if only as a streamed format.
AAC cannot be lossless, do you mean ALAC?
– slhck
May 24 '18 at 18:33
I mean "Apple Lossless Encoder", so yes I probably do mean ALAC. [Told you I wasn't a tech ;-) Fixed.
– Tetsujin
May 24 '18 at 18:35
Heh! Using ALAC though would not give you much compatibility other than macOS (and maybe iOS? I don't even know…)
– slhck
May 24 '18 at 18:38
I assumed windows/ios/car would essentially be an iTunes environment. I guess FLAC would work too, but as iTunes doesn't like it, it would be the same issue in reverse. tbh, I usually work & archive in WAV & drop to whatever I need as required - but I start from scratch, not from someone else's source material ;-))
– Tetsujin
May 24 '18 at 18:44
@Tetsujin Thanks! I do try to keep my music library free from having various versions of a file for different players (and for the car, I have to manually select the music files and copy these directly from my library). If I would go the lossless route, I would rather go for FLAC than for ALAC. But preference (for filesize and universal playability) is to use AAC (or MP3).
– Peter K.
May 25 '18 at 7:50
add a comment |
Not so much an answer as a bit of 'expert' opinion, for what it's worth [I'm a sound engineer, but not a coding/algorithm guy]
For iOS/car you just get iTunes to resample at 128k AAC - the option is in iTunes itself, it will make new versions just for your devices - you'll never hear the difference, certainly in the car, & from mobiles only in silent surroundings with seriously expensive headphones.
Window crushed down to save space...
If you want to archive at "maximum" use Apple lossless [ALAC].
It won't get back anything already gone, but it won't lose any more.
btw, iOS itself can now play Opus files [since iOS 11] - but I don't know whether that's via iTunes or if only as a streamed format.
Not so much an answer as a bit of 'expert' opinion, for what it's worth [I'm a sound engineer, but not a coding/algorithm guy]
For iOS/car you just get iTunes to resample at 128k AAC - the option is in iTunes itself, it will make new versions just for your devices - you'll never hear the difference, certainly in the car, & from mobiles only in silent surroundings with seriously expensive headphones.
Window crushed down to save space...
If you want to archive at "maximum" use Apple lossless [ALAC].
It won't get back anything already gone, but it won't lose any more.
btw, iOS itself can now play Opus files [since iOS 11] - but I don't know whether that's via iTunes or if only as a streamed format.
edited May 24 '18 at 18:36
answered May 24 '18 at 17:04
TetsujinTetsujin
15.7k53262
15.7k53262
AAC cannot be lossless, do you mean ALAC?
– slhck
May 24 '18 at 18:33
I mean "Apple Lossless Encoder", so yes I probably do mean ALAC. [Told you I wasn't a tech ;-) Fixed.
– Tetsujin
May 24 '18 at 18:35
Heh! Using ALAC though would not give you much compatibility other than macOS (and maybe iOS? I don't even know…)
– slhck
May 24 '18 at 18:38
I assumed windows/ios/car would essentially be an iTunes environment. I guess FLAC would work too, but as iTunes doesn't like it, it would be the same issue in reverse. tbh, I usually work & archive in WAV & drop to whatever I need as required - but I start from scratch, not from someone else's source material ;-))
– Tetsujin
May 24 '18 at 18:44
@Tetsujin Thanks! I do try to keep my music library free from having various versions of a file for different players (and for the car, I have to manually select the music files and copy these directly from my library). If I would go the lossless route, I would rather go for FLAC than for ALAC. But preference (for filesize and universal playability) is to use AAC (or MP3).
– Peter K.
May 25 '18 at 7:50
add a comment |
AAC cannot be lossless, do you mean ALAC?
– slhck
May 24 '18 at 18:33
I mean "Apple Lossless Encoder", so yes I probably do mean ALAC. [Told you I wasn't a tech ;-) Fixed.
– Tetsujin
May 24 '18 at 18:35
Heh! Using ALAC though would not give you much compatibility other than macOS (and maybe iOS? I don't even know…)
– slhck
May 24 '18 at 18:38
I assumed windows/ios/car would essentially be an iTunes environment. I guess FLAC would work too, but as iTunes doesn't like it, it would be the same issue in reverse. tbh, I usually work & archive in WAV & drop to whatever I need as required - but I start from scratch, not from someone else's source material ;-))
– Tetsujin
May 24 '18 at 18:44
@Tetsujin Thanks! I do try to keep my music library free from having various versions of a file for different players (and for the car, I have to manually select the music files and copy these directly from my library). If I would go the lossless route, I would rather go for FLAC than for ALAC. But preference (for filesize and universal playability) is to use AAC (or MP3).
– Peter K.
May 25 '18 at 7:50
AAC cannot be lossless, do you mean ALAC?
– slhck
May 24 '18 at 18:33
AAC cannot be lossless, do you mean ALAC?
– slhck
May 24 '18 at 18:33
I mean "Apple Lossless Encoder", so yes I probably do mean ALAC. [Told you I wasn't a tech ;-) Fixed.
– Tetsujin
May 24 '18 at 18:35
I mean "Apple Lossless Encoder", so yes I probably do mean ALAC. [Told you I wasn't a tech ;-) Fixed.
– Tetsujin
May 24 '18 at 18:35
Heh! Using ALAC though would not give you much compatibility other than macOS (and maybe iOS? I don't even know…)
– slhck
May 24 '18 at 18:38
Heh! Using ALAC though would not give you much compatibility other than macOS (and maybe iOS? I don't even know…)
– slhck
May 24 '18 at 18:38
I assumed windows/ios/car would essentially be an iTunes environment. I guess FLAC would work too, but as iTunes doesn't like it, it would be the same issue in reverse. tbh, I usually work & archive in WAV & drop to whatever I need as required - but I start from scratch, not from someone else's source material ;-))
– Tetsujin
May 24 '18 at 18:44
I assumed windows/ios/car would essentially be an iTunes environment. I guess FLAC would work too, but as iTunes doesn't like it, it would be the same issue in reverse. tbh, I usually work & archive in WAV & drop to whatever I need as required - but I start from scratch, not from someone else's source material ;-))
– Tetsujin
May 24 '18 at 18:44
@Tetsujin Thanks! I do try to keep my music library free from having various versions of a file for different players (and for the car, I have to manually select the music files and copy these directly from my library). If I would go the lossless route, I would rather go for FLAC than for ALAC. But preference (for filesize and universal playability) is to use AAC (or MP3).
– Peter K.
May 25 '18 at 7:50
@Tetsujin Thanks! I do try to keep my music library free from having various versions of a file for different players (and for the car, I have to manually select the music files and copy these directly from my library). If I would go the lossless route, I would rather go for FLAC than for ALAC. But preference (for filesize and universal playability) is to use AAC (or MP3).
– Peter K.
May 25 '18 at 7:50
add a comment |
protected by Ramhound Jan 21 at 19:01
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site (the association bonus does not count).
Would you like to answer one of these unanswered questions instead?
Heh, nice that you found this old answer of mine. I updated it with some new information. Back when I wrote it in 2013, Opus was relatively new, but now it's much more commonly used.
– slhck
May 24 '18 at 18:25
@slhck Your answer was quite useful indeed ! But opus probably has "matured" less than anticipated in 2013. Not in respect to browser support, but with regards to usage in stand-alone music files (no commonly / across platforms accepted container format -- well, at least according to wikipedia ...).
– Peter K.
May 25 '18 at 6:51
Yes, it's more used in YouTube and VoIP implementations.
– slhck
May 25 '18 at 8:42