I think I'm pretty close to having a code which will start at a directory, then spit out a fixed copy, using fd (instead of find) and ffmpeg. I have written the if statement here as psudo-code:
for i in $(fd -e .mp4 -e .avi);
do if [ffmpeg -v error -i "$i" -f null - 2] has an error, then
ffmpeg -err_detect ignore_err -i video.mkv -c copy video_fixed.mkv;
I believe that when you use 'fatal' if there is no fatal error, the file will be blank/zero. Which would be easier, but I think 'error' is more appropriate.
What I want to modify is to have the IF statement execute if there are errors, and do nothing if not. If there are errors it will create the video_fixed.mkv. However, I also don't want this to be video_fixed.mkv, I want it to be the same file name as $i with the same file extension as the original, and to replace the original with it. I'm also not sure if $i is just the filename, or the filename including the entire path, which makes things tricky, I'd have to capture the string after the last '/' as the file name.
If it's too hard to do the comparison, I'll have to just copy all the files regardless of if they have errors, but to do this I'll still need to name and override the copies to be the same as the originals.