Custom Column: Media Integrity Check with ffmpeg

Discuss and share scripts and script files...
Post Reply
python80
Posts: 16
Joined: 08 Jul 2022 05:49

Custom Column: Media Integrity Check with ffmpeg

Post by python80 »

We can see media errors in a log file with ffmpeg.

My video file: file.mp4

Code: Select all

ffmpeg -v error -i file.mp4 -f null - 2>error.log
How can I see error.log in a custom column?
Also I don't want to see lines which includes "Application provided invalid, non monotonically increasing dts to muxer in stream 0:".
Can we delete them with regular expressions?

Maybe like this:

Code: Select all

"^.*Application provided invalid, non monotonically increasing dts to muxer in stream 0.*$"

Code: Select all

(?-is)^(?=.*Application provided invalid, non monotonically increasing dts to muxer in stream 0).+\R
Is it possible?

Thanks for reading, sorry for bad English.

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

Re: Custom Column: Media Integrity Check with ffmpeg

Post by highend »

Possible? Sure

But running ffmpeg over every file will be slow...

Apart from that:
runret()
regexreplace()
One of my scripts helped you out? Please donate via Paypal

python80
Posts: 16
Joined: 08 Jul 2022 05:49

Re: Custom Column: Media Integrity Check with ffmpeg

Post by python80 »

highend wrote: 13 Oct 2023 23:56 Possible? Sure

But running ffmpeg over every file will be slow...
Yes, I know it. ffmpeg will check media completely.
highend wrote: 13 Oct 2023 23:56 Apart from that:
runret()
regexreplace()
I can't do it. :(
How should the script be?

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

Re: Custom Column: Media Integrity Check with ffmpeg

Post by highend »

Provide a .mp4 file (upload it on google drive, dropbox...) with errors and post the link
One of my scripts helped you out? Please donate via Paypal

python80
Posts: 16
Joined: 08 Jul 2022 05:49

Re: Custom Column: Media Integrity Check with ffmpeg

Post by python80 »

highend wrote: 14 Oct 2023 00:13 Provide a .mp4 file (upload it on google drive, dropbox...) with errors and post the link
https://drive.google.com/file/d/1c5TqlW ... sp=sharing

Code: Select all

X:\ffmpeg\x64>ffmpeg -v error -i "X:\S01EP01_Corrupt.mp4" -f null - 2>error.log
error.log:

Code: Select all

[h264 @ 000001d746536080] illegal short term buffer state detected
[h264 @ 000001d746545840] illegal short term buffer state detected
[h264 @ 000001d746545840] co located POCs unavailable
[h264 @ 000001d7465477c0] mmco: unref short failure
[null @ 000001d746a10540] Application provided invalid, non monotonically increasing dts to muxer in stream 0: 600 >= 600
[h264 @ 000001d746535780] reference picture missing during reorder
[h264 @ 000001d746535780] Missing reference picture, default is 65674
[h264 @ 000001d746535c00] reference picture missing during reorder
[h264 @ 000001d746535c00] Missing reference picture, default is 65696
[h264 @ 000001d746536080] reference picture missing during reorder
[h264 @ 000001d746536080] Missing reference picture, default is 65698

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

Re: Custom Column: Media Integrity Check with ffmpeg

Post by highend »

Adapt the path to ffmpeg and the folder where the logs should be stored

Code: Select all

