Date: Sat, 1 Jun 2002 20:01:52 -0700 (PDT) From: Ross Lippert <ripper@eskimo.com> To: freebsd-doc@freebsd.org Subject: A video chapter (pr doc/31653) Message-ID: <200206020301.UAA09990@eskimo.com>
next in thread | raw e-mail | index | archive | help
I have a video chapter I would like to submit to deal the lack of anything about video under freebsd, which is the pr in the subject line. I am new to the doc project and I'd like to have some guidance as to how to submit it, and get some people to look at it and give me pointers on style and docproj fine-points. I'm attaching it below. Specifically, I need advice on which commands are appropriate to man-entity-ify and wwhich ones are not. I don't know much about what the rationale is behind man-entities in the handbook sgml. -r <!-- The FreeBSD Documentation Project --> <chapter id="video"> <chapterinfo> <authorgroup> <author> <firstname>Ross</firstname> <surname>Lippert</surname> <contrib>Contributed by </contrib> </author> </authorgroup> <!-- 31 May 2002 --> </chapterinfo> <title>Video</title> <sect1 id="video-synopsis"> <title>Synopsis</title> <para>With some willingness to experiment, FreeBSD can support playback of video files and DVD's. The number of applications to encode, re-encode, and playback various video media is more limited than the number of sound applications. For example as of this writing, there is no good transcoding application in the FreeBSD Ports Collection, which could be use to interconvert between formats, as there is with <filename role="package">audio/sox</filename>. However, the software landscape in this area is changing rapidly.</para> <para>After reading this chapter, you will know: <itemizedlist> <listitem><para>Some ways in which video is supported by XFree86.</para></listitem> <listitem><para>Some ports/packages of video players/encoders which give good results.</para></listitem> <listitem><para>How to playback DVD's, .mpg and .avi files.</para></listitem> <listitem><para>How to rip DVD video tracks into data files.</para></listitem> </itemizedlist> </para> <para>Before reading this chapter, you should:</para> <itemizedlist> <listitem><para>Know how to configure your soundcard (<xref linkend="sound">).</para></listitem> <listitem><para>Know how to configure and install XFree86 (<xref linkend="x11">) <footnote> <para>It is assumed that XFree86 4.X be used. XFree86 3.X may work, but this author has not made the attempt</para> </footnote>. </para> </listitem> </itemizedlist> </sect1> <sect1 id="video-interface"> <title>Determining Video capabilities</title> <indexterm><primary>Xvideo</primary></indexterm> <indexterm><primary>Xv</primary></indexterm> <indexterm><primary>sdl</primary></indexterm> <indexterm><primary>SDL</primary></indexterm> <indexterm><primary>dga</primary></indexterm> <indexterm><primary>DGA</primary></indexterm> <indexterm> <primary>kernel configuration</primary> <secondary>options CPU_ENABLE_SSE</secondary> </indexterm> <indexterm> <primary>kernel configuration</primary> <secondary>options USER_LDT</secondary> </indexterm> <para>Video display under X11 suffers from a multitude of possibilities, what will each works is largely hardware dependent (mostly on the video card, and a little on the CPU). 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 XFree86 there may be significant improvement.</para> <para>A list of common video interfaces:</para> <orderedlist> <listitem> <para> X11 : normal X11 output using shared memory</para> </listitem> <listitem> <para> XVideo : an extension to the X11 interface which supports video in any X11 drawable.</para> </listitem> <listitem> <para> SDL : the Simple Directmedia Layer</para> </listitem> <listitem> <para> DGA : the Direct Graphics Access</para> </listitem> <listitem> <para> SVGAlib : low level console graphics layer</para> </listitem> </orderedlist> <para>Before you begin, you should know the model of the video card you have and the chip it uses. While XFree86 supports a wide variety of video cards, a much smaller number give good playback performance. To obtain a list of extensions supported by the X-server using your card use the command &man.xdpyinfo.1; while X11 is running.</para> <para>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 players default or are hardcoded to look for DVD media in <filename>/dev/dvd</filename>, it is also a good idea to have this symlinked to the appropriate device, for example <screen>&prompt.root; ln -sf /dev/acd0c /dev/dvd &prompt.root; ln -sf /dev/racd0c /dev/rdvd</screen> on FreeBSD-4.X and <screen>&prompt.root; ln -sf /dev/acd0c /dev/dvd</screen> on FreeBSD-5.X. </para> <para>Some of the packages discussed in the next section rely on the following kernel options: <programlisting>option CPU_ENABLE_SSE option USER_LDT</programlisting> and will not build correctly until you have rebooted with the new kernel. Also, setting the &man.sysctl.1; variables as below <programlisting>kern.ipc.shmmax=67108864 kern.ipc.shmall=32768</programlisting> to enhance the shared memory X11 interface. </para> <sect2 id="video-interface-xvideo"> <title>XVideo</title> <para>XFree86 4.X has an extension called <emphasis>XVideo</emphasis> (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 on even low-end machines (for example my PIII 400Mhz laptop). Unfortunately, the list of cards in which this feature is supported <quote>out of the box</quote> is currently:</para> <orderedlist> <listitem> <para>3DFX Voodoo 3</para> </listitem> <listitem> <para>Intel i810 and i815</para> </listitem> <listitem> <para>some S3 chips (such as Savage/IX and Savage/MX)</para> </listitem> </orderedlist> <para>If your card is not one of these, don't be disappointed yet. XFree86 4.X adds new xv capabilities with each release <footnote> <para>A popular familiar graphics card with generally very good XFree86 performance, nVidia, has yet to release the specifications on their XVideo support to the XFree86 team. It may be some time before XFree86 fully support XVideo for these cards.</para> </footnote>. To check whether the extension is running, use <command>xvinfo</command>. <screen>&prompt.user; xvinfo</screen> If the result looks like: <screen>X-Video Extension version 2.2 screen #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 </screen> then XVideo is supported for your card. Also note that the formats listed (YUV2, YUV12, etc) are not present with every implementation of Xvideo and their absense may hinder some players.</para> <para>If the result looks like: <screen>X-Video Extension version 2.2 screen #0 no adaptors present </screen> Then XVideo is probably not supported for your card.</para> <para>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 probably should read about ways to improving performance in the advanced reading <xref linkend="video-further-reading">. </sect2> <sect2 id="video-interface-SDL"> <title>Simple Directmedia Layer</title> <para>The Simple Directmedia Layer, SDL, was intended to be a porting layers 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.</para> <para>The SDL can be found at <filename role="package">sdl12</filename></para> </sect2> <sect2 id="video-interface-DGA"> <title>Direct Graphics Access</title> <para>Direct Graphics Access is an XFree86 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 must be run as <username>root</username></para> <para>The DGA extension can be tested and benchmarked by &man.dga.1;. When <command>dga</command> is running, it changes the colors of the display whenever a key is pressed. To quit, use <keycap>q</keycap>.</para> </sect2> </sect1> <sect1 id="video-ports"> <title>Ports and Packages Dealing with Video</title> <indexterm><primary>video ports</primary></indexterm> <indexterm><primary>video packages</primary></indexterm> <para>This section will discuss 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.</para> <para>Firstly, it is important to know that most of the video applications which run of FreeBSD were developed as Linux applications, originating in the past year. For this reason, they are both, very experimental and also riddled with Linux-isms which might prevent them from working at full efficiency on FreeBSD.</para> <para>By "experimental", I mean that you can expect re-encoders, players, and DVD decrypters to all have some major bugs, or interoperability problems with other programs. Here is a short list of the sorts of things I mean: <orderedlist> <listitem><para>An application cannot playback a file which another application produced.</para></listitem> <listitem><para>An application cannot playback a file which the application itself produced.</para></listitem> <listitem><para>The same application on two different machines, rebuilt on each machine for that machine, plays back the same file differently </para></listitem> <listitem><para>A seemingly trivial filter like rescaling of the image size results in very bad artifacts from a buggy rescaling routine. </para></listitem> <listitem><para>Application always dumping core.</para></listitem> <listitem><para>Documentation is not installed with the port and can be found either on the web or under <filename>${PORTPATH}/work/ </filename>.</para></listitem> </orderedlist> </para> <para>By "Linux-isms", I mean that there are some 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, because that is where the authors are primarily developing. These issues may not be noticed and worked around by the port maintainers which can lead to some problems like these: <orderedlist> <listitem><para>The use of <filename>/proc/cpuinfo</filename> to detect processor characteristics.</para></listitem> <listitem><para>A misuse of threads which causes a program to hang upon completion than truly terminate.</para></listitem> <listitem><para>Software not yet in the FreeBSD Ports Collection which is commonly used in conjunction with the application.</para> </listitem> </orderedlist> So far, these application developers have been cooperative with port maintainers to minimize the work-arounds needed for port-ing. </para> <sect2 id="video-mplayer"> <title>MPlayer</title> <para>MPlayer is a recently developed and rapidly developing video player. The goals of the MPlayer team are speed and flexibility on Linux and other UN*X's. The project was started when the team founder got fed up with bad playback performance on then available players. Some would say that interface has been sacrificed for streamlined design, but once you get used to the command line options and the key-stroke controls, it works very well.</para> <sect3 id="video-mplayer-building"> <title>Building MPlayer</title> <indexterm><primary>mplayer</primary> <secondary>making</secondary></indexterm> <para>MPlayer resides in <filename role="package">graphics/mplayer</filename>. 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. Thus it is important to build it from ports and not to use a binary package(though work is being done to make it more auto-detecting). Additionally, a number of options can be specified in the <command>make</command>, as you might see when you start: </para> <screen>&prompt.root; cd /usr/ports/graphics/mplayer &prompt.root; make You can enable additional compilation optimizations by defining WITH_OPTIMIZED_CFLAGS You can enable GTK GUI by defining WITH_GUI. You can enable DVD support by defining WITH_DVD. You can enable SVGALIB support by defining WITH_SVGALIB. You can enable VORBIS sound support by defining WITH_VORBIS. You can enable XAnim DLL support by defining WITH_XANIM. </screen> <para>If you have <filename role="package">x11-toolkits/gtk12</filename> installed, then you might as well enable to GUI. Otherwise, it is not worth the effort. If you intend to play (possibly CSS encoded) DVD's with MPlayer you must enable to DVD support option here <footnote><para>SOME SORT OF DISCLAIMER ABOUT CSS HERE</para> </footnote>. For example: <screen>&prompt.root; make WITH_DVD=yes WITH_SVGALIB=yes</screen> </para> <para>As of this writing, the MPlayer port will build its HTML documentation and one executable, <command>mplayer</command>. It can also be made to build an encoder, <command>mencoder</command>, which is a tool for re-encoding video. A modification to the <filename>Makefile</filename> can enable it. It may be enabled in subsequent versions of the port.</para> <para>The HTML documentation to MPlayer is very informative. If the reader finds the information on video hardware and interfaces in thie chapter lacking, the MPlayer documentation is a very thorough alternative. I urge it's reading by anyone wishing to obtain expertise in UN*X video.</para> </sect3> <sect3 id="video-mplayer-using"> <title>Using mplayer</title> <indexterm><primary>mplayer</primary> <secondary>use</secondary></indexterm> <para>Any user of mplayer must set up a <filename>.mplayer</filename> subdirectory directory of her home directory. This can currently be done by <screen>&prompt.user; cd /usr/ports/graphics/mplayer &prompt.user; make install-user</screen> which will create the necessary subdirectory. </para> <para>The command options for <command>mplayer</command> are listed in the manual page. For more detail there is HTML documentation. In this section, we will give some of the common use cases.</para> <para>To play from file, such as <filename>testfile.avi</filename> through an XVideo interface, <screen>&prompt.user; mplayer -vo xv testfile.avi</screen> through the SDL interface, <screen>&prompt.user; mplayer -vo sdl testfile.avi</screen> through X11, <screen>&prompt.user; mplayer -vo x11 testfile.avi</screen> through DGA (as root), <screen>&prompt.root; mplayer -vo dga testfile.avi</screen> through DGA via SDL, <screen>&prompt.root; mplayer -vo 'sdl:dga' testfile.avi</screen> It is worth trying all of these options, as their relative performance depends on many factors and will vary significantly with hardware. </para> <para>To play from a DVD, replace the <filename>testfile.avi</filename> with <option>-dvd <N></option> where <N> is the track number to play. For example, <screen>&prompt.root; mplayer -vo dga -dvd 2</screen> plays track 2 from <filename>/dev/dvd</filename>.</para> <para>To stop, pause, advance and so on, consult the keybindings output by running <command>mplayer -h</command> or in the manual page.</para> <para>Additional important options for playback are: <option>-fs -zoom</option> which engages the fullscreen mode and <option>-framedrop</option> which helps performance. </para> <para>In order for the mplayer command line to not become too large, a user can create a file <filename>.mplayer/config</filename> and set default options there: <programlisting>vo=xv fs=yes zoom=yes</programlisting> (Of course, do this in root's home directory if you plan on using dga). </para> <para>Finally, to rip a DVD track into a .vob file do, <screen>&prompt.root; mplayer -dumpstream -dumpfile out.vob -dvd 2</screen> which writes track 2 from <filename>/dev/dvd</filename> to <filename>out.vob</filename>. The output file will be MPEG and can be manipulated by the other packages discussed in this section.</para> </sect3> <sect3 id="video-mencoder"> <title>mencoder</title> <indexterm> <primary>mencoder</primary> </indexterm> <para> If you opt to install <command>mencoder</command> when you built the port, be forewarned that it is still quite experimental.</para> <para> To use <command>mencoder</command> it is a good idea to familiarize yourself with the options from the HTML documentation. There are innummerable ways to improve quality, lower bitrate, and change formats. However, here are a couple of examples to get you going: <screen>&prompt.user; mencoder input.avi -oac copy -ovc copy -o output.avi</screen> should simply copy <filename>input.avi</filename> to <filename>output.avi</filename>, but it is easy to find examples where the output is unplayable even by <command> mplayer</command>. <screen>&prompt.user; mencoder input.avi -oac mp3lame -lameopts br=192 \ -ovc lavc -lavcopts vcodec=mpeg4:vhq -o output.avi</screen> will re-encode <filename>input.avi</filename> in the MPEG4 codec with MPEG3 audio encoding (<filename role="package"> audio/lame</filename> is required). This actually produces playable output. Of course, <filename>input.avi</filename> can be replaced with <option>-dvd 1 /dev/dvd</option> and run as root. </para> </sect2> <sect2 id="video-xine"> <title>Xine</title> <para>Xine 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, <filename role="package">graphics/xine</filename>.</para> <para>The good news is that the above is pretty much true. Xine 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. </para> <para>As of this writing, there is no input module shipped with Xine which will play CSS encoded DVD's. There are third party builds which do have modules for this built in them, but none of these are in the FreeBSD Ports Collection. </para> <para>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. Xine also may perform much worse on the non-XVideo interfaces and has very few good alternatives to it. The Xine FAQ highly recommends that you have a video card which supports it.</para> <para>Xine can be started by itself <screen>&prompt.user; xine</screen> and the menus can be used to navigate to a file, or it can be started with the command line <screen>&prompt.user; xine -g -p mymovie.avi</screen> to start up without the gui and play a file.</para> </sect2> <sect2 id="video-ports-transcode"> <title>Transcode</title> <para>Transcode is not a player, but a suite of tools for re-encoding .avi and .mpg files. With Transcode, one has the ability to merge video files, repair broken files, using command line tools with <filename>stdin/stdout</filename> stream interfaces. </para> <para>Like MPlayer, Transcode is very experimental software which must be build from the port <filename role="package">graphics/transcode</filename>. Using a great many options to the <command>make</command>. I recommend: <screen>&prompt.root; make WITH_LIBMPEG2=yes</screen> or, if you plan to install <filename role="package">graphics/avifile </filename>, do <screen>&prompt.root; make WITH_AVIFILE=yes WITH_LIBMPEG2=yes</screen> and possibly adding <option>WITH_OPTIMIZED_CFLAGS=yes</option>.</para> <para>Here are some examples of <command>transcode</command> fir video conversion: <screen>&prompt.user; transcode -i input.vob -x vob -V -Z 320x240 -y opendivx -N 0x55 -o output.avi</screen> resizes and coverts <filename>input.vob</filename> to a DiVX (MPEG4) AVI file. <screen>&prompt.user; transcode -i input.vob -x vob -V -Z 320x240 -y mpeg -N 0x55 -o output.tmp &prompt.user; tcmplex -o output.mpg -i output.tmp.m1v -p output.tmp.mpa -m 1</screen> creates an MPEG video file (which is a very portable video format compared to the various AVI formats To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-doc" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200206020301.UAA09990>