r/PleX•
jayrox

Is there a way to automatically check media files for issues?

Help

Is there a way to automatically check media files for issues?

I've ripped a couple old DVDs a few months back and went to watch one a bit ago and found that there was an encoding issue about 45 mins into the movie and suddenly it skipped to about an hour in skipping about 15 mins of the movie.

I'd like to be able to have a background script/application that sits and scans my library's media and checks the files and reports back if it finds errors in the file. Such as a movie with a broken or incomplete video or audio stream.

I did some googling and found this link https://superuser.com/a/100290 which mentions using ffmpeg -v error -i file.avi -f null - 2>error.log

I was wondering if anyone else has run into this, what their solution was. I'd preferably find the problem before I sit down for an hour and get really into a movie just to find out that when I ripped it, something broke in the process.

Edit: So I've been messing with that ffmpeg snippet and this seems to be doing the trick in at least getting some info out to where I can use it to make decisions.

The following code is quickly (possibly even poorly) written in Go - https://github.com/jayrox/prbd

Posted May 22, 2017, 5:48 PM UTC · edited

367
GldRush98•

There's a difference between an encoding issue and actual file corruption though.

In your case, there may not be an error detected as the error occurred during the encode. The file may be fine technically speaking, there is just a chunk of video that didn't get encoded for some reason. I can't think of any way to programmatically find that type of problem with out just watching the file itself.

The ffmpeg line would however work well for detecting actual file corruption. For instance an incomplete download or file copy issue or something of that nature.

3
jayroxOPWindows, Android•

I've been messing with the ffmpeg line to test the file that was having issues and it spit out a ton of lines. Ran it against a file that plays fine and spits out nothing. So, I've written a small golang application to run ffprobe and ffmpeg against each file in my library and write two files out filename-probe.json and filename-analyze.txt and possibly a 3rd file filename-analyze-error.txt if errors are detected.

It's not very fast due to the process ffmpeg is doing but it appears to be doing what I initially am asking for.

I've put the source in the OP.

1
GldRush98•

Ah, so I assumed the error occurred during encode, but it looks like something did go wrong with the file itself. I guess that's what happens when I assume! Haha

1
jayroxOPWindows, Android•

I'm not 100% certain when the error occurred. I don't typically watch each movie as I add them to the collection. Just let the tools do their job.

I am going to let my little app run and identify as many possible issues as it can. Then see if I can use the info it presents and identify which errors actually mean something to the experience in watching it and which can be discarded. Maybe from that I can have a tool that runs in the background and keeps things in as a happy of state as possible and maybe others can find some use in it too.

1

Do you know of anything that will compare the length of the video to the runtime? There will be some variation, but i assume anything +-10% would indicate an issue with the encoding.

1
neztach•

As a side question, is there a way to scan media files to see if sound gets out of sync (bonus question: can it be automated to be fixed?)?

1
jayroxOPWindows, Android•

Good question, certainly one I'd be interested in resolving. I also want to have something that "normalizes" audio a bit. I won't say I am hard of hearing... just some sounds in movies I have a hard time with. Like whispers with other noises around it... or when they aren't loud enough to drown out my inner voice. I can hear the quietest of noises when my inner voice isn't too loud. Is that weird? I don't know but I'd certainly like to have my library formatted in such a way that I can enjoy all parts of the film.

2