Transcoding issues, non-constant CPU load
Added by Marco Jakobs over 8 years ago
Hi,
some builds ago the transcoding was improved in a way that now the CPU "speed" can be selected. That's a good point, but the transcoding itself "breaks" in a strange way.
Before, the CPU utilization was quite equal over the time and all was fine. My Mediaserver-VM runs with 6 out of 8 allowed VCores on a Dual Xeon E5430 server, Plex demonstrates that there is pretty enough transcoding power.
But what TVH does currently, is a bit strange. I have a "Road" profile which transcodes down to 2MBit/s. When selecting a HD station, the transcoding does this:
- It utilizes the CPU with 600% (so all six cores at full load) for a short time
- Then the TVH process is not even visible in TOP in the first ranks, very low CPU ... stream goes on
- The stream stutters, picture gets "grey" in VLC on the IPad (direct WiFi connection!), CPU goes to 600% again for a short time, stream continues
- CPU load not noticeable
- Stream stutters, Picture grey, 600% load
- And so on
I have no idea how this is implemented, but it seems TVH decodes some 10-15 seconds with max CPU into a buffer, then does nothing. When the buffer runs out, it panics and tries to decode again with max CPU, but the buffer runs out before the new decoded data is there, hence the stutter and "grey" picture.
During these very short max CPU use even subscribers using a local simple "pass" profile with basically no CPU load will get problems. Also recordings (pass!) will be affected.
If TVH would to an equal transcode (as Plex does), the CPU load would be somewhere around 80%, but continuously and all would be fine.
Any experiences here before I raise a bug report here?
Replies (3)
RE: Transcoding issues, non-constant CPU load - Added by Martin Bednar over 8 years ago
Hi,
My first try would be to try using other OS facilities to limit tvheadend CPU usage.
If you use systemd, so the way to to do it would be to
a) edit tvheadend.service to enable CPUAccounting and set a CPUQuota.
ie adding to the service section :
CPUAccounting=yes CPUQuota=400%
b) create /etc/systemd/system/tvheadend.service.d, and in there create a file named (for instance) 50-CPUQuota containing:
[Service] CPUAccounting=yes CPUQuota=400%
This way you can switch off CPU limiting in tvheadend, and see whether that's where the bug is.
Edit : damn, completely misunderstood your post. Sorry. Leaving info here in case its useful to someone.
RE: Transcoding issues, non-constant CPU load - Added by Marco Jakobs over 8 years ago
Martin,
however, thank you for the hint. I've created a tvheadend.service to limit the CPU load to 500%, otherwise the system will completely be blocked in the short times TVH uses all CPU power. So Plex has at least a core to breath ;-)
I've raised a ticket for the issue.
RE: Transcoding issues, non-constant CPU load - Added by Marco Jakobs over 8 years ago
Cool, Martin! That service file seems to solve it, CPU load is now constant! :-)
It's still stuttering a bit on HD, the buffer seems not big enough, CPU is around 260% here now. SD works good.