Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Repaired video "too long" and won't play #280

Open
dopeless opened this issue Apr 15, 2024 · 6 comments
Open

Repaired video "too long" and won't play #280

dopeless opened this issue Apr 15, 2024 · 6 comments

Comments

@dopeless
Copy link

Ciao, I've tried to repair some prores videos from Aromos Ninja 5 with no luck.
The created file won't play, and it's length is some 10 times longer, that it should be

I've also tried the forked version (https://github.com/anthwlock/untrunc) - it could restore video, but sound is a white noise.
I've tried Grau - it restores video, but audio alternates between normal sound and white noise.
I've got four audio channels, and i think that's the problem (I've read multiple threads about problems with multichannel sound).

But I'm pretty sure, the video can be fully restored.

Can I send you a sample to take a look?
Thank you.

@ponchio
Copy link
Owner

ponchio commented Apr 16, 2024 via email

@dopeless
Copy link
Author

Hello, have you had a chance to take a look at the videos? I've sent them to you via email a month ago, and still got no answer. Thanks.

@ponchio
Copy link
Owner

ponchio commented May 23, 2024 via email

@dopeless
Copy link
Author

dopeless commented May 23, 2024

Hi, first of all - thank you so much for taking time to fix it.
I've tried to fix it myself, as you described - and it really works! The video is fully restored!
But how can i calculate (or at least estimate) the samples count for other videos?
I mean, how can I get the reported number, and if I get it - do I need just to guess the real working number, or is there some way you've got the 24064?
Now I'm very close to get all the videos restored, hope for the last bit of help from you )
Thanks again.

P.S. And what does the -b option do?

@ponchio
Copy link
Owner

ponchio commented May 23, 2024

As you know you need a working video with the same characteristics.

if you run untrunc -a good.mp4, you will see each chunk size and offset. In your case the size reported is 288288 which /12 is 24024 (because it is computed from the data written in the atom stsz.
BUT if you check the distance from the offset of an audio packet (for example the first packet is 51799040) and the offset of the next video packet 52087808, it is 288768 (or 24064x12).

This can happens usually for padding (zero or random) , but in your case the additional 480 bytes seems filled with audio samples, can for memory alighment, for page allocations etc.

In your case the extra length is constant, contains audio, the sequence of video/audio is very regular, it could very possibly that I am wrong in interpreting the values (I tried to follo the documentation, but it sucks, when it exists).

Anyway unless you changed the audio parameters it is very likely that all the mp4 have the same problem and solution.

-b instructs untrunc on where the mdat (the atom containing the packets) starts, we only need to point it at the beginning of packet and in our case video packets are easier to spot.

If you want to spot a video packet use a hexeditor (bless for ubuntu works great), search for the ascii text "icpf", and the video packet starts 4 bytes before (works only for your video codec apch, obviously) (you can use the -a options to get the offsets in the good video).

@dopeless
Copy link
Author

That was much mor, than a "bit".
Everything seems more or less clear now.
I'll try to fix some videos on the weekend.
Thank you one more time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants