Conclusion: I will feed my flac 24 bit directly into Opus. I am fine with 48KHz output.
Hi Luciano and welcome to this forum; you don't have to blindly believe your ears, sometimes we are irrational, so let's try some tests. We are looking for a short uncompressed file similar to yours, I found this:
http://www.lindberg.no/hires/test/2L-056_03_stereo_192kHz.flac (http://www.lindberg.no/hires/test/2L-056_03_stereo_192kHz.flac) (2 ch, 192 kHz, 24 bits, 43 s, 29.014.198 byte)
Your aim is to preserve the highest quality; we have 2 axes to act on, one is the sampling frequency which in the chosen target format can only be less than and equal to 48 kHz, the other is the bit depth equal to 24 bits. Our source to the spectrogram looks like the following image:
So, the only remaining step would be resampling:
Resampling XiphWiki (https://wiki.xiph.org/index.php?title=OpusFAQ&mobileaction=toggle_view_desktop#But_won.27t_the_resampler_hurt_the_quality.3F_Isn.27t_it_better_to_use_44.1_kHz_directly.3F)
He says not to worry about the damage obtained by a good SRC because after Opus will do much worse. For example, the spectrogram of a wave file generated by reducing the sampling frequency from 192 kHz of the source file flac and, at the same time, increasing the resolution on the other axis from 24 to 32 bit (2 ch, 96 kHz, float 32 bits, 43 s, 33.079.064 byte, some encoders produce better results when they have an input 32-bit floating point wave file), looks as follows:
Now let's try your solution compressing the source with Opus from the command line:opusenc --music source.flac target.opus
We get an Ogg container 2 ch, 48 kHz, float 32 bits, 43 s, 3.322.333 byte (11,45% of flac source) with the following spectrogram, where the energy after the cutoff frequency has now been added as (a lot of) noise after 12 kHz.
It could have been even worse, the encoders are not all the same even when they make the same format, for example some highly complex AAC encoders (like Opus which by default always operates at maximum) would have made an horrible result.
Curiously, if instead I compress the flac file with an encoder with Ogg Vorbis at the highest quality I get a spectrogram almost identical to the original, even if in this case my ears indicate to me still audible differences. From the command line:oggenc -q 10 source.flac target.oga
returns a file 2 ch, 192 kHz, 43 s, 2.756.601 byte (9,5% of flac source) that looks like this:
Anyway I suggest Luciano to try with the exhale encoder, from the command line:exhale 4 source@96kHz.wav target.m4a
which in my opinion despite an intermediate passage in 32 bit float and the sampling frequency reduced to 96 kHz is the favorite of my ears.