Log in

View Full Version : Script to check for bad frames


TruthOverFacts
4th October 2022, 23:49
I had a file that was corrupted somehow after copying it over the network to another PC and now it has bad frames like this (see attached image)

I can't solve what's causing it but in the meantime I'd like to check other files I've copied to see if they have this issue too. Is there any script or any other way to test to see if other files have this issue?

https://i.postimg.cc/MXph3Wh5/bad.png (https://postimg.cc/MXph3Wh5)

StainlessS
5th October 2022, 00:32
See here:- Postimages instructions:- https://forum.doom9.org/showthread.php?p=1959414&highlight=postimage#post1959414

TruthOverFacts
5th October 2022, 00:41
Thanks, I'm new. How's that? I edited it.

johnmeyer
5th October 2022, 02:02
I have lots of AVISynth scripts for finding bad frames. Which script to use depends on the nature of the adjacent frames and also whether you have more than a single bad frame in a row.

You can start by looking at what I created in this thread:

Finding individual "bad" frames in video; save frame number; or repair (https://forum.doom9.org/showthread.php?p=1789509#post1789509)

TruthOverFacts
5th October 2022, 05:22
Thanks johnmeyer, I checked out the thread, it's important to note that I don't need to fix the files, I just need to know if they have the issue so I can redo them from the original source. What script would I use for that? Don't need the repair part. Thanks!

johnmeyer
5th October 2022, 05:23
You sent a private message to me saying, "I just need to know if they have the issue so I can redo them from the original source. What script would I use for that? Don't need the repair part."

it doesn't seem like you clicked on the link I provided, or if you did, you didn't read far enough. The script is heavily commented to make it easy to configure. At the beginning of the script is this comment:

#You can configure the script to write, to a file, the frame numbers of all frames which are detected as "bad".
#You can also configure it to automatically replace each bad frame with a new
#frame interpolated from its neighbors.

If you configure it to write the frame numbers to a file, it will give you a list of frame numbers of your bad frames. You can then use that information to instantly go to those frames without having to hunt around for them.

You may have to set the threshold in order to get the best results. Follow the directions for doing that. If you have it set to high or too low for your video, you will either miss a lot of bad frames or you will get a lot of false positives.

Also, as stated in the script, if you have multiple bad frames in a row, the script as configured will miss those. It is tuned to detect single bad frames of the type described in the comments.

Make sure when you visit that thread that you click on the link I provide in the first line which takes you to the final version of the script. This link will take you to the same place:

https://forum.doom9.org/showthread.php?p=1789584#post1789584

Set the variables as follows:

METRICS = FALSE # TRUE will show Metrics ONLY (i.e., TRUE overrides all other selctions)
SHOWDOT = FALSE # TRUE will add "***" to each replacment frame (for troubleshooting)
REPLACE = FALSE # TRUE will replace each bad frame with a one that is interpolated from adjacent frames
FILEWRITE = TRUE # TRUE will create a file which contains the frame numbers of all bad frames
filename = "E:\Bad.txt" # Set to name and location where you want the frame numbers stored

StainlessS
5th October 2022, 09:02
I seem to remember that ffmpeg (the full package) provides an additional exe called ffprobe, and that can be used to scan
a video file giving some kind of indication if found to be bad.

Perhaps someone knows this ffprobe well and can further advise how best to use it.

This is part of the ffprobe help file,


Simple multimedia streams analyzer
usage: ffprobe [OPTIONS] [INPUT_FILE]

Main options:
-L show license
-h topic show help
-? topic show help
-help topic show help
--help topic show help
-version show version
-formats show available formats
-codecs show available codecs
-decoders show available decoders
-encoders show available encoders
-bsfs show available bit stream filters
-protocols show available protocols
-filters show available filters
-pix_fmts show available pixel formats
-layouts show standard channel layouts
-sample_fmts show available audio sample formats
-loglevel loglevel set libav* logging level
-v loglevel set libav* logging level
-debug flags set debug flags
-fdebug flags set debug flags
-report generate a report
-max_alloc bytes set maximum size of a single allocated block
-cpuflags flags force specific cpu flags
-f format force format
-unit show unit of the displayed values
-prefix use SI prefixes for the displayed values
-byte_binary_prefix use binary prefixes for byte units
-sexagesimal use sexagesimal format HOURS:MM:SS.MICROSECONDS for time units
-pretty prettify the format of displayed values, make it more human readable
-print_format format set the output printing format (available formats are: default, compact, csv, flat, ini, json, xml)
-of format alias for -print_format
-show_data show packets data
-show_error show probing error
-show_format show format/container info
-show_frames show frames info
-show_format_entry entry show a particular entry from the format/container info
-show_packets show packets info
-show_streams show streams info
-count_frames count the number of frames per stream
-count_packets count the number of packets per stream
-show_program_version show ffprobe version
-show_library_versions show library versions
-show_versions show program and library versions
-show_private_data show private data
-private same as show_private_data
-default generic catch all option
-i input_file read specified file


EDIT: Maybe try on good file, and then again on your bad file, to see if it shows anything.

Let us know if it helps and how you used it.

EDIT:
ffprobe – Comprehensive Tutorial with 7 Examples:- https://ottverse.com/ffprobe-comprehensive-tutorial-with-examples/
unofficial tutorial, maybe not what you want, but might have some useful content [I have not read it].

Mounir
5th October 2022, 09:56
if it's an mpeg1/2 file you can scan for errors

StainlessS
5th October 2022, 11:30
Try Google search

ffprobe ffmpeg detect video file corruption


https://www.google.co.uk/search?q=ffprobe+ffmpeg+detect+video+file+corruption&biw=1920&bih=937&tbs=qdr%3Ay&ei=Vl89Y6fXKpXPgQaYxpXQCw&ved=0ahUKEwin2oLA88j6AhWVZ8AKHRhjBboQ4dUDCA4&uact=5&oq=ffprobe+ffmpeg+detect+video+file+corruption&gs_lcp=Cgdnd3Mtd2l6EAMyBQgAEKIEMgcIABAeEKIEMgUIABCiBDIFCAAQogQyBQgAEKIEOgoIABBHENYEELADOgoIIRDDBBAKEKABSgQIQRgASgQIRhgAUNkZWMAmYMQzaAFwAXgAgAGrA4gBjguSAQkwLjUuMC4xLjGYAQCgAQHIAQjAAQE&sclient=gws-wiz

Quite a few hits.

EDIT: Might want to trim above google links using "Tools/Past Year",
so as to ignore most of the old flash *.FLV type stuff from yesteryear.

EDIT: Edited above link, results limited to Past Year.