untrunc icon indicating copy to clipboard operation
untrunc copied to clipboard

src/mp4.cpp:537: void Mp4::saveVideo(const string&): Assertion `track.chunks_.size()' failed. // track.codec_.name_=avc1, track.getNumSamples()=14348

Open karepiu opened this issue 1 year ago • 5 comments

`Info: version 'v364-bd783dd' using ffmpeg '3.3.4' Lavc57.89.100 Info: reading DJI_0154.mp4 Info: parsing healthy moov atom ... Composition time offset atom found. Out of order samples possible.

Info: reading mdat from truncated file ... Info: Found 14348 packets ( avc1: 14348 avc1-keyframes: 479 ) Info: Duration of avc1: 7min 58s 744ms (478744 ms) src/mp4.cpp:537: void Mp4::saveVideo(const string&): Assertion track.chunks_.size()' failed. // track.codec_.name_=avc1, track.getNumSamples()=14348

Damaged file is > 2GB and seems the tool sees 7 mins of footage but still the chunk error.

Regards

karepiu avatar Jul 08 '24 19:07 karepiu

Please send me the files (healthy+broken) and I might take a look at some point. You can upload them on dropmefiles.net. If you think they are too big, you can use untrunc -sh file.mp4. In case you want to keep the link private, you can send me an email - see my Profile page. Thank you!

anthwlock avatar Jul 09 '24 11:07 anthwlock

@anthwlock While I'm not the original asker, I encountered the same issue: https://dropmefiles.net/en/Q8Se3 This is a healthy file that somehow throws tracks.chunck_.size()==0 on mp4.cpp line 537. tracks.size() is 1. Invoked using docker container: untrunc-master\untrunc-master>docker run -v untrunc-master\untrunc-master:/mnt untrunc /mnt/Test_Vid.mp4 /mnt/Test_Vid.mp4

Just tested the original repo: https://github.com/ponchio/untrunc That one was able to process the file.

DKATyler avatar Oct 15 '24 01:10 DKATyler

@anthwlock

I have the same issue as mentioned by @DKATyler. I performed a git bisect and observed that the issue was introduced in commit acd93a.

I hope it helps. Thanks for maintaining this repo.

joanpepcompany avatar Oct 24 '24 07:10 joanpepcompany

I am on a Mac and am running untrunc to fix an audio-only m4a. It seems to find the data but these lines appear in the terminal:

src/mp4.cpp:537: void Mp4::saveVideo(const string &): Assertion `track.chunks_.size()' failed. // track.codec_.name_=mp4a, track.getNumSamples()=96208 pstack is not available on this system.

Any ideas?

espiegel123 avatar Jul 15 '25 01:07 espiegel123

@anthwlock

I have the same issue as mentioned by @DKATyler. I performed a git bisect and observed that the issue was introduced in commit acd93a.

I hope it helps. Thanks for maintaining this repo.

I was having the same issue when compiling it myself. Since I'm not very familiar with the current code base (or C++ for that matter), I had some help from an LLM when diffing the current mp4.cpp and one before commit acd93a.

Seems like adding the following after if (g_muted) unmute(); close to the end of mp4.cpp might at least fix the failed assertion:

for (auto& t : tracks_) {
    t.pushBackLastChunk();  // finalize any in-progress chunk
}

I don't know why this is necessary after those changes, and I bet it probably points to some other part not working the same way as before. And I don't know if this is a good or correct solution 🤔

eebirke avatar Oct 20 '25 19:10 eebirke