Replace output of audios.language...

Any questions? Need some help?
Trikola
Posts: 2
Joined: 25 Jan 2016, 16:03

Replace output of audios.language...

Post by Trikola »

Hi,

I tried to rename/replace the output of audios.language and texts.language from for example [eng, de] to [English, German].
I used this part of code

Code: Select all

{" [$vf] [$ac "+af.replace('8ch', '7.1ch').replace('7ch', '6.1ch').replace('6ch', '5.1ch').replace('3ch', '2.1ch').replace('2ch','2.0ch')+"]"}
and I edited it to

Code: Select all

{"+audios.language.replace('[de, eng]', '[German, English]')+"]"}
But it seems like, that it doesn't work for me.
Can anyone help me, to find a solution.

Regards
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace output of audios.language...

Post by rednoah »

1.
audios.language is of type List and not String.

This is what you want:

Code: Select all

{audios.language*.toLocale().displayLanguage}
2.
MediaInfo property ChannelPositions/String2 with values like 3/2/0.1 might be more what you want.

e.g.

Code: Select all

{audio.ChannelPositionsString2.tokenize()*.toBigDecimal().sum()}
EDIT:

The {channels} binding has been added with r3467 to make this easier with future versions.
:idea: Please read the FAQ and How to Request Help.
Trikola
Posts: 2
Joined: 25 Jan 2016, 16:03

Re: Replace output of audios.language...

Post by Trikola »

Hi,

thanks for your answer, all works fine.
I reworked my dreamoutput...


The part shall now looks like this

Code: Select all

[Ger, Eng][DTS-5.1][Ger-Eng-Sub]
[Ger-AC3-5.1][Eng-DTS-5.1][Ger-Sub]
[Ger-AC3-5.1][Eng-DTS-5.1]
It should matches in all situation, and the language(s) should be only displayed like in my example.
Filebot should only look for german or english subtitles and output them, if there is more, than they shall be ignored


Thank you in advance

Regards
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Replace output of audios.language...

Post by kim »

Nice
The {channels} binding has been added with r3467 to make this easier with future versions.
BUT take a avi file with MP3 and you get
ChannelPositionsString2 undefined
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace output of audios.language...

Post by rednoah »

What does the mediainfo say? If ChannelPositionsString2 is not defined, is there anything else that can tell us that piece of information?

Image
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Replace output of audios.language...

Post by kim »

Audio
ID : 1
Format : MPEG Audio
Format version : Version 1
Format profile : Layer 3
Codec ID : 55
Codec ID/Hint : MP3
Duration : 1h 43mn
Bit rate mode : Constant
Bit rate : 128 Kbps
Channel(s) : 2 channels
Sampling rate : 48.0 KHz
Compression mode : Lossy
Stream size : 95.1 MiB (14%)
Alignment : Aligned on interleaves
Interleave, duration : 42 ms (1.00 video frame)
Interleave, preload duration : 504 ms
Writing library : LAME3.97
Encoding settings : -m s -V 4 -q 2 -lowpass 17 -b 128
<ALL Count='254' StreamCount='1' StreamKind='Audio' StreamKind/String='Audio' StreamKindID='0' StreamOrder='1' ID='1' ID/String='1' Format='MPEG Audio' Format_Commercial='MPEG Audio' Format_Version='Version 1' Format_Profile='Layer 3' InternetMediaType='audio/mpeg' CodecID='55' CodecID/Hint='MP3' CodecID/Url='http://www.iis.fraunhofer.de/amm/index.html' Codec='MPA1L3' Codec/String='MPEG-1 Audio layer 3' Codec/Family='MPEG-1' Codec/Info='MPEG-1 or 2 layer 3' Codec/Url='http://www.iis.fraunhofer.de/amm/index.html' Codec/CC='55' Duration='6233688' Duration/String='1h 43mn' Duration/String1='1h 43mn 53s 688ms' Duration/String2='1h 43mn' Duration/String3='01:43:53.688' Duration/String5='01:43:53.688' BitRate_Mode='CBR' BitRate_Mode/String='Constant' BitRate='128000' BitRate/String='128 Kbps' Channel(s)='2' Channel(s)/String='2 channels' SamplingRate='48000' SamplingRate/String='48.0 KHz' SamplingCount='299219328' FrameCount='259739' Compression_Mode='Lossy' Compression_Mode/String='Lossy' Delay='0' Delay/String3='00:00:00.000' Delay_Source='Stream' Delay_Source/String='Raw stream' Video_Delay='0' Video_Delay/String3='00:00:00.000' Video0_Delay='0' Video0_Delay/String3='00:00:00.000' StreamSize='99739008' StreamSize/String='95.1 MiB (14%)' StreamSize/String1='95 MiB' StreamSize/String2='95 MiB' StreamSize/String3='95.1 MiB' StreamSize/String4='95.12 MiB' StreamSize/String5='95.1 MiB (14%)' StreamSize_Proportion='0.13593' Alignment='Aligned' Alignment/String='Aligned on interleaves' Interleave_VideoFrames='1.00' Interleave_Duration='42' Interleave_Duration/String='42 ms (1.00 video frame)' Interleave_Preload='504' Interleave_Preload/String='504 ms' Encoded_Library='LAME3.97 ' Encoded_Library/String='LAME3.97 ' Encoded_Library_Settings='-m s -V 4 -q 2 -lowpass 17 -b 128' />
Maybe you can use
{audios.Channels.join()}
but if we can get a display option "2 = 2.0" it will be nice
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace output of audios.language...

