multiple audio tracks, more than 3 chapters, only english subs

Support for Windows users
Post Reply
CaptainKen
Posts: 4
Joined: 19 Dec 2024, 22:10
Location: Gilbert, AZ
Contact:

multiple audio tracks, more than 3 chapters, only english subs

Post by CaptainKen »

Could someone please help me modify the code below to include the following enhancements:

- List in filename not just the 1st, but all English aco audio tracks
- If the file includes more than 3 Chapters add "cp" to end of filename
- Only add "subs" to end of filename (before any above found "cp" qualifier) if it includes English textlanguages subs.

Example filename syntax:
Oppenheimer (2023 Bluray IMAX 1080p x265 DD 5.1 DDP Atmos 5.1 DTS-HD MA 5.1 subs cp)

Code: Select all

{n.replaceTrailingBrackets()} ({y} 
{fn.match(/REMUX/)} {source} {vf} 
{vc.replace(
	'AVC' : 'x264',
	'HEVC' : 'x265'
)} 
{aco.replace(
	'Dolby Digital Plus with Dolby Atmos' : 'DDP Atmos',
	'Dolby Digital Plus' : 'DDP',
	'Dolby Digital' : 'DD',
	'AC3' : 'DD',
	'DTS-HD Master Audio' : 'DTS-HD MA'
)} 
{channels}
{ 'en' in {textlanguages} ? ' subs' :null in {textlanguages} ? ' UNDSUB' : null }{subt})
Best regards.
User avatar
rednoah
The Source
Posts: 23942
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: multiple audio tracks, more than 3 chapters, only english subs

Post by rednoah »

:?: What does the MediaInfo Inspector say for the file at hand?


1.
You can use {audio} to access any audio stream property for all audio streams.


2.
You can use {menu} to access chapter information.


3.
Here's how I'd check if a specific subtitle language is available:

Format: Select all

{ textLanguages =~ /eng/ ? ' [ENGSUB]' : null }
:idea: Please read the FAQ and How to Request Help.
CaptainKen
Posts: 4
Joined: 19 Dec 2024, 22:10
Location: Gilbert, AZ
Contact:

Re: multiple audio tracks, more than 3 chapters, only english subs

Post by CaptainKen »

Thank you rednoah for quick reply and some details.

I only have a file that's already been processed and manually adjusted. IOW I don't have an example file containing audio or sub title tracks that I would normally use MKVToolNix to filter out. Also in my original example I added DTS-HD MA just as an example that some files also have.

My code currently extracts the first english aco audio code, but I don't know how to add multiple audio aco's to the filename?

Also don't know how to check for >3 chapters and then add "cp" if true?

MediaInfo

Code: Select all

[General]
Count                      : 349
StreamCount                : 1
StreamKind                 : General
StreamKind/String          : General
StreamKindID               : 0
UniqueID                   : 154038477547104951052278376963395130929
UniqueID/String            : 154038477547104951052278376963395130929 (0x73E2BB4D630612C4FC4C682DF5819631)
VideoCount                 : 1
AudioCount                 : 2
TextCount                  : 1
MenuCount                  : 1
Video_Format_List          : HEVC
Video_Format_WithHint_List : HEVC
Video_Codec_List           : HEVC
Video_Language_List        : en
Audio_Format_List          : AC-3 / E-AC-3
Audio_Format_WithHint_List : AC-3 / E-AC-3
Audio_Codec_List           : AC-3 / E-AC-3
Audio_Language_List        : en / en
Audio_Channels_Total       : 12
Text_Format_List           : PGS
Text_Format_WithHint_List  : PGS
Text_Codec_List            : PGS
Text_Language_List         : en
Format                     : Matroska
Format/String              : Matroska
Format/Url                 : https://matroska.org/downloads/windows.html
Format/Extensions          : mkv mk3d mka mks
Format_Commercial          : Matroska
Format_Version             : Version 4
FileSize                   : 11335640072
FileSize/String            : 10.6 GiB
FileSize/String1           : 11 GiB
FileSize/String2           : 11 GiB
FileSize/String3           : 10.6 GiB
FileSize/String4           : 10.56 GiB
Duration                   : 10825280
Duration/String            : 3h 0mn
Duration/String1           : 3h 0mn 25s 280ms
Duration/String2           : 3h 0mn
Duration/String3           : 03:00:25.280
Duration/String4           : 03:00:11:08
Duration/String5           : 03:00:25.280 (03:00:11:08)
OverallBitRate             : 8377162
OverallBitRate/String      : 8377 Kbps
FrameRate                  : 23.976
FrameRate/String           : 23.976 fps
FrameCount                 : 259472
StreamSize                 : 3197704
StreamSize/String          : 3.05 MiB (0%)
StreamSize/String1         : 3 MiB
StreamSize/String2         : 3.0 MiB
StreamSize/String3         : 3.05 MiB
StreamSize/String4         : 3.050 MiB
StreamSize/String5         : 3.05 MiB (0%)
StreamSize_Proportion      : 0.00028
IsStreamable               : Yes
Encoded_Date               : 2025-03-12 20:40:59 UTC
Encoded_Application        : mkvmerge v90.0 ('Hanging On') 64-bit
Encoded_Application/String : mkvmerge v90.0 ('Hanging On') 64-bit
Encoded_Library            : libebml v1.4.5 + libmatroska v1.7.1
Encoded_Library/String     : libebml v1.4.5 + libmatroska v1.7.1

