Fix bad files and streams with ffmpeg so VLC and other players would not crash It happened me many times that I could end up in corrupted video files:


video downloaded from official sources but with torrent and for some reason not all the pieces are there in .mkv, .ts or .mp4
records in .ts format where at a certain point the data is missing
copied videos from an old hard drive with damaged sectors


When I play this videos with VLC or other players they plays till a certain point and then instantly exits. Sometimes I can try to skip the bad part but I could meet another bad sector and have an insta-quit again.

Question is:

Can I fix this problems (I suppose stream and keyframes related) with ffmpeg and maybe in a -c copy fashion so I haven't to recompress everything?

What I want to achieve is a full lenght video where the missing parts are skipped, I prefer a glitch rather than having my videos crash.
If parts of the file reside on physically bad sectors, or for whatever reason, the OS cannot serve the whole file to FFmpeg, then naturally FFmpeg can't do anything about that. You should get a utility which can ignore those portions and write the salvageable parts to a new file, like ddrescue.

Now, if the file protocol is not the cause of errors, you can try

ffmpeg -err_detect ignore_err -i video.mkv -c copy video_fixed.mkv