Page 1 of 1

ffmpeg, kill, cpu, again

PostPosted: Tue Nov 28, 2017 2:54 am
by tcriss
Hi,

Sorry to ask the same question I saw being asked a number of times on these forums.
I could not find a real answer to it.

I understand that somehow, it is 'by design' to avoid stopping ffmpeg even if the user stops playing the video.

1. What is the purpose of keeping ffmpeg running? Why is it 'by design' like this?

Please don't just say 'is by design', that doesn't help. If there is an explanation in some other place, just send me the link please.

2. Is there a way of doing it automatically when the video stops? (no, don't say killall ffmeg, it not automatic and I am in front of my tv, not ssh-ing into my server, come on)

3. why is it that ffmpeg takes up the whole cpu power? 1 core or 10, seems that it always uses 100% available cores/threads.
Is there a way to 'nice' the use of ffmpeg in serviio? To avoid using the whole cpu?


Thanks,
Chris

Re: ffmpeg, kill, cpu, again

PostPosted: Tue Nov 28, 2017 10:46 am
by lagunaa
tcriss wrote:I understand that somehow, it is 'by design' to avoid stopping ffmpeg even if the user stops playing the video.

According to ticket #427:
Stop server now stops all FFmpeg processes and cleans the temp folder

so it should be fixed if you're on version 1.6.1 or above.
Cheers.

Re: ffmpeg, kill, cpu, again

PostPosted: Tue Nov 28, 2017 11:38 am
by atc98092
The main issue is that the DLNA protocol does not have anything that tells the server that the device has stopped playback, other than requesting a new video to begin playing to the same device. There's nothing to tell Serviio that playback has stopped. So unless you request a new video (that doesn't require any transcoding), there's nothing to stop ffmpeg until it reaches the end of the video.

Re: ffmpeg, kill, cpu, again

PostPosted: Tue Nov 28, 2017 12:48 pm
by tcriss
HI, thanks for the answers

stopping the server is not what I want, I want to avoid using ffmpeg when playing the video stops, without any other user intervention (to me this sounds perfectly reasonable)

I understand now that the DLNA protocol does not signal in any way that video playing was stopped.
Anyway, isn't there a way to detect, via polling the network maybe, if streaming continues or not?

thanks
Chris

Re: ffmpeg, kill, cpu, again

PostPosted: Tue Nov 28, 2017 2:07 pm
by atc98092
That's a question for Zip to answer, but my guess is that it isn't worth the effort. Most computers can handle ffmpeg running in the background, regardless of the CPU load. I know I can still use my computer, even when ffmpeg is showing almost 100% CPU usage. But that certainly varies based on the computer hardware.

Re: ffmpeg, kill, cpu, again

PostPosted: Tue Nov 28, 2017 2:21 pm
by zip
Yeah, imagine pausing the video while you have a phone call, coming back 20 minutes later and having to play from the beginning. Any other workaround is not 100%, so it's cause more troubles than it solves.

For ffmpeg usage, you can limit number of cores to use - for some encoders anyway - which might limit the usage. But usually, when you want smooth playback it's best to have FFmpeg finish ASAP.

Re: ffmpeg, kill, cpu, again

PostPosted: Tue Nov 28, 2017 7:30 pm
by tcriss
Ok,
the only thing that makes sense is that is non-trivial to implement (if DLNA does not signal stopping the player).
Otherwise, using the cpu is just a waste of resources. Is useless since watching has stopped.

*if* you start watching again, then yes, start transcoding again.
No need to 'optimize' this by leaving ffmeg running 'just in case' you want to resume something.

what if I stop watching a full movie after 2 minutes and come back later, after two hours? and all this in a low power home server (which has enough power for transcoding, but no need to waste it)?

Transcoding process should be 'owned' by the dlna server (it is started by the server and stopped by the server).
It's plain simple and reasonable.

I have no idea if other dlna servers allow this, but it would make perfect sense.
Thanks

Re: ffmpeg, kill, cpu, again

PostPosted: Tue Nov 28, 2017 10:11 pm
by atc98092
tcriss wrote:
what if I stop watching a full movie after 2 minutes and come back later, after two hours? and all this in a low power home server (which has enough power for transcoding, but no need to waste it)?


If that particular player has not requested a different movie, then it will play the file that have already been transcoded, without needing to be done again. The transcoded file is not deleted until that particular player asks for a different video.