O'Reilly logo

Linux Multimedia Hacks by Kyle Rankin

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Output to a TV with NVIDIA Cards

Use two different methods to output your video to a TV. One method uses NVIDIA’s special drivers and the other doesn’t.

A general-purpose Linux computer has incredible potential for playing videos. You can play not only DVDs, VCDs, and SVCDs, but also any .avi, .mpg, or even Ogg Theora videos on your hard drive. Of course, sometimes your furniture isn’t exactly arranged to watch movies on the computer, particularly with friends. In these cases it would nice to be able to output your computer display to your TV where you can more comfortably seat a group of people. Often support for TV-out under Linux is spotty, depending on the manufacturer, but with an NVIDIA card, you can pretty easily set up a cloned display on your television with either NVIDIA’s drivers or output to TV with the nvtv utility. This hack covers how to set up both methods for TV out on modern NVIDIA video cards.

nvtv

nvtv is a program designed to talk to NVIDIA cards directly to enable their TV out modes. It doesn’t require any special video drivers or kernel support, so it is a good choice if you don’t wish to install NVIDIA’s Linux drivers.

nvtv is packaged by most major distributions, so you can find and install it with your standard distribution package tool. If your distribution doesn’t package it, download the precompiled binary tarball from the official nvtv page at http://sourceforge.net/projects/nv-tv-out. Since the files are already compiled, you can extract them from the package and copy them directly to a bin directory in your path. To do this, use the following command as root:

	root@moses:~# tar xvzf nvtv-0.4.7-bin.tar.gz
	root@moses:~# cd nvtv-0.4.7-bin
	root@moses:~/nvtv-0.4.7-bin# cp nvtv nvtvd /usr/local/sbin/

Since nvtv directly accesses the video card, you will need to run the program as the root user (one reason to put it in an sbin/ directory). Become root and type nvtv in a terminal to start the program. The main window has a number of tabs along the far left side that organize the different configuration options. The nvtv tab opens to the Mode page. nvtv defaults to the PAL TV system, so if you live in the United States, be sure to change modes to NTSC. Then choose which resolution to output to the TV, and which size. Try the Normal size first and see if it fully fits your TV screen; if not, try Small, Huge, or the other modes and see what fits the screen best. You can also tweak the position of the output on the TV screen from the Position page. The Mode page also allows you to output only a particular window instead of the full screen, so you can click X Select and then click on the window you want to display.

Once you have configured the nvtv window to suit your environment, click Apply and then click TV On (or hit F1) to output to the TV. Click TV Off (or hit F2) to toggle back to the desktop display.

NVIDIA X Drivers

If you have NVIDIA’s proprietary drivers installed on your system, you might find that their method of TV output will work better for you. Installing and configuring NVIDIA’s X drivers is outside the scope of this hack, but NVIDIA’s documentation on the subject is thorough, so go to the official NVIDIA Linux driver page at http://www.nvidia.com/object/unix.html, click on the link to the latest driver, and then click on the link to the text README file from that page.

To add TV-out support to your NVIDIA driver, open your /etc/X11/ XF86Config-4 or /etc/X11/xorg.conf file and go to the Device section of the file where your NVIDIA card is configured, which will look something like the following:

	Section "Device"
		Identifier "Geforce2MX"
	VendorName "Unknown"
		BoardName "Unknown"
		Driver "nvidia"
		Option "NvAGP" "1"
		Option "NoLogo" "1"
		Option "CursorShadow" "On"
	EndSection

Don’t worry if your configuration is somewhat different from this one; the main thing is that you are configuring the Device section for your current NVIDIA card. NVIDIA calls their particular multiple display support Twin-view. While this is like Xinerama support under X, and even supports Xinerama extensions, it isn’t Xinerama. To turn on this support add a few extra options to this configuration to turn on Twinview and Cloning support, and to tell the driver to output to the TV:

	Option	"TwinView"
	Option	"TwinViewOrientation" "Clone"
	Option	"MetaModes" "1024x768,640x480"
	Option	"ConnectedMonitor" "CRT, TV"
	Option	"TVStandard" "NTSC-M"
	Option	"SecondMonitorHorizSync" "30-50"
	Option	"SecondMonitorVertRefresh" "60"

This config sets my CRT to 1024 x 768 while the TV is set to 640 x 480. You might want to set both displays to be the same resolution, particularly if you plan to run a program full-screen. In addition, I set the TVStandard option to NTSC-M, but refer to NVIDIA’s documentation for all of the different PAL modes that are supported. Finally I set up the horizontal and vertical rates for my TV. Be sure to use conservative settings like these unless you know for sure that your TV can support higher frequencies. After all the additions have been made, the Device section should look like the following:

	Section "Device"
		Identifier "Geforce2MX"
	VendorName "Unknown"
		BoardName "Unknown"
		Driver "nvidia"
		Option "NvAGP" "1"
		Option "NoLogo" "1"
		Option "CursorShadow" "On"
		Option "TwinView"
		Option "TwinViewOrientation" "Clone"
		Option "MetaModes" "1024x768,640x480"
		Option "ConnectedMonitor" "CRT, TV"
		Option "TVStandard" "NTSC-M"
		Option "SecondMonitorHorizSync" "30-50"
		Option "SecondMonitorVertRefresh" "60"
	EndSection

Now save your changes, log out of your desktop environment, and restart the X server either through GDM/KDM/XDM or by hitting Ctrl-Alt-backspace. X will start up with the display cloned on both your monitor and your television. If, for some reason, X doesn’t start or isn’t outputting to TV, check for clues at /var/log/XFree86.0.log or /var/log/xorg.0.log.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required