4.16. MPEG decoders

4.16.1. DVB output and input

MPlayer supports cards with the Siemens DVB chipset from vendors like Siemens, Technotrend, Galaxis or Hauppauge. The latest DVB drivers are available from the Linux TV site. If you want to do software transcoding you should have at least a 1GHz CPU.

Configure should detect your DVB card. If it did not, force detection with

./configure --enable-dvb

Then compile and install as usual.

USAGE.  Hardware decoding of streams containing MPEG-1/2 video and/or MPEG audio can be done with this command:

mplayer -ao mpegpes -vo mpegpes file.mpg|vob

Decoding of any other type of video stream requires transcoding to MPEG-1, thus it's slow and may not be worth the trouble, especially if your computer is slow. It can be achieved using a command like this:

mplayer -ao mpegpes -vo mpegpes yourfile.ext
mplayer -ao mpegpes -vo mpegpes -vf expand yourfile.ext

Note that DVB cards only support heights 288 and 576 for PAL or 240 and 480 for NTSC. You must rescale for other heights by adding scale=width:height with the width and height you want to the -vf option. DVB cards accept various widths, like 720, 704, 640, 512, 480, 352 etc. and do hardware scaling in horizontal direction, so you do not need to scale horizontally in most cases. For a 512x384 (aspect 4:3) MPEG-4 (DivX) try:

mplayer -ao mpegpes -vo mpegpes -vf scale=512:576

If you have a widescreen movie and you do not want to scale it to full height, you can use the expand=w:h filter to add black bands. To view a 640x384 MPEG-4 (DivX), try:

mplayer -ao mpegpes -vo mpegpes -vf expand=640:576 file.avi

If your CPU is too slow for a full size 720x576 MPEG-4 (DivX), try downscaling:

mplayer -ao mpegpes -vo mpegpes -vf scale=352:576 file.avi

If speed does not improve, try vertical downscaling, too:

mplayer -ao mpegpes -vo mpegpes -vf scale=352:288 file.avi

For OSD and subtitles use the OSD feature of the expand filter. So, instead of expand=w:h or expand=w:h:x:y, use expand=w:h:x:y:1 (the 5th parameter :1 at the end will enable OSD rendering). You may want to move the image up a bit to get a bigger black zone for subtitles. You may also want to move subtitles up, if they are outside your TV screen, use the -subpos <0-100> option to adjust this (-subpos 80 is a good choice).

In order to play non-25fps movies on a PAL TV or with a slow CPU, add the -framedrop option.

To keep the aspect ratio of MPEG-4 (DivX) files and get the optimal scaling parameters (hardware horizontal scaling and software vertical scaling while keeping the right aspect ratio), use the new dvbscale filter:

for a  4:3 TV: -vf dvbscale,scale=-1:0,expand=-1:576:-1:-1:1
for a 16:9 TV: -vf dvbscale=1024,scale=-1:0,expand=-1:576:-1:-1:1

Digital TV (DVB input module). You can use your DVB card for watching Digital TV.

You should have the programs scan and szap/tzap/czap/azap installed; they are all included in the drivers package.

Verify that your drivers are working properly with a program such as dvbstream (that is the base of the DVB input module).

Now you should compile a ~/.mplayer/channels.conf file, with the syntax accepted by szap/tzap/czap/azap, or have scan compile it for you.

If you have more than one card type (e.g. Satellite, Terrestrial, Cable and ATSC) you can save your channels files as ~/.mplayer/channels.conf.sat, ~/.mplayer/channels.conf.ter, ~/.mplayer/channels.conf.cbl, and ~/.mplayer/channels.conf.atsc, respectively, so as to implicitly hint MPlayer to use these files rather than ~/.mplayer/channels.conf, and you only need to specify which card to use.

Make sure that you have only Free to Air channels in your channels.conf file, or MPlayer will wait for an unencrypted transmission.

