MoleMan1024 / audiowagon

AudioWagon will play audio files from an attached USB flash drive in cars equipped with Android Automotive OS
https://moleman1024.github.io/audiowagon/
GNU General Public License v3.0
58 stars 18 forks source link

Metadata extraction for .flac files is slow #103

Closed MoleMan1024 closed 1 year ago

MoleMan1024 commented 1 year ago

Discussed in https://github.com/MoleMan1024/audiowagon/discussions/101

Metadata extraction for .flac files is slow, investigate why.

MoleMan1024 commented 1 year ago

Testset: 73 .flac files Baseline: ~45 seconds to index library

Re-used the caching audio source for metadata extraction and worked on a TODO to re-use the metadataretriever for album art. Using those changes it now only takes ~19 seconds to index at the expense of slightly more memory usage during indexing.

gahabana commented 1 year ago

that is indeed great improvent - looking forward to it !!! ... out of curiousity - my guess is it is probably at least 10 times faster with MP3 files - do you have baseline to share (FAQ states "This process will take some time (a couple of minutes for 10000 files)." Could it be that Android metadataretriever library is just sub-optimal for non-MP3 files ?

MoleMan1024 commented 1 year ago

do you have baseline to share (FAQ states "This process will take some time (a couple of minutes for 10000 files)."

Yeah mp3s work okay for me, haven't done measurements in a while.

Could it be that Android metadataretriever library is just sub-optimal for non-MP3 files ?

Well someone developed an alternative based on FFMpeg (which I can't use because it is missing a raw dataSource implementation), maybe because the other one was too slow or did not support enough file formats?

MoleMan1024 commented 1 year ago

Added another optimization to read filesize only once and store it in datasource to avoid mutex locking unnecessarily. Down to ~15 seconds with the testset above (on debug build on development mobile phone).

MoleMan1024 commented 1 year ago

This will be in version 2.3.6

gahabana commented 1 year ago

thank you - have tested it with 40k tracks library in MP3 format and it finished in Volvo 2022 model in less then an hour. that is more then 2x improvement.

Will check tomorrow with Flac and/or Opus and let you know.

Thank you !!!

gahabana commented 1 year ago

thank you - have tested it with 40k tracks library in MP3 format and it finished in Volvo 2022 model in less then an hour. that is more then 2x improvement.

Will check tomorrow with Flac and/or Opus and let you know.

Thank you !!!

OK. This morning I did put fresh drive with 1.1TB music (Flac 16bit files, about 41000 of them) and was driving for about 25-30 minutes and in that time AudioWagon has indexed about 18k files ... so would take slightly above an hour for 41k songs . Manual start of indexing is good option since it allows me to 'continue' where it stopped last time (though it takes some time to go through songs which are already in DB) but that is couple of minutes only.

With these enhancements - i think this is very usable even for people with large libraries they wish to keep in the car.

If one was to dream about even 'better' solution it would be that indexing would run in background while user can use what had been indexed until that point. Of course, then it would be possible for someone to remove drive from the car, delete some songs that were indexed and put drive back expecting them to play before indexing has been completed but for all other scenarious it would be great addition (people tend to make smaller changes to library after it had been built).

THANK YOU!

gahabana commented 1 year ago

Lastly, for what it is worth - i do have 3 pci nvme drives and 3 USB-C enclosures. One has ASM2362 chipset and the other 2 have JMS583 and drives were WD Black PCIe 512GB and 2TB drives are PNY-CS3030 and Intel 660p. All three in different scenarios work just fine in Volvo connected to USB-C port in armrest.