Page 1 of 2

Video AND Photo resolution column

Posted: 26 Sep 2020 10:26
by TMProjection
Hey all, just wondering, is it possible to make a custom column that shows both the video and photo resolution?

It would be good to combine the code below with something for images, but i cannot seem to find a script for calling image resolutions

$mediaInfo = "C:\Program Files\MediaInfo_CLI_20.08_Windows_x64\MediaInfo.exe";
return regexreplace(runret("$mediaInfo --Inform=Video;%Width%x%Height% ""<cc_item>"""), "\r?\n");

Re: Video AND Photo resolution column

Posted: 26 Sep 2020 11:00
by highend
Create a file like inform.txt somewhere and fill it with

Code: Select all

Video;%Width%x%Height%
Image;%Width%x%Height%
and call it e.g. with --Inform="file://d:/inform.txt" on your <cc_item>

Re: Video AND Photo resolution column

Posted: 26 Sep 2020 11:04
by TMProjection
little bit confused, is

--Inform="file://d:/inform.txt" on your <cc_item>

a script for the custom column?

i would like a column that displays hundreds of resolutions etc, just all in one column

Re: Video AND Photo resolution column

Posted: 26 Sep 2020 11:08
by highend
Sure it is

Replace your --Inform=Video;%Width%x%Height%
with --Inform=""file://d:/inform.txt"" (or wherever you've created that file)
in your cc script

Re: Video AND Photo resolution column

Posted: 26 Sep 2020 12:08
by TMProjection
So for example:

