Detect Atmos sound (handling nulls in groovy)

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
jarrods
Posts: 9
Joined: 16 Jun 2017, 01:24

Detect Atmos sound (handling nulls in groovy)

Post by jarrods »

I have used this to show if movie has Atmos:

Code: Select all

[{ac}{audio[0].format_profile =~ /Atmos/ ? '+Atmos' : ''} {channels}]
which gave outputs for sound such as: [TrueHD+Atmos 7.1] or [DTS 5.1] or [TrueHD 5.1] etc which is exactly what I wanted.

I have found a few movies that the Atmos track is not on audio[0]. For example the movie I am testing script changes with has:

Code: Select all

audio[0]. format_profile	= MA / Core
audio[1]. format_profile 	= TrueHD+Atmos / TrueHD
audio[2]. format_profile 	= null  (Binding “format_profile”: undefined)
audio[3]. format_profile 	= MA / Core
audio[4]. format_profile 	= null
audio[5]. format_profile 	= null
If in Groovy web console I do this:

Code: Select all

def myList = ["MA / CoreTrue","HD+Atmos / TrueHD", null, "MA / Core",null,null]
println myList.any { it =~ /Atmos/ } ? "ATMOS" : "NO"
I get “ATMOS” which seems to work, so In my script I tried:

Code: Select all

[{ac}{audio.format_profile.any { it =~ /Atmos/ } ? '+Atmos' : ''} {channels}]
but I get error Binding “null” undefined. I have read a few groovy articles on ignoring nulls but I can’t seem to find a way to search all audio tracks for the word Atmos.
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Detect Atmos sound (handling nulls in groovy)

Post by rednoah »

This would be the easiest solution:

Code: Select all

{audio.FormatProfile =~ /Atmos/ ? ' [Atmos]' : null}
:!: Untested. I don't have any multi-stream Atmos / NoAtmos files lying around. It might not work.

:!: audio might look like a list, but it's not, it's dynamically evaluated, so there could be internal issues when accessing properties that are only partially defined. A sample file for testing would be helpful.
:idea: Please read the FAQ and How to Request Help.
jarrods
Posts: 9
Joined: 16 Jun 2017, 01:24

Re: Detect Atmos sound (handling nulls in groovy)

Post by jarrods »

thanks for reply.

{audio.FormatProfile =~ /Atmos/ ? ' [Atmos]' : null}

gives: (i) Binding "null": undefined

{audio[0].FormatProfile} gives MA/Core
{audio[1].FormatProfile} gives TrueHD+Atmos / TrueHD
{audio[2].FormatProfile} gives Binding “format_profile”: undefined
{audio[2].Format} gives AC-3

I'm not sure how I can give you sample as files are ATMOS movies. the one I am using for testing is 28GByte. I can export something from MediaInfo app if you tell me what you need.
jarrods
Posts: 9
Joined: 16 Jun 2017, 01:24

Re: Detect Atmos sound (handling nulls in groovy)

Post by jarrods »

btw {audio.format} gives: [DTS, TrueHD, AC-3, DTS, DTS, AC-3, AC-3, AC-3, AC-3, AC-3, AC-3, AC-3, AC-3]

and that is why I thought I could use list .any that supposedly wipes nulls.
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Detect Atmos sound (handling nulls in groovy)

Post by rednoah »

You might be able to copy a small part of the video:
https://forum.videohelp.com/threads/359 ... tle-tracks

Just a few seconds should be enough, but the MediaInfo would be the same.
:idea: Please read the FAQ and How to Request Help.
jarrods
Posts: 9
Joined: 16 Jun 2017, 01:24

Re: Detect Atmos sound (handling nulls in groovy)

Post by jarrods »

I looked at all audio details in MediInfo and see the Atmos track has "Object Based / 8 channels" in the channel description. So I tried...

[{ac}{audio.channels.any { it =~ /Object/ } ? '+Atmos' : ''} {channels}]