[Video]
Count                            : 390
StreamCount                      : 1
StreamKind                       : Video
StreamKind/String                : Video
StreamKindID                     : 0
StreamOrder                      : 0
ID                               : 1
ID/String                        : 1
UniqueID                         : 10847681843967364466
Format                           : HEVC
Format/String                    : HEVC
Format/Info                      : High Efficiency Video Coding
Format/Url                       : http://www.itu.int
Format_Commercial                : HEVC
Format_Profile                   : Main@L4@High
InternetMediaType                : video/H265
CodecID                          : V_MPEGH/ISO/HEVC
Duration                         : 10822145.000000
Duration/String                  : 3h 0mn
Duration/String1                 : 3h 0mn 22s 145ms
Duration/String2                 : 3h 0mn
Duration/String3                 : 03:00:22.145
Duration/String4                 : 03:00:11:08
Duration/String5                 : 03:00:22.145 (03:00:11:08)
BitRate                          : 7037782
BitRate/String                   : 7038 Kbps
Width                            : 1920
Width/String                     : 1920 pixel
Height                           : 1080
Height/String                    : 1080 pixel
Stored_Height                    : 1088
Sampled_Width                    : 1920
Sampled_Height                   : 1080
PixelAspectRatio                 : 1.000
DisplayAspectRatio               : 1.778
DisplayAspectRatio/String        : 16:9
FrameRate_Mode                   : CFR
FrameRate_Mode/String            : CFR
FrameRate                        : 23.976
FrameRate/String                 : 23.976 (24000/1001) fps
FrameRate_Num                    : 24000
FrameRate_Den                    : 1001
FrameCount                       : 259472
ColorSpace                       : YUV
ChromaSubsampling                : 4:2:0
ChromaSubsampling/String         : 4:2:0
BitDepth                         : 8
BitDepth/String                  : 8 bit
Bits-(Pixel*Frame)               : 0.142
Delay                            : 0
Delay/String3                    : 00:00:00.000
Delay/String4                    : 00:00:00:00
Delay/String5                    : 00:00:00.000 (00:00:00:00)
Delay_Source                     : Container
Delay_Source/String              : Container
StreamSize                       : 9520487195
StreamSize/String                : 8.87 GiB (84%)
StreamSize/String1               : 9 GiB
StreamSize/String2               : 8.9 GiB
StreamSize/String3               : 8.87 GiB
StreamSize/String4               : 8.867 GiB
StreamSize/String5               : 8.87 GiB (84%)
StreamSize_Proportion            : 0.83987
Language                         : en
Language/String                  : en
Language/String1                 : en
Language/String2                 : en
Language/String3                 : eng
Language/String4                 : en
Default                          : Yes
Default/String                   : Yes
Forced                           : No
Forced/String                    : No
colour_description_present       : Yes
colour_description_present_Sourc : Container / Stream
colour_range                     : Limited
colour_range_Source              : Container / Stream
colour_primaries                 : BT.709
colour_primaries_Source          : Container / Stream
transfer_characteristics         : BT.709
transfer_characteristics_Source  : Container / Stream
matrix_coefficients              : BT.709
matrix_coefficients_Source       : Container / Stream

