Column MediaInfo

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
DarKHawK
Posts: 17
Joined: 25 Nov 2012 04:55

Column MediaInfo

Post by DarKHawK »

Hi,

I have a lot of video files that may contain slop data.
I need to create a column that subtracts video stream size and audio stream size from total file size.
Tried Ai and it failed miserably.

Thank you.

highend
Posts: 14923
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: Column MediaInfo

Post by highend »

Code: Select all

    $filePath = <cc_item>;
    $fileSize = filesize($filePath);

    $mediaInfo = "<xydrive>\Tools\@CLI Tools\MediaInfo\MediaInfo.exe";
    $result    = runret("""$mediaInfo"" --Inform=file://D:\all_streams.txt ""$filePath""");

    $sizeTotal = 0;
    foreach($line, $result, <crlf>, "e") {
        $size = gettoken($line, 2, ":", "t");
        if ($size) { $sizeTotal += $size; }
    }
    if ($sizeTotal) { return formatbytes($fileSize - $sizeTotal); }
    return "---";
While D:\all_streams.txt contains:

Code: Select all

Video;Video:%StreamSize%\r\n
Audio;Audio:%StreamSize%\r\n
One of my scripts helped you out? Please donate via Paypal

DarKHawK
Posts: 17
Joined: 25 Nov 2012 04:55

Re: Column MediaInfo

Post by DarKHawK »

Thanks for the reply.

It returns ---

If I run \MediaInfo.exe" --Inform=file://D:\all_streams.txt "filename.mp4"
It returns:
Video:739649416
Audio:22230207

Edit:

Sorry, my bad, some files have "Source stream size" instead of "Stream size"

Thanks a lot

Post Reply