modestimpala / OdinOnDemand

A mediaplayer mod for Valheim using SoundcloudExplode and YoutubeExplode
https://valheim.thunderstore.io/package/ValMedia/OdinOnDemand/
GNU Affero General Public License v3.0
1 stars 0 forks source link

stutter and cutout of audio #25

Open ZenDragonX opened 4 months ago

ZenDragonX commented 4 months ago

When playing audio from youtube it stutters often. after the song plays once it cuts out even though I have it set to loop.

It seems like it's either streaming the audio and having buffer underuns (not likely as I have 1gbps connection) or it's doing the decompression in the cpu in software instead of hardware acceleration?

Not sure what's going on. Sounds flawless when i listen to the same audio stream on youtube.

This audio track: https://www.youtube.com/watch?v=1t7W6NtTKAw&ab_channel=ThieveryCorporation

modestimpala commented 4 months ago

Thanks for the report, ZenDragonX.

Very odd. I just tested this on a theater screen and radio with that specific video and encountered zero buffering issues and it looped just fine.

Any other info you can provide? Did this change happen with a specific OdinOnDemand update? (downgrade) What mediaplayer objects are you encountering this issue on? Is it every YouTube video or just a select few? Try local videos, local audio, soundcloud, and remote videos: any issues there?

As you said I doubt it's an internet speed issue given your throughput, however, YouTube can still throttle connections which can be an issue with third-party libraries accessing videos like the one I use, YouTubeExplode.

It's also unlikely that it's decoding on the CPU and causing that issue, even if it were, I'd imagine most modern CPUs can handle simple video decoding or otherwise YouTube itself wouldn't work very well on computers without dedicated graphics cards. That sort of depends on Unity's decoding: we use the built-in Unity Video Player which handles the downloading and decoding of video files. It does not need to re-encode which would be the heavy hitter.

If you are playing with lots of mods, try a clean profile. I had a previous report of stuttering playback in heavily built up forts as well, although I did not encounter this personally.

You could upload your Player.log files of a clean profile and perhaps a video of the aforementioned issue and I can check them out, but this may be difficult to debug.

Regards Moddy

ZenDragonX commented 4 months ago

I am streaming audio only via the phonograph piece. No video. I run a lot of other mods so performance is critical. I have a 1070gtx gpu and i7 cpu. I get around 60-100fps in game. Stuttering seems to happen as I move around. Background loading of other objects perhaps? Is the audio being played on the main game thread ?

modestimpala commented 4 months ago

All videos play using Unity's Video Player, which is connected to an Audio Source. Gramophone only lacks a physical "screen" for the video to render to. That's why it's important for me to know if regular .mp3s have the same issue on your setup, because audio only files are downloaded and sent directly to the Audio Source.

Unity runs video decoding on a background thread, and if your hardware supports it, it leverages hardware acceleration to speed this up.

It's interesting that you have such high FPS but the video stutters. There are only a few tweakable settings for Unity's Video Player, when I have time I can cook up a special .dll for you to try but I'm not sure it will make a difference. I'm wondering if a different mod is causing performance issues.

We can try SimpleMonoProfiler to determine performance issues.

  1. Download Bepinex Plugin
  2. Place zip contents in Valheim folder
  3. Default profiler dump is ~ (tilde/backquote)
  4. Load your game save, get things playing, then hit the dump hotkey. Wait a minute or two, then dump it again.
  5. Take the most recent dump file (it should be considerably smaller) and upload it here for me to analyze.

    Warning: The profiler always runs and will noticeably slow down the game

Here's what my OOD performance looks like: image Column2 is call count, Column4 is total runtime and Column5 is memory allocation. The new dynamic radio system does lots of calls for Station Simulation, but keep in mind two things, I have several stations simulating playback in my setup, and total runtime is very low. Compare it to the remote control item, which shoots raycasts and used up way more runtime and even allocated memory. These values may not be totally accurate but can help find the root cause of the issue.

I'll likely need more information to help debug this. Mod list, Player.log, video of the issue.

Did this change happen with a specific OdinOnDemand update? Are other mediaplayer objects affected or only the Gramophone? Is it every YouTube video or just a select few? Try local videos, local audio, soundcloud, and remote videos: any issues there?

modestimpala commented 4 months ago

@ZenDragonX One extra note, you mentioned

Stuttering seems to happen as I move around

Try disabling the in-game volume mixer in OdinOnDemand\config.json image

Set "Fade" to "None"

Regards Moddy