Page 1 of 1

Mediainfo Variable | Retrieving Specific Values

Posted: Sat Mar 20, 2021 10:16 am
by taner
Hi Admin-Team,

I'm trying to grab specific values of the "%s_info_mediainfo%"-output.
But I'm not sure how to populate.
Specifically: which command would be necessary to get for example the value of "format_commercial" within the video-section of the json-output?
$jsonget('%s_info_mediainfo%', '[???].format_commercial').

If possible it would be great if someone could help me.
I would prefer to avoid using mediainfo in command executor to get the values because having already a built-in-option would simplify these specific workflows where I need it.

Taner

Re: Mediainfo Variable | Retrieving Specific Values

Posted: Sat Mar 20, 2021 3:43 pm
by admin
Hi taner,

Yes I think this is doable but because we don't know what index the video has we need to pull some regex magic on the media info string.
So, create some variable like %s_my_variable% and the "Populate" node to set:

Line 1 -> %s_my_variable% to $regext("%s_info_mediainfo%", '(?s)"@type"\s*:\s*"Video".+"Format_Commercial"\s*:\s*"\w+"')
Line 2 -> %s_my_variable% to $jsonget("{%s_my_variable%}", "Format_Commercial")

This should give you what you're after.

-steinar

Re: Mediainfo Variable | Retrieving Specific Values

Posted: Sun Mar 21, 2021 12:23 pm
by taner
Great!
Many Thanks!

Re: Mediainfo Variable | Retrieving Specific Values

Posted: Sun Mar 21, 2021 9:03 pm
by emcodem
@taner
just on a sidenote, because i had a case reported just last week:
Please be aware that the mediainfo output for format_commercial is a "guess" from mediainfo, so in difference to e.g. some video height or such, it is not a value that comes from the media file but it was calculated by mediainfo.
So the value you face might be inaccurate in some cases, e.g. here some snipped from mediainfo source code for XDCAMHD:

Code: Select all

        else if (Retrieve(Stream_Video, 0, Video_Format)==__T("MPEG Video") && 
        			!Retrieve(Stream_Video, 0, Video_Format_Settings_GOP).empty() && 
        			Retrieve(Stream_Video, 0, Video_Format_Settings_GOP)!=__T("N=1") && 
        			Retrieve(Stream_Video, 0, Video_Colorimetry)==__T("4:2:2") && 
        			(Retrieve(Stream_Video, 0, Video_BitRate)==__T("50000000") 
        			|| Retrieve(Stream_Video, 0, Video_BitRate_Nominal)==__T("50000000") 
        			|| Retrieve(Stream_Video, 0, Video_BitRate_Maximum)==__T("50000000")))
        {
            Fill(Stream_General, 0, General_Format_Commercial_IfAny, "XDCAM HD422");
            Fill(Stream_Video, 0, Video_Format_Commercial_IfAny, "XDCAM HD422");
        }
The above check is very rough, e.g. RDD9 defines the GOP must be (N<=12, M<=3) but above only checks if N=1. Besides i am not sure if the Bitrate checks will always be fine after some XDCAM has been edited. Still the file would be really xdcam compatible but mediainfo would report that its not.

All that just means, you should be aware that the data you are checking for is a calculated value which is not guaranteed to be 100% correct.

Re: Mediainfo Variable | Retrieving Specific Values

Posted: Wed Mar 24, 2021 6:48 pm
by taner
@emcodem: thanks for the info!
Good to know.