gpmf-extract
gpmf-extract copied to clipboard
In browser memory allocation
First of all, congrats for the great work! I am using your code in a project to analyze GPS data for go-kart and trackday. I extract the GPMF data in the browser, and used browserify to bundle the code together. I run the module as below:
data = await gpmfExtract([file object],true,progress);
The problem that started to show up lately, is that the memory the browser allocates to process a single big file (4GB mp4 file) is so big that eventually the window hangs. I've checked that the same issue happens when I process the file in https://goprotelemetryextractor.com/free/# (it allocates almos 7GB for the chrome process). Maybe this is a mp4box issue?
It could be an mp4box issue. I'm not sure, as for larger files I use and recommend offline versions of the extractor, which use ffmpeg instead of mp4box. How large are your files?
Hi Juan,
Thanks for your prompt response. Last month I was at a 500 mile gokart racing, analising the telemetry from a team. Each driver had a 1h stint to race continuously, and they had different types of cameras with different setups. The smallest I had was 3x 4GB files and the largest 7x 4GB files.
Em dom., 26 de dez. de 2021 às 15:52, Juan Irache @.***> escreveu:
It could be an mp4box issue. I'm not sure, as for larger files I use and recommend offline versions of the extractor, which use ffmpeg instead of mp4box. How large are your files?
— Reply to this email directly, view it on GitHub https://github.com/JuanIrache/gpmf-extract/issues/46#issuecomment-1001227311, or unsubscribe https://github.com/notifications/unsubscribe-auth/AU3ZXK4WPF2XZJZRWVO6Z4DUS5QAHANCNFSM5KZFMK2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
-- Pedro Barrionuevo Roese (51) 981729393
of course I call the function on one file at a time, sendo the extracted GPMF to my server, and only then call for the next file.
Em dom., 26 de dez. de 2021 às 15:59, Pedro Barrionuevo Roese < @.***> escreveu:
Hi Juan,
Thanks for your prompt response. Last month I was at a 500 mile gokart racing, analising the telemetry from a team. Each driver had a 1h stint to race continuously, and they had different types of cameras with different setups. The smallest I had was 3x 4GB files and the largest 7x 4GB files.
Em dom., 26 de dez. de 2021 às 15:52, Juan Irache < @.***> escreveu:
It could be an mp4box issue. I'm not sure, as for larger files I use and recommend offline versions of the extractor, which use ffmpeg instead of mp4box. How large are your files?
— Reply to this email directly, view it on GitHub https://github.com/JuanIrache/gpmf-extract/issues/46#issuecomment-1001227311, or unsubscribe https://github.com/notifications/unsubscribe-auth/AU3ZXK4WPF2XZJZRWVO6Z4DUS5QAHANCNFSM5KZFMK2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
-- Pedro Barrionuevo Roese (51) 981729393
-- Pedro Barrionuevo Roese (51) 981729393
I haven't experienced problems with 4GB files on the online version of the Extractor. Except maybe on Firefox, which caused some issues in the past, but I thought they had been solved
Thanks for the additional information. I will try to find the time to investigate this. If you make some progress or find something else in the meantime, please let me know
Juan,
Thanks once again for your kind answer. I am willing to help, but since I am in the very first steps of developing, I’ll need some help to get started. If you can pin point the parts of the library where the filereader splits the video file in chunks and feed it to the other functions, then maybe I can help you to find the bug.
Em seg., 27 de dez. de 2021 às 18:20, Juan Irache @.***> escreveu:
Thanks for the additional information. I will try to find the time to investigate this. If you make some progress or find something else in the meantime, please let me know
— Reply to this email directly, view it on GitHub https://github.com/JuanIrache/gpmf-extract/issues/46#issuecomment-1001765497, or unsubscribe https://github.com/notifications/unsubscribe-auth/AU3ZXKZIRMC6LGXKHEFVOOTUTDKDBANCNFSM5KZFMK2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
-- Pedro Barrionuevo Roese (51) 981729393
I haven't touched this repo in a while, but I would start by trying the following:
- Update mp4box and see if the issue persists
- Force the program to run in webworker and "factory" mode and see if both produce the problem (line 126 of index.js)
I haven't touched this repo in a while, but I would start by trying the following:
- Update mp4box and see if the issue persists
- Force the program to run in webworker and "factory" mode and see if both produce the problem (line 126 of index.js)
Ok, so I think we might have found the issue: mp4box was up to date, reinstalled it, all the same, so, nothing related to it. However, when I force the program to use the readBlock instead of the worker, the problem is gone. So, I'll try to understand the worker and then attempt to debug.
Hi there! I’ve noticed the problem too for a while. In my experience there seems to be less issues with this library on Mac. It extracts GoPro Hero 8 4K 4GB videos and .LRV likes using Chrome browser no problem although Mac Firefox crashes regularly.
I have been using Windows 10 more recently with my website https://maps.video and have noticed that randomly the progress bar gets stuck and I think this is due to memory issues also. .LRV files being much smaller in file size seem to always work perfectly with Chrome at least, Firefox can still crash.
I have tested extracting 4GB video files on my Windows 10 laptop and a Bootcamped Windows 10 Mac. They both have the same issue on Chrome with the progress bar stopping and the extraction halting (see screenshots where it has got stuck). It seems to get stuck when the memory is high and for certain videos that it does not seem to like.
I also extract the GPMF data in the browser, and use browserify to bundle the code together. I do:
window.gpmfExtract(file, true, progress).then(function (res) {
Would really appreciate a fix if one would be made available as most my customers use Windows Chrome.
Thanks!
Windows 10 Laptop:
Bootcamped Mac (Windows 10):
I'm thinking that, if this is only happening with web workers, one quick workaround would be to set an option not to use the web worker. Not ideal, but maybe enough for now. I have implemented that in the dev branch but I won't be able to test this on Windows for a few days: https://github.com/JuanIrache/gpmf-extract/tree/dev
Happy to hear your feedback. Note that the arguments of the main function have changed. See the readme.
Hi Juan,
Many thanks for this, will try tomorrow :-)
Tom
On Thu, 30 Dec 2021, 17:41 Juan Irache, @.***> wrote:
I'm thinking that, if this is only happening with web workers, one quick workaround would be to set an option not to use the web worker. Not ideal, but maybe enough for now. I have implemented that in the dev branch but I won't be able to test this on Windows for a few days: https://github.com/JuanIrache/gpmf-extract/tree/dev
Happy to hear your feedback. Note that the arguments of the main function have changed. See the readme.
— Reply to this email directly, view it on GitHub https://github.com/JuanIrache/gpmf-extract/issues/46#issuecomment-1003123070, or unsubscribe https://github.com/notifications/unsubscribe-auth/AH3S53PGCWTGU56P5OFPGQLUTSKUTANCNFSM5KZFMK2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you commented.Message ID: @.***>
In order to test this quickly, I've published an update here that uses the new approach: https://goprotelemetryextractor.com/free
I appreciate any feedback, especially if you currently have access to large files and the problematic systems/browsers
Thanks!
I have just tested the new dev branch code by creating a new bundle and changing the gpmf function parameters but I am still getting the same problem. Sometimes the file will extract properly but a lot of the time the total system memory climbs above 80% which is when it stalls.
My windows 10 computer has 16Gb memory and I am loading 4Gb 4K videos. I tested the same problematic video file in your telemetry extractor free site several times and monitored the memory. The memory never climbed high like it does for my site https://maps.video and seemed to work perfectly.
So I have to ask what is the difference between your telemetry extractor javascript and mine? Is this a memory leak/management issue?
Thanks!
Thank you for testing that. Are you using the useWorker:false option?
Don't think so, how do I do it?
gpmfExtract(file, {
browserMode: true,
progress: progressFunction,
useWorker: false
})
.then(function (res) {
// Do smth
})
Ideally a future version will work well with the worker too. But this might be working well for now, if the free tool gave you good results.
Of course, testing now...
Seems to have done the trick, memory much better now but will test more. Does this mean the videos are extracted only on the main UI thread?
Thanks!
Hi Juan,
I tested extensivelly without the worker and works fine
Em sex., 31 de dez. de 2021 às 08:10, Thomas Rumens < @.***> escreveu:
Of course, testing now...
— Reply to this email directly, view it on GitHub https://github.com/JuanIrache/gpmf-extract/issues/46#issuecomment-1003347558, or unsubscribe https://github.com/notifications/unsubscribe-auth/AU3ZXK4JBLCP7P5ADS5OAL3UTWFRBANCNFSM5KZFMK2A . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.
You are receiving this because you authored the thread.Message ID: @.***>
-- Pedro Barrionuevo Roese (51) 981729393
Great! I will merge this.
Yes. This will only use the UI thread, so it's not ideal. I appreciate it if anyone makes progress on the worker front.
Thanks. The UI is working fine on my website, Mac and Windows during extraction. (Zooming and dragging Google Map etc).
It might be time to retry. With @JuanIrache we have made changes to the parser. To my knowledge, the RAM usage should be much better now.
Try calling
mp4boxFile.releaseUsedSamples(id, samples[samples.length - 1].number);
at the end of onSamples
https://github.com/JuanIrache/gpmf-extract/blob/a0bdd225f64c4ecda53bc0797f586ffe8b53e039/index.js#L104
MP4Box holds on to the samples otherwise.
https://github.com/gpac/mp4box.js/blob/325741b592d910297bf609bc7c400fc76101077b/src/isofile.js#L539
If you are able to test the memory footprint, it would be great if you could test the hypothesis. Of true, please do a small PR. If you could create a test to ensure the memory is not leaking anymore, it would be also great!