Post by rednoah »

Fixed with r3551.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Replace output of audios.language...

Post by kim »

Found new bug:

source: dts_animated_logo_lossless.x264.DTS-HD.MA.7.1-DWEU.mkv
http://www.demo-world.eu/download-2d-tr ... d_logo.jpg

"Channel(s) : 8 channels / 6 channels
Channel positions : Front: L C R, Side: L R, Back: L R, LFE / Front: L C R, Side: L R, LFE"

{audio.ChannelPositionsString2.tokenize()} = [3, 2, 2.1, 3, 2, 0.1]
{audio.Channels} = 8 6

{Channels} = java.lang.NumberFormatException
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace output of audios.language...

Post by rednoah »

The link doesn't work. I'll either need that file or the media info audio table (FileBot Bindings Dialog) as text.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Replace output of audios.language...

Post by kim »

you need to click the dts pic...

but ok a direct link:
http://s1.demo-world.eu/hd_trailers.php ... s-DWEU.mkv


"media info audio table (FileBot Bindings Dialog) as text":
is there a command for that ?

Audio
ID : 2
Format : DTS
Format/Info : Digital Theater Systems
Format profile : MA / Core
Mode : 16
Format settings, Endianness : Big
Codec ID : A_DTS
Duration : 21s 355ms
Bit rate mode : Variable
Bit rate : Unknown / 1 509 Kbps
Channel(s) : 8 channels / 6 channels
Channel positions : Front: L C R, Side: L R, Back: L R, LFE / Front: L C R, Side: L R, LFE
Sampling rate : 48.0 KHz
Bit depth : 24 bits
Compression mode : Lossless / Lossy
Language : English
Default : Yes
Forced : No


Format DTS
Format/Info Digital Theater Systems
Format_Commercial DTS
Format_Profile MA / Core
Format_Settings_Mode 16
Format_Settings_Endianness Big
CodecID A_DTS
Codec DTS-HD
Codec/String DTS-HD
Codec/Family DTS
Duration 21355
Duration/String 21s 355ms
Duration/String1 21s 355ms
Duration/String2 21s 355ms
Duration/String3 00:00:21.355
Duration/String5 00:00:21.355
BitRate_Mode VBR
BitRate_Mode/String Variable
BitRate Unknown / 1509000
BitRate/String Unknown / 1 509 Kbps
Channel(s) 8 / 6
Channel(s)/String 8 channels / 6 channels
ChannelPositions Front: L C R, Side: L R, Back: L R, LFE / Front: L C R, Side: L R, LFE
ChannelPositions/String2 3/2/2.1 / 3/2/0.1
ChannelLayout C L R Ls Rs LFE
SamplingRate 48000
SamplingRate/String 48.0 KHz
Resolution 24
Resolution/String 24 bits
BitDepth 24
BitDepth/String 24 bits
Compression_Mode Lossless / Lossy
Compression_Mode/String Lossless / Lossy
Delay 0
Delay/String3 00:00:00.000
Delay_Source Container
Delay_Source/String Container
Video_Delay 0
Video_Delay/String3 00:00:00.000
Video0_Delay 0
Video0_Delay/String3 00:00:00.000
Language en
Language/String English
Language/String1 English
Language/String2 en
Language/String3 eng
Language/String4 en
Default Yes
Default/String Yes
Forced No
Forced/String No
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace output of audios.language...

