Check the integrity of batch video files

Asked

Viewed 490 times

4

How to check automatically and customizable via Shell/Programming Language the integrity (file Incomplete/Corrupted) of video files (.avi, .mp4, .mkv among others) ?

OBS: Having as limiting factor the lack of a HASH prior files.

  • I changed the title, because automatic and customizable are already practically "embedded" within the "programming"

  • No preblema @Guilhermenascimento

1 answer

5


Since there is no HASH prior (when there was certainty of the state of the file) it is necessary to use a Third Party program FFMPEG and a script executed via Powershell that automates the execution of checking the video files of a given folder:

Script:

$logPath = "C:\Users\User\projeto1\error.log"
$videosFolder = "C:\Users\User\videos"
$ffmpegPath = "C:\ffmpeg\bin\ffmpeg.exe"
$arquivos = Get-ChildItem -path $videosFolder | 
    Where-Object {
        ($_.extension -eq ".mp4" -or $_.extension -eq ".mkv")
    }
foreach($item in $arquivos){
    "+#+#+ " + $item.FullName >> $logPath
    &$ffmpegPath -v error -i $item.FullName -f null 2 >> $logPath 2>&1
}
  1. In the script I determine the addresses of the folder where the videos are, where the FFMPEG and where the LOG file will be created with the errors of each video
  2. I select the files based on my needs (only videos with extension .mp4 and .mkv)
  3. For each file run the FFMPEG passing some control parameters such as how verbose the check should be.

Notes:

  • The check is frame by frame so the errors are by frame.

  • It was arranged so that errors were printed below the file name. (There may be no errors, or there may be several errors in each frame which generates a huge Log file).

  • NEVER let the errors be displayed in the default output, always leave to be stored in the Log file.

  • I added a string +#+#+ differentiated at the beginning of each file path to facilitate the search.

Test Data:

4 files have been tested:

  • 2 Perfect (11 MB each)
  • 1 Incomplete (Revised by Bittorrent before the end (still partially reproducible)) (55 MB)
  • 1 Corrupted (I opened the file on Notepad++ and added random characters) (11 MB)

Test time:

  • Displaying Error Messages in Log File: 17 Seconds
  • Displaying Error messages in Powershell Console: 14 Minutes

Log file size: 19 MB

Browser other questions tagged

You are not signed in. Login or sign up in order to post.