Home » Questions » Computers [ Ask a new question ]

How can I check the integrity of a video file (avi, mpeg, mp4...)?

How can I check the integrity of a video file (avi, mpeg, mp4...)?

This title could be somewhat misleading, so let me explain ...

Asked by: Guest | Views: 295
Total answers/comments: 4
Guest [Entry]

"For windows, You can 'batch' check integrity for videos on current folder and all subfolders with this bat file:


@echo off

set ""filtro=%1""
if [%filtro%]==[] (
set ""filtro=*.mp4""

for /R %%a in (%filtro%) do call :doWork ""%%a""

exit /B

C:\ffmpeg\bin\ffmpeg.exe -v error -i %1 -f null - > ""%~1.log"" 2>&1


checkvideo.bat [filter]

If you don't give one filter, will get '*.mp4'.

Samples: checkvideo.bat checkvideo.bat *.avi

Setup: Download FFmpeg for Windows from here: ffmpeg.zeranoe.com/builds/ and unzip them Change C:\ffmpeg\bin\ in the bat file for the path where you have unzipped ffmpeg Put checkvideo.bat on a folder included in the Path or add his folder to Path environment variable

UPDATE: As of September 18,2020, the above link is no longer valid so Windows users can download FFmpeg form here or here"
Guest [Entry]

"Easier version

for file in *.mp4; do ffmpeg -v error -i ""$file"" -f null - >error.log 2>&1; print ""$file""; done

This will print the file name as they are being processed.

error.log will contain the errors."
Guest [Entry]

"Although this is an old post, and I'm sure there's other ways to valid video files now. However, for a full video file check, you can use mplayer.exe.
Using the below (.bat) script will recursively check video files and save validated ones in a integritychecked.log file (to skip next time its run).
if not ""%1"" equ """" (
pushd %1
) else (
pushd ""%~dp0""

setlocal EnableDelayedExpansion
for /F ""tokens=1,2 delims=#"" %%a in ('""prompt #$H#$E# & echo on & for %%b in (1) do rem""') do (
set ""DEL=%%a""

echo This script with validate video files in the folder/sub-folders. Please ensure mplayer.exe is accessible in PATH.
echo Either run this script from the desired (parent) directory or specify the directory when running this script. eg checkvideo.bat <full path>

REM Append date and time to integritychecked.log file
for /f ""tokens=1-9 delims=/:. "" %%d in (""%date% %time: =0%"") do echo Started: %%g%%f%%e_%%h%%i%%j>>integritychecked.log

FOR /F ""delims=*"" %%G in ('dir /b /s *.mkv *.mp4 *.mpg *.mpeg *.xvid *.webm *.m2v *.m4v *.3gp *.3g2 *.avi *.mov *.flv *.wmv') DO (
REM Confirm if already checked or not from log file
set found=0
for /F ""usebackq tokens=*"" %%s in (""integritychecked.log"") do (
if %%G equ %%s (
set found=1
REM echo ""FOUND = %%G = %%s""

if !found! equ 0 (
echo Verifying ""%%G""
mplayer -tsprobe 10000000 -benchmark -forcedsubsonly -mc 0 -nosound -nosub -noautosub -vo null ""%%G"" 2>""%%G.log""
REM ffmpeg -v error -i ""%%G"" -map 0:1 -f null - 2>""%%G.log""
FOR %%F in (""%%G.log"") DO (
if %%~zF equ 0 (
del %%F
call :colour 0a ""Video is good""
) else (
call :colour 0c ""Error in video file:""
type %%F
call :colour 0e ""This can be found in the video's .log file""
REM Save entry to log file (as checked)
echo %%G>>integritychecked.log
) else (
echo already verified ""%%G""...skipping.
call :colour 0a ""Verifying complete!"" && echo.
cd %~p0
exit /b

set ""param=^%~2"" !
set ""param=!param:""=\""!""
rem Prepare a file ""X"" with only one dot
<nul > X set /p "".=.""
findstr /p /A:%1 ""."" ""!param!\..\X"" nul
<nul set /p "".=%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%%DEL%""
rem Delete ""X"" file
del X
exit /b"
Guest [Entry]

"I have developed this python script which checks media files integrity (or tries to), please read instructions for details and limits,
also feedbacks are appreciated: