kevinGodell / mp4frag

Parser that works with ffmpeg to read piped data and fragment mp4 into an initialization segment and media segments. It can also get the codec info and generate an fmp4 HLS m3u8 playlist.
https://kevingodell.github.io/mp4frag/
MIT License
68 stars 15 forks source link

Is there any way of handling "mdat not found" error cleanly #12

Closed karlbrowns closed 3 years ago

karlbrowns commented 3 years ago

I haven't found what in my stream causes this error to occur, but occasionally it does. At which point my web server crashes. I need to a) handle it so that the webserver doesn't crash and b) handle it so that mp4frag can restart and continue to play the video once it does find a valid mdat.

kevinGodell commented 3 years ago

mp4frag.on('error'). The server will crash if you do not have an 'error' event listener as that is the nature of nodejs. If you get any error from mp4frag, it cannot continue due to corrupted or missing data. The best thing to do is call mp4frag.resetCache() which will put it back to its default state and clear all of the internal buffers. Then start your video feed new and pipe it in the mp4frag. That is my best guess without having a sample of your code or ffmpeg commands. Also, you can try using my unreleased version of mp4frag. You would have to do a npm install kevinGodell/mp4frag and that will give you the latest version that I have not had time to clean up and release. But, it has been fully field tested by my friends at nodered.org where i am developing an experimental streaming video solution. Currently it works great for me with 14 ip cams that run 24/7 and are available to watch in all modern browsers.