Video playback is a very new and rapidly developing application area. Be patient. Not everything is going to work as smoothly as it did with sound.
Before you begin, you should know the model of the video card you have and the chip it uses. While Xorg supports a wide variety of video cards, fewer give good playback performance. To obtain a list of extensions supported by the X server using your card use the command xdpyinfo(1) while X11 is running.
It is a good idea to have a short MPEG file which can be
treated as a test file for evaluating various players and
options. Since some DVD players will look for DVD media in
/dev/dvd by default, or have this device
name hardcoded in them, you might find it useful to make
symbolic links to the proper devices:
# ln -sf /dev/acd0 /dev/dvd
# ln -sf /dev/acd0 /dev/rdvdNote that due to the nature of devfs(5),
manually created links like these will not persist if you reboot
your system. In order to create the symbolic links
automatically whenever you boot your system, add the following
lines to /etc/devfs.conf:
Additionally, DVD decryption, which requires invoking special DVD-ROM functions, requires write permission on the DVD devices.
To enhance the shared memory X11 interface, it is recommended that the values of some sysctl(8) variables should be increased:
There are several possible ways to display video under X11. What will really work is largely hardware dependent. Each method described below will have varying quality across different hardware. Secondly, the rendering of video in X11 is a topic receiving a lot of attention lately, and with each version of Xorg, there may be significant improvement.
A list of common video interfaces:
X11: normal X11 output using shared memory.
XVideo: an extension to the X11 interface which supports video in any X11 drawable.
SDL: the Simple Directmedia Layer.
DGA: the Direct Graphics Access.
SVGAlib: low level console graphics layer.
Xorg has an extension called XVideo (aka Xvideo, aka Xv, aka xv) which allows video to be directly displayed in drawable objects through a special acceleration. This extension provides very good quality playback even on low-end machines.
To check whether the extension is running, use
xvinfo:
% xvinfoXVideo is supported for your card if the result looks like:
Also note that the formats listed (YUV2, YUV12, etc) are not present with every implementation of XVideo and their absence may hinder some players.
If the result looks like:
Then XVideo is probably not supported for your card.
If XVideo is not supported for your card, this only means that it will be more difficult for your display to meet the computational demands of rendering video. Depending on your video card and processor, though, you might still be able to have a satisfying experience. You should probably read about ways of improving performance in the advanced reading Section 8.4.3, “Further Reading”.
The Simple Directmedia Layer, SDL, was intended to be a porting layer between Microsoft® Windows®, BeOS, and UNIX®, allowing cross-platform applications to be developed which made efficient use of sound and graphics. The SDL layer provides a low-level abstraction to the hardware which can sometimes be more efficient than the X11 interface.
The SDL can be found at devel/sdl12.
Direct Graphics Access is an X11 extension which allows
a program to bypass the X server and directly alter the
framebuffer. Because it relies on a low level memory mapping to
effect this sharing, programs using it must be run as
root.
The DGA extension can be tested and benchmarked by
dga(1). When dga is running, it
changes the colors of the display whenever a key is pressed. To
quit, use q.
This section discusses the software available from the FreeBSD Ports Collection which can be used for video playback. Video playback is a very active area of software development, and the capabilities of various applications are bound to diverge somewhat from the descriptions given here.
Firstly, it is important to know that many of the video applications which run on FreeBSD were developed as Linux applications. Many of these applications are still beta-quality. Some of the problems that you may encounter with video packages on FreeBSD include:
An application cannot playback a file which another application produced.
An application cannot playback a file which the application itself produced.
The same application on two different machines, rebuilt on each machine for that machine, plays back the same file differently.
A seemingly trivial filter like rescaling of the image size results in very bad artifacts from a buggy rescaling routine.
An application frequently dumps core.
Documentation is not installed with the port and can be
found either on the web or under the port's work
directory.
Many of these applications may also exhibit “Linux-isms”. That is, there may be issues resulting from the way some standard libraries are implemented in the Linux distributions, or some features of the Linux kernel which have been assumed by the authors of the applications. These issues are not always noticed and worked around by the port maintainers, which can lead to problems like these:
The use of /proc/cpuinfo to detect
processor characteristics.
A misuse of threads which causes a program to hang upon completion instead of truly terminating.
Software not yet in the FreeBSD Ports Collection which is commonly used in conjunction with the application.
So far, these application developers have been cooperative with port maintainers to minimize the work-arounds needed for port-ing.
MPlayer is a recently developed and rapidly developing video player. The goals of the MPlayer team are speed and flexibility on Linux and other Unices. The project was started when the team founder got fed up with bad playback performance on then available players. Some would say that the graphical interface has been sacrificed for a streamlined design. However, once you get used to the command line options and the key-stroke controls, it works very well.
MPlayer resides in multimedia/mplayer.
MPlayer performs a variety of
hardware checks during the build process, resulting in a
binary which will not be portable from one system to
another. Therefore, it is important to build it from
ports and not to use a binary package. Additionally, a
number of options can be specified in the
make command line, as described in the
Makefile and at the start of the
build:
# cd /usr/ports/multimedia/mplayer
# make
N - O - T - E
Take a careful look into the Makefile in order
to learn how to tune mplayer towards you personal preferences!
For example,
make WITH_GTK1
builds MPlayer with GTK1-GUI support.
If you want to use the GUI, you can either install
/usr/ports/multimedia/mplayer-skins
or download official skin collections from
http://www.mplayerhq.hu/homepage/dload.htmlThe default port options should be sufficient for most
users. However, if you need the XviD codec, you have to
specify the WITH_XVID option in the
command line. The default DVD device can also be defined
with the WITH_DVD_DEVICE option, by
default /dev/acd0 will be used.
As of this writing, the
MPlayer port will build its HTML
documentation and two executables,
mplayer, and mencoder,
which is a tool for re-encoding video.
The HTML documentation for MPlayer is very informative. If the reader finds the information on video hardware and interfaces in this chapter lacking, the MPlayer documentation is a very thorough supplement. You should definitely take the time to read the MPlayer documentation if you are looking for information about video support in UNIX®.
Any user of MPlayer must set
up a .mplayer subdirectory of her
home directory. To create this necessary subdirectory,
you can type the following:
% cd /usr/ports/multimedia/mplayer
% make install-userThe command options for mplayer are
listed in the manual page. For even more detail there is
HTML documentation. In this section, we will describe only
a few common uses.
To play a file, such as
,
through one of the various video interfaces set the
testfile.avi-vo option:
% mplayer -vo xv testfile.avi% mplayer -vo sdl testfile.avi% mplayer -vo x11 testfile.avi# mplayer -vo dga testfile.avi# mplayer -vo 'sdl:dga' testfile.aviIt is worth trying all of these options, as their relative performance depends on many factors and will vary significantly with hardware.
To play from a DVD, replace the
with testfile.avidvd:// where
N -dvd-device
DEVICEN is the title number to play
and
is the device node for the DVD-ROM. For example, to play
title 3 from DEVICE/dev/dvd:
# mplayer -vo xv dvd://3 -dvd-device /dev/dvdThe default DVD device can be defined during the build
of the MPlayer port via the
WITH_DVD_DEVICE option. By default,
this device is /dev/acd0. More
details can be found in the port
Makefile.
To stop, pause, advance and so on, consult the
keybindings, which are output by running mplayer
-h or read the manual page.
Additional important options for playback are:
-fs -zoom which engages the fullscreen mode
and -framedrop which helps
performance.
In order for the mplayer command line to not become too
large, the user can create a file
.mplayer/config and set default options
there:
Finally, mplayer can be used to rip a
DVD title into a .vob file. To dump
out the second title from a DVD, type this:
# mplayer -dumpstream -dumpfile out.vob dvd://2 -dvd-device /dev/dvdThe output file, out.vob, will be
MPEG and can be manipulated by the other packages described
in this section.
Before using mencoder it is a good
idea to familiarize yourself with the options from the HTML
documentation. There is a manual page, but it is not very
useful without the HTML documentation. There are
innumerable ways to improve quality, lower bitrate, and
change formats, and some of these tricks may make the
difference between good or bad performance. Here are a
couple of examples to get you going. First a simple
copy:
% mencoder input.avi -oac copy -ovc copy -o output.aviImproper combinations of command line options can yield
output files that are unplayable even by
mplayer. Thus, if you just want to rip
to a file, stick to the -dumpfile in
mplayer.
To convert
to the MPEG4 codec with MPEG3 audio encoding (input.aviaudio/lame is required):
% mencoder input.avi -oac mp3lame -lameopts br=192 \
-ovc lavc -lavcopts vcodec=mpeg4:vhq -o output.aviThis has produced output playable by
mplayer and
xine.
can be replaced with input.avidvd://1 -dvd-device
/dev/dvd and run as root
to re-encode a DVD title directly. Since you are likely
to be dissatisfied with your results the first time around,
it is recommended you dump the title to a file and work on
the file.
The xine video player is a
project of wide scope aiming not only at being an all in one
video solution, but also in producing a reusable base library
and a modular executable which can be extended with plugins.
It comes both as a package and as a port, multimedia/xine.
The xine player is still very rough around the edges, but it is clearly off to a good start. In practice, xine requires either a fast CPU with a fast video card, or support for the XVideo extension. The GUI is usable, but a bit clumsy.
As of this writing, there is no input module shipped with xine which will play CSS encoded DVDs. There are third party builds which do have modules for this built in them, but none of these are in the FreeBSD Ports Collection.
Compared to MPlayer, xine does more for the user, but at the same time, takes some of the more fine-grained control away from the user. The xine video player performs best on XVideo interfaces.
By default, xine player will start up in a graphical user interface. The menus can then be used to open a specific file:
% xineAlternatively, it may be invoked to play a file immediately without the GUI with the command:
% xine -g -p mymovie.aviThe software transcode is not a
player, but a suite of tools for re-encoding video and audio
files. With transcode, one has the
ability to merge video files, repair broken files, using
command line tools with stdin/stdout
stream interfaces.
A great number of options can be specified during the
build from the multimedia/transcode port, we
recommend the following command line to build
transcode:
# make WITH_OPTIMIZED_CFLAGS=yes WITH_LIBA52=yes WITH_LAME=yes WITH_OGG=yes \
WITH_MJPEG=yes -DWITH_XVID=yesThe proposed settings should be sufficient for most users.
To illustrate transcode capacities, one
example to show how to convert a DivX file into a PAL MPEG-1
file (PAL VCD):
% transcode -i
input.avi -V --export_prof vcd-pal -o output_vcd
% mplex -f 1 -o output_vcd.mpg output_vcd.m1v output_vcd.mpaThe resulting MPEG file,
,
is ready to be played with MPlayer.
You could even burn the file on a CD-R media to create a Video
CD, in this case you will need to install and use both output_vcd.mpgmultimedia/vcdimager and sysutils/cdrdao programs.
There is a manual page for transcode, but
you should also consult the transcode
wiki for further information and examples.
The various video software packages for FreeBSD are developing rapidly. It is quite possible that in the near future many of the problems discussed here will have been resolved. In the mean time, those who want to get the very most out of FreeBSD's A/V capabilities will have to cobble together knowledge from several FAQs and tutorials and use a few different applications. This section exists to give the reader pointers to such additional information.
The MPlayer documentation is very technically informative. These documents should probably be consulted by anyone wishing to obtain a high level of expertise with UNIX® video. The MPlayer mailing list is hostile to anyone who has not bothered to read the documentation, so if you plan on making bug reports to them, RTFM.
The xine HOWTO contains a chapter on performance improvement which is general to all players.
Finally, there are some other promising applications which the reader may try:
This, and other documents, can be downloaded from ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/
For questions about FreeBSD, read the
documentation before
contacting <questions@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.