which gives: [DTS+Atmos 7.1]

This is ok. At least is shows it has an Atmos track which is my main requirement. But is should be TrueHD for atmos. Should/does {ac} show the 'best' audio quality available?
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Detect Atmos sound (handling nulls in groovy)

Post by rednoah »

{ac} uses CodecID/Hint or Format from Audio Stream 0.
:idea: Please read the FAQ and How to Request Help.
jarrods
Posts: 9
Joined: 16 Jun 2017, 01:24

Re: Detect Atmos sound (handling nulls in groovy)

Post by jarrods »

OK.
Well I have settled on:

Code: Select all

[{audio.channels.any { it =~ /Object/ } ? 'TrueHD+Atmos' : {ac}} {channels}]
If any stream is object based then it is Atmos. I will assume TrueHD but it might be DD+. My groovy skills are far too low to find the number of the index of the Object Based stream and look its format up. If not Atmos then I just use {ac} and take whatever is stream 0 which usually will be best audio. thanks. btw could you possibly alter {ac} to include Atmos if any stream is ObjectBased (the true definition of Atmos audio)?? cheers.
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Detect Atmos sound (handling nulls in groovy)

Post by rednoah »

1.
I'd really appreciate a small sample file. So I can find out if that's an internal bug that can be fixed to make the format work as expected.


2.
{ac} is stable API and won't change unless there is a very good reason. Automatically selecting the "best" stream for the {ac} would bring countless non-obvious issues. What is "best"? What if "best" is a commentary audio track? What if "best" has "better" codec but much lower bitrate? etc
:idea: Please read the FAQ and How to Request Help.
jarrods
Posts: 9
Joined: 16 Jun 2017, 01:24

Re: Detect Atmos sound (handling nulls in groovy)

Post by jarrods »

I have put 5 seconds here.... http://jarrod.biz/atmos.zip

Point taken about 'best' audio. Let me rephrase the request.

An Atmos movie has information like this:
ID : 1
Format : TrueHD
Format profile : TrueHD+Atmos / TrueHD
Codec ID : A_TRUEHD
Channel(s) : Object Based / 8 channels
Channel positions : Object Based / Front: L C R, Side: L R, Back: L R, LFE

It is TrueHD Audio but the channels description of Object Based should trigger you to change Format from TrueHD to TrueHD+Atmos. All other audio formats are Channel Based audio; Atmos by design (and its patents) is Object Based audio.

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

Re: Detect Atmos sound (handling nulls in groovy)

Post by rednoah »

This will work most of the time, as long as the Atmos audio stream is before the audio stream that doesn't define FormatProfile:

Code: Select all

{audio.any{ it.FormatProfile =~ /Atmos/ } ? 'Atmos' : null}
This will always work. It's a bit more tricky because it'll need to catch the exceptions when FormatProfile is undefined:

Code: Select all

{audio.any{ a -> call{a.FormatProfile} =~ /Atmos/ } ? 'Atmos' : null}

I won't modify {ac} but I'll add an {atmos} binding just for you. ;)


EDIT:

In your case, modifying {ac} would not make a difference, because Audio Stream 0 is not a TrueHD+Atmos anyway, so the result will always be DTS.
:idea: Please read the FAQ and How to Request Help.
jarrods
Posts: 9
Joined: 16 Jun 2017, 01:24

Re: Detect Atmos sound (handling nulls in groovy)

Post by jarrods »

Oh OK. that's great news. I'm a bit concerned though as I don't know what's happening to future FileBot versions. I need the 32bit msi one but see that the only Windows seems to be a purchase from Windows 10 store. I don't care if it's pay for the 32bit version but I know you can't sell that in Windows 10 store.
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Detect Atmos sound (handling nulls in groovy)

Post by rednoah »

1.
After having a look, I'm not really sure about how I feel about a new {atmos} binding that checks all streams. Is there some other binding logic you could think of? Some overarching meaning? Like is "audio codec attributes" or something like that. What is TrueHD? What is Atmos? What is TrueHD with or without Atmos?


