Sonic Analysis and x86-ARM data migration

Hi all. I run Plex on a Raspberry Pi, which I know cannot run Sonic Analysis.

However, I wanted to ask a few questions to the team as they might help me understand what may or may not happen here, so I can explore options.

I’m referencing the Move an Install to Another System | Plex Support support article, since my data directory and media is all in an external drive, and I have a Linux x86 laptop.

What I’m thinking: plug the external drive to the laptop, run the sonic analysis for my current media there, and then take it back to the Raspberry Pi.

My questions:

  1. Would the presence of the Sonic Analysis metadata alone enable the relevant mixes on PlexAmp, or are the mixes also not available in an ARM system? I would expect that the metadata alone would turn it on, unless there is something at the binary level that is turning off that capability (the mixes) on the server side.

  2. Any specific concerns here, especially moving forward? Meaning, would this end up being similar to running Sonic Analysis once, and then staying with that analysis without running it again - which is what I’m considering - or do you foresee any other potential issues in future database upgrades and what not? The usual “backup database” recommendations are definitely being accounted for, but thought I’d ask.

I’d like to hear from the devs/team, even if it’s just a “theoretically it might work” or “no it won’t because of X”. I fully understand that this is very likely not supported. I’ll also likely end up trying it at some point, unless someone tells me out of the gate that it won’t work so I don’t waste my time, but any tips here would be great.

Thanks, and have a great weekend!

2 Likes

not dev, but see related post/thread @ Sonic Analysis - has processed 6 albums in 40 minutes - #73 by TeknoJunky

the analysis data is linked to the media items locations/paths/ID’s in the database, keeping that all together is difficulty.

you are going to be better served by permanently adding/moving your music library to a more capable server. You can leave your videos hosted on RPI, and setup a separate music server on a more appropriately powered PC.

Thanks. That’s a good pointer - I will have everything in the same path, as I am planning on migrating the database and keeping everything running in the migration. That being said, fully noted, and I’ll be double careful with it.

I could consider moving the music server elsewhere, but unfortunately I do not have the hardware - my laptop is my work laptop, it’s not always turned on, nor online, nor with me. And I don’t have a desk PC.

I’ll keep you all posted, but it’d be a shame to find out at the end that mixes feature is flag-disabled on ARM systems. We’ll see!

you do realize, that even if you get it working, as soon as you add any new music content, it won’t be able to be analyzed, and then you have to do the whole (clone/move > analyze > clone/move) process over again.

it is just not that worth it. IMO.

@TeknoJunky apologies for the delay here.

I am aware of that, but given that my music library doesn’t change much, it is a process I’m willing to endure. I’m basically mounting over the same file and data paths across two unix folders (well, for the most part - I need to keep the respective Preferences.xml file). The database move works well, and the data works well as well, so the process isn’t that cumbersome to be honest, but I get where you’re coming from. In my case, worst case scenario, every month or so I’d just mount the folder on my x86 Linux laptop and scan new songs.

The reason for the delay is that it took me the last 3-4 days to run the analysis on my library.

Alas, even with the updated database and the resulting “Music Analysis 1” folder and databases (Album.tree, Artist.tree, Mapping.db and Track.tree), while the option to start Track Radio shows up, it can’t play the tracks - it says there are 0 sonically related tracks.

I checked the permissions, and things seem to be in place, exact same paths and folders, so I wonder: is there something in the ARM binaries that’s just preventing this from working? The hard part - the computation, for which there are no ARM libraries for - has been done and imported.

The .db file is a plain sqlite database with a simple mappings table. I imagine that the tree files are where the relationships are stored.

Is there anything else I should or could be looking into, or would it be unreasonable to ask for these features (not the analysis, but the experience) to be available for ARM provided the metadata is there? Or perhaps it is already there and should work, but it’s just something on my end?

