axiomatic-systems / Bento4

Full-featured MP4 format, MPEG DASH, HLS, CMAF SDK and tools
http://www.bento4.com
2.03k stars 483 forks source link

Reassemble packets into a new MP4 file #983

Open alanccw opened 2 months ago

alanccw commented 2 months ago

I have many MP4 files which are truncated in their tails, which make them not playable. I analyze these files manually and find the ftyp and moov boxes and their child boxes are all OK. But part of the data in mdat box are lost, which corresponding to some packet data only, which is <= 5% of the total packets.

So I wrote a small app that can parse all the data in the MP4 and read all the meta info from the boxes(except for mdat box), and get all the existing packets and save them as separate .dat files. Now I want to reassemble them back into a valid MP4 file.

Can I implement that with your Bento4 API? I have tried ffmpeg commandline and API but failed.