Kodi Community Forum
Win CPU Usage Mystery - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: PVR & Live TV Support (https://forum.kodi.tv/forumdisplay.php?fid=167)
+---- Forum: Windows Media Center (WMC) (https://forum.kodi.tv/forumdisplay.php?fid=205)
+---- Thread: Win CPU Usage Mystery (/showthread.php?tid=216983)

Pages: 1 2


CPU Usage Mystery - tufkal - 2015-02-01

Hello Kodi WMC folks, first post here so be gentle.

I have been using XBMC + WMC w/ ServerWMC happily for quite some time on my HTPC. It is a simple small form factor PC, with a Pentium Dual Core CPU, 4GB RAM, and a Hauppauge HVR-2250 getting OTA channels with a roof mounted antenna.

I recently had some time off and decided to update my media center PCs, and updated to 14.0 Kodi from Gotham. Everything went great, except my OTA TV via ServerWMC. I previously had no problems whatsoever, and with no changes to the hardware I now have what presents as a hardware limitation.

The problem is on HD channels, I get desynced audio and stutter on the video. CPU usage is 99% when this occurs. I can tune SD channels and watch them, but the CPU goes to near 80% to do this.

I assumed that something in the code had changed, so I went into my bag of parts and upgraded the CPU to a Core 2 Duo (from PDC). This helped, but only slightly. HD is still impossible to watch, and SD consumes over 50% CPU usage.

I understand that ServerWMC remuxes the .wtv live buffer file into a .ts container, which can be played as a stream by Kodi. What I don't understand is what changed, and why it worked before?

I have done many (10+) reinstalls of fresh Windows 8.1, each time using a different version of serverwmc and pvr.wmc, or different settings in some area. No changes.

The tuner card is fine, and works in WMC just fine (full HD, 15% cpu usage). I also tested it works with NextPVR without problems.

I have no problem reinstalling Windows many more times if I have to to fix this problem, and can provide any logs from any section of the process that might help someone help me.

The biggest question is....why did it work in Gotham? What changed? Does Kodi not use hardware acceleration on .ts streams in 14.x? Did I do something special I'm not remembering to my Gotham setup to make it work? Any ideas?


..(I realize in re-reading this I keep referring to Gotham vs Kodi, when i really mean Gotham vs Helix or XBMC vs Kodi. Sorry for any confusion).


RE: CPU Usage Mystery - krustyreturns - 2015-02-01

You mention that you played around with swmc/pvr.wmc versions. Did you every try just going back to gotham? From what you write it sounds like that was the offender right? Not that it would be a solution to downgrade, I'm just wondering.

When you upgraded the cpu, what did the cpu usage change to for hd? Does the audio still get out of sync? Also have you looked to see the process that is eating most of he cycles? Did you re-install windows after the cpu upgrade?

Swmc does need to repackage the tuner output file (wtv) to a 'ts' file for streaming, but that has been true from day one and the algo has only changed slightly as swmc has progressed. Is recorded tv also pegging your processor or just live-tv?

There might be a clue if you post a serverwmc log (on pastebin.com) when you are playing back hd video. Also let us know the versions of serverwmc and pvr.wmc that you are running and what you were running when things worked.


RE: CPU Usage Mystery - tufkal - 2015-02-01

(2015-02-01, 18:34)krustyreturns Wrote: You mention that you played around with swmc/pvr.wmc versions. Did you every try just going back to gotham? From what you write it sounds like that was the offender right? Not that it would be a solution to downgrade, I'm just wondering.
I have not tired to go back to Gotham no, so many things are broken with 13.2 now that addon authors have updated to Helix. I suppose I could try for diagnostic purposes, but I feel like the answer should be simpler to find.

(2015-02-01, 18:34)krustyreturns Wrote: When you upgraded the cpu, what did the cpu usage change to for hd? Does the audio still get out of sync? Also have you looked to see the process that is eating most of he cycles? Did you re-install windows after the cpu upgrade?

CPU usage for HD is still 99%, out of sync audio, stutters even with the much better CPU. I know it helped, because CPU usage on SD shows is lower. And yes I reinstalled Windows many times before and after the CPU change. The CPU upgrade helped the system overall alot, and helped the SD remux, but still not enough for HD. The process is the Kodi.exe process (not ServerWMC or any WMC service/process). Being in Windows I am limited in my options to tear into the process threads to get any deeper.

(2015-02-01, 18:34)krustyreturns Wrote: Swmc does need to repackage the tuner output file (wtv) to a 'ts' file for streaming, but that has been true from day one and the algo has only changed slightly as swmc has progressed. Is recorded tv also pegging your processor or just live-tv?
Recorded TV is fine, it's just playing back the .wtv file at that point. Also background recording is fine, as WMC is just creating the .wtv file.

(2015-02-01, 18:34)krustyreturns Wrote: There might be a clue if you post a serverwmc log (on pastebin.com) when you are playing back hd video. Also let us know the versions of serverwmc and pvr.wmc that you are running and what you were running when things worked.
I'm not sure what I was running in Gotham, but it would have been whatever was in the official repo at the release time of 13.2.

Logs: http://pastebin.ca/2913932
ServerWMC Version: 1175 (from http://bit.ly/ServerWMC)
pvr.wmc Version: 0.3.108 (from http://bit.ly/ServerWMC)

Was me tuning in to channel 13.1 for around 30 seconds, enough to watch a HD commercial desync and slowly degrade to the point the audio from the next one was starting before the current one was done showing on screen.


RE: CPU Usage Mystery - tufkal - 2015-02-01

Here are some more logs, I let it run a bit longer these times (~2mins)

http://pastebin.ca/2913938


RE: CPU Usage Mystery - krustyreturns - 2015-02-01

Looking at the first log you posted there is a major delay where swmc is stopped from getting new tuner data, and writing out data to the ts file. Its here:

2015/02/01 11:21:43.706 StreamFileSize> client HTPC-PC, count: 5, ts stream size: 42,336,256 (wtv: 522,977,280)
2015/02/01 11:21:46.831 StreamFileSize> client HTPC-PC, count: 10, ts stream size: 42,336,256 (wtv: 522,977,280)
2015/02/01 11:21:49.888 StreamFileSize> client HTPC-PC, count: 15, ts stream size: 42,336,256 (wtv: 522,977,280)
2015/02/01 11:21:53.041 StreamFileSize> client HTPC-PC, count: 20, ts stream size: 42,336,256 (wtv: 522,977,280)
2015/02/01 11:21:55.934 Parse> Last number of attempts for Guid header was large: 3786
2015/02/01 11:21:55.949 WriteChunk> long interval between writes (ms): 15674

Not sure if is caused by a disk problem or by the fact that the cpu is overloaded. Its interesting that hd wtv files are playing fine. Go to the debug tab in swmc and turn off 'delete temporary files'. Then play a hd live stream for a while, like a minute or two. I assume this will be laggy. After you stop this, then play back the ts file that's in the folder tempswmc located in your recorded tv folder. Does the ts file playback okay in kodi?


RE: CPU Usage Mystery - tufkal - 2015-02-02

I watched 2 minutes of Tom Brady talking to Bob Costas, which had very bad audio desync and video stutter. At a few points the video got fast and the audio re-synced, but then shortly afterwards because of the stutter, the audio desynced, repeat repeat repeat.

It had a clean log:
Code:
2015/02/01 16:46:32.700 OpenLiveStream> -----------------done-------------------------
2015/02/01 16:46:32.703 Finished request OpenLiveStream in 7.30s
2015/02/01 16:47:24.784 Received client request: HTPC-PC|127.0.0.1|GetTimers
2015/02/01 16:47:24.786 Finished request GetTimers in 0.00s
2015/02/01 16:47:24.792 Received client request: HTPC-PC|127.0.0.1|GetRecordings
2015/02/01 16:47:24.802 Finished request GetRecordings in 0.01s
2015/02/01 16:49:03.744 Received client request: HTPC-PC|127.0.0.1|CloseLiveStream
2015/02/01 16:49:03.744 CloseStream> -----------------start------------------------

I made the change you suggested, and then went to playback to .ts and the .wtv files from the TempSWMC folder from Kodi's file manager. They were both 190MB. They both played perfectly, with no video stutter or audio desync.

That's at least something new to add to the equation that I had not tested before.

I thought you might be on to something with the hard drive. 190MB over approx 90s doesn't seem like it would be too much for the hard drive, but then again it is remuxing it into another file at the same time so it's really 380MB over 90s of disk I/O. The math on that comes out to be a bit over 4 MB/s in just writing, A quick run of HDTune shows the drive being used gets 100MB/s sequential read, and 43MB/s sequential write, so it appears it's not the fault of my HD being overtaxed.


RE: CPU Usage Mystery - scarecrow420 - 2015-02-02

do you have another device you could try as a remote client? See if the "server" is able to do the remux job, and remote client able to view it without issues?

In terms of hard drive speed etc it isnt just a matter of adding up the MB/s but if it is trying to read and write to/from different areas of disk and is seeking/jumping around etc that can have more of an impact than the pure 380MB over 90 seconds would indicate

It's interesting that once they are files on disk (and not being actively written to/remuxed) you say you can play back the WTV and TS file in Kodi just fine. When you have the maxxed CPU issue, what process is reported as consuming that CPU? Also if you show the Kodi overlay ("O" on keyboard) during playback, it shows you the video/audio stream types and os on... do you see any difference in what this shows when viewing a channel LIVE vs viewing the TS file afterwards?


RE: CPU Usage Mystery - IanPH - 2015-02-02

Hello tufkal. I was reading this thread and was wondering. What's the CPU load when playing an HD mkv?

Could it be that the Kodi build you installed broke video hardware acceleration for your specific hardware setup?
If you reinstall the version that


RE: CPU Usage Mystery - tufkal - 2015-02-03

Scarecrow,

I don't have another device I can try as a remote client, I'm all wireless and these MPEG2 wtv files are just too much for WiFi. But based on the test I performed that I explain below, I think it would be fine if sending it to another client.

This really makes things interesting (or confusing depending on how you look at it).

I started watching a HD channel in Kodi, saw the usual audio de-sync and video stutter, then I hit CTRL+ALT+DEL and brought up task manager. I killed the Kodi process the hard way, without letting it signal a clean close. This means that WMC was still writing the .wtv file, ServerWMC was still reading it, remuxing it, and making the .ts file. Kodi was closed, but ServerWMC and MCE were still doing there job.

I then opened the .ts file with Windows Media Player. I have now been watching close to 10 minutes of an HD program with absolutely no problems. MCE is still making the 500MB+ wtv buffer file, and ServerWMC is still remuxing it into the .ts file on the fly as I'm watching the .ts file with Windows Media Player.

Basically I interrupted the process and switched which piece of software is playing the .ts file.

CPU usage is where it should be, around 30%.

So......the internal Kodi playback engine can't play the .ts file correctly?? ...and Windows Media Player can? I'm having a hard time wrapping my head around what I'm seeing, but I am seeing it with my own eyes. I've tried this twice now in WMP just to make sure I'm not going crazy, and it's still working perfectly.

*NOTE: Works perfectly with VLC playing the .ts file too, just in case WMP had some proprietary codec helping
**NOTE: Eventually ServerWMC stops remuxing because it realizes the Kodi client is not there anymore.



So....
-WMC is working, creating the 500MB+ live tv buffer file
-ServerWMC is working, remuxing it into the .ts file
-A media player can play the .ts file
All happening at the same time, with under 50% CPU, like it should be (and like it was in Gotham).

The CPU usage is coming from the media players (WMP, VLC, etc), but it is manageable like it sohuld be (and was in Gotham). As I said before, the process that consumed the 99% CPU was kodi.exe, so it's gotta be in the playback engine of Kodi for that type of file (MPEG2/AC3).

.....which is really really odd. Because that means one of 2 things:
-Kodi changed the way it decodes that kind of file, or
-ServerWMC changed the format of the .ts file

It's unlikely Kodi changed MPEG2 or AC3 decoding, as they are such common codecs, and I believe you scarecrow when you say that remux algorithm hasn't changed at all.

...my head hurts now...


RE: CPU Usage Mystery - Dilligaf - 2015-02-03

Try renaming c:/users/User_name/AppData/Roaming/kodi and xbmc if it still exists then run Kodi and resetup everything then see if the problem still exists. I'm thinking there's something causing problems in your settings or in the update from xbmc to kodi. Renaming these directories will cause it to act like a fresh install. If it works you can copy your databases from the renamed folders


RE: CPU Usage Mystery - scarecrow420 - 2015-02-03

So you did test Kodi playing back the completed ts file right? And that was ok? If so it's even weirder that it only has trouble with the "growing" ts file

Kodi has all sorts of hardware/software decoding settings etc (iit uses ffmpeg and there certainly would have been newer ffmpeg changes included in Kodi compared to XBMC) so I do think it more likely to be your Kodi configuration than anything else. What video card do you have? Dilligafs suggestion will be good to test. Also confirming my question above about ts file playback after remux has finished, and checking video file information (O on keyboard while viewing)


RE: CPU Usage Mystery - tufkal - 2015-02-03

(2015-02-03, 05:45)Dilligaf Wrote: Try renaming c:/users/User_name/AppData/Roaming/kodi and xbmc if it still exists then run Kodi and resetup everything then see if the problem still exists. I'm thinking there's something causing problems in your settings or in the update from xbmc to kodi. Renaming these directories will cause it to act like a fresh install. If it works you can copy your databases from the renamed folders

As I explained in my first post, I have done multiple re-installs of Windows, each time installing Kodi fresh. I do the WMC, ServerWMC, and pvr.wmc setup before I even turn off the RSS feeds in Confluence, or add a single media source. It is always a fresh folder/install each time I have tried it, and it is always the first thing I do.


RE: CPU Usage Mystery - tufkal - 2015-02-03

(2015-02-03, 17:01)scarecrow420 Wrote: So you did test Kodi playing back the completed ts file right? And that was ok? If so it's even weirder that it only has trouble with the "growing" ts file

Kodi has all sorts of hardware/software decoding settings etc (iit uses ffmpeg and there certainly would have been newer ffmpeg changes included in Kodi compared to XBMC) so I do think it more likely to be your Kodi configuration than anything else. What video card do you have? Dilligafs suggestion will be good to test. Also confirming my question above about ts file playback after remux has finished, and checking video file information (O on keyboard while viewing)

Yeah, when you suggested I turn off the file deleting in debug mode, I was able to play the ts file from within Kodi without issue. So it would indeed be a 'growing' ts file issue. The video card in use is a GeForce 7100 IGP, nothing special just has HDMI out basically.

I will check the file video information during a stream tonight.


RE: CPU Usage Mystery - Dilligaf - 2015-02-03

(2015-02-03, 17:16)tufkal Wrote:
(2015-02-03, 05:45)Dilligaf Wrote: Try renaming c:/users/User_name/AppData/Roaming/kodi and xbmc if it still exists then run Kodi and resetup everything then see if the problem still exists. I'm thinking there's something causing problems in your settings or in the update from xbmc to kodi. Renaming these directories will cause it to act like a fresh install. If it works you can copy your databases from the renamed folders

As I explained in my first post, I have done multiple re-installs of Windows, each time installing Kodi fresh. I do the WMC, ServerWMC, and pvr.wmc setup before I even turn off the RSS feeds in Confluence, or add a single media source. It is always a fresh folder/install each time I have tried it, and it is always the first thing I do.

But did you delete the kodi and xbmc directorys in /roaming between reinstalls? They contain settings and will not be removed by an uninstall or overwritten by a new install


RE: CPU Usage Mystery - tufkal - 2015-02-03

(2015-02-03, 17:52)Dilligaf Wrote:
(2015-02-03, 17:16)tufkal Wrote:
(2015-02-03, 05:45)Dilligaf Wrote: Try renaming c:/users/User_name/AppData/Roaming/kodi and xbmc if it still exists then run Kodi and resetup everything then see if the problem still exists. I'm thinking there's something causing problems in your settings or in the update from xbmc to kodi. Renaming these directories will cause it to act like a fresh install. If it works you can copy your databases from the renamed folders

As I explained in my first post, I have done multiple re-installs of Windows, each time installing Kodi fresh. I do the WMC, ServerWMC, and pvr.wmc setup before I even turn off the RSS feeds in Confluence, or add a single media source. It is always a fresh folder/install each time I have tried it, and it is always the first thing I do.

But did you delete the kodi and xbmc directorys in /roaming between reinstalls? They contain settings and will not be removed by an uninstall or overwritten by a new install

I am completely re-installing Windows and formatting my hard drive each time.