📄 video-playback.html
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta name="generator" content="HTML Tidy, see www.w3.org" /><title>Video Playback</title><meta name="GENERATOR" content="Modular DocBook HTML Stylesheet Version 1.7" /><link rel="HOME" title="FreeBSD Handbook" href="index.html" /><link rel="UP" title="Multimedia" href="multimedia.html" /><link rel="PREVIOUS" title="MP3 Audio" href="sound-mp3.html" /><link rel="NEXT" title="Setting Up TV Cards" href="tvcard.html" /><link rel="STYLESHEET" type="text/css" href="docbook.css" /></head><body class="SECT1" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#840084"alink="#0000FF"><div class="NAVHEADER"><table summary="Header navigation table" width="100%" border="0" cellpadding="0"cellspacing="0"><tr><th colspan="3" align="center">FreeBSD Handbook</th></tr><tr><td width="10%" align="left" valign="bottom"><a href="sound-mp3.html"accesskey="P">Prev</a></td><td width="80%" align="center" valign="bottom">Chapter 7 Multimedia</td><td width="10%" align="right" valign="bottom"><a href="tvcard.html"accesskey="N">Next</a></td></tr></table><hr align="LEFT" width="100%" /></div><div class="SECT1"><h1 class="SECT1"><a id="VIDEO-PLAYBACK" name="VIDEO-PLAYBACK">7.4 VideoPlayback</a></h1><i class="AUTHORGROUP"><span class="CONTRIB">Contributed by</span> Ross Lippert.</i> <p>Video playback is a very new and rapidly developing application area. Be patient. Noteverything is going to work as smoothly as it did with sound.</p><p>Before you begin, you should know the model of the video card you have and the chip ituses. While <b class="APPLICATION">Xorg</b> and <b class="APPLICATION"><spanclass="TRADEMARK">XFree86</span>™</b> support a wide variety of video cards, fewergive good playback performance. To obtain a list of extensions supported by the X serverusing your card use the command <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=xdpyinfo&sektion=1&manpath=XFree86+4.4.0"><span class="CITEREFENTRY"><span class="REFENTRYTITLE">xdpyinfo</span>(1)</span></a> while X11is running.</p><p>It is a good idea to have a short MPEG file which can be treated as a test file forevaluating various players and options. Since some DVD players will look for DVD media in<tt class="FILENAME">/dev/dvd</tt> by default, or have this device name hardcoded inthem, you might find it useful to make symbolic links to the proper devices:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">ln -sf /dev/acd0c /dev/dvd</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">ln -sf /dev/racd0c /dev/rdvd</kbd></pre><p>On FreeBSD 5.X, which uses <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=devfs&sektion=5&manpath=FreeBSD+6-current"><span class="CITEREFENTRY"><span class="REFENTRYTITLE">devfs</span>(5)</span></a> thereis a slightly different set of recommended links:</p><pre class="SCREEN"><samp class="PROMPT">#</samp> <kbd class="USERINPUT">ln -sf /dev/acd0 /dev/dvd</kbd><samp class="PROMPT">#</samp> <kbd class="USERINPUT">ln -sf /dev/acd0 /dev/rdvd</kbd></pre><p>Note that due to the nature of <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=devfs&sektion=5&manpath=FreeBSD+6-current"><span class="CITEREFENTRY"><span class="REFENTRYTITLE">devfs</span>(5)</span></a>,manually created links like these will not persist if you reboot your system. In order tocreate the symbolic links automatically whenever you boot your system, add the followinglines to <tt class="FILENAME">/etc/devfs.conf</tt>:</p><pre class="PROGRAMLISTING">link acd0 dvdlink acd0 rdvd</pre><p>Additionally, DVD decryption, which requires invoking special DVD-ROM functions,requires write permission on the DVD devices.</p><p>Some of the ports discussed rely on the following kernel options to build correctly.Before attempting to build, add these options to the kernel configuration file, build anew kernel, and reboot:</p><pre class="PROGRAMLISTING">option CPU_ENABLE_SSEoption USER_LDT</pre><div class="NOTE"><blockquote class="NOTE"><p><b>Note:</b> <var class="LITERAL">option USER_LDT</var> does not exist onFreeBSD 5.X.</p></blockquote></div><p>To enhance the shared memory X11 interface, it is recommended that the values of some<a href="http://www.FreeBSD.org/cgi/man.cgi?query=sysctl&sektion=8"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">sysctl</span>(8)</span></a> variablesshould be increased:</p><pre class="PROGRAMLISTING">kern.ipc.shmmax=67108864kern.ipc.shmall=32768</pre><div class="SECT2"><h2 class="SECT2"><a id="VIDEO-INTERFACE" name="VIDEO-INTERFACE">7.4.1 Determining VideoCapabilities</a></h2><p>There are several possible ways to display video under X11. What will really work islargely hardware dependent. Each method described below will have varying quality acrossdifferent hardware. Secondly, the rendering of video in X11 is a topic receiving a lot ofattention lately, and with each version of <b class="APPLICATION">Xorg</b>, or of <bclass="APPLICATION"><span class="TRADEMARK">XFree86</span></b>, there may be significantimprovement.</p><p>A list of common video interfaces:</p><ol type="1"><li><p>X11: normal X11 output using shared memory.</p></li><li><p>XVideo: an extension to the X11 interface which supports video in any X11drawable.</p></li><li><p>SDL: the Simple Directmedia Layer.</p></li><li><p>DGA: the Direct Graphics Access.</p></li><li><p>SVGAlib: low level console graphics layer.</p></li></ol><div class="SECT3"><h3 class="SECT3"><a id="VIDEO-INTERFACE-XVIDEO" name="VIDEO-INTERFACE-XVIDEO">7.4.1.1XVideo</a></h3><p><b class="APPLICATION">Xorg</b> and <b class="APPLICATION"><spanclass="TRADEMARK">XFree86</span> 4.X</b> have an extension called <spanclass="emphasis"><i class="EMPHASIS">XVideo</i></span> (aka Xvideo, aka Xv, aka xv) whichallows video to be directly displayed in drawable objects through a special acceleration.This extension provides very good quality playback even on low-end machines.</p><p>To check whether the extension is running, use <tt class="COMMAND">xvinfo</tt>:</p><pre class="SCREEN"><samp class="PROMPT">%</samp> <kbd class="USERINPUT">xvinfo</kbd></pre><p>XVideo is supported for your card if the result looks like:</p><pre class="SCREEN">X-Video Extension version 2.2screen #0 Adaptor #0: "Savage Streams Engine" number of ports: 1 port base: 43 operations supported: PutImage supported visuals: depth 16, visualID 0x22 depth 16, visualID 0x23 number of attributes: 5 "XV_COLORKEY" (range 0 to 16777215) client settable attribute client gettable attribute (current value is 2110) "XV_BRIGHTNESS" (range -128 to 127) client settable attribute client gettable attribute (current value is 0) "XV_CONTRAST" (range 0 to 255) client settable attribute client gettable attribute (current value is 128) "XV_SATURATION" (range 0 to 255) client settable attribute client gettable attribute (current value is 128) "XV_HUE" (range -180 to 180) client settable attribute client gettable attribute (current value is 0) maximum XvImage size: 1024 x 1024 Number of image formats: 7 id: 0x32595559 (YUY2) guid: 59555932-0000-0010-8000-00aa00389b71 bits per pixel: 16 number of planes: 1 type: YUV (packed) id: 0x32315659 (YV12) guid: 59563132-0000-0010-8000-00aa00389b71 bits per pixel: 12 number of planes: 3 type: YUV (planar) id: 0x30323449 (I420) guid: 49343230-0000-0010-8000-00aa00389b71 bits per pixel: 12 number of planes: 3 type: YUV (planar) id: 0x36315652 (RV16) guid: 52563135-0000-0000-0000-000000000000 bits per pixel: 16 number of planes: 1 type: RGB (packed) depth: 0 red, green, blue masks: 0x1f, 0x3e0, 0x7c00 id: 0x35315652 (RV15) guid: 52563136-0000-0000-0000-000000000000 bits per pixel: 16 number of planes: 1 type: RGB (packed) depth: 0 red, green, blue masks: 0x1f, 0x7e0, 0xf800 id: 0x31313259 (Y211) guid: 59323131-0000-0010-8000-00aa00389b71 bits per pixel: 6 number of planes: 3 type: YUV (packed) id: 0x0 guid: 00000000-0000-0000-0000-000000000000 bits per pixel: 0 number of planes: 0 type: RGB (packed) depth: 1 red, green, blue masks: 0x0, 0x0, 0x0</pre><p>Also note that the formats listed (YUV2, YUV12, etc) are not present with everyimplementation of XVideo and their absence may hinder some players.</p><p>If the result looks like:</p><pre class="SCREEN">X-Video Extension version 2.2screen #0no adaptors present</pre><p>Then XVideo is probably not supported for your card.</p><p>If XVideo is not supported for your card, this only means that it will be moredifficult 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 asatisfying experience. You should probably read about ways of improving performance inthe advanced reading <a href="video-playback.html#VIDEO-FURTHER-READING">Section7.4.3</a>.</p></div><div class="SECT3"><h3 class="SECT3"><a id="VIDEO-INTERFACE-SDL" name="VIDEO-INTERFACE-SDL">7.4.1.2 SimpleDirectmedia Layer</a></h3><p>The Simple Directmedia Layer, SDL, was intended to be a porting layer between <spanclass="TRADEMARK">Microsoft</span>® <span class="TRADEMARK">Windows</span>®,BeOS, and <span class="TRADEMARK">UNIX</span>®, allowing cross-platform applicationsto be developed which made efficient use of sound and graphics. The SDL layer provides alow-level abstraction to the hardware which can sometimes be more efficient than the X11interface.</p><p>The SDL can be found at <ahref="http://www.FreeBSD.org/cgi/url.cgi?ports/devel/sdl12/pkg-descr"><ttclass="FILENAME">devel/sdl12</tt></a>.</p></div><div class="SECT3"><h3 class="SECT3"><a id="VIDEO-INTERFACE-DGA" name="VIDEO-INTERFACE-DGA">7.4.1.3 DirectGraphics Access</a></h3><p>Direct Graphics Access is an <b class="APPLICATION"><spanclass="TRADEMARK">XFree86</span></b> extension which allows a program to bypass the Xserver and directly alter the framebuffer. Because it relies on a low level memorymapping to effect this sharing, programs using it must be run as <ttclass="USERNAME">root</tt>.</p><p>The DGA extension can be tested and benchmarked by <ahref="http://www.FreeBSD.org/cgi/man.cgi?query=dga&sektion=1&manpath=XFree86+4.4.0"><spanclass="CITEREFENTRY"><span class="REFENTRYTITLE">dga</span>(1)</span></a>. When <ttclass="COMMAND">dga</tt> is running, it changes the colors of the display whenever a keyis pressed. To quit, use <b class="KEYCAP">q</b>.</p></div></div><div class="SECT2"><h2 class="SECT2"><a id="VIDEO-PORTS" name="VIDEO-PORTS">7.4.2 Ports and Packages Dealingwith Video</a></h2><p>This section discusses the software available from the FreeBSD Ports Collection whichcan be used for video playback. Video playback is a very active area of softwaredevelopment, and the capabilities of various applications are bound to diverge somewhatfrom the descriptions given here.</p><p>Firstly, it is important to know that many of the video applications which run onFreeBSD were developed as Linux applications. Many of these applications are stillbeta-quality. Some of the problems that you may encounter with video packages on FreeBSDinclude:</p><ol type="1"><li><p>An application cannot playback a file which another application produced.</p></li><li><p>An application cannot playback a file which the application itself produced.</p></li><li><p>The same application on two different machines, rebuilt on each machine for thatmachine, plays back the same file differently.</p></li><li><p>A seemingly trivial filter like rescaling of the image size results in very badartifacts from a buggy rescaling routine.</p></li><li><p>An application frequently dumps core.</p></li><li><p>Documentation is not installed with the port and can be found either on the web orunder the port's <tt class="FILENAME">work</tt> directory.</p></li></ol><p>Many of these applications may also exhibit ``Linux-isms''. That is, there may beissues resulting from the way some standard libraries are implemented in the Linuxdistributions, or some features of the Linux kernel which have been assumed by theauthors of the applications. These issues are not always noticed and worked around by theport maintainers, which can lead to problems like these:</p><ol type="1"><li><p>The use of <tt class="FILENAME">/proc/cpuinfo</tt> to detect processorcharacteristics.</p></li><li><p>A misuse of threads which causes a program to hang upon completion instead of trulyterminating.</p></li><li><p>Software not yet in the FreeBSD Ports Collection which is commonly used in conjunctionwith the application.</p></li></ol><p>So far, these application developers have been cooperative with port maintainers tominimize the work-arounds needed for port-ing.</p><div class="SECT3"><h3 class="SECT3"><a id="VIDEO-MPLAYER" name="VIDEO-MPLAYER">7.4.2.1 MPlayer</a></h3><p><b class="APPLICATION">MPlayer</b> is a recently developed and rapidly developingvideo player. The goals of the <b class="APPLICATION">MPlayer</b> team are speed andflexibility on Linux and other Unices. The project was started when the team founder gotfed up with bad playback performance on then available players. Some would say that thegraphical interface has been sacrificed for a streamlined design. However, once you getused to the command line options and the key-stroke controls, it works very well.</p><div class="SECT4">
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -