anthwlock / untrunc

Restore a truncated mp4/mov. Improved version of ponchio/untrunc
GNU General Public License v2.0
1.87k stars 182 forks source link

Video only partially restored #79

Closed 4nn4r3ll4 closed 2 years ago

4nn4r3ll4 commented 3 years ago

First of all, thank you immensely for your work on this project!

I've been trying to fix some broken 1080p downloads from the NHK Video On Demand service (NHK VOD). I've downloaded several episodes of the same show, Japanology Plus, and only a couple of them are broken - so I have like 40 files that could be used as working references for the corrupted ones (same show, same lenght of the episode, same resolution etc). Also, for the each broken episode is available the same working episode at a smaller resolution (same exact episode, 720p).

Basically, apart from some minor out-of-sync audio issues, untrunc is able to recover almost the entire episode...if it wasn't for the last minute or so. I've tried running it with the -s option activated but without any luck.

Any chance you could help me figure this out?

I'll send one example (they're all identical): I'm trying to fix the 1080p mp4 download of this episode. You'll find it at the following link, it's named "broken.mp4". At the same link you'll also find "working_same_720.mp4", the exact same working episode at the smaller resolution of 720p. You'll also find "working_1080.mp4", a different working episode of the same series, same lenght, same resolution of the one I'm trying to recover. Lastly, you'll find "working_short_1080.mp4": a smaller working 1080p download from the same source of a shorter video of another series.

I've tried them all as reference working videos but they all produce the same result, missing the last minute or so!

MEGA LINK: https://mega.nz/folder/5hh2DKyI#M4DtjRDmi0EnyuCKuVpnBQ

Thanks again for your huge work and thanks in advance for the help with this one!

anthwlock commented 3 years ago

Do you have an Idea how they got corrupted in the first place? To me it looks like the last X MB got cut away, and with it the last ~1min or so of the video material. So basically I believe that untrunc recovers everything there is to recover

4nn4r3ll4 commented 3 years ago

No idea, I've tried downloading in many ways (youtube-dl, ffmpeg, web services) and I end up with the same corrupted file every time. What made me think that this corrupted file could indeed contain the whole video was that its size matches very well the one of the working ones that I was able to download from the same source... I really can't get my head around it! Thanks again for taking the time, for real :)

anthwlock commented 3 years ago

No idea, I've tried downloading in many ways (youtube-dl, ffmpeg, web services) and I end up with the same corrupted file every time.

Can you play the video when using the URL directly youtube-dl -g <url>?

What made me think that this corrupted file could indeed contain the whole video was that its size matches very well the one of the working ones that I was able to download from the same source...

I think that the healthy files are a little bit bigger, probably just enough to fit the extra ~1min + mp4-index (aka moov atom).

The part that untrunc currently doesn't recover seems to only be around ~50kbit, which is not enough for 1min of content. So I fear that not much can be improved in this case, I think the 1min is lost.. :/

You could however use ffmpeg to add the last ~1min from the healthy 720p file, and add it to the recovered 1080p file. So you'd get a complete file, which is mostly in 1080p.

4nn4r3ll4 commented 3 years ago

Nope, it doesn't play! So it must be as you suggested, thank you so much! And thanks also for the suggestion, still...no idea I would go on doing that (merging 1080p and 720p)... I guess I should upscale the 720p first? What about x264 settings, I guess they should match (almost) perfectly, right? :S

anthwlock commented 3 years ago

What about x264 settings, I guess they should match (almost) perfectly, right? :S

Seems so, I tried the naive approach (just using -vf scale=1920:-2 and then -f concat), and the second half (which should show the upscaled part) was just black. Options include:

  1. reencode both files, as (implicitly) suggested here
  2. try to find the right x264 settings. While this would save computation time, I dont know how hard it would be, or if it is possible (in case of your files) at all. This could be a start though.

In case you succeed with 2. let me know, would be interesting to know/hear what settings had to be adjusted!