Finally, even if it’s not working, would it be useful to store the results of the analysis (Music Analysis 1 path) for the future, assuming that I also keep the same database with the same indices?

Thanks all, and apologies for the trouble.

did you clone the entire databases folder, or just the main db?
you may need to ensure the whole folder is cloned.

and of course it may simply not work on arm, even if the required data exists.

it wasn’t clear from your post, did you confirm it does work on the x86 laptop?

Apologies, you’re right, I didn’t state it.

It works perfectly fine on the x86 laptop - there was a small issue at the beginning, as the process crashed, but restarting it rebuilt the index and then it worked fine.

The Plex Media Server folder - and all the media - is on an external drive. I am just plugging it in and mounting it in the different machines, so the entire folder, database, data, caches, etc, are exactly the same files. I use a symbolic link to mount it in the same path in both systems.

It works on the x86 Linux, but on the ARM device states that it can’t find more related songs. Oh well, it’s probably the case that it might not work on ARM even if the data exists :slight_smile:

Thanks for being on top of this though. If anyone else tries it or has other angles to try out, I’ll be happy to try it out. I might try out your approach of having a separate music library on the x86 laptop, that I’ll only use when I’m working (I suppose it’s a compromise), though if I could run this in the same system even without being able to update the analysis data, that’d be my preference for the sake of keeping things tidy and in the same place.

Have an awesome day!

1 Like

I’m also running my Plex server on a Raspberry Pi 4 and as a lot of ARM users, I’ll be extremely happy to use Sonic as well.
So, if it’s possible to make it works the way you trie here it would be a great step !

Also, maybe the Sonic team is working on an ARM version of this feature ?

Unfortunately, as mentioned in multiple threads, the libraries needed for the Sonic analysis aren’t available for ARM architectures, so for now there are no plans.

That’s why I tried to see if I could get the computation to be done elsewhere, but so far I’m a bit stuck. Either the team considers having the server-side ready to work with this data model (assuming it’s possible, which it may not), or maybe it already is and I’m just missing something very obvious, hence my attempt at starting this thread.

Ok, so a few more findings - and tagging @TMC who was also interested in this use case, in a separate thread.

I tested a few scenarios on my x86 and ARM Linux devices (bolds for the Sonic data):
A) Pre-sonic DB, no “Music Analysis 1” folder
B) Pre-sonic DB, with “Music Analysis 1” folder
C) Post-sonic DB, no “Music Analysis 1” folder
D) Post-sonic DB, with “Music Analysis 1” folder

Also, for labeling scenarios, I’m referring to x86 and ARM as the two scenarios.

A) Pre-sonic DB, no “Music Analysis 1” folder
This scenario works the same in x86 and ARM, and it’s exactly what Plex worked like prior to the Sonic analysis feature being released. No changes there.
The only difference is that in a x86 device I have the option to enable Sonic Analysis, which will proceed to analyze the library.

B) Pre-sonic DB, with “Music Analysis 1” folder
This scenario works differently across ARM and x86.
In ARM, there are absolutely no changes - works as previous Plex did.
In x86 it will display the “Sonically Similar Artists/Albums” information on Plex (Web, at least, I believe on PlexAmp as well). It does not enable “Play Track Radio” options, nor “Album Radio”, etc. It does not suggest Sonically Related tracks on PlexAmp.

C) Post-sonic DB, no “Music Analysis 1” folder
This scenario works the same in x86 and ARM. It enables the “Play Track Radio”/Play Album radio options on PlexAmp. It does not show Sonically Related Artists/Albums, nor present sonically related suggestions. Alas, in both scenarios it will not work because (I assume) it will need the data in the Music Analysis 1 folder to retrieve related items. We get a “found 0 sonically related tracks” etc.

D) Post-sonic DB, with “Music Analysis 1” folder
This scenario works differently across ARM and x86.
On x86, it works as intended: Sonically Similar items get shown in the UI, sonically related songs show up, you can start Track Radio, etc.
On ARM, however, it works the same as scenario C: we get the “Play Track Radio” entry, but it can’t find any sonically related tracks.