In your audio and video fields you can use an extended syntax: ...:pid[+pid]:... (for a maximum of 6 pids each); in this case MPlayer will include in the stream all the indicated pids, plus pid 0 (that contains the PAT). You should always include in each row the PMT and PCR pids for the corresponding channel (if you know them). You can also specify 8192, this will select all pids on this frequency and you can then switch between the programs with TAB. This might need more bandwidth, though cheap cards always transfer all channels at least to the kernel so it does not make much of a difference for these. Other possible uses are: televideo pid, second audio track, etc.

If MPlayer complains frequently about

Too many video/audio packets in the buffer

or if you notice a growing desynchronization between audio and video verify the presence of the PCR pid in your stream (needed to comply with the buffering model of the transmitter) and/or try to use the libavformat MPEG-TS demuxer by adding -demuxer lavf -lavfdopts probesize=128 to your command line.

To show the first of the channels present in your list, run

mplayer dvb://

If you want to watch a specific channel, such as R1, run

mplayer dvb://R1

If you have more than one card you also need to specify the number of the card where the channel is visible (e.g. 2) with the syntax:

mplayer dvb://2@R1

To change channels press the h (next) and k (previous) keys, or use the OSD menu.

To temporarily disable the audio or the video stream copy the following to ~/.mplayer/input.conf:

% set_property  switch_video -2
& step_property switch_video
? set_property  switch_audio -2
^ step_property switch_audio

(Overriding the action keys as preferred.) When pressing the key corresponding to switch_x -2 the associated stream will be closed; when pressing the key corresponding to step_x the stream will be reopened. Notice that this switching mechanism will not work as expected when there are multiple audio and video streams in the multiplex.

During playback (not during recording), in order to prevent stuttering and error messages such as 'Your system is too slow' it is advisable to add

-mc 10 -speed 0.97 -af scaletempo

to your command line, adjusting the scaletempo parameters as preferred.

If your ~/.mplayer/menu.conf contains a <dvbsel> entry, such as the one in the example file etc/dvb-menu.conf (that you can use to overwrite ~/.mplayer/menu.conf), the main menu will show a sub-menu entry that will permit you to choose one of the channels present in your channels.conf, possibly preceded by a menu with the list of cards available if more than one is usable by MPlayer.

If you want to save a program to disk you can use

mplayer -dumpfile r1.ts -dumpstream dvb://R1

If you want to record it in a different format (re-encoding it) instead you can run a command such as

mencoder -o r1.avi -ovc xvid -xvidencopts bitrate=800 \
    -oac mp3lame -lameopts cbr:br=128 -pp=ci dvb://R1

Read the man page for a list of options that you can pass to the DVB input module.

FUTURE.  If you have questions or want to hear feature announcements and take part in discussions on this subject, join our MPlayer-DVB mailing list. Please remember that the list language is English.

In the future you may expect the ability to display OSD and subtitles using the native OSD feature of DVB cards.

4.16.2. DXR2

MPlayer supports hardware accelerated playback with the Creative DXR2 card.

First of all you will need properly installed DXR2 drivers. You can find the drivers and installation instructions at the DXR2 Resource Center site.


-vo dxr2

Enable TV output.

-vo dxr2:x11 or -vo dxr2:xv

Enable Overlay output in X11.

-dxr2 <option1:option2:...>

This option is used to control the DXR2 driver.

The overlay chipset used on the DXR2 is of pretty bad quality but the default settings should work for everybody. The OSD may be usable with the overlay (not on TV) by drawing it in the colorkey. With the default colorkey settings you may get variable results, usually you will see the colorkey around the characters or some other funny effect. But if you properly adjust the colorkey settings you should be able to get acceptable results.

Please see the man page for available options.

4.16.3. DXR3/Hollywood+

MPlayer supports hardware accelerated playback with the Creative DXR3 and Sigma Designs Hollywood Plus cards. These cards both use the em8300 MPEG decoder chip from Sigma Designs.

First of all you will need properly installed DXR3/H+ drivers, version 0.12.0 or later. You can find the drivers and installation instructions at the DXR3 & Hollywood Plus for Linux site. configure should detect your card automatically, compilation should go without problems.