Post by rednoah »

So apparently a single audio stream can have multiple multi-channel audio streams. What do you think would be the best output? Just the first one "7.1" or all of them [7.1, 5.1] same as media info reports?

EDIT: In my development version it works, but evaluates to 12.2 :lol:
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Replace output of audios.language...

Post by kim »

I have a file with 2 audio streams (6ch/2ch)
{Channels} now only show (looks like just the first ?)
but with {audios.Channels[0]}/{audios.Channels[1]} you can write out all Channels...


I also have a file with 2 audio streams (2ch/6ch) :
{Channels} = 2.0 (not 5.1)
{audios.Channels[0]}/{audios.Channels[1]} = 2/2 (weird)
{audios.Channels} = 2, 2

not writing the 5.1 ch is a problem (I believe that was working some time ago, maybe something on my end ?)

Format AAC
Format_Profile HE-AAC / LC
CodecID 40
Codec AAC LC-SBR
Codec/String AAC LC-SBR
Codec/Family AAC
BitRate_Mode VBR
BitRate_Mode/String Variable
BitRate 81488
BitRate/String 81.5 Kbps
BitRate_Maximum 99416
BitRate_Maximum/String 99.4 Kbps
Channel(s) 2
Channel(s)/String 2 channels
ChannelPositions Front: L R
ChannelPositions/String2 2/0/0
ChannelLayout L R
SamplingRate 48000 / 24000
SamplingRate/String 48.0 KHz / 24.0 KHz

Format AAC
Format_Profile HE-AAC / LC
CodecID 40
Codec/Family AAC
BitRate_Mode VBR
BitRate_Mode/String Variable
Channel(s) 2
Channel(s)/String 2 channels
Channel(s)_Original 6
Channel(s)_Original/String 6 channels
ChannelPositions Front: L C R, Side: L R, LFE
ChannelPositions/String2 3/2/0.1
ChannelLayout C L R Ls Rs LFE
SamplingRate 48000 / 24000
SamplingRate/String 48.0 KHz / 24.0 KHz

What do you think would be the best output? Just the first one "7.1" or all of them [7.1, 5.1] same as media info reports?
I think always display the best/most channels e.g. if 7.1 and 5.1 = 7.1 or 2.0 and 5.1 = 5.1
all DTS-HD Master Audio files has this multi-single audio stream thing (it looks like) but only/always listed just e.g 7.1

BUT there need to be a way to show all the channels:
if same audio track but diff. number of channels e.g. if 7.1 and 5.1 = 7.1 or 2.0 and 5.1 = 5.1
if diff. language (maybe a "channels.english" to show only english track, but not all have lang info) then show best from all languages e.g. EN.5.1 DE.2.0

e.g. {Channels.all} = [5.1, 5.1, 2.0]
{Channels.Lang.all} = [EN 5.1, DE 5.1, EN 2.0]
{Channels.best} = [5.1]
{Channels.english.best} = [5.1]
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace output of audios.language...

Post by rednoah »

1.
Keep in mind that all the simple bindings like {channels} always use Stream 0 of that type, and the value may be based on a set of mediainfo properties.


audios[0].Channels is the same as audios[0]['Channel(s)'] and allows you to specifically pick mediainfo that isn't predefined in filebot:

Code: Select all

Channel(s) 2
The predefined filebot binding just happens to have a similar name as the mediainfo property.


2.
Using the highest channels value within Audio Stream 0 makes sense for the {channels} bindings. The rest seems overly specific to your exact use case. I'll leave that to the Groovy code in your format.


EDIT:


3.
The audio/audios thing has always bugged me. Also, this particular use case is tricky with Groovy because FileBot internally sanitizes the / slashes away.