Once again, this is exactly the same data in the same file structures - my media and Plex Media Server data folder are in an external drive, which I symlink from /var/lib/plexmediaserver/Library/Application\ Support/. Permissions are catered for, etc. Both systems are Linux, I just change the Preferences.xml file so that they register as two separate servers. For sanity checking, I migrated the same setup to my wife’s work Macbook, and it behaves exactly as the x86 Linux machine (i.e. it works well, and results are equally replicable there).

Following @TeknoJunky 's sound remarks, this has zero chances of working in a setup where paths change - which would include migrations across Operating System with different path separators.

Based on the fact that scenarios C behave the same across ARM and x86, but that scenario D works like C in ARM make me think that for some reason Plex is unable to access the Sonic analysis database.

My hypotheses for that, off the top of my head:

  1. It’s a Sonic database location issue;
  2. It’s a permissions issue;
  3. The code path simply isn’t available in ARM binaries;

For 1), I have no idea why it would be located elsewhere, and I have no idea to assess that as even with a Debug log there is no message around “can’t find XXX”.

For 2), it’s a possibility, but the permissions seem to be correct - plex:plex for all. And it works in Mac and x86 Linux with the same permission setup, so I’m not strongly inclined to this option.

For 3), it’s a likely option, with a few potential reasons:

  • There are other x86-specific libraries that are required for this to work when playing back these mixes, and as such it is disabled for ARM.
  • It simply is disabled as the feature wasn’t really expected to be of use for ARM - meaning, there is no expectation on ARM for that folder to exist.
  • It is disabled because of the same compile-time or runtime flags that enable “Sonic Analysis” (and that aren’t shown on ARM).

Hoping that it not the first option (also, because the explanation in the FAQ for its absence is that “Unfortunately, the neural network libraries required for the sonic analysis are not currently available for ARM-based processors. That means that this feature is currently only supported for Plex Media Server running on x86/x86-64 processors”) and assuming it is a fairly risk-free change (as in its absence it seems to behave exactly as previous Plex) would it be possible to get this code path to be active for ARM, meaning, if the folder is present, use its data to show Sonically Related items and play Track/Album radio, thus fully supporting the data migration path across system since (if) the playback does not depend on x86-specific libraries?

Tagging @elan for awareness if possible, as he was also involved in answering another Sonic Analysis thread, so he might be more informed about this area and can certainly clarify any parts we’re missing here.

Above all, thank you @TeknoJunky and everyone who’s been involved in supporting the community in this rollout, and the entire team for putting together this awesome feature. I am just trying to see if there is an option to relieve the possible code-constraints on ARM for this feature to support this.

Have an awesome weekend.

EDIT: And I will say, the mixes I’m getting have been so far stellar. It’s great to be able to explore my library this way, and listen to songs that hadn’t surfaced often so far but that make a lot of sense in the mixes. Thank you!

3 Likes

It’s this, the code isn’t compiled in on ARM.

Thanks for confirming.

If that is the case, and I know that it might be not completely trivial, but given that:

  • The code seems to behave the same without the “Music Analysis” folder, whether it is compiled there (x86) or not (ARM) - so for all the users without the folder, it will behave the same;
  • That particular part of the code doesn’t seem to depend on x86-specific libraries;
  • Enabling that code could allow for migration of this set of data and usage in other platforms (in, admittedly, edge cases);

if the team could consider having that specific part of the code (mixes, radio and sonically similar albums/artists being shown by the frontend) compiled in on ARM, it would be awesome.

I do understand that it might mean “more code to test”, but I am hoping that it isn’t such an extensive part of the code - and that it is decoupled enough - that it could be considered at some point with minimal downside and potential benefits for part of the user base.

Thank you for taking the time and, once again, congratulations to the team.

