Before configuring video playback, determine the model of the video card 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 Xorg server using the card, run xdpyinfo(1) while Xorg is running.
It is a good idea to have a short MPEG test file for
evaluating various players and options. Since some DVD
applications look for DVD media in /dev/dvd
by default, or have this
device name hardcoded in them, it might be useful to make
symbolic links to the proper devices:
#
ln -sf /dev/acd0 /dev/dvd
#
ln -sf /dev/acd0 /dev/rdvd
Due to the nature of devfs(5), manually created links
will not persist after a system reboot. In order to create the
symbolic links automatically when the system boots, add the
following lines to /etc/devfs.conf
:
DVD decryption invokes special DVD-ROM functions and requires write permission on the DVD devices.
To enhance the shared memory Xorg interface, it is recommended to increase the values of these sysctl(8) variables:
There are several possible ways to display video under Xorg. What works is largely hardware dependent. Each method described below will have varying quality across different hardware.
Common video interfaces include:
Xorg: normal output using shared memory.
XVideo: an extension to the Xorg interface which supports video in any drawable object.
SDL: the Simple Directmedia Layer.
DGA: the Direct Graphics Access.
SVGAlib: low level console graphics layer.
Xorg has an extension called XVideo, also known as Xvideo, Xv, and xv. It allows video to be directly displayed in drawable objects through a special acceleration. This extension provides good quality playback even on low-end machines.
To check whether the extension is running, use
xvinfo
:
%
xvinfo
XVideo is supported for the card if the result looks like:
The formats listed, such as YUV2 and YUV12, are not present with every implementation of XVideo and their absence may hinder some players.
If the result looks like:
XVideo is probably not supported for the card. This means that it will be more difficult for the display to meet the computational demands of rendering video. Depending on the video card and processor, one might still be able to have a satisfying experience.
The Simple Directmedia Layer, SDL, is a porting layer for many operating systems allowing cross-platform applications to be developed which make 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 Xorg interface.
SDL can be installed using the devel/sdl12
package or port.
DGA is an
Xorg extension which allows a
program to bypass the Xorg server
and directly alter the framebuffer. Because it relies on a low
level memory mapping, programs using it must be run as
root
.
The DGA extension can be tested and
benchmarked using dga(1). When dga
is
running, it changes the colors of the display whenever a key is
pressed. To quit, press q.
This section introduces some of the software available from the FreeBSD Ports Collection which can be used for video playback.
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 commonly encountered 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 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 applications may also exhibit “Linux®-isms”. 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.
Relies on software which is not yet available in the FreeBSD Ports Collection.
MPlayer is a command-line video player with an optional graphical interface which aims to provide speed and flexibility. This application, as well as other graphical front-ends, is available from the FreeBSD Ports Collection.
MPlayer is available as a
package or port in multimedia/mplayer
. Several
compile options are available and a variety of hardware
checks occur during the build process. For these reasons,
some users prefer to build the port rather than install the
package. The available options will be displayed in a
menu after these commands are input:
#
cd /usr/ports/multimedia/mplayer
#
make
The menu options should be reviewed to determine the type of support to compile into the port. If an option is not selected, MPlayer will not be able to display that type of video format. Use the arrow keys and spacebar to select the required formats. When finished, press Enter to continue the port compile and installation.
By default, this package or port will build the
mplayer
command line utility and the
gmplayer
graphical utility. To encode
videos, install the multimedia/mencoder
port. Due
to licensing restrictions, a package is not available for
MEncoder
.
The first time MPlayer is
run, it will create ~/.mplayer
in the user's
home directory. This subdirectory contains default versions
of the user-specific configuration files.
This section describes only a few common uses. Refer
to the mplayer
manual page for a complete
description of its numerous options.
To play the file
,
specify the video interfaces with
testfile.avi
-vo
:
%
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.avi
It is worth trying all of these options, as their relative performance depends on many factors and will vary significantly with hardware.
To play a DVD, replace the
with testfile.avi
dvd://
, where
N
-dvd-device
DEVICE
N
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/dvd
The default DVD device can be defined during the build
of the MPlayer port by
including the
WITH_DVD_DEVICE=/path/to/desired/device
option. By default, the device is
/dev/acd0
. More details can be found
in the port's
Makefile.options
.
To stop, pause, advance, and so on, consult the
keybindings, which are displayed by running mplayer
-h
, or read the manual page.
Additional playback options include
-fs -zoom
, which engages fullscreen mode,
and -framedrop
, which helps
performance.
Each user can add commonly used options to their
~/.mplayer/config
like so:
mplayer
can be used to rip a DVD
title to a .vob
. To dump the second
title from a DVD:
#
mplayer -dumpstream -dumpfile out.vob dvd://2 -dvd-device /dev/dvd
The output file, out.vob
, will be
MPEG and can be manipulated by the other packages described
in this section.
The MPlayer documentation is technically informative and should 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 before making a bug report, read the documentation first.
Before using mencoder
, it is a good
idea to become familiar with the options described in the
HTML
documentation. There are innumerable ways to
improve quality, lower bitrate, and change formats, and some
of these options may make the difference between good or bad
performance. Improper combinations of command line options
can yield output files that are unplayable even by
mplayer
.
Here is an example of a simple copy:
%
mencoder input.avi
-oac copy -ovc copy -o output.avi
To rip to a file, use -dumpfile
with
mplayer
.
To convert
to the MPEG4 codec with MPEG3 audio encoding, first install
the input.avi
audio/lame
port.
Due to licensing restrictions, a package is not available.
Once installed, type:
%
mencoder input.avi
-oac mp3lame -lameopts br=192 \
-ovc lavc -lavcopts vcodec=mpeg4:vhq -o output.avi
This will produce output playable by applications such
as mplayer
and
xine
.
can be replaced with input.avi
dvd://1 -dvd-device
/dev/dvd
and run as root
to re-encode a DVD title directly. Since it may take a few
tries to get the desired result, it is recommended to dump
the title to a file and to work on the file.
xine is a video player with a
reusable base library and a modular executable which can be
extended with plugins. It can be installed using the
multimedia/xine
package or
port.
In practice, xine requires either a fast CPU with a fast video card, or support for the XVideo extension. The xine video player performs best on XVideo interfaces.
By default, the xine player starts a graphical user interface. The menus can then be used to open a specific file.
Alternatively, xine may be invoked to play a file immediately without the graphical interface:
%
xine
Alternatively, it may be invoked to play a file immediately without the GUI with the command:
%
xine -g -p mymovie.avi
The xine HOWTO contains a chapter on performance improvement which is general to all players.
transcode provides a suite of
tools for re-encoding video and audio files.
transcode can be used to merge
video files or repair broken files using command line tools
with stdin/stdout
stream
interfaces.
transcode can be installed
using the multimedia/transcode
package or
port. Many users prefer to compile the port as it provides a
menu of compile options for specifying the support and codecs
to compile in. If an option is not selected,
transcode will not be able to
encode that format. Use the arrow keys and spacebar to select
the required formats. When finished, press
Enter to continue the port compile and
installation.
This example demonstrates 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.mpa
The resulting MPEG file,
,
is ready to be played with MPlayer.
The file can be burned on a CD-R media to create a Video CD. In
this, install and use the output_vcd.mpg
multimedia/vcdimager
and sysutils/cdrdao
programs.
In addition to the manual page for
transcode
, refer to the transcode
wiki for further information and examples.
All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/
Questions that are not answered by the
documentation may be
sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.