Automated DVD menu authoring with pdfLATEX
←
→
Page content transcription
If your browser does not render page correctly, please read the page content below
Automated DVD menu authoring with pdfLATEX Péter Szabó Budapest University of Technology and Economics, Dept. of Computer Science and Information Theory, H-1117 Hungary, Budapest, Magyar tudósok körútja 2. pts (at) cs dot bme dot hu http://www.inf.bme.hu/~pts/ Abstract dvdauthor is an excellent low-level free tool for video DVD authoring on Unix systems. However, it doesn’t provide a convenient way for drawing the menu background and buttons. We present dvdmenuauthor, a collection of scripts for automated DVD authoring with menus. dvdmenuauthor uses pdfLATEX macros for menu composition, Xpdf for menu rendering, and dvdauthor for DVD filesystem authoring. 1 Background Popular reasons for adding menus to a DVD: DVD-Video [8] is today’s most popular home enter- • DVD menus are a good quality addon for Holly- tainment video format. Video shops and video rental wood-style movies. Both the visual appearance services used to provide films on VHS cassettes in the and the sound of the menu is in theme with the 1990s, but now they offer DVD discs almost exclu- movie, and the first minute spent on navigating sively. DVD not only provides cheaper reproduction the menu (mostly in order to select the audio costs, better video and audio quality than VHS, and stream and subtitles) is now part of the fun the multiple camera angles, audio tracks and subtitles, spectator experiences. but it also has an advanced, programmable (but op- • If the DVD contains a lot of material (up to 8 tional) navigation facility called DVD menus (or DVD hours are feasible using double-layer discs and extras). lossy compression), spectators expect an order The remote control of a DVD player device has in which they can easily find the title they are several menu buttons (such as menu, top menu, au- looking for. Menus with thumbnail images and dio, subtitle and angle), which, when pressed, sus- title captions make navigation easier. It is also pend playback and jump to a menu. A menu is a possible to have multiple menus that point to single-page interactive part of the DVD, designed the same set of titles, but in different logical and programmed by the DVD creator. It can be order. Usually 2 × 2 or 3 × 2 thumbnails are animated (possibly in a loop), and it can have audio displayed in a single menu, and such menus as well. A menu has several on-screen buttons, one are linked together using buttons. Most DVD of them being highlighted. The arrow buttons (up, authoring software provide an automated wizard right, down and left) on the remote control can be for generating thumbnailed menus of this kind. used move the highlight, or, when the DVD is played • DVD menus make it possible to present an in- on a computer, the highlight is moved to the button teractive show to the spectators, in which they under the mouse. The enter button can be used can choose among 2 or 3 endings of the movie, to execute the action associated to the highlighted or they can even choose in the middle how the on-screen button. Possible actions: story should advance. Of course, movie creators • resume or start playback at a specific location; must record all possible storylines, which is a lot of extra work, and the capacity of the DVD disk • jump to another menu (possibly with a specific also limits the available choices. However, it can button pre-highlighted); be feasible to give the spectator 3 choice points • change a playback-related variable (such as au- and thus have 2 · 2 · 2 = 8 storylines altogether dio stream, subtitle language and angle); in a 1-hour long movie. • change an auxiliary variable (to be used later) — • It is also possible to offer a trivia game (playable integer arithmetic operators are available; by the spectator) in DVD format. For example, • execute a conditional block (if–then–else). the famous Who wants to be a millionaire TV 166 TUGboat, Volume 29, No. 1 — XVII European TEX Conference, 2007
Automated DVD menu authoring with pdfLATEX game has a DVD version [16], in which the next so a multi-gigabyte temporary ISO image file question is chosen randomly from about 1000 doesn’t have to be created. pre-recorded questions. Even the three lifelines are present. All these are programmed as a set 2 Motivation of DVD menus. This article focuses on DVD menu authoring, i.e. The process of designing and creating a DVD-Video adding menus and integrating DVD-Video compo- disc is called DVD authoring. It consists of these nents. It presents a solution based on the combina- steps: tion of dvdauthor XML integration and LATEX type- 1. DVD stream authoring: The video, audio and setting. The reasons why such a solution can be subtitle streams are created, imported and mul- useful: tiplexed together to DVD-compatible MPEG-2 • Our solution uses only free software and runs program stream files. The DVD standard im- on Unix systems. We have tried several tools poses quite a lot of restrictions on the file format, [3, 14, 7, 11], but we haven’t found such a tool the video resolution, the frame rate, the video for Unix which is user-friendly, well-integrated codec, the audio codec and the audio sample (doesn’t need a specific version of several dozen rate. However, there are tools (such as the free other software packages to work), reliable (no DeVeDe [2]) which can convert any stream to random crashes) and ready for production use a DVD-compatible stream. Most video edit- (no major bugs and annoyances, no memory ing tools have DVD-compatible export filters. leaks). We decided to develop our own software, For simple MPEG video editing, we recommend which is practical and usable for menu-based MPEG Video Wizard [17], which is not only ef- DVD authoring. ficient to use, but it also runs quickly enough • Most popular video editing programs provide even in virtualised environments. only a wizard, which streamlines creating simple 2. DVD menu authoring: The menu background menus (such as thumbnail buttons for each title), images (or animations), buttons and captions and doesn’t let the user specify the exact menu are designed, menus and titles (i.e. streams au- structure. thored in the previous steps) are combined using programmed actions. This step is the integra- • A template-based, non-WYSIWYG solution is tion part of the DVD authoring process, because useful for repetitive, automated menu genera- the way individual background images, thumb- tion, such as generating a navigable DVD slide- nails, captions and stream files are combined show from a set of images, or generating several together is specified in this step. If dvdauthor DVDs (with different video content) using one [3] is used in the next step, the details of the in- menu theme. tegration are specified in its XML project input • LATEX provides a separation of text and design file. that is versatile enough for several designs to 3. DVD filesystem creation: The various stream be tried (and possibly customised) for the same files and declarations are combined to a DVD- menu structure. Most WYSIWYG DVD menu Video filesystem (with the VIDEO_TS folder). creation tools let the user manipulate the de- This is a completely automatic process (and sign of one object a time. Most of them don’t takes about 5 minutes on modern PCs for a support requests like “let’s see the same design single-layer full DVD). On Linux, dvdauthor with 10% larger buttons”, and even those that [3] is the only well-known free tool that can do support it, won’t be able to adjust the spac- the job; other programs are usually easy-to-use ing properly around the resized buttons. With frontends to dvdauthor. LATEX, however, those kinds of changes can be 4. DVD image creation: An ISO image file is cre- easily done with glue nodes and a little macro ated automatically from the DVD filesystem. On programming. Linux systems, it is usually done with mkisofs • TEX can typeset textual labels of high quality. [13], with the -dvd-video option. Most DVD authoring programs have very lim- 5. DVD disc burning: The ISO image file is au- ited typographic capabilities, for example they tomatically burnt to a DVD disc. On Linux don’t support manual line breaking, line justi- systems, growisofs [10] is a convenient command- fication, automatic line breaking, pair kerning line tool to do the job. It can also combine this and accented characters are not available. Using step with the previous one (DVD image creation), LATEX we get all these features. TUGboat, Volume 29, No. 1 — XVII European TEX Conference, 2007 167
Péter Szabó 3 Design decisions 4 The manual way of authoring DVDs It was our intention to use existing software if possi- This section gives an introduction to DVD-Video ble, and add or change things where existing software concepts, and it also presents the pure, manual way is not powerful enough. We have found that dvd- of DVD menu authoring using dvdauthor. The way author’s XML project file provides an efficient and presented here is similar to typesetting documents precise way for DVD menu authoring — except for with TEX: there are a bunch of input files, most drawing the menus (and converting them to a for- of them being plain text files written by humans, mat that dvdauthor understands). Thus we decided and there are some non-WYSIWYG tools, which can to supplement the XML project file with drawing be applied to the input files in the correct order to operations, and write some scripts that extract the produce the desired output. drawing operations, typeset the menus, render them 4.1 DVD without menus to images, convert the images, and run dvdauthor to create the DVD file system. We chose LATEX for DVD stream authoring is beyond the scope of this pa- the markup language of drawing operations, mostly per, so we assume that the movie is already prepared because it has powerful typesetting capabilities, and in a set of DVD-compatible MPEG-2 stream files. Un- its macro language is powerful enough to implement fortunately, there is no validator for this file format. the necessary housekeeping (e.g. which button was If there is a problem with the file (for example, the emitted to which page). wrong audio codec is used, or the multiplexing packet We wanted to keep LATEX programming at a size is incorrect), dvdauthor will usually complain, minimum, because LATEX is not convenient for gen- but the error message doesn’t always indicate clearly eral data processing. Thus we use LATEX mostly for the reason for the problem. The free video conversion typesetting. Perl scripts generate the document to tools MEncoder [12] and FFmpeg [9] can generate a typeset from the project XML file, and Perl scripts conforming MPEG-2 stream if called with the proper drive the further conversion of pdfLATEX’s PDF out- parameters. See the source code of DeVeDe [2] for put to images (using the pdftoppm tool of Xpdf parameters to MEncoder. [19]). LATEX macros emit some metainformation to A DVD-Video disc consists of titles and menus. the .aux file (e.g. the correspondence of PDF page A title is a stream that contains video and audio numbers and DVD menu button names), which is (multiple video and audio channels possible). The also read by the Perl scripts. playback of a title can start at the beginning or at We wanted to reuse as many LATEX typesetting any specific position (given by a time offset from the constructs as possible, thus the style file just sets beginning). A chapter is a logical unit within a title. the page size, the margins and the default font size, DVD players usually let the user choose a title (by its and lets the user draw the menu with LATEX. We number) to start playback at (not all players expose don’t enforce any specific layout, any layout can chapter boundaries within the title to the user). be designed using TEX boxes, glues and macro pro- The simplest, completely automatic way to cre- gramming. However, we don’t use automatic page ate a DVD without menus is to use dvdauthor [3]. breaks: the user has to decide in advance how many For example, menus to have. (Automatic page breaks wouldn’t dvdauthor -o dir -t a.mpg b.mpg c.mpg fit with dvdauthor’s project file easily anyway.) The dvdauthor -o dir -t d.mpg e.mpg style file also provides some drawing primitives useful dvdauthor -o dir -T for DVD menus: colourful frames, framed buttons, creates a DVD with two titles. Title 1 contains single-colour buttons (of any shape) and absolute 3 chapters (from the contents of video files a.mpg, positioning. b.mpg and c.mpg, respectively). Title 2 contains 2 We designed the project file syntax so that users chapters (from the contents of video fies d.mpg and don’t have to type the same information twice, and e.mpg, respectively). For each title, files dir/VIDEO data relationships are often expressed by putting _TS/VTS_NN_* are created, where NN is the number related pieces close to each other. For example, it of the title. The last command (with the -T) creates is possible to specify the thumbnail image file name the table of contents (to files dir/VIDEO_TS/VIDEO_ as an attribute to the DVD tag. The TS.*). Please note that the contents of the video image file name will be passed as a parameter to the files are copied, so running dvdauthor takes time and appropriate macro that draws the image. needs free disk space (about the same size as the The software we have written, dvdmenuauthor, total size of the input files). The DVD filesystem is free to use and is available for download from [6]. created in dir can be played with most media players 168 TUGboat, Volume 29, No. 1 — XVII European TEX Conference, 2007
Automated DVD menu authoring with pdfLATEX on Linux (e.g. Xine, VLC, Kaffeine and MPlayer). If jump to a different menu without the enter remote it looks right, it can be burnt to disc: control button. [15] is a detailed tutorial about this. growisofs -dvd-compat -Z /dev/dvd \ Animated thumbnails (where the thumbnail of the -dvd-video dir/ current button is animated) can be also be created this way. To have animated thumbnails, a separate, 4.2 DVD with menus animated menu has to be created for each button, each menu having only one button and neighbouring If menus are involved or complex settings have to actions, which jump to another menu. be specified, then a project file (in XML format) Both titles and menus support executing code should be prepared for dvdauthor, which specifies all before the title or menu is entered (specify such code aspects of the DVD (how chapters, titles and menus inside the in the dvdauthor XML fie) and when should be formed from input files; what settings it is left (use the tag). The tag of the should be used; what code should be executed at main menu can contain code to skip the intro video events like title playback beginning, title playback unless the disc playback has just started. This can end and remote control button press). Then the be implemented as a conditional jump instruction. DVD filesystem would be created by the command The condition should depend on a variable, which is dvdauthor -x project.xml set just before jumping to the intro. The manual page of dvdauthor [4] gives an excel- The similarity of titles and menus implies that lent and concise introduction to DVD-Video concepts. menus can have audio and animation. These fea- However, it doesn’t contain examples for complex tures for menus are provided by default, since the XML projects. To get such an example, one should menu background is an MPEG-2 file itself, which try some GUI DVD authoring tools (such as [11, 14]) can contain audio, and of course can contain anima- and see what files they generate. tion. DVD authoring applications (including dvd- A DVD menu is similar to a title, with some ex- menuauthor) usually support only still images for tra interactive features, such as buttons and actions. menus, and they take care of converting these im- Buttons form an extra visual layer above the menu. ages to MPEG-2 videos of a few seconds in length. Each button is a rectangular image (other shapes Making the menu video loop is straightforward: the can be specified using transparent pixels) with only menu’s code has to be extended with a jump a small number of colors (≤ 16). Buttons on a menu command that jumps to the beginning of the menu. page might not overlap. Each button has 4 neigh- DVD players are usually slow when jumping (par- bours (left, right, up and down). A neighbour is tially because a seek on the DVD disc is slow), so activated when the user presses the corresponding expect about a half second of audio lag when the arrow button on the remote control. When a menu is menu loops. Some players also ignore remote control being shown, it has a current button. Only the image buttons during this lag. of the current button is drawn over the video, none There are some additional concepts which are of the other buttons are displayed. When another important to understand before designing a DVD button is activated, it becomes the current button, it structure by hand. Such concepts are: vmgm, titleset gets displayed (and the previous button gets hidden). and cell. These are documented in the manual page When the user presses the enter remote control but- of dvdauthor [4]. ton, the code associated with the current button is Sometimes a code snippet in a DVD program is executed. The code can be specified in the project too long. Unfortunately, dvdauthor doesn’t always XML file inside the corresponding tag. The indicate this error condition properly. The solution syntax is similar to a very small subset of C, it is is to split the containing menu to two or more menus, documented in the manual page of dvdauthor. each of them containing half of the code, and jumping Menus can also contain actions. An action is to each other when necessary. like a button with code (to be executed), but with- out a visual representation. An action is activated Restrictions There are some restrictions on the either by the arrow keys on the remote control (in sources and targets of direct jumps in the DVD pro- this case, the action must be a neighbour of the gram code. (For example, one cannot jump from one current button), or by special keys (such as angle) titleset directly to another one. Another example: in on the remote control. Actions are very briefly doc- some jumps, the target menu number cannot be spec- umented; just a little information can be found in ified — the so-called entry point must be given.) To the manual page of spumux (a tool which is part of overcome these restrictions, an indirect jump can be the dvdauthor suite). Actions can also be used to used: set a variable, jump to the main menu, whose TUGboat, Volume 29, No. 1 — XVII European TEX Conference, 2007 169
Péter Szabó code examines the variable and jumps to the For example, if we move or resize a button, then desired target title or menu. dvdauthor provides a the background stream, the button layers and the scarcely documented facility (the jumppad="1" at- button bounding boxes have to be properly modified. tribute) to do this automatically. However, this dvdmenuauthor does all these automatically. might produce extra errors if the DVD program code To find out how to assemble the visual elements is long. It is safer to implement the indirect jumps to an MPEG-2 stream, the easiest way is to examine by hand. the auxiliary files generated by GUI frontends to dvdauthor [11, 14]. The XML syntax is explained 4.3 Drawing the menus in the manual page of dvdauthor and its spumux All aspects of the DVD can be specified straightfor- tool, and also in [5]. dvdmenuauthor contains a wardly in the dvdauthor XML project file, except Perl script called genmpeg.pl, which can generate a for the menu background image, the menu button DVD-compatible MPEG-2 stream from a series of images and the button neighbour relationships. Our still images. aim with dvdmenuauthor was to automate this pro- cess as far as possible, while still leaving full control 5 DVD menus with dvdmenuauthor to the user. But first let’s see a manual method. The 5.1 A menu with thumbnails visual part of a DVD menu consists of: Figure 1 shows a typical thumbnail menu in a 3 × 2 • background stream: an MPEG-2 stream with layout. The menu has a background, a title caption, video and audio. For simple menus, the audio up to 6 thumbnail buttons (now actually 5), a caption is silent, and the video contains a single still for each thumbnail, and three navigation buttons image repeated for a couple of seconds. (dvd- to reach other menus. For simplicity, big numbers menuauthor supports only still images without are displayed instead of real thumbnails from the audio.) video. In the figure, thumbnail button number 1 is • button highlight layer: a single image with a highlighted with an ochre rectangular frame. few colours and transparency. This layer con- Figure 2 shows how to define such a menu in sists the union of the button images. When dvdauthor’s XML project file. All the visual ele- the DVD player displays a menu, it draws the ments, including the background, the button layers image of the current button (taken from the but- and the button bounding boxes are encoded in the ton highlight layer) over the background stream. file menu42.mpg. Probably spumux was used to mul- A simple button highlight layer contains only tiplex these visual elements to the file. The figure a single colour besides the transparent pixels. shows that each button has a name and a corre- (dvdmenuauthor supports only a single colour.) sponding program code to execute when the button • button select layer: similar to the button high- is activated. If there are any actions in the menu, light layer, but a button is drawn from here they also appear as tags here. when it is activated (with enter ). The duration Figure 3 shows how to draw the same menu us- that the image is displayed is just a few hundred ing dvdmenuauthor. It also illustrates the following milliseconds: it lasts until the DVD player loads features of the software: the next title or menu. Usually the button high- • LATEX markup can be used to typeset the cap- light layer is the same as the button select layer, tions (see \emph). but with a different color. • TEX’s line breaking algorithm can be used (see • button bounding boxes: the rectangular bound- caption of button 1). ing box of each button on the menu. These • The visual design is separated from the menu- boxes must not overlap. specific data (actual captions and thumbnail • button neighbours: the name of the left, right, up images) using templates. Only the menu-specific and down neighbour for each button. dvdauthor data is shown on the figure. is able to infer neighbourhood relationships from • All information needed to render a button are bounding box coordinates. packed together to the XML tag. The • button and action names: these are used by attributes with the tex: namespace are passed dvdauthor to identify the button (or action) to LATEX. within the menu, in order to be able to add code • There is no need to specify button bounding to be executed when the button is selected. boxes. It is quite cumbersome to keep all these visual To further illustrate the magic happening, Fig- elements in sync by hand when drawing the menus. ure 4 shows the LATEX code snippet generated from 170 TUGboat, Volume 29, No. 1 — XVII European TEX Conference, 2007
Automated DVD menu authoring with pdfLATEX Figure 1: A menu created by dvdmenuauthor g5=6; jump menu 2; jump menu 3; jump menu 4; jump menu 5; jump vmgm menu 1; jump vmgm menu 1; jump vmgm menu 1; Figure 2: A menu definition in the dvdauthor project file \thispagebgimage{}{pal_bg_light} \thispagetemplate{palthumbsix} \menucaption{Fazekas szalagavató 1998.\ december} g5=6; jump menu 2; jump menu 3; jump menu 4; jump menu 5; jump vmgm menu 1; jump vmgm menu 1; jump vmgm menu 1; jump vmgm menu 1; Figure 3: A menu definition in the dvdmenuauthor project file TUGboat, Volume 29, No. 1 — XVII European TEX Conference, 2007 171
Péter Szabó \begin{dvdmenupage}{e1,e2,e3,e4,e5,prev,back,next} \thispagebgimage{}{pal_bg_light} \thispagetemplate{palthumbsix} \menucaption{Fazekas szalagavató 1998.\ december} \begingroup\def\dvdbuttonattrXname{e1} \def\dvdbuttonattrXcaption{a szalagtűzés \emph{előtt}} \def\dvdbuttonattrXimage{1.png} \dvdprocessbutton\endgroup \begingroup\def\dvdbuttonattrXname{e2} \def\dvdbuttonattrXcaption{szalagtűzés} \def\dvdbuttonattrXimage{2.png} \dvdprocessbutton\endgroup ... \begingroup\def\dvdbuttonattrXname{next} \def\dvdbuttonattrXdummy{} \dvdprocessbutton\endgroup \end{dvdmenupage} Figure 4: The LATEX code snippet generated from the dvdmenuauthor definition the dvdauthor definition on Figure 3. We can see \putat{x }{y}boxspec that for each attribute with a tex: prefix, a macro Typesets the specified material with its reference \dvdbuttonattrX... is defined, and the command point at (x, y). Creates a properly shifted box of size \dvdprocessbutton is called after the macro defini- zero. Can be used for absolute positioning if called tions for each button. The tex:dummy attribute is at the top of the page. Can be used with \vbox for just an indicator that the button must be processed last line alignment or \vtop for first line alignment. by LATEX. This command can be used in templates. The macros \menucaption and \dvdprocess button are defined in template palthumbsix. They \begin{dvdmenupage}{buttonlist} take care of the visual formatting of the menu data. Renders a DVD menu page with the specified buttons \dvdprocessbutton has the available button names (in the specified order). For technical reasons (see hardwired, and it formats and positions a button Subsection 6.2) each button is rendered on its own based on its name. onto a separate PDF page. 5.2 New LATEX commands provided \framehbox{sep-dimen}{hbox-contents} Although dvdmenuauthor encourages the use of ex- Similar to the built-in command \framebox, but isting LATEX commands, it also defines some new allows catcode changes and verbatims in the box. commands, most of them related to positioning and Unfortunately, catcode changes don’t work in gen- button typesetting. eral in dvdmenuauthor, because the dvdmenupage environment reads its contents to a macro for multi- \thispagecolor{colorname} ple rendering. Changes the background of the current page to the specified color. Like most graphics operations in \aliascolor{oldname}{newname} dvdmenuauthor, it works only with pdfLATEX. Copies a colour definition to be usable as a different name. \thispagebgimage{optionlist}{filename} Sets the background image for the current page. The \dvdtextbutton{name}{text} image will be loaded by the \includegraphics com- Typesets a button. Doesn’t wrap its contents in mand using the pdftex driver. a box, so a button can be in a middle of a para- graph, even line breaks are allowed. Each button has \thispagetemplate{templatename} three forms: background, highlighted and selected. Selects the specified template for the current page. In background mode, text is typeset normally, in This means defining some macros, for example the highighted mode, it is typeset in dvdhighlightedcolor sample template palthumbsix defines \menucaption (without color changes and images), and in selected and \dvdprocessbutton. mode it typesets in dvdselectedcolor. 172 TUGboat, Volume 29, No. 1 — XVII European TEX Conference, 2007
Automated DVD menu authoring with pdfLATEX \dvdframebutton{name}{text} 5. Authoring the DVD filesystem. This is just a Typesets a button inside a \hbox. In background simple dvdauthor run (with the -x option using mode, emits the \hbox. In highlighted mode, it emits the XML project file generated in the first step). an empty box surrounded by a frame (using the pa- This step might take quite a lot of time (up to rameters \dvdbuttonframesep, \dvdbuttonframe 5 minutes on modern systems for a full, 4.7 GB width and dvdhighlightedcolor ). This command can DVD), and it needs free disk space about the be used to typeset thumbnail buttons. same size as the sum of the input video sizes. The recommended DVD preview application is Xine \begin{narrowcentering} [18]. It can be installed from source in any mod- Like \begin{centering}, but doesn’t reset the nat- ern Linux distribution. Although the user interface ural width of \leftskip and \rightskip to zero. (toolbars and menus) of Xine is quite ugly, and not convenient to operate, Xine has very good keybind- 5.3 Working with dvdmenuauthor ings, especially suitable for DVD menu navigation TEX users are familiar with the edit–compile–pre- (a remote control panel is also available — press Alt– view cycle of TEX document preparation, possibly hEi to make it visible). See the manual page of xine extended with a final conversion and printing or pub- for the list of available keys. MPlayer is not rec- lishing. The same cycle exists with dvdmenuauthor. ommended for DVD menu testing, because MPlayer In the edit cycle, the user edits an XML project file doesn’t support DVD menus yet. Although VLC has with LATEX markup for the menus, in the compile DVD menu support, sometimes it crashes or behaves cycle the user compiles the project files (and the unexpectedly. Kaffeine and Totem should also be media files it refers to) to a DVD image, and finally given a try. the user previews the DVD on screen, including the Since dvdauthor runs slowly when the videos to menus and titles. The publishing step is burning the be put on the DVD are large, the compile step might DVD filesystem to disc. be too slow for the user. To solve this, dvdmenu- In the edit step any text editor can be used, author has the dvdmenutest.sh shell script, which preferably one with XML syntax highlighting facili- warps a dvdauthor project XML files so that all titles ties. Unfortunately, LATEX snippets won’t be high- (but not menus!) are replaced with dummy short lighted as LATEX markup. The dvdmenuauthor con- videos, so that the total video size would be small, tains an example project file ex.dmp.xml . and thus dvdauthor runs quickly. The compile step consists of feeding the project The publishing step means creating an ISO im- file to a few scripts. The Makefile in the dvdmenu- age (with mkisofs) and/or burning it to disc (with author distribution automates this. (There is no growisofs). The -dvd-video flag of mkisofs must be incremental compilation support yet: the whole DVD specified in both command lines. filesystem is regenerated from scratch in each make run.) The following steps constitute compilation: 6 Implementation tricks 1. Generating the menu LATEX source file and the Some details of the implementation are worth men- dvdauthor XML project file. This is done by the tioning, because the tricks employed can be useful gendap.pl Perl script. in other TEX or DVD-related projects. 2. Compiling the LATEX source file to PDF. This is 6.1 Bounding box calculation just a regular pdfLATEX run. The Makefile runs dvdmenuauthor calculates button bounding boxes pdfLATEX twice, in case there are \refs. automatically. This operation is impossible within 3. Rendering the PDF to PPM raster image files. TEX, because there is no way to inquire about the This is done by the excellent pdftoppm utility absolute (x, y) coordinates of an item within a box. from Xpdf. Solution: dvdmenuauthor uses a bluescreen tech- 4. Combining the PPM images to short MPEG-2 nique [1]. The LATEX component emits each button streams for the menus. This is done by the on its own to a PDF page with a blue background, genspuxml.pl Perl script, which calls another and a Perl script analyses the rendered page. The Perl script genmpeg.pl (to generate an MPEG- bounding box is the smallest rectangle on the page 2 stream from still images), and the spumux whose complement contains only blue pixels. A little tool from dvdauthor (to multiplex the button extra housekeeping is done for identifying the button layers to the background). Since some image pages belonging to the same menu, because later processing is done in Perl, this step can take they have to be merged again to a button highlight about three seconds for each menu. layer. TUGboat, Volume 29, No. 1 — XVII European TEX Conference, 2007 173
Péter Szabó Limitations: It is not possible to force a bound- Solution: The character set of the XML docu- ing box larger than it appears. It is not possible to ment must be specified in the encoding= attribute use that specific shade of blue in buttons. Fortu- of the
Automated DVD menu authoring with pdfLATEX To solve this, one could render at viewing size (thus [4] The manual page of dvdauthor. degrading rendering quality a little) or one could http://dvdauthor.sourceforge.net/doc/ condense the fonts horizontally (not easy to do in [5] Anders Dahnielson. DVD Author Primer. TEX, but the pdfTEX font expansion feature might December 31, 2003. http://en.dahnielson. be useful). com/2003/12/dvd-author-primer.html 8 Conclusion [6] dvdmenuauthor, automated DVD menu authoring with pdfLATEX. http://freshmeat. TEX can be used productively for typesetting many net/projects/dvdmenuauthor different kinds of work: high quality (possibly inter- [7] DVDStyler, a cross-platform GUI DVD national) documents, maths, presentation slides and authoring system. http://www.dvdstyler. music, to name a few. Other uses of TEX include de/ developing software and its documentation together, preparing web-ready books, and rearranging PDF [8] Wikipedia article on DVD-Video. http: pages. DVD menu authoring is also a new, non- //en.wikipedia.org/wiki/DVD-Video standard use. [9] FFmpeg, a very fast command-line video and We have designed dvdmenuauthor, a program audio converter. for project-file-driven (non-WYSIWYG) automated http://ffmpeg.mplayerhq.hu/ DVD menu authoring with powerful menu drawing [10] DVD+RW-tools, a set of tools for burning and facilities. It is now a free proof-of-concept imple- examining DVD discs. http://fy.chalmers. mentation. DVD menus can be drawn using LATEX se/~appro/linux/DVD+RW/tools/ markup to have high typographic quality output. [11] KMediaFactory, template-based GUI DVD Layout and menu data can be separated using tem- authoring software. http://freshmeat.net/ plates. Since dvdauthor is used for integration, users projects/kmediafactory/ have full freedom to create complex and/or smart [12] MEncoder, the command-line movie encoder of menus they want. The system design (compilation the MPlayer suite. and templates) makes it possible to experiment with http://www.mplayerhq.hu/ layout changes any time in the authoring process. [13] mkisofs, a tool for creating CD and DVD dvdmenuauthor is not easy to start using for an filesystems. http://cdrecord.berlios.de/ average user who expects WYSIWYG and wizards. However, we hope that LATEX users would find it [14] ’Q’ DVD-Author, a GUI frontend for dvdauthor convenient, and the software can evolve from its and other related tools. present proof-of-concept version to a stable, general http://qdvdauthor.sourceforge.net/ and powerful tool like the mainstream TEX-based [15] Samantha Lane. Switched menus with programs. dvdauthor. http://www.geocities.com/ samanthalane/dvd/index.html References [16] Who Wants to Be a Millionaire — DVD game [1] Wikipedia article on the Bluescreen technique. review. http://www.ciao.co.uk/Who_Wants_ http://en.wikipedia.org/wiki/Bluescreen To_Be_A_Millionaire_DVD_Game__Review_ [2] DeVeDe, a GUI program to create video 5480599 DVDs suitable for home players, from any [17] Womble MPEG Video Wizard, a commercial number of video formats supported by MPlayer. nonlinear MPEG video editor. http://www.rastersoft.com/programas/ http://www.womble.com/products/ devede.html [18] Xine, a free multimedia player. [3] dvdauthor, a tool that assembles multiple http://xinehq.de/index.php/home mpeg program streams into a suitable DVD [19] Xpdf, an open source viewer for PDF files. filesystem. http://dvdauthor.sourceforge. http://www.foolabs.com/xpdf/ net/ TUGboat, Volume 29, No. 1 — XVII European TEX Conference, 2007 175
You can also read