2 Likes

Based on the responses to launch, I’d actually be open to trying to get things to run completely (but slowly) on ARM. The issue with just enabling the usage is that it’s hard to partially light up a feature, if you know what I mean.

Main issue is just finding time for working on seeing if the deps build on those platforms.

Really appreciate your kindness.

3 Likes

Fully get that - wasn’t looking for that to be a path for adoption, but rather an “unintentional non-locking of a feature” so a few could at least start using it :slight_smile: But I completely understand that and respect that angle.

For what it’s worth - and without knowing the exact set of dependencies, but from what I recall from the logs, the process seemed to use ffmpeg for the conversion to wav (which you probably already used anyway for transcoding), and TensorFlow at least.

I do recall a few years ago hearing about TensorFlow and ARM boards, but I only found this for TensorFlow Lite (which I don’t know what it means, or whether it supports your use case).

I did explore, in my case, trying to run Plex on my Raspberry Pi (ARM) under box86 - which is similar to Wine, in that it is a Linux Userspace x86 Emulator targeted at ARM Linux devices - but since it only supports ARM32 I gave up, as I’m on ARM64.

So that’s as far as I went, in case it can help the team in any way.

One thing that you could explore, if easier (unsure how?) would be to allow for a user to run the process on another server in their account, provided it had the necessary hardware - or even to allow for distributed computation. Meaning, you’d send over the audio file, compute whatever needs to be computed, and then send back the results to be stored in the database. To be fair, I’d expect (assumption) that many people would be able to install a Plex Media Server on a “not-always-on” computer to handle the analysis, and potentially - as you already have the “local discovery logic” in place for casting to other Plex devices, if the device would be in the same network you could just connect directly and not use the internet for that data transfer.

Not the ideal setup, to be honest, but lacking running these on a Plex cloud, using fingerprints and such, this is as close as I’d get to making this happen in a scenario where it is impossible to run the libraries on ARM.

Well, enough rambling on my end. Do let me know if there’s anything I can help with/test/something. On my end, I’ll be excitedly waiting for future developments, whatever they may be :slight_smile:

Have a great weekend!

2 Likes

I would be very interested in this also - I typically use a Odroid N2+ server for Plex but I am currently I have setup my work MacMini to run the music analysis using Rosetta (mapping the folder structure so the paths to the music should be the same). It seems it might take 4-5 days :grinning: - but I would love to transfer the results back to the Odroid - I would be willing to write some SQLite tools / scripts if the Music Analytic DB structure was published (or at least mostly stable).

1 Like

Just here to say that now, especially with having to be back to the office, I can no longer use my x86 laptop as the Plex server (as my music is in a NAS, and the laptop is with me), so if there’d be the possibility of considering opening the code path on the ARM builds to show the information if present and use sonically related content for the mixes it would make a tremendous difference here.

Keep up the great work!

Hi all, and happy Thanksgiving for those who celebrate it.

I wanted to re-bring up this small plea of enabling the usage in ARM devices if it’s just compiling the working code in, even without the ability to perform the actual analysis.

I understand it doesn’t address the larger ARM-devices needs, but unless I’m missing something, having the working code compiled in doesn’t seem to hurt anyone, while it could benefit a few who are in this scenario.

The truth is that since I’ve been back to the office for the past few months I have very much missed the track mixes that the Sonic Analysis allowed for, as the normal artist mixes end up going through much of the same songs more often than not.

Please consider it if the code is already written, working, and is just not being compiled in for an apparent lack of use case.

Thank you, and apologies for keeping asking for this. Hope everyone is staying safe.

1 Like

it’s a bit trickier because we need to build the new dependencies for ARM. might not be that hard, but not trivial.

2 Likes

Thank you for the reply, and that’s completely fair.

I suppose that I’ll keep hoping that it makes it at some point :slight_smile:

Have a great weekend!

If possible, would look forward to this so much!