$mediaInfo = "C:\Program Files\MediaInfo_CLI_20.08_Windows_x64\MediaInfo.exe";
return regexreplace(runret("$mediaInfo --Inform="file://C:/Program Files/MediaInfo_CLI_20.08_Windows_x64/New Text File.txt" ""<cc_item>"""), "\r?\n");

this returns:

runexreplace(runret("C:\Program Files\MediaInfo_CLI_20.08_Windows_x64\MediaInfo.exe --Inform="file:

im pretty sure im doing what you suggested, or did i make a mistake?

also do you think calling that file would result in slow downs?

Re: Video AND Photo resolution column

Posted: 26 Sep 2020 12:52
by highend
You need two quotation marks around it (in the same way as with ""<cc_item>"") and that file is in the file cache so it shouldn't cause any slowdowns

Re: Video AND Photo resolution column

Posted: 26 Sep 2020 14:03
by TMProjection
thats awesome mate, thank you, just donated a little :)

got a few more questions

say i have this script:

Audio Codec
$mediaInfo = "C:\Program Files\MediaInfo_CLI_20.08_Windows_x64\MediaInfo.exe";
return regexreplace(runret("$mediaInfo --Inform=Audio;%Format% ""<cc_item>"""), "\r?\n");

To output: AACAAC

but i also want to display number of streams

Audio Streams
$mediaInfo = "C:\Program Files\MediaInfo_CLI_20.08_Windows_x64\MediaInfo.exe";
return regexreplace(runret("$mediaInfo --Inform=General;%AudioCount% ""<cc_item>"""), "\r?\n");

anyway to combine it so it displays something like AAC x 2
Also i cant figure out how to output spaces

Re: Video AND Photo resolution column

Posted: 26 Sep 2020 14:47
by highend
E.g.:

Code: Select all

$mediaInfo = "C:\Program Files\MediaInfo_CLI_20.08_Windows_x64\MediaInfo.exe";
    $result = trim(runret("""$mediaInfo"" --Inform=""file://C:/Program Files/MediaInfo_CLI_20.08_Windows_x64/stream_format.txt"" ""<cc_item>"""), <crlf>);
    return regexreplace($result, "(^\d+?)([a-z].+)$", "$2 x $1");
with stream_format.txt content of:

Code: Select all

Audio;%Format%
General;%AudioCount%

Re: Video AND Photo resolution column

Posted: 26 Sep 2020 16:58
by klownboy
You may want to also look into using a "mixed" column type where you would use Special Property Dimensions or whatever for your images file types and use your MediaInfo for your video. You make a new mixed type column, name it and select the 2 column types one for Image dimensions and one for Video dimension using your existing Video size script. You shouldn't need to use MediaInfo for image files (i.e., there are plenty of XY built-in Special Properties and Windows canonical properties to use). From the help file...it's worth looking into even if you don't use it for this.
· Mixed: The column is defined as a set of other Custom Columns. If those other Custom Columns have non-overlapping Filters defined you can make a context-sensitive column this way which will display data in dependence of the file type. You could e.g. show pixel dimensions for images, play time for audio files, page count for documents, and the version number for executables -- all in ONE column! Details see Mixed Columns below.

Re: Video AND Photo resolution column

Posted: 27 Sep 2020 12:53
by TMProjection
highend wrote: ↑26 Sep 2020 14:47 E.g.:

Code: Select all

$mediaInfo = "C:\Program Files\MediaInfo_CLI_20.08_Windows_x64\MediaInfo.exe";
    $result = trim(runret("""$mediaInfo"" --Inform=""file://C:/Program Files/MediaInfo_CLI_20.08_Windows_x64/stream_format.txt"" ""<cc_item>"""), <crlf>);
    return regexreplace($result, "(^\d+?)([a-z].+)$", "$2 x $1");
with stream_format.txt content of:

Code: Select all

Audio;%Format%
General;%AudioCount%


Thank you so much for the help btw, ill donate some more if you can help me with this:

Is there anyway to make it show
AAC x 2, instead of AACAAC x 2?

And say i also wanted to include video codec, and any subtitles if a file has any, i understand how you would include these parameters in the .txt file but im a bit confused in this line:
return regexreplace($result, "(^\d+?)([a-z].+)$", "$2 x $1");

i dont really understand what all the codes represent
so say i have a file with 1 video stream, 2 audio, 3 subtitles
HEVCx265, AAC x 2, PGS x 2
for example

this is the current code i use for my video:
$mediaInfo = "C:\Program Files\MediaInfo_CLI_20.08_Windows_x64\MediaInfo.exe";
return regexreplace(runret("$mediaInfo --Inform=Video;%Format%%Encoded_Library_Name% ""<cc_item>"""), "\r?\n");

Re: Video AND Photo resolution column

Posted: 27 Sep 2020 12:56
by TMProjection
klownboy wrote: ↑26 Sep 2020 16:58 You may want to also look into using a "mixed" column type where you would use Special Property Dimensions or whatever for your images file types and use your MediaInfo for your video. You make a new mixed type column, name it and select the 2 column types one for Image dimensions and one for Video dimension using your existing Video size script. You shouldn't need to use MediaInfo for image files (i.e., there are plenty of XY built-in Special Properties and Windows canonical properties to use). From the help file...it's worth looking into even if you don't use it for this.
· Mixed: The column is defined as a set of other Custom Columns. If those other Custom Columns have non-overlapping Filters defined you can make a context-sensitive column this way which will display data in dependence of the file type. You could e.g. show pixel dimensions for images, play time for audio files, page count for documents, and the version number for executables -- all in ONE column! Details see Mixed Columns below.
Thanks for that, what i have noticed is there is quiet a drastic slow down with MediaInfo columns, so i setup shortcuts to change column layouts for when i need fast browsing to informed video column browsing for example

Would you using a mixed column would speed up browsing?

Re: Video AND Photo resolution column

Posted: 27 Sep 2020 15:59
by highend
The fastest way is to decide in the script if image of video properties are needed (by file extension) and only use mediainfo for video and the property() script command for images for all properties.
AAC x 2, instead of AACAAC x 2?
By using a simple replace() script command
And say i also wanted to include video codec, and any subtitles if a file has any, i understand how you would include these parameters in the .txt file but im a bit confused in this line:
return regexreplace($result, "(^\d+?)([a-z].+)$", "$2 x $1");
That was necessary because format and count were unseparated and needed a different order. By using \r\n at the end of each line in the .txt file you could use gettoken() to get the necessary parts instead

Re: Video AND Photo resolution column

Posted: 28 Sep 2020 15:57
by highend
E.g.:

Code: Select all

    if (strpos(get("genericfiletype", "{:Image}"), "*.<cc_ext>") != -1) {
        return property("#image.dimensions", <cc_item>);

    // Video(s)
    } elseif (strpos(get("genericfiletype", "{:Video}"), "*.<cc_ext>") != -1) {
        $mediaInfo   = "C:\Program Files\MediaInfo_CLI_20.08_Windows_x64\MediaInfo.exe";
        $result      = trim(runret("""$mediaInfo"" --Inform=""file://C:/Program Files/MediaInfo_CLI_20.08_Windows_x64/stream_format.txt"" ""<cc_item>""", , 65001), <crlf>, "R");
        $general     = gettoken($result, 1, <crlf>);
        $video       = gettoken($result, 2, <crlf>);
        $audio       = gettoken($result, 3, <crlf>);
        $vDimensions = gettoken($video, 1, ":");
        $vFormat     = gettoken($video, 2, ":");

        $output      = "$vDimensions, $vFormat, $audio x $general";
        $output      = replace($output, "AACAAC", "AAC");
        return $output;
    }
with this content for the stream_format.txt file:

Code: Select all

General;%AudioCount%\r\n
Video;%Width%x%Height%:%Format%%Encoded_Library_Name%\r\n
Audio;%Format%\r\n

Re: Video AND Photo resolution column

Posted: 29 Sep 2020 02:50
by jupe
I haven't tested your script, but to me it looks like it will give a false count of the audio tracks, if for example you have a file with a AAC, AC3, DTS tracks, currently it would be listed as AAC x 3 I think, another thing is that if you had say 3+ AAC tracks in a row the AACAAC replacement would fail to produce the desired return I assume, also if the same codecs weren't adjacent you would have multiple listings.

Also if you decide to change it, subtitles are excluded currently, but were requested, although you may be leaving it up to the OP to add that part themselves.

Re: Video AND Photo resolution column

Posted: 29 Sep 2020 07:44
by highend
but to me it looks like it will give a false count of the audio tracks, if for example you have a file with a AAC, AC3, DTS tracks, currently it would be listed as AAC x 3 I think, another thing is that if you had say 3+ AAC tracks in a row the AACAAC replacement would fail to produce the desired return I assume
Quite possible. But I neither have such video files to test and not the time to mux them (apart from the multitude of possible combinations).
subtitles are excluded currently, but were requested, although you may be leaving it up to the OP to add that part themselves.
That's the intention, because he said:
And say i also wanted to include video codec, and any subtitles if a file has any, i understand how you would include these parameters in the .txt file
I just wanted to show how my comments from the previous post can be implemented scripting wise...