Optimizing fglrx:
First is to modify your xorg.conf. I have done a lot of research on this particular part of this guide and in your xorg.conf all you should need is the following options set in the driver section under where it says Driver "fglrx".
su gedit /etc/X11/xorg.conf
or
su kedit /etc/X11/xorg.conf
This snippet allows for OpenGL Rendering to work properly in MythTV, reduces tearing greatly if not removes it for Xv, while in part completely removes it with OpenGL as well. It specifically tells X which monitor to overlay on (Should be enabled even if a single monitor setup.), and also enables FastTLS an AMD optimization.
Code:
Option "TexturedVideoSync" "on" #HD4xxx & HD5xxx use textured video to render Xv. This helps to remove tearing.
Option "Capabilities" "0x00000800" #This option also turns on vertical syncing as well. Both can and do work well together.
Option "OpenGLOverlay" "off" #This is for workstations and certain commercial graphics applications for them. Nothing as Linux user that we do needs this so disabled.
Option "UseFastTLS" "on"
Option "OverlayOnCRTC2" "0" #For some reason when only using one monitor it should see this and use overlay on it correctly and does not. This I believe is what caused some of the MyThTV issues. This needs to be set to 0 for a single monitor application and in a multiple monitor to the one MythTV is displayed on.
Now it is time to reboot your machine and configure the Catalyst Control Center:
Open as administrator from your machine's launch menu or by the means below the Catalyst Control Center
$ amdxdg-su -c amdcccle
or
$ sudo amdcccle
Now we need to adjust several settings here before continuing.
Note before starting that these settings work on the HD4670 without issue. On the older GPU's supported by the proprietary driver or even a lower 4XXX model, these settings may be too much for system to handle and run smoothly. There might have to be some tweaking to your specific system.
Go to the 3D section of the options list on the left. These settings actually effect 2D rendering in Linux as well to some extent. It doesn't say it does, but they do. It is because rendering even when not using OpenGL in Linux still uses it for things like vertical syncing, also we will be using OpenGL rendering in a large part of this guide for rendering and playback.
You are going to manually override the system settings on each of the options for 3D to their max settings. I have absolutely no problems with rendering doing so and the quality difference is quite noticeable. If your system has problems handling the workload they will have to be brought back from max settings a little.
Anti-Aliasing:
Override and set to 8x
Adaptive Anti-Aliasing:
Override and set to Quality
Anisotropic Filtering:
Override and set to 16x
MipMap Detail:
Override and set to High Quality
More Settings:
Wait for Vertical Refresh
Set to on unless application specifies off
* This is the second to last option. You can set to be always on, but no need for it. If an application wants no refresh rate syncing let it. Plus having it on is actually better in my opinion. What is so great getting 10,000 frames a second if the display can't reproduce it. Visually all you will see perceive is what the display is capable of.
Enable Catalyst AI:
You want to enable and set to advanced.
You will need to at minimum log out and back in for these settings to take effect, but I would suggest a reboot to be safe. Sometimes fgrlx settings don't want to take unless there is a reboot involved, and the nature of the beast so to speak.
VA-API Files:
Install in this order. If you try to install in any other order it should throw an error.
Mplayer Compile and Install:
Before starting please note. If you are using the nightly stable or tree builds of MythTV you will encounter your package manager wanting to remove MythTV. The reason being is MythTV is using a new VDAPU library and MPlayer needs the old one to have it's dependencies met. I am currently trying to get it to work around this, but to little success. If you want to compile your own you will have to let it remove the newer MythTV, or I do have two pre-compiled versions of MPlayer that I made before switching to the nightly builds of MythTV 0.22.
One is a strict MPlayer without GUI, the other is compiled for a the GUI and because of it buggy as all hell. They have been compiled for X86_64 on an AMD AM2 based processor but should in theory run on any X86_64 system. I have created a tarred bziped file of them. It is too big to include here, but if there is enough interest I will find a place to setup a link to from here. Message me or post here if you you like me to include a link to them.
To build your own:
1. $ sudo apt-get build-dep mplayer
2. Extract the bzip2 file containing MPlayer and enter the extracted directory.
3. $ ./checkout-patch-build.sh
Let it build MPlayer. It could take a few for the compiling of MPlayer. If you smoke, now would be a good time to go have one. It took on my AM2 Dual Core less then 10 minutes, about a cigarette to be honest, and that was applying the patches besides the compile.
This is just mplayer, no gmplayer is compiled with the script. It is best for use with keyboard shortcuts and / or Lirc on the note of controls. Remember though this version of Mplayer was given to us through the generosity of the VA-API XvBA interface and it's developer so don't be going awwwww man or complaining.
To start this VA-API enabled Mplayer for Testing:
*Below was taken from the readme word for word
$ cd mplayer-vaapi
$ ./mplayer -vo vaapi -va vaapi <URI>
<URI> can be a pathname or an URL.
For OpenGL rendering:
$ ./mplayer -vo vaapi:gl -va vaapi <URI>
For OpenGL rendering with reflection effect:
$ ./mplayer -vo vaapi:gl:reflect -va vaapi <URI>
The reflect option is as it sounds, and kinda trippy..lol.
It provides a mirrored copy of the file you are playng inside the MPlayer window.
Test MPlayer at this point with an MPEG4 stream such as AVC1, WM3 aka WM9, or VC1. It uses either Xv and GL rendering, Regardless of which renderer you choose, everything should be working for you beautifully on the note of hardware acceleration. I personally find the picture quality a little bit better using the openGL renderer and it is absolutely tear free besides. Plus it actually uses a bit less processor on my system then Xv, go figure.
You can compile this version of MPlayer to use the GUI, but will have to go into the directory yourself to do so. In order to do this, you need to either manually patch the source or let the script run to do it and make the default MPlayer that it does.
Then go into the directory, and do a make clean after the script has completed. You can do the make-config, make, etc yourself now. Remember you will have to pass the options to MPlayer for it to compile with VA-API support.
This is how you would do it:
$ ./configure --enable-vaapi --disable-vdpau
Then you need to configure the GUI and OSD for it:
$ ./configure --enable-gui --enable-menu
Finally Compile it:
$ make
If you are satisfied with how it is working and want to install it:
*Remember this is experimental and I will not take responsibility for doing this. You will need to have the packaged version of MPlayer removed to do so as well.
$ make install
Please Note:
There is a patch for VLC to use the VA-API library. It has not been mainstreamed into the code at this point. If you were to want VLC you need to get this patch, apply it, and compile your own copy of it. I do not have the patch or the source code for VLC linked here. You can go to the VideoLan website for it.
I would like to setup a VA-API PPA for 9.10 and other releases as well. If someone wants to build packages of compiled versions of MPlayer in 32bit or 64bit, VLC, etc., message me here and I will get it all setup. Ubuntu really needs to have one easy setup repository for doing this.
At this Point:
Now your system is ready to have your video applications configured, in the case of this guide MythTV and Mplayer primarily. In order to do so properly lets look at what we have done up till this point and also what has been added to the fgrlx driver but not widely documented. It will all start to click with seeing everything listed here.
Hardware Decoding / Acceleration:
MPEG1&2 Decoding and Acceleration:
It is little known that as of Catalyst Control Center 9.10, maybe even before this release of it, AMD re-enabled hardware decoding of these streams through the AVIVO now UVD interface using XvMC not XvBA. It works very well, and for the most part is fully compatible with the VIA implementation that nVidia also supports in their older GPU's. HD MPEG2 streams decode on my system use almost no processor and only 30% of the GPU at peak hits to it decoding, heavy action scenes are an example, but the core is keeping itself at the minimum clocking when under 30% load. This is using MythTV, which was itself using the processors at around 10% combined on a dual core AM2.
This capability is only available on HD4xxx and higher GPU's from what some members out here are finding out. This may change at some point though and dependent on AMD supporting it through their proprietary driver. If someone on a GPU prior to the HD4xxx's tries this and it is a success let me know or post it here so this section can be corrected.
MPEG4, AVC, WM3 aka WM9, and VC1 Decoding and Acceleration:
Even though "experimental", you now have hardware accelerated decoding of MPEG4 based streams. Personally I have found the results to be far superior then ffmpeg decoding with no artifacts, not had one crash using it so far, and would not consider this to be experimental myself at this point, but who am I to argue.
Update January 29, 2010:
I have currently tested the hardware decoding with a variety of "non-supported" formats. I have tried the old Windows hacked DiVX 3 along with the legal version 5 encoded files and they playback flawless. They do have a tendency to tax the GPU a little, especially DiVX 3, but regardless play very well for me. I have also tried ffmpeg and Xvid encoded videos with great success as well. From my experience, I will say with relative safety that it will play nearly all MPEG4 formats.
No More Tearing:
Making the changes you have to your xorg.conf and Catalyst Control Center should now have tearing as a thing of the past. For Xv rendering it is substantially reduced to nearly non existent levels. You may on a rare occasion see a tear or line cutting through the picture, usually in very high speed movement, but not what it was before then.
OpenGL, whether with or without the use of XvBA hardware decoding and acceleration, will be absolutely 100% tear free. With the settings of Catalyst Control Center, the picture quality should be better then Xv as well. You may have to increase the brightness settings a little though. This is from my experience of course, and your's may vary.
With the update of this guide, you are now presented with choices in rendering using MythTV owning an AMD GPU finally. We have never been able to properly run OpenGL rendering with MythTV and I have seen posts to this extent going back several years.
No offense meant to the MythTV developers, but they have never truly addressed the owners of ATI / AMD GPU's. We are like the red headed stepchildren of the MythTV community of users. While the favorite son, nVidia, has received all of your love with us over in the corner, neglected, even ridiculed and made fun of.
When MythTV 0.22 was in development, the VA-API which would have benefited a large number of GPU's including both AMD and nVidia was neglected, yet VDAPU wasn't. This limited hardware acceleration of MPEG4 to only nVidia. That is to extent proof to this favoritism and being the red headed stepchild. This lead me to rebel like us red headed stepchildren tend to do and find my own solution, and I did eventually.
No More Pulling Your Hair Out:
Watching video without tearing, until now using AMD GPU's has been a pull your hair out, and want to scream situation. The distributions should help minimize this, and help it from not happening offering compiled binaries of these drivers for use. Yet they don't. These are settings I provided for the xorg.conf are common to nearly all AMD graphics using proprietary drivers, especially HD4xxx and higher. The other settings in the Catalyst Control Center can be set I am sure to default to what I have found to be optimal assuming detection of the GPU is done correctly. If not a pop up windows saying hey you have this driver installed and these settings should be made to not encounter tearing, etc, would be nice.
The MythTV developer's focus on nVida to an extent hasn't help with hair pulling. There is little to no documentation on getting the most out of AMD graphics with MythTV from them, yet there is post after post on many forums asking for solutions and help. Then at least in my experience, when going out actively searching for a solution or a suggestion to improve playback on the MythTV IRC channels instead of anything constructive I am told to go out and purchase an nVida card far inferior to my AMD and nearly costing the same. How is that a solution?
So to save you from pulling your hair out, I did instead. I jokingly say to some it is why I began buzzing my head down. Because my hairline couldn't take much more of dealing with getting MythTV and it was the only way to keep the hair I still got..lol.
Now it is time that we have all the components to put them all together and have them play nice.
Putting it all Together:
It is time to setup MythTV and MPlayer. The way described here does not replace the existing install of MPlayer you have. Where this software is considered experimental I deemed it best to create a bin directory in the user's home directory, and then call it like any other application from a modification to the bashrc script for the account being used. Lets see how everything goes together.
Getting MPlayer to Work with Shortcuts and by Calling it Directly:
We now need to setup this version of MPlayer to be able to be called by command line by name and also by shortcuts without providing paths.
Create a directory called bin in your home directory as follows:
~$ mkdir /home/{username)/bin
Now move your compiled MPlayer directory into the bin directory you just created:
You can do this but need to have the name change if directly in bin, otherwise the symbolic link won't work properly. The other options would be to set it inside another directory. Then there will be no issue. That is how I actually did mine.
~$ mv /home/{username}/{directory where you extracted the whole archive}/mplayer-vaapi-20100114/mplayer-vaapi /bin/mplayer
Now we need to symlink mplayer and gmplayer if you compiled a graphics enabled version to be executable the way we want. You will need to make 3 symlinks for this to work properly. One of these symlinks is needed if only using MPlayer created by the script.
All these commands are assuming that you are in the bin directory you created.
Needed Symlink:
ln -s mplayer-vaapi /mplayer/mplayer
Optional gmplayer Symlinks:
ln -s /mplayer/gmplayer /mplayer/mplayer
ln -s gmplayer-vaapi /mplayer/gmplayer
*This one can also link directly to the mplayer binary file itself as well. I figured this way it is consistent.
Now we need to make it so when you are in a terminal or click on a shortcut bash knows what to do. You need to have your bin directory declared in one of two files. It can be declared locally or globally in bashrc. If you declare it globally, regardless the account you are in, you should create a bin directory for it, even if there is nothing in it at all.
Declaring in Bash Locally:
To Open the File:
$ gedit ~/.bashrc
$ kate ~/.bashrc
Declaring in Bash Globally:
$ su gedit /etc/bash.bashrc
$ su kate /etc/bash.bashrc
Add the Following at the Bottom of bashrc:
PATH=$PATH:~/bin
export PATH
Log out or reboot. If declaring globally, to be safe I would reboot. Honestly I would just reboot regardless. Now you should be able to call Mplayer and GMplayer by the names of the symlinks that you created. To test it open up a terminal and try it.
Example (If gmplayer config was done before making the binaries)
$ gmplayer-vaapi
If you want to try MPlayer (This example uses the openGL renderer. I had an issue with the bottom of the video cut off in full screen my self):
$ mplayer-vaapi -vo vaapi:gl -va vaapi <URI>
To create shortcuts, refer to your desktop's documentation.
Now onto setting up MythTV.