r3881 fixes this, by breaking backwards compatibility. {audio[0]} is now Stream 0, and {audio} is now all streams.

e.g.

Code: Select all

{audio.ChannelPositionsString2*.split(' / ')*.collect{ it.split('/')*.toBigDecimal().sum() }*.max()}
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Replace output of audios.language...

Post by kim »

Look like dts-hd 2in1 works now, but i still have files with "Channel(s)_Original" that {Channel} or {audio.channels} dont use or display. {audio[1]['Channel(s)_Original']} do but I think it needs to be part of {Channel}, check and display the best, 2.0 vs 5.1 = 5.1; {Channel} = 5.1 and don't just display the first audio stream.
file: this in 2 audio streams:
1st audio stream:
Channel(s) 2
ChannelPositions/String2 2/0/0

2nd audio stream:
Channel(s) 2
Channel(s)_Original 6
ChannelPositions/String2 3/2/0.1
also maybe add:
from my htpc.groovy

Code: Select all

if (s.'Channel(s)' != null) {
	if (s.'Channel(s)_Original' != null){
		channels((s.'Channel(s)_Original').trim())
	}
	else {
		channels((s.'Channel(s)').trim())
	}
}
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace output of audios.language...

Post by rednoah »

{channels} uses ChannelPositions/String2, if that's not defined then Channel(s)_Original and then Channel(s) as a last resort.

Also, {channels} is only based on Stream 0, same as ac, af, vc, vf, etc.

All the audio binding directly map to media info properties, whatever they may be.
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Replace output of audios.language...

Post by kim »

I tried and made this :
{def au = audio.ChannelPositionsString2*.split(' / ')*.collect{ it.split('/')*.toBigDecimal().sum() }*.max(); if(au[1] > au[0]) return au[1] else channels}

so pls make update to {channels} or make new {channels.best}

I know you can make it better then me...
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace output of audios.language...

Post by rednoah »

So this is all about modifying htpc.groovy? Not about a format expression?


* Why do you assume that there are exactly two audio streams? Might be none. Might be more than two.


This will work regardless of how many audio streams there are:

Code: Select all

{audio.ChannelPositionsString2*.split(' / ')*.collect{ it.split('/')*.toBigDecimal().sum() }*.max().max()}
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Replace output of audios.language...

Post by kim »

"So this is all about modifying htpc.groovy? Not about a format expression?"
No, it's about improvement by fixing, adding or to make easier to use.

htpc.groovy aka the *.nfo xml file:
it needs to show any and all usable info/data in KODI/plex style
now if file has "Channel(s)_Original" (audio) it will not get into the nfo file only "Channel(s)"
e.g. my file from before:
1st audio stream: Channel(s) 2

2nd audio stream:
Channel(s) 2
Channel(s)_Original 6

nfo show only
<channels>2</channels>
and
<channels>2</channels>

it need to show:
<channels>2</channels>
and
<channels>6</channels>

Regarding format expression:
ask ppl if they prefer writing:
{audio.ChannelPositionsString2*.split(' / ')*.collect{ it.split('/')*.toBigDecimal().sum() }*.max().max()}
or
{channels}

"Why do you assume that there are exactly two audio streams? Might be none. Might be more than two."
I don't, I just made it work for me and thats why I wrote "I know you can make it better then me..."


"This will work regardless of how many audio streams there are:
Code: Select all
{audio.ChannelPositionsString2*.split(' / ')*.collect{ it.split('/')*.toBigDecimal().sum() }*.max().max()}"

THX it works
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace output of audios.language...

Post by rednoah »

Neither Plex nor Kodi have a spec for their nfo files, so the htpc.groovy script is community drive. If you think it should behave differently, just let me know. ;)

https://github.com/filebot/scripts/comm ... 15f77646ef
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Replace output of audios.language...

Post by kim »

Nice to know...I will post updates to htpc when I have something to share...

Code: Select all

channels(s.'ChannelPositions/String2'.split(' / ').collect{ it.split('/')*.toBigDecimal().sum() }.max().setScale(1, java.math.RoundingMode.HALF_UP).toPlainString())
I cant get it to work in GUI ?

