4

I am using a modified version of the GetMetaData script originally written by Ed Wilson at Microsoft (https://devblogs.microsoft.com/scripting/hey-scripting-guy-how-can-i-find-files-metadata/) and then modified by user wOxxOm here https://stackoverflow.com/a/42933461/5061596 . I'm trying to analyze all my DVD and BluRay rips and see what tool was used to create them. Mainly I want to check which ones I compressed with Handbrake and which ones came directly from MakeMKV. The problem is I can't find this field.

If I use the "stock" scrip and change the number of properties it looks for from 0 - 266 up to 0 - 330 I find the extra file info like movie length, resolution, etc. But I can't find the tool used. For example here is what the MediaInfo Lite tool reports:

MediaInfo Lite Example

But looking through the meta data I get something like this with no "Writing application" property:

Name              : Ad Astra (2019).mkv
Size              : 44.1 GB
Title             : Ad Astra
Length            : 02:03:02
Frame height      : 2160
Frame rate        : ‎23.98 frames/second
Frame width       : 3840
Total bitrate     : ‎51415kbps
Audio tracks      : TrueHD S24 7.1 [Eng]
Contains chapters : Yes
Subtitle tracks   : PGS [Eng], PGS [Eng]
Video tracks      : HEVC (H265 Main 10 @L5.1)

How do I go about finding that property or is it not something that I can pull through PowerShell?

Edit: The info I'm looking for IS in Windows Explorer looking at the properties of the file and the details tab so if Explorer can see it I would think I should be able to:

enter image description here

ADY
  • 101
  • 1
  • 9
  • from what i can tell, the metadata that windows shows is ONLY what the "plugin" knows about. if you install an app that has such an explorer addon, it allows windows to grab that metadata ... but it only shows what that "enabler" has exposed. you may need to use a 3rd party util to grab the info. – Lee_Dailey Apr 02 '22 at 21:54
  • MediaInfo Lite does have a CLI that I'm sure can get the data since the GUI does but I was really hoping I could grab it without using a third party program. – ADY Apr 02 '22 at 22:10
  • unfortunately, i think you are stuck with using an external util. PoSh can call it and catch the info to use ... especially if you can get the output as in CSV or JSON format. – Lee_Dailey Apr 02 '22 at 22:45
  • So I just checked the standard file "properties" from Windows Explorer and it does show that field as "Tool name". So maybe there is a chance. – ADY Apr 02 '22 at 23:28
  • ah! then you really otta be able to get that info. have you tried upping the maximum id? you mentioned `330` ... so perhaps bump it up to 500? – Lee_Dailey Apr 03 '22 at 03:25
  • Yeah, 400, 500, 1000. No difference in the output. But I'll keep playing with it. – ADY Apr 03 '22 at 11:23
  • 1
    arg! i am out of ideas ... i will go back to lurking. i wish you the best of good luck! [*grin*] – Lee_Dailey Apr 03 '22 at 15:11
  • Could that info perhaps bee in an [Alternate Data Stream](https://davidhamann.de/2019/02/23/hidden-in-plain-sight-alternate-data-streams/) – Theo Apr 04 '22 at 12:28
  • No, I checked and there was no ADS but another user figured it out. – ADY Apr 05 '22 at 13:42

1 Answers1

2

edit: actually, this seems more reliable. So far any file that mediainfo can read, this also works with.

$FILE = "C:\test.mkv"
$content = (Get-Content -Path $FILE -First 100) + (Get-Content -Path $FILE -Tail 100)
if(($content -match '\*data')[0] -match '\*data\W*([\w\n\s\.]*)'){
    write-host "Writing Application:" $Matches[1]
    exit
}elseif(($content -match 'M€.*WA(.*)s¤')[0] -match 'M€.*WA(.*)s¤'){
    write-host "Writing Application:" $Matches[1]
}

It looks like the last bytes in the file after *data that specify the writer, so try this:

(Get-Content -Path "c:\video.mkv" -Tail 1) -match '\*data\W*(.*)$' | out-null
write-host "Writing Application:" $Matches[1]

On my test file that resulted in "HandBrake 1.5.1 2022011000"

I'm not sure what standard specifies this sorry. There's also a host of useful info on the first line of data in the file as well, e.g:

ftypmp42 mp42iso2avc1mp41 free6dÊmdat ôÿÿðÜE齿ÙH·–,Ø Ù#îïx264 - core 164 r3065 ae03d92 - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: 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 deadz one=21,11 fast_pskip=1 chroma_qp_offset=0 threads=18 lookahead_threads=5 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=23.0 qcomp=0.60 qpmin =0 qpmax=69 qpstep=4 vbv_maxrate=14000 vbv_bufsize=14000 crf_max=0.0 nal_hrd=none filler=0 ip_ratio=1.40 aq=1:1.00

I couldn't replicate your success viewing the info with Windows Explorer, the field is invisible for me even though I can view it with MediaInfo etc

Mike Anthony
  • 429
  • 3
  • 9
  • Thank-you for the code, it seems to be working on the couple MKV files I've tested it on and I'm sure I wouldn't have gotten that search expression down, I would have taken the entire string and did a awful mid or search command so I appreciate it. Now to download some sample MP4 and other media and see if the data section is the same. And also to look at more of it to see what else is in there. – ADY Apr 05 '22 at 13:38
  • 3
    As for Windows Explorer the "Tool Name" showed up on two machines that I had K-Lite Codec Pack & MediaInfo installed on but did NOT show on a fresh Windows 10 install. So out of curiosity I installed the K-Lite Codec "basic" pack without Media Info and the tool name did show up. Explorer must be taking advantage of one of the codecs that gets installed somehow. Before codec install: https://imgur.com/PU77XY6 After codec install: https://imgur.com/Mb1GtCw Sample file used: https://filesamples.com/formats/mkv Kinda neat. – ADY Apr 05 '22 at 13:41