2.
Indeed, there is no 32-bit version of FileBot on the Store. It's just not worth the extra effort. How come you're running 32-bit Windows 10 in 2017???
:idea: Please read the FAQ and How to Request Help.
jarrods
Posts: 9
Joined: 16 Jun 2017, 01:24

Re: Detect Atmos sound (handling nulls in groovy)

Post by jarrods »

The Audio format is TrueHD. Format is the best word for that. You can have a TrueHD audio file and the audio engineer can direct the sound of something to the various audio CHANNELS. Like put the sound of an explosion in the Left Back Surround of the 7.1 CHANNELS. Atmos is total different. It is OBJECT based. The audio engineer has an Object (say a helicopter) and he moves it around the sound stage. The 'position' of the object is recorded with the actual sound in the TrueHD stream, so it is still TrueHD (and {ac} should report that). In a movie theatre the Atmos decoder will move the sound around the say 24 speaker channels based on what position it is supposed to be in the sound-stage. In home theatre with 7.1 channels the sound is again decoded and it puts the sound as best as it can with the speakers available. The best attribute to add would be something as a supplement to {ac} like {co} (channel/object). It could return +Atmos" or "". Nobody wants to mark normal 7.1 as "7.1 Channel" but many would like "7.1 Atmos". Some notes.... https://blog.dolby.com/2014/09/dolby-at ... o-matters/

I do have Windows 7 PCs & laptops, 4 x Synology NAS with over 100TB disk total but yes I do have a HP MediaSmart server as well that runs Windows Home Server v1 (based on Windows Small Business Server 2003) which is 32 bit. It is my torrent server. uTorrent and FileBot are only apps on it. If 32bit FileBot is stuck at current version then that's fine. It works 99.9% of the time. In the rare cases {hd} gives "" instead of UHD or my old Atmos problem it was easy to correct filename manually.
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Detect Atmos sound (handling nulls in groovy)

Post by rednoah »

1.
Thanks for the thorough explanation. That makes things more clear to me.


2.
I see. You have older and newer machines. I thought you were running Windows 10 because you mentioned the Store which only works on 10 anyway.

I won't maintain the old installers, but if the need arises, I can give you a development build (e.g. zip archive) that should run any machine that can run Java. It's a bit of work, but you're a long time contributor.
:idea: Please read the FAQ and How to Request Help.
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Detect Atmos sound (handling nulls in groovy)

Post by rednoah »

I've added the {aco} binding for "audio channel object" and that'll just give you the value of the first defined Codec_Profile property (the bit before the / character).
:idea: Please read the FAQ and How to Request Help.
jarrods
Posts: 9
Joined: 16 Jun 2017, 01:24

Re: Detect Atmos sound (handling nulls in groovy)

Post by jarrods »

thanks Reinhard I'm keen to test this. I've made a paypal payment for your assistance and the use I have had out of the existing 32bit version.

your reason not to maintain the 32/64 .msi installers? is it too much work (I imagined an automated script did all the compiles) or is it there is no simple store-front to sell? there must be a few like me who will never use Win10 and would pay for an msi installer subscription (individual ftp username/password???).
User avatar
rednoah
The Source
Posts: 22976
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Detect Atmos sound (handling nulls in groovy)

Post by rednoah »

1.
You can try the latest jar and replace it yourself in your existing install folder:
viewtopic.php?f=7&t=1609

You'll need to gpg and xz to verify and extract the file.


2.
Subscription for legacy installers is not planned. Just not worth the effort. Especially not at the Windows Store price point. Also, paying users (rightly so) would expect updates until the end of time.

All of the reluctant Windows 7 users will eventually end up using Windows 10 or 11 or whatnot, even if it takes a decades. Probably much earlier if they finally make Windows not-fugly again with the next update. :D
:idea: Please read the FAQ and How to Request Help.
Post Reply