From owner-freebsd-doc Mon Jun 3 19:21:22 2002 Delivered-To: freebsd-doc@freebsd.org Received: from mx1.eskimo.com (mx1.eskimo.com [204.122.16.48]) by hub.freebsd.org (Postfix) with ESMTP id 85D8B37B400 for ; Mon, 3 Jun 2002 19:20:31 -0700 (PDT) Received: from eskimo.com (ripper@eskimo.com [204.122.16.13]) by mx1.eskimo.com (8.9.1a/8.8.8) with ESMTP id TAA24355; Mon, 3 Jun 2002 19:20:24 -0700 Received: (from ripper@localhost) by eskimo.com (8.9.1a/8.9.1) id TAA24404; Mon, 3 Jun 2002 19:20:24 -0700 (PDT) Date: Mon, 3 Jun 2002 19:20:24 -0700 (PDT) Message-Id: <200206040220.TAA24404@eskimo.com> From: Ross Lippert To: ue@nathan.ruhr.de Cc: freebsd-doc@FreeBSD.ORG In-reply-to: <20020603060702.GO65310@nathan.ruhr.de> (message from Udo Erdelhoff on Mon, 3 Jun 2002 08:07:03 +0200) Subject: Re: A video chapter (pr doc/31653) Sender: owner-freebsd-doc@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.org OK, I thnk I have addressed your points. Again, I am not sure how to build the man entities, but I have de-amp-ed them so as not to cause confusion. But I think the question is still open as to whether to turn the sound chapter into a multimedia chapter or have a chapter on its own. I'm leaning towards expanding the sound chapter into multimedia, but there is some issue of integration, like should the current sound chapter be turned into half a chapter with this the other half? Or should the sections be flattened together or what. If I'm given license I'll integrate with the sound chapter myself as I judge fit, but if there is someone maintaining it, let's talk. -r ps the current version -- still wanting feedback Ross Lippert Contributed by Video Playback Synopsis 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 audio/sox. However, the software landscape in this area is changing rapidly. After reading this chapter, you will know: Some ways in which video is supported by XFree86. Some ports/packages of video players/encoders which give good results. How to playback DVD's, .mpg and .avi files. How to rip DVD video titles into data files. Before reading this chapter, you should: Know how to configure your soundcard (). Know how to configure and install XFree86 () It is assumed that XFree86 4.X is being used. XFree86 3.X may work, but this author has not made the attempt. Determining Video capabilities Xvideo Xv sdl SDL dga DGA kernel configuration options CPU_ENABLE_SSE kernel configuration options USER_LDT Video display under X11 suffers from a multitude of possibilities, what will each works 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 XFree86 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 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. 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 /dev/dvd, it is also a good idea to have a symbolic link to the appropriate device: &prompt.root; ln -sf /dev/acd0c /dev/dvd &prompt.root; ln -sf /dev/racd0c /dev/rdvd On FreeBSD-5.X, which uses devfs there is a slightly different set of recommended links: &prompt.root; ln -sf /dev/acd0c /dev/dvd &prompt.root; ln -sf /dev/acd0c /dev/rdvd Some of the packages discussed in the next section rely on the following kernel options to build correctly. Before attempting to build, add these options to the kernel and reboot: option CPU_ENABLE_SSE option USER_LDT To enhance the shared memory X11 interface, it is recommended that the values of some &man.sysctl.1; variables should be increase: kern.ipc.shmmax=67108864 kern.ipc.shmall=32768 XVideo XFree86 4.X 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 on even low-end machines (for example my PIII 400Mhz laptop). Unfortunately, the list of cards in which this feature is supported out of the box is currently: 3DFX Voodoo 3 Intel i810 and i815 some S3 chips (such as Savage/IX and Savage/MX) If your card is not one of these, do not be disappointed yet. XFree86 4.X adds new xv capabilities with each release 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. . To check whether the extension is running, use xvinfo: &prompt.user; xvinfo XVideo is supported for your card if the result looks like: 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 Also note that the formats listed (YUV2, YUV12, etc) are not present with every implementation of Xvideo and their absense may hinder some players. If the result looks like: X-Video Extension version 2.2 screen #0 no adaptors present 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 probably should read about ways to improving performance in the advanced reading . Simple Directmedia Layer 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. The SDL can be found at sdl12 Direct Graphics Access 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 root The DGA extension can be tested and benchmarked by &man.dga.1;. When dga is running, it changes the colors of the display whenever a key is pressed. To quit, use q. Ports and Packages Dealing with Video video ports video packages 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. 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. 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: 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. Application always dumping core. Documentation is not installed with the port and can be found either on the web or under ${PORTPATH}/work/ . 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: The use of /proc/cpuinfo to detect processor characteristics. A misuse of threads which causes a program to hang upon completion than truly terminate. 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 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 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. Building MPlayer mplayer making MPlayer resides in graphics/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. Thus 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 which echo at the start of the build. &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. If you have x11-toolkits/gtk12 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 SOME SORT OF DISCLAIMER ABOUT CSS HERE . Some reasonable options are: &prompt.root; make WITH_DVD=yes WITH_SVGALIB=yes As of this writing, the MPlayer port will build its HTML documentation and one executable, mplayer. It can also be made to build an encoder, mencoder, which is a tool for re-encoding video. A modification to the Makefile can enable it. It may be enabled by default in subsequent versions of the port. 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 its reading by anyone wishing to obtain expertise in Unix video. Using mplayer mplayer use Any user of mplayer must set up a .mplayer subdirectory directory of her home directory. to create this necessary subdirectory, you can do the following: &prompt.user; cd /usr/ports/graphics/mplayer &prompt.user; make install-user The command options for mplayer are listed in the manual page. For even more detail there is HTML documentation. In this section, we will give some of the common use cases. To play from file, such as testfile.avi through one of the various video interfaces set the : &prompt.user; mplayer -vo xv testfile.avi &prompt.user; mplayer -vo sdl testfile.avi &prompt.user; mplayer -vo x11 testfile.avi &prompt.root; mplayer -vo dga testfile.avi &prompt.root; 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 from a DVD, replace the testfile.avi with where <N> is the title number to play and ${DEVICE} is the device file for the DVD-ROM. For example, to play title 3 from /dev/dvd: &prompt.root; mplayer -vo dga -dvd 2 /dev/dvd 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: which engages the fullscreen mode and 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: vo=xv fs=yes zoom=yes Remember, if you are going to run as root then set this in the root home directory as well. Finally, mplayer can be used to rip a DVD title into a .vob file. To dump out title 2 from a DVD: &prompt.root; mplayer -dumpstream -dumpfile out.vob -dvd 2 /dev/dvd The output file, out.vob, will be MPEG and can be manipulated by the other packages discussed in this section. mencoder mencoder If you opt to install mencoder when you build, be forewarned that it is still quite experimental. To use 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. There are innummerable ways to improve quality, lower bitrate, and change formats, and some of these tricks may make the difference between good playback performance and bad. Here are a couple of examples to get you going. First a simple copy: &prompt.user; mencoder input.avi -oac copy -ovc copy -o output.avi It is easy to find examples where the output is unplayable even by mplayer. Thus, if you just want to rip to a file, stick to the in mplayer. To re-encode input.avi in the MPEG4 codec with MPEG3 audio encoding ( audio/lame is required): &prompt.user; mencoder input.avi -oac mp3lame -lameopts br=192 \ -ovc lavc -lavcopts vcodec=mpeg4:vhq -o output.avi This has produced output playable by mplayer and Xine. input.avi can be replaced with 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. Xine 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, graphics/xine. 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. 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. 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. Xine can be started by itself: &prompt.user; xine The menus can then be used to open a file, or it can be started to play a file immediately without the gui with the command: &prompt.user; xine -g -p mymovie.avi Transcode 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 stdin/stdout stream interfaces. Like MPlayer, Transcode is very experimental software which must be build from the port graphics/transcode. Using a great many options to the make. I recommend: &prompt.root; make WITH_LIBMPEG2=yes If you plan to install graphics/avifile, then add that option: &prompt.root; make WITH_AVIFILE=yes WITH_LIBMPEG2=yes Here are two examples of transcode for video conversion which produce rescaled output. The first encodes the output to an openDIVX AVI file, while the second encodes to the much more portable MPEG format. &prompt.user; transcode -i input.vob -x vob -V -Z 320x240 \ -y opendivx -N 0x55 -o output.avi &prompt.user; transcode -i input.vob -x vob -V -Z 320x240 \ -y mpeg -N 0x55 -o output.tmp tcmplex -o output.mpg -i output.tmp.m1v -p output.tmp.mpa -m 1 There is a manual page for transcode, but for the various tc* utilities which are also installed, there is only a curt output. In comparison, transcode runs significantly slower than mencoder, but it has a better chance of producing a more widely playable file. I can play transcode MPEGs on older copies of Windows Media Player and Apple's Quicktime, for example. Further Reading I have no doubt that within a year, much that is in this chapter will be out of date. Video will probably be much less problematic to get working well and a port will be in the collection which turns a FreeBSD system into a DVD-playing, PVR, and virtual A/V studio. Until that day arrives, 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 some links to learn more in case this chapter was just helpful enough. 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 may become useful additions to the FreeBSD Ports Collection: XTheater AVIFile To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-doc" in the body of the message