Pruning the contents of video.internetmediatype

Any questions? Need some help?
Post Reply
LostAbove
Posts: 6
Joined: 03 Feb 2024, 13:14

Pruning the contents of video.internetmediatype

Post by LostAbove »

I would like to include the variable video.internetmediatype in my renamed files. The contents of this typically looks like "video/H264" or "video/H265". I want to remove the "video/" text to leave me with "H264" or H265" but I am failing. Unaltered the slash in video.internetmediatype causes obvious problems as FileBot interprets it as part of a file path, but slash aside I can't even remove the "video" text. It also seems to wrap the resultant video.internetmediatype string in square brackets for reasons I can't fathom.

My current match string (obviously this doesn't address the slash or the square brackets but baby steps):

Code: Select all

{ allOf{n.upperInitial().space('.')}{edition}{y}.join('.')}.[{ allOf{ vf }{ vs }{ bitdepth + 'bit' }{ video.internetmediatype.replace('video':'')}{ vcf }{ acf }.join('.') }]
The result is the string is untouched:
Image

The path for the file is:

Code: Select all

Y:\movies\Big.Trouble.in.Little.China.1986.DVDRip.x264-DJ.mkv
Media info for the file concerned:

Code: Select all

[General]
Count                      : 349
StreamCount                : 1
StreamKind                 : General
StreamKind/String          : General
StreamKindID               : 0
UniqueID                   : 179178189814673367012160557334274128728
UniqueID/String            : 179178189814673367012160557334274128728 (0x86CC76D035842E14E128C294AC8E3B58)
VideoCount                 : 1
AudioCount                 : 1
MenuCount                  : 1
Video_Format_List          : AVC
Video_Format_WithHint_List : AVC
Video_Codec_List           : AVC
Video_Language_List        : en
Audio_Format_List          : AAC LC
Audio_Format_WithHint_List : AAC LC
Audio_Codec_List           : AAC LC
Audio_Language_List        : en
Audio_Channels_Total       : 2
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 2
FileSize                   : 822623902
FileSize/String            : 785 MiB
FileSize/String1           : 785 MiB
FileSize/String2           : 785 MiB
FileSize/String3           : 785 MiB
FileSize/String4           : 784.5 MiB
Duration                   : 5743264
Duration/String            : 1h 35mn
Duration/String1           : 1h 35mn 43s 264ms
Duration/String2           : 1h 35mn
Duration/String3           : 01:35:43.264
Duration/String4           : 01:35:43:07
Duration/String5           : 01:35:43.264 (01:35:43:07)
OverallBitRate             : 1145863
OverallBitRate/String      : 1146 Kbps
FrameRate                  : 25.000
FrameRate/String           : 25.000 fps
FrameCount                 : 143582
IsStreamable               : Yes
Encoded_Application        : HandBrake 0.9.9
Encoded_Application/String : HandBrake 0.9.9
Encoded_Library            : libmkv 0.6.5
Encoded_Library/String     : libmkv 0.6.5

[Video]
Count                            : 383
StreamCount                      : 1
StreamKind                       : Video
StreamKind/String                : Video
StreamKindID                     : 0
StreamOrder                      : 0
ID                               : 1
ID/String                        : 1
UniqueID                         : 26274
Format                           : AVC
Format/String                    : AVC
Format/Info                      : Advanced Video Codec
Format/Url                       : http://developers.videolan.org/x264.html
Format_Commercial                : AVC
Format_Profile                   : Main@L4
Format_Settings                  : CABAC / 4 Ref Frames
Format_Settings_CABAC            : Yes
Format_Settings_CABAC/String     : Yes
Format_Settings_RefFrames        : 4
Format_Settings_RefFrames/String : 4 frame
InternetMediaType                : video/H264
CodecID                          : V_MPEG4/ISO/AVC
CodecID/Url                      : http://ffdshow-tryout.sourceforge.net/
Duration                         : 5743280
Duration/String                  : 1h 35mn
Duration/String1                 : 1h 35mn 43s 280ms
Duration/String2                 : 1h 35mn
Duration/String3                 : 01:35:43.280
Duration/String4                 : 01:35:43:07
Duration/String5                 : 01:35:43.280 (01:35:43:07)
Width                            : 704
Width/String                     : 704 pixel
Height                           : 304
Height/String                    : 304 pixel
Sampled_Width                    : 704
Sampled_Height                   : 304
PixelAspectRatio                 : 1.000
DisplayAspectRatio               : 2.316
DisplayAspectRatio/String        : 2.35:1
FrameRate_Mode                   : CFR
FrameRate_Mode/String            : CFR
FrameRate_Mode_Original          : VFR
FrameRate                        : 25.000
FrameRate/String                 : 25.000 fps
FrameRate_Num                    : 25
FrameRate_Den                    : 1
FrameCount                       : 143582
ColorSpace                       : YUV
ChromaSubsampling                : 4:2:0
ChromaSubsampling/String         : 4:2:0
BitDepth                         : 8
BitDepth/String                  : 8 bit
ScanType                         : Progressive
ScanType/String                  : Progressive
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
Encoded_Library                  : x264 - core 130 r2273 b3065e6
Encoded_Library/String           : x264 core 130 r2273 b3065e6
Encoded_Library_Name             : x264
Encoded_Library_Version          : core 130 r2273 b3065e6
Encoded_Library_Settings         : cabac=1 / ref=1 / deblock=1:0:0 / analyse=0x1:0x111 / me=hex / subme=2 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=0 / me_range=16 / chroma_me=1 / trellis=0 / 8x8dct=0 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=0 / threads=6 / lookahead_threads=2 / sliced_threads=0 / nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=1 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=10 / rc=crf / mbtree=1 / crf=20.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / vbv_maxrate=20000 / vbv_bufsize=25000 / crf_max=0.0 / nal_hrd=none / ip_ratio=1.40 / aq=1:1.00
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 : Stream
colour_range                     : Limited
colour_range_Source              : Stream
colour_primaries                 : BT.601 PAL
colour_primaries_Source          : Stream
transfer_characteristics         : BT.709
transfer_characteristics_Source  : Stream
matrix_coefficients              : BT.601
matrix_coefficients_Source       : Stream
FrameCount_Source                : General_Duration
Duration_Source                  : General_Duration

[Audio]
Count                     : 287
StreamCount               : 1
StreamKind                : Audio
StreamKind/String         : Audio
StreamKindID              : 0
StreamOrder               : 1
ID                        : 2
ID/String                 : 2
UniqueID                  : 30444
Format                    : AAC
Format/String             : AAC LC
Format/Info               : Advanced Audio Codec Low Complexity
Format_Commercial         : AAC
Format_AdditionalFeatures : LC
CodecID                   : A_AAC-2
Duration                  : 5743264
Duration/String           : 1h 35mn
Duration/String1          : 1h 35mn 43s 264ms
Duration/String2          : 1h 35mn
Duration/String3          : 01:35:43.264
Duration/String5          : 01:35:43.264
Channel(s)                : 2
Channel(s)/String         : 2 channel
ChannelPositions          : Front: L R
ChannelPositions/String2  : 2/0/0
ChannelLayout             : L R
SamplesPerFrame           : 1024
SamplingRate              : 48000
SamplingRate/String       : 48.0 KHz
SamplingCount             : 275676672
FrameRate                 : 46.875
FrameRate/String          : 46.875 fps (1024 SPF)
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
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
SamplingCount_Source      : General_Duration
Duration_Source           : General_Duration

[Menu]
Count              : 145
StreamCount        : 1
StreamKind         : Menu
StreamKind/String  : Menu
StreamKindID       : 0
Chapters_Pos_Begin : 101
Chapters_Pos_End   : 145
00:00:00.000       : Chapter 1
00:02:26.336       : Chapter 2
00:06:01.976       : Chapter 3
00:08:13.216       : Chapter 4
00:09:31.216       : Chapter 5
00:12:12.456       : Chapter 6
00:13:24.056       : Chapter 7
00:14:38.736       : Chapter 8
00:17:11.456       : Chapter 9
00:19:28.176       : Chapter 10
00:23:29.256       : Chapter 11
00:26:56.856       : Chapter 12
00:29:44.016       : Chapter 13
00:31:24.096       : Chapter 14
00:33:22.496       : Chapter 15
00:34:34.336       : Chapter 16
00:35:15.896       : Chapter 17
00:36:08.616       : Chapter 18
00:36:55.976       : Chapter 19
00:38:33.576       : Chapter 20
00:42:29.816       : Chapter 21
00:44:17.176       : Chapter 22
00:47:33.376       : Chapter 23
00:49:35.216       : Chapter 24
00:54:19.136       : Chapter 25
00:57:27.896       : Chapter 26
00:59:13.176       : Chapter 27
01:00:22.456       : Chapter 28
01:01:51.104       : Chapter 29
01:03:25.184       : Chapter 30
01:06:46.264       : Chapter 31
01:08:05.384       : Chapter 32
01:09:55.624       : Chapter 33
01:12:42.864       : Chapter 34
01:13:12.944       : Chapter 35
01:14:49.504       : Chapter 36
01:22:21.544       : Chapter 37
01:23:39.984       : Chapter 38
01:24:28.584       : Chapter 39
01:25:37.504       : Chapter 40
01:27:31.104       : Chapter 41
01:29:10.864       : Chapter 42
01:31:31.744       : Chapter 43
01:32:13.744       : Chapter 44

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

Re: Pruning the contents of video.internetmediatype

Post by rednoah »

:?: Why not use {vc} video codec or {vcf} video compression format though?



:idea: As for getting the H264 bit from video/H264 from the first video stream, that would look like this:

Properties: Select all

InternetMediaType : video/H264

Format: Select all

{ video[0].InternetMediaType.split('/')[-1] }
:idea: Please read the FAQ and How to Request Help.
LostAbove
Posts: 6
Joined: 03 Feb 2024, 13:14

Re: Pruning the contents of video.internetmediatype

Post by LostAbove »

Many thanks for the help with InternetMediaType. Can I ask what flavor of Regex does FileBot use ? (So I can read up)

As for why not use {vc} or {vcf}. I have a few files where 265 or 264 is mentioned in the file name, but {vc}.{vcf} just produce HVEC.HVEC or AVC.AVC. InternetMediaType seemed to be the only variable to preserve this.
User avatar
rednoah
The Source
Posts: 23002
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Pruning the contents of video.internetmediatype

Post by rednoah »

AVC is h264. HVEC is h265. These terms are interchangeable. But in any case, if your code produces the values you want to see, then all is good.


FileBot uses the java.util.regex.Pattern regex engine. That said, you generally don't need to worry about flavours or regex, it'll all the same for the typical use cases. I recommend RegExr for testing and prototyping.



EDIT:

:?: Note that no regex has been used / relevant in this thread so far, so asking about regex flavours seems a perplexing and off-topic when I think about it. Did you have anything specific in mind? Another unrelated use case perhaps?
:idea: Please read the FAQ and How to Request Help.
LostAbove
Posts: 6
Joined: 03 Feb 2024, 13:14

Re: Pruning the contents of video.internetmediatype

Post by LostAbove »

Fair comment on the Regex, it was a parallel question I had after reading a few other posts here.

That said, where is the .split() function documented ? and the list of other available functions ? All I have found so far are here https://www.filebot.net/naming.html and what pressing F1 in the app gives you.

Finally and back on topic, if the MediaInfo doesn't contain the actual codec implimentation used (x264 etc.) and only the existing file name makes mention of this, is there anyway to include this in the new filename ?
User avatar
rednoah
The Source
Posts: 23002
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Pruning the contents of video.internetmediatype

Post by rednoah »

:idea: String.split() is Java API. Please read FileBot Groovy Expression Reference Documentation for details.


:idea: You can match information from the file path or file name:

Format: Select all

{ '.' + fn.match(/x264/) }

:idea: AFAIK, files encoded with x264 typically do have the Encoded_Library_Name property set. That's what we use in the {vc} binding to yield x264 instead of generic AVC.
:idea: Please read the FAQ and How to Request Help.
LostAbove
Posts: 6
Joined: 03 Feb 2024, 13:14

Re: Pruning the contents of video.internetmediatype

Post by LostAbove »

rednoah wrote: 07 Feb 2024, 19:45 :idea: AFAIK, files encoded with x264 typically do have the Encoded_Library_Name property set. That's what we use in the {vc} binding to yield x264 instead of generic AVC.
Typically I have quite a few where this isn't the case and the only reference to the implimentation used is in the file name. Still i'm in a much better place to handle all of this than I was at the start of this thread.

I know this is a rather talanted bit of software but I feel this might be stretching it, is there a way to go from matching a string in the filename (x264 / x265) to filling the Encoded_Library_Name property ? A two pass approach could then be:

1) Move any ref to x264/x265 in filename to Encoded_Library_Name property, (optionaly only if empty).
2) Rename using {vc}
User avatar
rednoah
The Source
Posts: 23002
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Pruning the contents of video.internetmediatype

Post by rednoah »

e.g. match x264 from the file name if possible, or use vc otherwise:

Format: Select all

{ any{ fn.match(/x264|x265/) }{ vc } }
See Learn how {expressions} work and useful Helper Functions for details.
:idea: Please read the FAQ and How to Request Help.
LostAbove
Posts: 6
Joined: 03 Feb 2024, 13:14

Re: Pruning the contents of video.internetmediatype

Post by LostAbove »

OK, but I can't correct the empty Encoded_Library_Name property ?
User avatar
rednoah
The Source
Posts: 23002
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Pruning the contents of video.internetmediatype

Post by rednoah »

LostAbove wrote: 07 Feb 2024, 20:46 OK, but I can't correct the empty Encoded_Library_Name property ?
FileBot does not write / modify files. MediaInfo properties are generally read-only, and you can only "set" them by re-writing / re-muxing / re-encoding the file at hand into a new file.
:idea: Please read the FAQ and How to Request Help.
LostAbove
Posts: 6
Joined: 03 Feb 2024, 13:14

Re: Pruning the contents of video.internetmediatype

Post by LostAbove »

Got you, I think that's all avenues explored. I will thank you for your help and awesome software, it's clear from the short time I have used FileBot that they are both of high quality.
Post Reply