Mediainfo Variable | Retrieving Specific Values

Questions and answers on how to get the most out of FFAStrans
Post Reply
taner
Posts: 204
Joined: Sun Jun 19, 2016 6:36 pm

Mediainfo Variable | Retrieving Specific Values

Post 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
admin
Site Admin
Posts: 1687
Joined: Sat Feb 08, 2014 10:39 pm

Re: Mediainfo Variable | Retrieving Specific Values

Post 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
taner
Posts: 204
Joined: Sun Jun 19, 2016 6:36 pm

Re: Mediainfo Variable | Retrieving Specific Values

Post by taner »

Great!
Many Thanks!
emcodem
Posts: 1811
Joined: Wed Sep 19, 2018 8:11 am

Re: Mediainfo Variable | Retrieving Specific Values

Post 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.
emcodem, wrapping since 2009 you got the rhyme?
taner
Posts: 204
Joined: Sun Jun 19, 2016 6:36 pm

Re: Mediainfo Variable | Retrieving Specific Values

Post by taner »

@emcodem: thanks for the info!
Good to know.
Post Reply