Best way to reduce CPU use (by ~10%) during software encoding and decoding with minimal quality loss

Asked by Aaron Whitehouse on 2009-02-21

Hello,

I have just upgraded my HTPC (to one based on the AMD 780G chipset). The weakest link in my new machine is the CPU, which is a Sempron LE-1200 (instead of the 2.4GHz P4 in the old machine). While I thought the Sempron would be faster, it seems to be slightly slower at video encoding/decoding than the P4 was, meaning that my current settings (512x576, 2200 bitrate, MPEG-4, quality between 2 and 15, max 3 quality difference between frames, scale bitrate for frame size, HQ encoding and 4MV), which worked fine in Live TV (i.e. one encoding stream, one decoding stream, no DCT encoding, no interlaced motion estimation) on the P4, are slightly too demanding for the new CPU. The new CPU is sitting at around 90+% in Top and is the video is quite jerky. I am guessing that the CPU is hitting 100% on occasion, stalling the playback.

I have two cards in the machine - a bttv software encoder and a Hauppauge PVR-150 with MPEG-2 hardware encoding. I will probably switch the default card to be the hardware encoder (MPEG-2 takes heaps of room, but I have a new HDD), but I will still need to be able to record one hardware, one software and play one back. Playing MPEG-2 actually seems to take slightly more CPU than playing back MPEG-4, which surprised me.

So here is my question (after all of that background): I only think that I need to reduce CPU use by about 10%, but I am not sure which settings are the best to change in order to get that. Disabling 4MV or HQ encoding saves a lot, but the picture isn't very good. Tweaking the max and min quality makes some difference, but I'm not sure which to change. What is the best thing for me to change?

Thanks!

Question information

Language:
English Edit question
Status:
Solved
For:
Mythbuntu Edit question
Assignee:
No assignee Edit question
Solved by:
Aaron Whitehouse
Solved:
2009-02-22
Last query:
2009-02-22
Last reply:
2009-02-22
Nick Fox (nickj-fox) said : #1

I would suggest Disabling Commercial Flagging in the backend setup, also set your playback settings to CPU-- in the front end. Also disable transcoding jobs in the backend setup.

This might give you enough CPU back to have 'ok' playback, however don't expect High Quality or to do any HD video. Also, after looking at/answering your previous post, you are using the OSS ati drivers, if you switch to FGLRX you will gain some video performance back. However stating again, do not expect HD Video to work in these conditions.

Thank you very much.

I tried switching to the non-free drivers through the "Restricted Drivers Manager". Now I just get coloured dots and shapes instead of a desktop etc. X seems pretty stuffed on both D-Sub and HDMI.

What is the easiest way to uninstall the flgrx and go back to what it was using before? I can get to a terminal with Ctrl + Alt + F1 on the D-Sub.

Thanks.

Nick Fox (nickj-fox) said : #3

I think you might have a driver conflict if you are having these results. I
suggest checking to make sure you are actually using the correct drivers

# sudo dpkg -l | grep xorg-driver-fglrx

If you get nothing back fglrx is not installed. If it does come back with
the package info, try the following:

# sudo dpkg -l | grep ati

There should not be any ati packages other than the Ati Catalyst Control
Centre. If there are packages driver packages installed, do this:

# sudo dpkg --purge <package_name>

Then edit your xorg.conf and make sure in the device section:

Driver "fglrx"

Then restart gdm:

# sudo /etc/init.d/gdm restart

If its still not working try a reboot just for good measure.

-Nick

# sudo apt-get install --reinstall xorg-driver-fglrx

On Sat, Feb 21, 2009 at 6:20 PM, Aaron Whitehouse <
<email address hidden>> wrote:

