OUTDATED with NVidia driver 302.17!!!!!
(It has support for xrandr 1.2/1.3 and can distinguish between 23.976 and 24)

Howto achieve judder free perfectly synced playback.

Since there's a lot of misinformation in the forum about how xorg display modes works, I though I'd post a howto and explain how to do it the (in my opinion) right way.

First of all, modelines are not a the magic solution to all your problems. Modelines are only needed with tv's that have faulty EDID information. Most TVs provide the correct modes for 29.97/59.94 Hz, but the modes are not used by xrandr by default, so XBMC can't see that they are available.

To check how ~24 and ~60 Hz modes are currently handled on your setup you can run the following command:(XBMC Live doesn't have libgtk, which is required by nvidia-settings. Either check the refresh inside XBMC instead by pausing a video and pressing "o", or run "sudo apt-get install libgtk2.0-0".)

The command will print the actual refresh rates used when switching the way XBMC does. Most setups will show 24 and 60 Hz instead of the wanted 23.97 and 59.94 Hz. You can run the command again after step 3 to check the difference.

The steps needed to set everything up are:

Adding a proper xorg.conf

Finding what modes the TV says it supports in it's EDID.

Adding the wanted modes to xorg.conf so XBMC can use them.

Adjusting the settings in NVIDIA's drivers.

Adjusting the settings in XBMC.

Automatic installation

All the steps can be performed automatically by dropping to a shell by pressing CTRL-ALT-F1 and running this script either by using copy & paste to an empty fileor by downloading it using:

The XBMC forum contains a lot of posts with messy xorg.conf settings, using options that are enabled by default, deprecated or unrelated to video playback.
This is all that is needed. Don't use options you don't understand! Explanations to all the options can be found in the NVIDIA drivers manual.
The ModeDebug option makes the nvidia driver print all the available modes to Xorg's log file.

2. Finding what modes the TV says it supports in it's EDID.

Now that ModeDebug is enabled Xorg needs to be restarted so the available modes will be written to the log file.
Hook up your HDMI cable and restart Xorg.

Code:

sudo service gdm restart

or if you are running XBMC Live:

Code:

sudo service xbmc-live stop
sudo service xbmc-live start

When Xorg is up and running again, bring up a terminal and run the following command to Parse Xorg's log file and output a text file with all the available modes on your desktop:

If you don't have any 23.97 or 59.94 modes here, that's when you need to use modelines instead! Use the test command in the beginning of the post to see if your modelines work as expected. Then continue with step 4.

My TV supports both both 60 and 59.94 Hz. The left column is the name of the mode. As you can see both modes have names that start with "1920x1080_60". Since xrandr can't have two ~60 Hz modes available at the same time, we need to tell it to use the 59.94 Hz mode when switching to a ~60 Hz refresh rate. Same needs to be done with the ~24 Hz mode.

The two modes I want are called "1920x1080_60_0" and "1920x1080_24_0" since they provide the correct refresh rates. To enable these, paste the names of the modes to the Modes-line of /etc/X11/xorg.conf replacing the current setting. The first mode on the line will be your default mode. In my case it looks like this when done:

Code:

Modes "1920x1080_60_0" "1920x1080_24_0"

Save and exit. Restart Xorg for the settings to take effect:

Code:

sudo service gdm restart

or if you are running XBMC Live:

Code:

sudo service xbmc-live stop
sudo service xbmc-live start

4. Adjusting the settings in NVIDIA's drivers.

To enable all the right and disable all the wrong options in the drivers you can run this command: (Not needed on XBMC Live)

The only problem I have is, that I need to set a sound delay of 200ms for all my movies to be in sync, but when I save it with "Set as default for all movies", it only lasts until XBMC restarts... then it forgets the 200ms delay setting and resets it to zero.

The only problem I have is, that I need to set a sound delay of 200ms for all my movies to be in sync, but when I save it with "Set as default for all movies", it only lasts until XBMC restarts... then it forgets the 200ms delay setting and resets it to zero.

Nice script!. I get this error when running the script on my newly installed system. Anyone who can help me fix it?, because nvidia-settings --help doesnt help me much . I can add that I am new to linux.

5/6 Applying NVIDIA settings
No protocol specified

ERROR: The control display is undefined; please run `nvidia-settings --help`
for usage information.

No protocol specified

ERROR: The control display is undefined; please run `nvidia-settings --help`
for usage information.

EDIT: Hmmm everything seems to be working as it should, even with the error .

sonic Wrote:Nice script!. I get this error when running the script on my newly installed system. Anyone who can help me fix it?, because nvidia-settings --help doesnt help me much . I can add that I am new to linux.

5/6 Applying NVIDIA settings
No protocol specified

ERROR: The control display is undefined; please run `nvidia-settings --help`
for usage information.

No protocol specified

ERROR: The control display is undefined; please run `nvidia-settings --help`
for usage information.

EDIT: Hmmm everything seems to be working as it should, even with the error .

This part is acctually not needed if you have a newly installed system, so you're good!