Subsonic FFMPEG playback - nice value

General discussions.

Moderator: moderators

Subsonic FFMPEG playback - nice value

Postby mbro » Sat Dec 21, 2013 6:49 pm

Hi all. I've been running Subsonic for a year or so, and absolutely love it. With my setup, I have a subsonic "appliance" (an old PC running Debian 12.04 off a CF card) with its audio output piped into my home stereo. My music is all stored on a NAS appliance on the network. I use a tablet to control it, and have music throughout my house. I've upgraded to Subsonic 4.8, and everything is working, but I have another thought. Because my "appliance" is a little under-powered, when using my remote (tablet) and the appliance is doing playback, periodically it stalls briefly - there's a disruption in the audio playback because subsonic is reading the library, or performing a search. If I renice ffmpeg to -20 while its playing back, then there's no problem.

So my question is this... Currently, when audio playback starts, the niceness value of ffmpeg is 0. If I renice ffmpeg to -20, the playback is smoother. So what launches ffmpeg? Can a config file somewhere be adjusted to launch ffmpeg playback with an alternate nice value? I looked to see if there's a config file for ffmpeg (ffserver.conf), however it doesn't appear there's a value or field for specifying a nice value. I could cron a script that runs every 3 seconds and looks for ffmpeg in the ps -A output, parses for the pid and executes a renice -20 on that pid, but thats not "elegant".

Any guidance here?
mbro
 
Posts: 23
Joined: Fri Mar 30, 2012 9:59 pm

Re: Subsonic FFMPEG playback - nice value

Postby mbro » Sun Dec 22, 2013 9:51 pm

Ok, so I was chattin' with my homey, and he had a good idea. He thought about a script to run that would loop and set the re-nice value to -20 and loop every 2 seconds. Script looks like this:

/root/ffmpeg_renice.sh (I chmod +x'd it) contents:

while true; do renice -20 `pidof ffmpeg` ; sleep 2 ; done


Saved that, chmod +x /root/ffmpeg_renice.sh
Now it needs to run. So as a test I ran " /root/ffmpeg_renice.sh & " and away it runs. Sweet! But I also needed to make it run at startup. So the next idea was add this to crontab:
crontab -e

Add the following to the crontab file:
@root /root/ffmpeg_renice.sh

So with that added, when it restarts, this will run and ffmpeg will be re-nice'd every 2 seconds set to -20 (high priority). More testing going on.

Anybody else got another approach?
mbro
 
Posts: 23
Joined: Fri Mar 30, 2012 9:59 pm

Re: Subsonic FFMPEG playback - nice value

Postby Jebba » Sun Dec 29, 2013 12:01 pm

i´m looking for something simillar!

I have an ARM Qnap box that sometimes cannot feed the USB soundcard its music stream without hickups. You apparently identified ffmpeg as the stalling process for on-server sound processing?
Jebba
 
Posts: 21
Joined: Sun Jul 28, 2013 9:43 pm

Re: Subsonic FFMPEG playback - nice value

Postby mbro » Wed Jan 01, 2014 8:31 pm

I'm not entirely sure that ffmpeg is stalling, but more like other high priority threads and processes steal necessary CPU cycles and disrupt the audio stream. I've tried re-nice ffmpeg, tried altering its priority and making ffmpeg a realtime process, but certain specific actions can still disrupt ffmpeg output. I'm considering going the other direction and altering the priority/niceness of processes that interrupt ffmpeg to be a lower priority. Subsonic 4.9beta3 seems to do a better job of playback, but I have some more testing to do.
mbro
 
Posts: 23
Joined: Fri Mar 30, 2012 9:59 pm

Re: Subsonic FFMPEG playback - nice value

Postby Jebba » Thu Jan 02, 2014 2:06 pm

Please keep us updated if you manage to find a solution :)

I talked with a buddy about this, who knows more about linux processes. He also pointed me into the corner of (re)nice, but also said it could be something with the USB controller that isn't prioritized compared to other hardware.
I'll try to get hold of him again if your lead doesn't pan out.
Jebba
 
Posts: 21
Joined: Sun Jul 28, 2013 9:43 pm


Return to General

Who is online

Users browsing this forum: No registered users and 4 guests