Thanks a lot.
My bad. I was just using "{}" and the results was not as expected... and I'm not dealing with limit cases where order can be discussed.
Exemple when comparing "FR AC3@384kb/s" vs "EN EAC3@1024kb/s" :
Strange result when using {bestBitRate}, the reason I was not understanding what was "BestBitRate" (how AC3@384 can be considered better than EAC3@1024) :

The fact is that {} shouldn't be there...
I just want to notice here that the result is the same if you remove everything (you choose nothing and you have a result...) :

I still don't understand why... and it didn't help me to troubleshoot myself (now we know the problem is myself

)
Perhaps there's a way to return null if no option is chosen at the end (and so switch to "no_audio") ? Well, it's not really important.
And the working test I was looking for, removing the {} (not sure it's the "good way" to do for someone wanting only the higher bitrate as result) :
To talk about "what is the best", I totally agree that it's not that simple to order things, because it could be sorted by :
- Codec from the codecList (but hard to organize) : MP2 < MP3 < PCM < AAC < AC3 < EAC3 < ... But which one is better from AAC/AC3 or TrueHD Atmos/DTS-X or ... and what between AC3 5.1 & EAC3 2.0 (don't know if it exists but you get the idea...)
- Bitrate (what is done actually). Must be the most relevant even if, in some rare cases, bitrate can be lower but quality higher due to better compression of the algorithm...
- Max bitrate, thanks for the idea... but average must be better
- Number of channels : 2.0 < 5.1 < 7.1 < 9.1
Well, really hard to find a way to sort.
Now, it's working as expected with this (even if I don't know what is "addToList" which can be preferred by the "any" because it's at the front :
Code: Select all
any{addToList}{[bestPreferredLang, bestBitRate].findAll().unique().join(' & ')}{defaultStream}{bestBitRate}{preferredStream}
Also working with this, that I shoud propably use, because I think I understood (more or less...

) :
Code: Select all
[bestPreferredLang, bestBitRate].findAll().unique().join(' & ')
Well, to be honest it's really cool & good enough to me, even if it could be even better. Let's take some cases :
- For a movie, like above, with AC3@384 FR & EAC3@1024 EN => Show both (best FR then best "other/foreign").
- For a movie with AC3@384 FR & DTS@1500 FR & AC3@384 EN => Show only DTS FR (the best of all available) ;
Is it sure that "bestPreferredLang" will always take DTS@1500 FR over AC3@384 FR ? I mean select the highest bitrate of all FR, because it's only selecting against "preferedLang", not best bitrate. I guess it's because listStream is sorted by bitrate... (but if so, why not only taking the first of the list for bestBitRate ? ; bestBitRate = listStream(it)[0])
- For a movie with AC3@350 FR & AC3@340 EN => Show only AC3 FR (best of the best)
- For a movie with AC3@340 FR & AC3@350 EN => I would prefer to only display FR, but it's not working this way now (350 > 340...). Would it be possible/easy to display the alternative audio (other that French) IF bitrate is higher (already done) but also codec is different ?
Something like :
bestPreferredLang.codec <> bestBitRate.codec ? Show both : show bestPreferredLang only.
Just not sure we can play with bestPreferredLang & bestBitRate like this because they are Strings as I understand... probably needed to take it from audioStreams like :
def betterForeign = ?!? I could probably try things but it will not probably be ideal...
seems working :
Code: Select all
audioStreams.findAll{ it.bitrate == audioStreams.bitrate.max() }.codec == audioStreams.findAll{ it.lang == preferredLang }.codec ? bestPreferredLang:[bestPreferredLang, bestBitRate].join(' & ')
Thanks again for your answers and for the time you take to read all of this
