kim wrote: 06 Mar 2020, 18:19
You are missing the first part ?
Code: Select all
{
def preferredLang = 'Eng'
def useChFilter = false
def filter = { [it.codec, it.ch, it.objects, it.lang] }
I did change this part as well.
I've also tried to just use your script and nothing else.
So like this:
Code: Select all
{
def preferredLang = 'Eng'
def useChFilter = false
def filter = { [it.codec, it.ch, it.objects, it.lang] }
def codecList =
[
'MP3' : 'MP3',
'PCM' : 'PCM',
'AAC LC' : 'AAC',
'AAC LC SBR' : 'AAC',
'AAC LC SBR PS' : 'AAC',
'AC 3' : 'AC3',
'AC 3 Dep' : 'EAC3',
'E AC 3' : 'EAC3',
'E AC 3 JOC' : 'EAC3 Atmos',
'AC 3 Dep JOC' : 'EAC3 Atmos',
'DTS' : 'DTS',
'DTS 96 24' : 'DTS 96-24',
'DTS ES' : 'DTS-ES',
'DTS ES XXCH' : 'DTS-ES',
'DTS XBR' : 'DTS-HD HRA',
'DTS ES XBR' : 'DTS-HD HRA',
'DTS ES XXCH XBR' : 'DTS-HD HRA',
'DTS XLL' : 'DTS-HD MA',
'DTS ES XLL' : 'DTS-HD MA',
'DTS ES XXCH XLL' : 'DTS-HD MA',
'DTS XLL X' : 'DTS X',
'MLP FBA' : 'TrueHD',
'MLP FBA 16 ch' : 'TrueHD Atmos'
]
def audioStreams = []
def audioClean = { it.replaceAll(/[\p{Pd}\p{Space}]/, ' ').replaceAll(/\p{Space}{2,}/, ' ').slash(' ') }
def channelClean = { it.replaceAll(/Debug.+|Object\sBased\s?\/?|(\d+)?\sobjects\s\/\s|0.(?=\d.\d)|20/).replaceAll(/6.0/,'5.1').replaceAll(/8.0/,'7.1') }
def oneStream = { it.collect{ filter(it) }*.minus(null).unique().flatten().join(' ') }
def dString = { it.toDouble().toString() }
def toInt = { it.toInteger() }
any{audio.collect{ au ->
def codec = audioClean(any{ au['CodecID/Hint'] }{ au['Format'] })
def format_profile = any{ audioClean(au['Format_AdditionalFeatures'])}{}
def String ch = any{ channelClean(au.ChannelPositionsString2).tokenize('\\/')*.toDouble().toString().sum() }
{ channelClean(dString(au.ChannelsOriginal)) } { channelClean(dString(au.Channels)) }
def chFilter = ( ( ( (ac == 'AAC'||ac == 'MP3') && ch != '2.0') || ( (ac == 'AC3'||ac == 'EAC3'||ac == 'DTS'||ac == 'TrueHD'||ac == 'MLPFBA') && ch != '5.1' ) ) ? ch : null )
def combined = allOf{codec}{format_profile}.join(' ')
audioStreams << ['index' : codecList.findIndexOf { it.key == combined }, 'default' : any {au['default'][0].toBoolean() }{ audio.size == 1 ? true : '' },
'codec' : codecList.get(combined, 'Add to "' + combined + '" codecList'), 'combined' : combined, 'ch' : useChFilter ? chFilter : ch,
'bitrate' : any{ toInt(au.BitRate) }{ toInt(au.BitRate_Maximum) }{ dString(au.FrameRate) }{null},
'objects' : any{ '[' + au['NumberOfDynamicObjects'] + ' Objs]' }{null}, 'lang' : any{ au.'LanguageString3'.upperInitial() }{null} ]
return audioStreams
}
def addToList = audioStreams.codec.findAll{ it.contains('Add to') }.unique().sort()
def allStreams = audioStreams.collect{ filter(it) }*.minus(null).unique()*.join(' ')
def preferredStream = oneStream(audioStreams.findAll{ it.index == audioStreams.index.max() })
def bestBitRate = oneStream(audioStreams.findAll{ it.bitrate == audioStreams.bitrate.max() })
def defaultStream = oneStream(audioStreams.findAll{ it.default == true })
def bestPreferredLang = any{ audioStreams.findAll{ it.lang == preferredLang }.sort{ a, b -> b.bitrate <=> a.bitrate }.collect{ filter(it) }*.minus(null).unique().get(0).join(' ') }{}
any{addToList}{bestPreferredLang}{defaultStream}{bestBitRate}{preferredStream}
}{'NO_AUDIO'}
}
For .mkv-fies it is working perfectly fine but for BD-folder structures (.m2ts-files) it gives no audio.
kim wrote: 06 Mar 2020, 18:19
useChFilter = this line:
Code: Select all
def chFilter = ( ( ( (ac == 'AAC'||ac == 'MP3') && ch != '2.0') || ( (ac == 'AC3'||ac == 'EAC3'||ac == 'DTS'||ac == 'TrueHD'||ac == 'MLPFBA') && ch != '5.1' ) ) ? ch : null )
= if AAC/MP3 2.0 OR AC3/EAC3/DTS/TrueHD/MLPFBA 5.1, then don't show the 2.0/5.1 part
what is your full format?
Ah, I see. Thanks fot the explanation.
I am using this format at the moment:
Code: Select all
{az}/{collection}/{
def KIND = ( media.find{media.fileextension != 'm2ts'} ? 'NOBD'
: 'BD' )
def LOCLANG = any{ (audio.find{ it.language == 'en'} ? 'LOCENG'
: 'LOCGER' ) } {null}
( KIND == 'NOBD' ? ( ( LOCLANG == 'LOCENG' ) ? {any{localize.eng.ny.upperInitial()/localize.eng.ny.upperInitial()}{ny.upperInitial()/ny.upperInitial()}}
: {any{localize.deu.ny.upperInitial().replace('Ä', 'Ae').replace('ä', 'ae').replace('Ö', 'Oe').replace('ö', 'oe').replace('Ü', 'Ue').replace('ü', 'ue').replace('ß', 'ss')/localize.deu.ny.upperInitial().replace('Ä', 'Ae').replace('ä', 'ae').replace('Ö', 'Oe').replace('ö', 'oe').replace('Ü', 'Ue').replace('ü', 'ue').replace('ß', 'ss')}{ny.upperInitial()/ny.upperInitial()}} )
: {any{localize.eng.ny.upperInitial()/localize.eng.ny.upperInitial()}{ny.upperInitial()/ny.upperInitial().fn.matchAll(/UHD|SBS|framepacked/)}} )
} {
def KIND = ( media.find{media.fileextension != 'm2ts'} ? 'NOBD'
: 'BD' )
( KIND == 'BD' ? {''+fn.match(/HSBS|SBS|H-SBS/)} : {null})
}{' '+tags}{' '+vf}{' '+any{hdr}{'SDR'}}{' '+fn.matchAll(/UHD|MVC|framepacked/)}{' '+s3d}{
def preferredGer = 'DEU'
def preferredEng = 'ENG'
def codecList =
[
'MP3' : 'MP3',
'PCM' : 'PCM',
'AAC' : 'AAC',
'AAC LC' : 'AAC',
'AAC LC SBR' : 'AAC',
'AAC LC SBR PS' : 'AAC',
'AC 3' : 'AC3',
'AC 3 Dep' : 'EAC3',
'E AC 3' : 'EAC3',
'DTS' : 'DTS',
'DTS 96 24' : 'DTS 96-24',
'DTS ES' : 'DTS-ES',
'DTS ES XXCH' : 'DTS-ES',
'DTS XBR' : 'DTS-HD HRA',
'DTS ES XBR' : 'DTS-HD HRA',
'DTS ES XXCH XBR' : 'DTS-HD HRA',
'DTS XLL' : 'DTS-HD MA',
'DTS ES XLL' : 'DTS-HD MA',
'DTS ES XXCH XLL' : 'DTS-HD MA',
'MLP FBA' : 'TrueHD',
'DTS XLL X' : 'DTS X',
'E AC 3 JOC' : 'EAC3 ATMOS',
'AC 3 Dep JOC' : 'DD+ ATMOS',
'AC 3 MLP FBA 16 ch' : 'TrueHD ATMOS',
'AC 3 MLP FBA 16-ch' : 'TrueHD ATMOS',
'MLP FBA 16 ch' : 'TrueHD ATMOS'
]
def filter = { [it.lang, it.codec, it.ch] }
def audioStreams = []
def audioClean = { it.replaceAll(/[\p{Pd}\p{Space}]/, ' ').replaceAll(/\p{Space}{2,}/, ' ').slash(' ') }
def channelClean = { it.replaceAll(/Debug.+|Object\sBased\s?\/?|(\d+)?\sobjects\s\/\s|0.(?=\d.\d)|20/).replaceAll(/6.0/,'5.1').replaceAll(/8.0/,'7.1')}
def oneStream = { it.collect{ filter(it) }*.minus(null).unique().flatten().join(' ') }
def dString = { it.toDouble().toString() }
def toInt = { it.toInteger() }
audio.collect{ au ->
def codec = audioClean(any{ au['CodecID/Hint'] }{ au['Format'] })
def format_profile = any{ audioClean(au['Format_AdditionalFeatures'])}{}
def String ch = any{ channelClean(au.ChannelPositionsString2).tokenize('\\/')*.toDouble().toString().sum() }
{ channelClean(dString(au.ChannelsOriginal)) } { channelClean(dString(au.Channels)) }
def chFilter = (( ( (ac == 'AAC'||ac == 'MP3') && ch != '2.0') || ( (ac == 'AC3'||ac == 'EAC3'||ac == 'DTS'||ac == 'TrueHD'||ac == 'MLPFBA') && ch != '5.1' ) ) ? ch : null)
def combined = allOf{codec}{format_profile}.join(' ')
audioStreams << ['index' : codecList.findIndexOf {it.key == combined}, 'default' : any{au['default'][0].toBoolean()}{audio.size == 1 ? true : ''},
'codec' : codecList.get(combined, 'UNKNOWN_FORMAT'), 'combined' : combined, 'ch' : ch,
'bitrate' : any{toInt(au.BitRate)}{toInt(au.BitRate_Maximum)}{au.FrameRate.toDouble()}{null},
'objects' : any{'[' + au['NumberOfDynamicObjects'] + ' Objs]'}{null}, 'lang' : any{au.'LanguageString3'.upper() }{null} ]
return audioStreams
}
def allStreams = audioStreams.collect{ filter(it) }*.minus(null).unique()*.join(' ')
def preferredStream = oneStream(audioStreams.findAll{ it.index == audioStreams.index.max() })
def bestBitRate = oneStream(audioStreams.findAll{ it.bitrate == audioStreams.bitrate.max() })
def defaultStream = oneStream(audioStreams.findAll{it.default == true})
def bestPreferredGer = any{audioStreams.findAll{it.lang == preferredGer }.sort{it.bitrate}.reverse().collect{ filter(it) }*.minus(null).unique().get(0).join(' ')}{preferredStream}
def bestPreferredEng = any{audioStreams.findAll{it.lang == preferredEng }.sort{it.bitrate}.reverse().collect{ filter(it) }*.minus(null).unique().get(0).join(' ')}{bestBitRate}
' '+[defaultStream, bestPreferredEng, bestPreferredGer ].unique().join(' ').space(' ')
}{
def gersub = text.find{ it.language == 'de'}
' '+gersub.language+'-sub'
}{
def engsub = text.find{ it.language == 'en'}
' '+engsub.language+'-sub'
}{fn.match(/-fanart|-banner|-clearart|-clearlogo|-discart|-landscape|-poster/)}{subt}
With this format for .m2ts-files it at least gives me the information "TrueHD ATMOS 7.1" e.g. (so just without the language).
It includes your script before your last changes.
@rednoah
I found an issue with 4.9.0 on windows but it may be hard to replicate.
I did create some formats yesterday with the application and I used them. Later that day I wanted to use them again but they were gone. They are not available in the preset selection anymore. I don't exactly know what happened during that time.