[Audio]
Count                      : 301
StreamCount                : 2
StreamKind                 : Audio
StreamKind/String          : Audio
StreamKindID               : 0
StreamKindPos              : 1
StreamOrder                : 1
ID                         : 2
ID/String                  : 2
UniqueID                   : 2626030937765111260
Format                     : AC-3
Format/String              : AC-3
Format/Info                : Audio Coding 3
Format/Url                 : https://en.wikipedia.org/wiki/AC3
Format_Commercial          : Dolby Digital
Format_Commercial_IfAny    : Dolby Digital
Format_Settings_Endianness : Big
CodecID                    : A_AC3
Duration                   : 10822176.000000
Duration/String            : 3h 0mn
Duration/String1           : 3h 0mn 22s 176ms
Duration/String2           : 3h 0mn
Duration/String3           : 03:00:22.176
Duration/String5           : 03:00:22.176
BitRate_Mode               : CBR
BitRate_Mode/String        : CBR
BitRate                    : 640000
BitRate/String             : 640 Kbps
Channel(s)                 : 6
Channel(s)/String          : 6 channel
ChannelPositions           : Front: L C R, Side: L R, LFE
ChannelPositions/String2   : 3/2/0.1
ChannelLayout              : L R C LFE Ls Rs
SamplesPerFrame            : 1536
SamplingRate               : 48000
SamplingRate/String        : 48.0 KHz
SamplingCount              : 519464448
FrameRate                  : 31.250
FrameRate/String           : 31.250 fps (1536 SPF)
FrameCount                 : 338193
Compression_Mode           : Lossy
Compression_Mode/String    : Lossy
Delay                      : 0
Delay/String3              : 00:00:00.000
Delay/String5              : 00:00:00.000
Delay_Source               : Container
Delay_Source/String        : Container
Video_Delay                : 0
Video_Delay/String3        : 00:00:00.000
Video_Delay/String5        : 00:00:00.000
StreamSize                 : 865774080
StreamSize/String          : 826 MiB (8%)
StreamSize/String1         : 826 MiB
StreamSize/String2         : 826 MiB
StreamSize/String3         : 826 MiB
StreamSize/String4         : 825.7 MiB
StreamSize/String5         : 826 MiB (8%)
StreamSize_Proportion      : 0.07638
Title                      : Dolby Digital 5.1
Language                   : en
Language/String            : en
Language/String1           : en
Language/String2           : en
Language/String3           : eng
Language/String4           : en
ServiceKind                : CM
ServiceKind/String         : Complete Main
Default                    : Yes
Default/String             : Yes
Forced                     : No
Forced/String              : No
bsid                       : 8
dialnorm                   : -31 dB
acmod                      : 7
lfeon                      : 1
cmixlev                    : -4.5 dB
surmixlev                  : -6 dB
dialnorm_Average           : -31 dB
dialnorm_Minimum           : -31 dB
dialnorm_Maximum           : -31 dB
dialnorm_Count             : 742

[Audio]
Count                      : 306
StreamCount                : 2
StreamKind                 : Audio
StreamKind/String          : Audio
StreamKindID               : 1
StreamKindPos              : 2
StreamOrder                : 2
ID                         : 3
ID/String                  : 3
UniqueID                   : 4242192811328277948
Format                     : E-AC-3
Format/String              : E-AC-3
Format/Info                : Enhanced AC-3
Format/Url                 : https://en.wikipedia.org/wiki/Dolby_Digital_Plus
Format_Commercial          : Dolby Digital Plus
Format_Commercial_IfAny    : Dolby Digital Plus
Format_Settings_Endianness : Big
InternetMediaType          : audio/eac3
CodecID                    : A_EAC3
Duration                   : 10825280.000000
Duration/String            : 3h 0mn
Duration/String1           : 3h 0mn 25s 280ms
Duration/String2           : 3h 0mn
Duration/String3           : 03:00:25.280
Duration/String5           : 03:00:25.280
BitRate_Mode               : CBR
BitRate_Mode/String        : CBR
BitRate                    : 640000
BitRate/String             : 640 Kbps
Channel(s)                 : 6
Channel(s)/String          : 6 channel
ChannelPositions           : Front: L C R, Side: L R, LFE
ChannelPositions/String2   : 3/2/0.1
ChannelLayout              : L R C LFE Ls Rs
SamplesPerFrame            : 1536
SamplingRate               : 48000
SamplingRate/String        : 48.0 KHz
SamplingCount              : 519613440
FrameRate                  : 31.250
FrameRate/String           : 31.250 fps (1536 SPF)
FrameCount                 : 338290
Compression_Mode           : Lossy
Compression_Mode/String    : Lossy
Delay                      : 0
Delay/String3              : 00:00:00.000
Delay/String5              : 00:00:00.000
Delay_Source               : Container
Delay_Source/String        : Container
Video_Delay                : 0
Video_Delay/String3        : 00:00:00.000
Video_Delay/String5        : 00:00:00.000
StreamSize                 : 866022400
StreamSize/String          : 826 MiB (8%)
StreamSize/String1         : 826 MiB
StreamSize/String2         : 826 MiB
StreamSize/String3         : 826 MiB
StreamSize/String4         : 825.9 MiB
StreamSize/String5         : 826 MiB (8%)
StreamSize_Proportion      : 0.07640
Title                      : Dolby Digital EX 5.1
Language                   : en
Language/String            : en
Language/String1           : en
Language/String2           : en
Language/String3           : eng
Language/String4           : en
ServiceKind                : CM
ServiceKind/String         : Complete Main
Default                    : Yes
Default/String             : Yes
Forced                     : No
Forced/String              : No
bsid                       : 16
dialnorm                   : -25 dB
compr                      : -0.28 dB
acmod                      : 7
lfeon                      : 1
dialnorm_Average           : -25 dB
dialnorm_Minimum           : -25 dB
dialnorm_Maximum           : -25 dB
dialnorm_Count             : 742
compr_Average              : 5.44 dB
compr_Minimum              : 0.53 dB
compr_Maximum              : 6.02 dB
compr_Count                : 740