-vo dxr3:prebuf:sync:norm=x:device

overlay activates the overlay instead of TV-out. It requires that you have a properly configured overlay setup to work right. The easiest way to configure the overlay is to first run autocal. Then run mplayer with dxr3 output and without overlay turned on, run dxr3view. In dxr3view you can tweak the overlay settings and see the effects in realtime, perhaps this feature will be supported by the MPlayer GUI in the future. When overlay is properly set up you will no longer need to use dxr3view. prebuf turns on prebuffering. Prebuffering is a feature of the em8300 chip that enables it to hold more than one frame of video at a time. This means that when you are running with prebuffering MPlayer will try to keep the video buffer filled with data at all times. If you are on a slow machine MPlayer will probably use close to, or precisely 100% of CPU. This is especially common if you play pure MPEG streams (like DVDs, SVCDs a.s.o.) since MPlayer will not have to reencode it to MPEG it will fill the buffer very fast. With prebuffering video playback is much less sensitive to other programs hogging the CPU, it will not drop frames unless applications hog the CPU for a long time. When running without prebuffering the em8300 is much more sensitive to CPU load, so it is highly suggested that you turn on MPlayer's -framedrop option to avoid further loss of sync. sync will turn on the new sync-engine. This is currently an experimental feature. With the sync feature turned on the em8300's internal clock will be monitored at all times, if it starts to deviate from MPlayer's clock it will be reset causing the em8300 to drop any frames that are lagging behind. norm=x will set the TV norm of the DXR3 card without the need for external tools like em8300setup. Valid norms are 5 = NTSC, 4 = PAL-60, 3 = PAL. Special norms are 2 (auto-adjust using PAL/PAL-60) and 1 (auto-adjust using PAL/NTSC) because they decide which norm to use by looking at the frame rate of the movie. norm = 0 (default) does not change the current norm. device = device number to use if you have more than one em8300 card. Any of these options may be left out. :prebuf:sync seems to work great when playing MPEG-4 (DivX) movies. People have reported problems using the prebuf option when playing MPEG-1/2 files. You might want to try running without any options first, if you have sync problems, or DVD subtitle problems, give :sync a try.

-ao oss:/dev/em8300_ma-X

For audio output, where X is the device number (0 if one card).

-af resample=xxxxx

The em8300 cannot play back samplerates lower than 44100Hz. If the sample rate is below 44100Hz select either 44100Hz or 48000Hz depending on which one matches closest. I.e. if the movie uses 22050Hz use 44100Hz as 44100 / 2 = 22050, if it is 24000Hz use 48000Hz as 48000 / 2 = 24000 and so on. This does not work with digital audio output (-ac hwac3).

-vf lavc

To watch non-MPEG content on the em8300 (i.e. MPEG-4 (DivX) or RealVideo) you have to specify an MPEG-1 video filter such as libavcodec (lavc). See the man page for further info about -vf lavc. Currently there is no way of setting the fps of the em8300 which means that it is fixed to 30000/1001 fps. Because of this it is highly recommended that you use -vf lavc=quality:25 especially if you are using prebuffering. Then why 25 and not 30000/1001? Well, the thing is that when you use 30000/1001 the picture becomes a bit jumpy. The reason for this is unknown to us. If you set it to somewhere between 25 and 27 the picture becomes stable. For now all we can do is accept this for a fact.

-vf expand=-1:-1:-1:-1:1

Although the DXR3 driver can put some OSD onto the MPEG-1/2/4 video, it has much lower quality than MPlayer's traditional OSD, and has several refresh problems as well. The command line above will firstly convert the input video to MPEG-4 (this is mandatory, sorry), then apply an expand filter which won't expand anything (-1: default), but apply the normal OSD onto the picture (that's what the "1" at the end does).

-ac hwac3

The em8300 supports playing back AC-3 audio (surround sound) through the digital audio output of the card. See the -ao oss option above, it must be used to specify the DXR3's output instead of a sound card.