from log:
NullPointerException: Cannot invoke method split() on null object
remember the:
"BUT take a avi file with MP3 and you get
ChannelPositionsString2 undefined"

"{audio.ChannelPositionsString2*.split(' / ')*.collect{ it.split('/')*.toBigDecimal().sum() }*.max().max()}"
on 2ch AAC file it only show "2" not "2.0"

and if you could make it so we get better error log... like on line xxxx or something ?
+ if why error it will not write any nfo file or get any pics (artwork)

btw in Kodi: if you export to an nfo file it will write
<channels>6</channels>
not
<channels>5.1</channels>
but kodi has problem with <channels>5.1</channels>
maybe it just scans it itself and don't use nfo/xml data ?

update # 1 htpc
all the "replaceAll" and "trim" is because ppl on http://www.themoviedb.org/ do stuff they should not do
added some to "job"
if (p.character != null) {} : is because the hole artwork thing break if error

Code: Select all

			i.people.each{ p ->
				if (p.director) {
					director(p.name)
				} else if (p.actor) { 
					actor {
						name((p.name).trim())
						if (p.character != null) {
							role((p.character).replaceAll('\n', '').replaceAll('( )+', ' ').trim())
						}
					}
				} else if (p.job ==~ /Writer/) {
					credits(p.name)
				} else if (p.job ==~ /Author|Novel|Characters|Adaptation|Storyboard|Screenplay|Story|Book/) {
					credits("$p.name ($p.job)")
				}
			}
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace output of audios.language...

Post by rednoah »

Alright, so we want this instead then? Same as before, just prefer 'Channel(s)_Original' property if available.

Code: Select all

s.'Channel(s)_Original' ?: s.'Channel(s)'
@see https://github.com/filebot/scripts/comm ... 45f1f81d69
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Replace output of audios.language...

Post by kim »

For now I think "just prefer 'Channel(s)_Original' property if available"
is for the best BUT again what if no/null audio ?
(not very likely, I know, but could happen)

If there was a global .... skip if null... that would help a lot

2.
I see you updated htpc people part :)
there is a reason why I have credits on it's own... in kodi credits = Writer... so on screen
Writer
person (Writer)
else if (p.job ==~ /Writer/) {
credits(p.name)
}
It's my preference because I think "Writer: person (Writer)" looks bad... but what do the community think ?
User avatar
rednoah
The Source
Posts: 22991
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Replace output of audios.language...

Post by rednoah »

1.
If s.'Channel(s)' is undefined, it'll yield an empty string, so there will be an empty <channels> element in the nfo file, which means no / unknown channels.

2.
Does Kodi not display the <writer> element as Writer? <credits> is for all the people that aren't writers.

Code: Select all

if (p.writer) {
    writer(p.name)
}
:idea: Please read the FAQ and How to Request Help.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Replace output of audios.language...

Post by kim »

Image
As you can see "Writer" ("Writer" = <credits> in code/xml/nfo)


"<credits> is for all the people that aren't writers."
No, only writer or sub category of writer

Now:
person (Writer)

My version
person / dif. person (Screenplay)...


ALL the others:
<actor>
<name>person</name>
<role>role</role>
</actor>

has dif. a place "Cast"
e.g. person as role


only change writer aka credits part ALL else is ok

EDIT: I looked at your htpc code

You misunderstood me... this "writer(p.name)"

Code: Select all

					director(p.name)
				} else if (p.writer) {
					writer(p.name)
				} else if (p.actor) { 
must be "credits(p.name)"

Code: Select all

					director(p.name)
				} else if (p.writer) {
					credits(p.name)
				} else if (p.actor) { 
Last edited by kim on 11 Apr 2016, 13:47, edited 1 time in total.
kim
Power User
Posts: 1251
Joined: 15 May 2014, 16:17

Re: Replace output of audios.language...

Post by kim »

I added "Producer" to htpc/nfo

Code: Select all

				if (p.director) {
					director(p.name)
				} else if (p.job ==~ /Producer/) {
					producer(p.name)
				} else if (p.actor) { 

for some reason this makes the order random between
<director>, <credits> and <producer> ?

can't think of any more "crew" jobs that is useful ?
Post Reply