[Text]
Count                 : 305
StreamCount           : 1
StreamKind            : Text
StreamKind/String     : Text
StreamKindID          : 0
StreamOrder           : 3
ID                    : 4
ID/String             : 4
UniqueID              : 18066139241367934469
Format                : PGS
Format/String         : PGS
Format_Commercial     : PGS
CodecID               : S_HDMV/PGS
CodecID/Info          : Picture based subtitle format used on BDs/HD-DVDs
Duration              : 10392465.000000
Duration/String       : 2h 53mn
Duration/String1      : 2h 53mn 12s 465ms
Duration/String2      : 2h 53mn
Duration/String3      : 02:53:12.465
Duration/String4      : 01:42:53
Duration/String5      : 02:53:12.465 (01:42:53)
BitRate               : 61705
BitRate/String        : 61.7 Kbps
FrameRate             : 0.594
FrameRate/String      : 0.594 fps
FrameCount            : 6172
ElementCount          : 6172
StreamSize            : 80158693
StreamSize/String     : 76.4 MiB (1%)
StreamSize/String1    : 76 MiB
StreamSize/String2    : 76 MiB
StreamSize/String3    : 76.4 MiB
StreamSize/String4    : 76.45 MiB
StreamSize/String5    : 76.4 MiB (1%)
StreamSize_Proportion : 0.00707
Title                 : English SDH
Language              : en
Language/String       : en
Language/String1      : en
Language/String2      : en
Language/String3      : eng
Language/String4      : en
Default               : No
Default/String        : No
Forced                : No
Forced/String         : No

[Menu]
Count              : 121
StreamCount        : 1
StreamKind         : Menu
StreamKind/String  : Menu
StreamKindID       : 0
Chapters_Pos_Begin : 101
Chapters_Pos_End   : 121
00:00:00.000       : Chapter 01
00:07:23.526       : Chapter 02
00:16:36.078       : Chapter 03
00:27:24.017       : Chapter 04
00:36:01.701       : Chapter 05
00:42:51.652       : Chapter 06
00:52:31.607       : Chapter 07
00:59:56.593       : Chapter 08
01:10:53.583       : Chapter 09
01:17:58.215       : Chapter 10
01:24:14.341       : Chapter 11
01:36:07.011       : Chapter 12
01:43:06.931       : Chapter 13
01:51:19.631       : Chapter 14
02:00:18.378       : Chapter 15
02:09:02.193       : Chapter 16
02:17:08.637       : Chapter 17
02:32:05.199       : Chapter 18
02:47:40.759       : Chapter 19
02:54:12.734       : Chapter 20
User avatar
rednoah
The Source
Posts: 23942
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: multiple audio tracks, more than 3 chapters, only english subs

Post by rednoah »

CaptainKen wrote: Today, 03:41 My code currently extracts the first english aco audio code, but I don't know how to add multiple audio aco's to the filename?
{aco} already considers multiple audio streams but will generally only yield one value. There is no {aco} for all audio streams. {aco} is based on audio.Codec_Profile and audio.Format_Profile and audio.Format_Commercial depending on the file at hand.

:idea: audio.Format_Commercial will work for the specific file information posted above:

Format: Select all

{ audio.Format_Commercial }

CaptainKen wrote: Today, 03:41 Also don't know how to check for >3 chapters and then add "cp" if true?
I don't have a test file at hand but based on the file information above this should work:

Format: Select all

{ menu.count{ it =~ /:/ } >= 3 ? ' [3+ CHAPTERS]' : null }
:idea: Please read the FAQ and How to Request Help.
Post Reply