31
Views
2
Comments
Solved
[ResumableJS] Re-combine the mp4 chunks results in a not-playable/corrupted file
resumablejs
Reactive icon
Forge asset by Vincent Koning
Application Type
Reactive

Hi All,

I am stuck on a problem and hope can find some insights here.

I plan to use ResumableJS to upload a large mp4 (1GB). Firstly, split the video/mp4 file into smaller chunks and upload to a server. Then, on the server side, I re-combine those chunks back to a single mp4 file with binary contention.

I would expect it should work as I merely split and re-combine a single large mp4 file. However, in my current project, for small size (<=250 MB) it seems working fine. But for large mp4 (>=800 MB), the re-combined video is not able to play in VLC. And I am pretty sure the original file is fine. Even the file size is the same. But the re-combined video cannot play.

Just wondering do you have any idea what might go wrong?


Regards,

George

2021-07-21 12-04-07
George.Qiao
Solution

Finally, I solved my problem. If anyone hits a similar problem, you may try the same way I used. 


In ResumableJS.js (version 1.0), line 57, the code says `method:'multipart'`. In most cases, it is fine, especially for text based data. However, for mp4, it is not the best option for the server side to parse the form/multipart binary properly. At least in my case, the server-side multipart parser I used has some issues to extract the binary properly. For small mp4, the parser seems working fine. However, for large mp4 file (1GB+), it often ended up with a un-playable mp4 file after merging. This is also related to the underlying form/multipart encoding, which is utf-8 by default. 


In my case, I changed `method:'multipart'` to `method:'octet'`. This is to post chunks as octet-stream instead of multipart form data. This also simplifies the serverside logic. Now, I just need to binary concat the chunks and not to worry about parsing multipart form data anymore. Tested with 1GB+ mp4 files and pdf files. All working fine.

2020-09-21 08-42-47
Vincent Koning

Hi George,

Good to hear you have solved your issue. Since it deviates from the default configuration I will not update the component for this. I want to keep this a pure as possible for upgrade reasons. But perhaps you could upload your version here so others could benefit from this?

Greetings,

Vincent

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.