> Question #61858 on Mythbuntu changed:
> https://answers.launchpad.net/mythbuntu/+question/61858
>
> Status: Answered => Open
>
> Aaron Whitehouse is still having a problem:
> Thank you very much.
>
> I tried switching to the non-free drivers through the "Restricted
> Drivers Manager". Now I just get coloured dots and shapes instead of a
> desktop etc. X seems pretty stuffed on both D-Sub and HDMI.
>
> What is the easiest way to uninstall the flgrx and go back to what it
> was using before? I can get to a terminal with Ctrl + Alt + F1 on the
> D-Sub.
>
> Thanks.
>
> --
> You received this question notification because you are a member of
> Mythbuntu Developers, which is an answer contact for Mythbuntu.
>

Thank you very much for your help, Nick.

That didn't fix my problem. There was a xserver-xorg-video-ati installed, which I couldn't uninstall because it was a dependency of xserver-xorg-video-ati. I force removed that and checked the other things that you suggested, but it didn't help. Now I can't reinstall the fglrx package because it complains that -ati isn't there. Are you sure that it shouldn't be installed?

I watched more carefully this time, and the desktop comes up okay, but as soon as Mythfrontend starts, the screen goes crazy - it is like some of the pixels (only some, most of the screen is black) from a band down the left side have been stretched across the whole screen. For example, if I move to the second virtual desktop (Ctrl + Alt + Right) and click in the top left corner, a group of white dots drops down (the applications menu) across the full width of the screen.

Any further help would be excellent. If we can't sort out Fglrx, is there an easy way to go back to the stock ati driver short of reinstalling?

Is the non-free driver likely to improve performance even though no video formats are specifically accelerated (no UVD support etc.)?

I've changed back to ati by doing a sudo apt-get -f install and then changing the xorg.conf to read "ati" in the device section.

Nick Fox (nickj-fox) said : #6

Aaron, I am currently in the Mythbuntu IRC support channel. If you can please join me there to work on your issue.

Channel: #ubuntu-mythtv on irc.freenode.net

Ask for help with this LP Question # and I will find you.

Nick,

It looks as though I have missed you, but thank you so much for all of
your help!

Nick Fox wrote:
> Your question #61858 on Mythbuntu changed:
> https://answers.launchpad.net/mythbuntu/+question/61858
>
> Status: Open => Answered
>
> Nick Fox proposed the following answer:
> Aaron, I am currently in the Mythbuntu IRC support channel. If you can
> please join me there to work on your issue.
>
> Channel: #ubuntu-mythtv on irc.freenode.net
>
> Ask for help with this LP Question # and I will find you.
>

This question has gone way off topic, so I have started a new question on my fglrx issues at:
Question #61979
https://answers.launchpad.net/mythbuntu/+question/61979
I have added to the question there, so please follow that if you were helping me with this!

The best answer to reducing CPU use without losing too much quality was to reduce the encoding resolution from 512x576 to 480x576.

Excellent!

I had a go at installing the official drivers from the ATi site and I was really impressed. I'll give details for anyone else who reads this page. You download a 75MB file. Then you run the installer and it figures out what Xorg, kernel etc you have and what you need. But here is the cool part: instead of just installing, you can get it to build packages for your distribution (i.e. "Ubuntu 8.10"):
./ati-restoffilename --buildpkg Ubuntu/8.10
(you can get a list from --listpkg)
Then you install those with Gdebi and you can manage them as with normal packages.

The increase in video quality was amazing, but the CPU usage amazed me: before the new drivers, recording MPEG4 was 30-40%, playing back MPEG4 was 30-40%, recording MPEG2 (hardware) was a few percent, playing back MPEG2 was 40-50% (now you can see my CPU issues, especially when recording two channels and playing back MPEG2). Now, recording is the same, but playing back MPEG4 is 10% and MPEG2 is 7% (after bumping the resolution back to 512x576). I had no idea that Xv made that much difference.

I'm very happy that the Free ATi drivers are getting it now (radeon and radeonhd)!

Just for those following this as some kind of guide, you do have to change the "ati" in your /etc/X11/xorg.conf to "fglrx" (I didn't have to change anything else) - otherwise X will not work and you'll have issues.