$ffmpeg    = "D:\Tools\@Command Line Tools\yt-dlp\ffmpeg\bin\ffmpeg.exe";
    $logPath   = "D:\Temp";
    $base      = gpc(<cc_item>, "base");
    $logFile   = trim($logPath, "\", "R") . "\" . $base . ".log";
    $batchFile = "%TEMP%\~xy_ffmpeg.bat";

    $batchContent = lax("$ffmpeg" -v error -i "<cc_item>" -f null - 2>"$logFile");
    writefile($batchFile, $batchContent, , "utf8");
    run "$batchFile", "%TEMP%", 2, 0;

    $content = "";
    if (exists($logFile) == 1) {
        $content = readfile($logFile, , , 65001);
        $content = regexreplace($content, "^.*?Application provided invalid, non monotonically increasing dts to muxer in stream.*?(\r?\n|$)");
    }
    return $content;
I would set the trigger to "Click" for the definition of the custom column but ofc it's your choice...
Item filter should be set to only video file types you'd like to check
2023-10-14_080910.png
2023-10-14_080910.png (28.39 KiB) Viewed 3818 times
One of my scripts helped you out? Please donate via Paypal

Native2904
Posts: 47
Joined: 23 Apr 2025 18:48
Location: Aachen

Re: Custom Column: Media Integrity Check with ffmpeg

Post by Native2904 »

@Highend
Hello, I discovered this script and wanted to give it a try... to check films before uploading them to the NAS and avoid any nasty surprises.

Even though the script wasn't for me, could you have a look and see if you can find any errors?
I don't really trust ChatGPT when it comes to XY and its scripts.

Code: Select all

[in#0] Error opening input: Invalid argument
Error opening input file .
Error opening input files: Invalid argument
XYplorer_VcMJsJrMey.jpg
XYplorer_VcMJsJrMey.jpg (125.51 KiB) Viewed 1922 times
This is the adjusted script:

Code: Select all

$ffmpeg    = "c:\Youtube\ffmpeg.exe";
    $logPath   = "c:\Youtube\Log\";
    $base      = gpc(<cc_item>, "base");
    $logFile   = trim($logPath, "\", "R") . "\" . $base . ".log";
    $batchFile = "%TEMP%\~xy_ffmpeg.bat";

    $batchContent = lax("$ffmpeg" -v error -i "<cc_item>" -f null - 2>"$logFile");
    writefile($batchFile, $batchContent, , "utf8");
    run "$batchFile", "%TEMP%", 2, 0;

    $content = "";
    if (exists($logFile) == 1) {
        $content = readfile($logFile, , , 65001);
        $content = regexreplace($content, "^.*?Application provided invalid, non monotonically increasing dts to muxer in stream.*?(\r?\n|$)");
    }
    return $content;

Being ignorant, I thought that perhaps it was because I wasn't saving the log data in the folder:

Code: Select all

 $logPath   = ‘D:\Temp’;

and that the script was then colliding with this line:

Code: Select all

 $batchFile = ‘%TEMP%\~xy_ffmpeg.bat’;
?
Lts. 64-bit XY-Port. ƒ Cascadia Code @ Windows 11 Pro 24H2 ▣ 1920x1080 ⇵ 115%
Glückauf

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

Re: Custom Column: Media Integrity Check with ffmpeg

Post by highend »

Show the content of %TEMP%\~xy_ffmpeg.bat
One of my scripts helped you out? Please donate via Paypal

Native2904
Posts: 47
Joined: 23 Apr 2025 18:48
Location: Aachen

Re: Custom Column: Media Integrity Check with ffmpeg

Post by Native2904 »

Sry, but %TEMP% means C:\Windows\Temp ?
Nothing is created in this regard.
Tempordner.jpg
Tempordner.jpg (280.02 KiB) Viewed 1901 times
XYplorer_PkD847wUJR.jpg
XYplorer_PkD847wUJR.jpg (32.71 KiB) Viewed 1901 times
Lts. 64-bit XY-Port. ƒ Cascadia Code @ Windows 11 Pro 24H2 ▣ 1920x1080 ⇵ 115%
Glückauf

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

Re: Custom Column: Media Integrity Check with ffmpeg

Post by highend »

Just enter it into XY's address bar and hit enter:
%TEMP%\~xy_ffmpeg.bat
One of my scripts helped you out? Please donate via Paypal

Native2904
Posts: 47
Joined: 23 Apr 2025 18:48
Location: Aachen

Re: Custom Column: Media Integrity Check with ffmpeg

Post by Native2904 »

:oops: :oops: :oops:
changing the Path from $logPath = "c:\Youtube\Log\"; to "C:\Windows\Temp" makes it functional.
Last edited by Native2904 on 06 Oct 2025 11:51, edited 1 time in total.
Lts. 64-bit XY-Port. ƒ Cascadia Code @ Windows 11 Pro 24H2 ▣ 1920x1080 ⇵ 115%
Glückauf

Native2904
Posts: 47
Joined: 23 Apr 2025 18:48
Location: Aachen

Re: Custom Column: Media Integrity Check with ffmpeg

Post by Native2904 »

highend wrote: 06 Oct 2025 11:26 Just enter it into XY's address bar and hit enter:
%TEMP%\~xy_ffmpeg.bat
"c:\Youtube\ffmpeg.exe" -v error -i "C:\Users\Home\Downloads\S01EP01_Corrupt.mp4" -f null - 2>"C:\Windows\Temp\S01EP01_Corrupt.log"
Lts. 64-bit XY-Port. ƒ Cascadia Code @ Windows 11 Pro 24H2 ▣ 1920x1080 ⇵ 115%
Glückauf

Post Reply