is there a way to detect the different Audio tracks?

All about user-defined episode / movie / file name format expressions
Post Reply
DevXen
Power User
Posts: 164
Joined: 12 Oct 2014, 21:15

is there a way to detect the different Audio tracks?

Post by DevXen »

So i'm trying to detect the different audio tracks of a video file.
{audios.groupBy{ it.language }.collect{ c, a -> a*.language}.flatten()})
seems to work. but i'd guess only if the audio track has an encoded language.

I have several videos that have the main audio track, and then a commentary. that i can't get it to display anything for the audio track at all.
in those cases (I'd like it to display "2 audio tracks") unless there was a way to determine if one was a commentary. that would be nice. though i'm guessing not possible.
and if it has 2 audio tracks, maybe: 1. English 2ch, 2. English 6ch)
would be nice


I did see this: {'.'+audios.groupBy{ it.Codec }.collect{ c, a -> [c] + a*.Language }.flatten().join('.')}{'.['+texts.language.flatten().join('.')+']'}{'.'+vc}

from another post on here that I was working with. but it isn't detecting many of the videos with the second commentary track. - (that i verified in Windows Media player are indeed in the video) - I'd assume maybe not all videos have the language name encoded in the audio track, so it just doesn't pull anything up? i'm not sure.


I would appreciate any help or advice. thank you.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: is there a way to detect the different Audio tracks?

Post by rednoah »

First thing is to do "Format Dialog" -> "Bindings Dialog" -> "MediaInfo Viewer" and see what exactly what information is available for which file. Once you know what data you have there rest will be just a bit of Groovy magic.

Image
:idea: Please read the FAQ and How to Request Help.
DevXen
Power User
Posts: 164
Joined: 12 Oct 2014, 21:15

Re: is there a way to detect the different Audio tracks?

Post by DevXen »

Ok, I did that, and in this file specifically, it's showing 3 Audio tracks. But no language set, which I'm sure was not set when it was encoded. that sucks. but it's what I assumed. I wonder if there's a way to edit it to add that info in. Hmm. I'll have to look into that.
So with this one (and i'd assume many others)

how would i use groovy, to detect if more than 1 audio track is in the file, and Display the language and channels for each, and when no language is found
for the track, put: the codec instead.

Example: (1. English 6ch, 2 DTS 8ch, 3 MP3 1ch)


I have:
{if (audios.id[1]) {"(AUD "+audios.groupBy{ it.id }.collect{ c, a -> a*.id+"-"+a*.channels+"ch," }.flatten().join(' ').replaceAll(' ','').replaceAll('-','- ').replaceAll(',',', ')+")"}}
Which is mostly working.
it shows as:
(AUD 1 - 2ch, 2 - 1ch, 3 - 1ch, )

The Problems it's having:
1. There is a comma and space after the last Audio track channels, i can' figure out how to remove.
2. If i insert a*.language it works but only on files that have the language bit set, for my video that doesn't it fails, and doesn't display anything.
I've tried adding an IF before the +a*.channels, to see if that would help. but it just caused the whole thing to either fail, or display a script closure error.
User avatar
rednoah
The Source
Posts: 22998
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: is there a way to detect the different Audio tracks?

Post by rednoah »

1.
I'm not sure on the details, but you can check if certain fields are defined with != null or != "" or any{...}{...} or all{...}{...}

2.
I'd solve that issue by using join() correctly. Keep in mind that values may be empty String "" so you might wanna take that into account.
:idea: Please read the FAQ and How to Request Help.
Post Reply