This is a "plugin" for the Video Disk Recorder (VDR).

Written by:                   Sascha Volkenandt <sascha at akv-soft dot de>
                              sponsored by Open Source Factory
                              designed for xeatre.tv

                              Some changes merged by Helmut Auer
                              <helmut at helmutauer dot de>

Revision 0.0.009-TEN:         ProjectX/AC3/dual audio channel splitting/16:9
                              all APIDs/charset/layout fixes and extensions by
                              TEN <burn.20.TEN at spamgourmet.com>

Translations:                 Italian by Gianni Zacchia (Pizzak) 
                              <gianni.zacchia at katamail.com>

Latest version available at:  http://ten.htpc-forum.de - Thanks to HelAu for hosting! :-)
Patchlevel/diff discussed at: http://www.vdr-portal.de/board/thread.php?threadid=48264#post452236
Base version available at:    http://www.e-tobi.net/vdr-experimental/pool/source/vdr/vdr-plugin-burn_0.0.009.orig.tar.gz
Project's homepage 0.0.4a-5:  http://www.xeatre.tv/community/burn/
Former versions available at: http://vdr.unetz.com/download/burn/

See the file COPYING for license information.


Purpose
-------

This Plugin enables VDR to write compliant DVDs from VDR recordings while 
being able to control the process and to watch progress from inside VDRs 
on-screen-display. If the selected recordings don't fit the DVD, the video
tracks are requantized (shrinked) automatically.

The created menus support multipage-descriptions (in case the recording summary
exceeds one page).


Requirements
------------

ProjectX.jar       -  http://switch.dl.sourceforge.net/sourceforge/project-x/ProjectX_Source_eng_0.90.4.00.zip
  ** Tested with ProjectX 0.90.4.00/30.03.2006

marks2bytepos.pl   - http://www.vdr-portal.de/board/thread.php?postid=406015#post406015
  ** Could use some testing with 2006-01-07 version
  ** Optional, required for best results when cutting with ProjectX

vdrsync.pl       - http://vdrsync.vdrportal.de 
  ** Tested with 0.1.3PRE1-050115

requant          - http://metakine.com/files 
  ** ATTN: Currently only the snapshot from around July 2004 is supported
  ** For convenience, I've uploaded the package to:
  ** http://www.xeatre.tv/community/burn/contrib/M2VRequantizer.tar.gz

tcrequant, tcmplex, tcmplex-panteltje
(transcode)      - http://www.transcoding.org/
(panteltje)      - http://panteltje.com/panteltje/dvd/
  ** Tested with 0.6.10 - 1.0.0
  ** If using tcmplex-panteltje, 0.4.7 or later is required

Imlib2           - http://enlightenment.org/pages/imlib2.html
  ** Tested with 1.0.5 - 1.2.1
  ** needs at least some truetype font support (freetype or libttf) and png

dvdauthor        
spumux
(dvdauthor)      - http://dvdauthor.sourceforge.net
  ** Tested with 0.6.10 - 0.6.11

growisofs   
(dvd+rwtools)    - http://fy.chalmers.se/~appro/linux/DVD+RW
  ** Tested with 5.13
  ** needs mkisofs

ppmtoy4m
mpeg2enc
(mjpegtools)     - http://mjpeg.sourceforge.net/
  ** Tested with 1.6.0 - 1.6.3-RC3

y4mscaler        - http://www.mir.com/DMG/Software/
  ** Tested with 0.6.2 and 8.1
  ** Be sure to use one that works with your version of mjpegtools

convert          
(ImageMagick)    - http://www.imagemagick.org/
  ** Tested with 5.5.7
  ** Must be compiled with png support


Installation
------------

0. Say your prayers. Backup, just in case no Supreme Being is watching today...

1. Untar the archive inside VDR's plugin-source folder (backing up earlier 
   versions, if any); compile and install it while VDR is stopped

   /etc/init.d/vdr stop

   cd /usr/local/src/VDR/PLUGINS/src
   mv burn burn.backup
   tar xzvf vdr-plugin-burn_0.0.009-TEN.tar.gz
   ln -s burn-0.0.009-TEN burn
   cd burn
   make all ISODIR=/film
   tar cvzf burn-scripts.tar.gz /usr/bin/burnmark.sh /usr/bin/handlearchived.sh /usr/bin/vdrburn.sh
   cp /usr/lib/vdr/libvdr-burn.so.1.3.34 libvdr-burn.so.1.3.34.backup
   cp libvdr-burn.so /usr/lib/vdr/libvdr-burn.so.1.3.34
   tar cvzf burn-scripts.tar.gz /usr/bin/burnmark.sh /usr/bin/handlearchived.sh /usr/bin/vdrburn.sh
   cp scripts/*.sh /usr/bin

   You may have to adjust names to your version of VDR and/or /usr/local/bin.

2. Copy the font file and menu image templates into "/etc/vdr/plugins/burn",
   the VDR configuration directory - or better yet, use the nice backgrounds
   found here: http://www.vdr-wiki.de/wiki/index.php/Vorlagen_%28burn-plugin%29

   tar cvzf etc_burn.tar.gz /etc/vdr/plugins/burn
   cp -a burn /etc/vdr/plugins/

   Adjust the setting for nice execution, DVD chapter length, if vdrsync
   should do the cutting and which mplex/requant programs to use in the
   previously copied /etc/vdr/plugins/burn/vdrburnscript.conf if you like :-)
   - be sure to remove any conflicting overrides from /usr/bin/vdrburn.sh in 
   this case.
   Use /etc/vdr/plugins/burn/ProjectX.ini to store global settings for ProjectX
   when used in burn (e.g. to work around bugs of certain DVD players). In case
   of conflict, requirements for specific recordings by /usr/bin/vdrburn.sh may
   override certain parameters from this file.

3. Add the following entry to your reccmds.conf

   Mark for DVD-Writer        : /usr/bin/burnmark.sh -add
   Delete Mark                : /usr/bin/burnmark.sh -del
   Clean archived recording   : /usr/bin/handlearchived.sh -clean
   Restore archived recording : /usr/bin/handlearchived.sh -restore

   Example configuration files for reccmds.conf in different languages can be
   found in "PLUGINS/src/burn/scripts".

4. Compile and test the latest ProjectX

   cd /usr/local/src
   wget "http://switch.dl.sourceforge.net/sourceforge/project-x/ProjectX_Source_eng_0.90.4.00.zip"
   unzip ProjectX_Source_eng_0.90.4.00.zip
   cd ProjectX_Source_0.90.4
   sh build.sh
   java -jar ProjectX.jar -?

5. If you want to use ProjectX for cutting, download and install FireFly's
   marks2bytepos.pl.tgz cutmark converter
   
   cd /usr/local/src
   wget "http://www.vdr-portal.de/board/attachment.php?attachmentid=8392" -O marks2bytepos.tgz
   tar xzvf marks2bytepos.tgz
   mv marks2bytepos.pl /usr/bin

6. Enjoy! :-)

   /etc/init.d/vdr start


Usage
-----

When starting VDR and the Plugin, you can specify the directory where the 
temporary files will reside, your dvd recorder device, and optionally a 
directory where a possible ISO is placed. If you specify both a dvd recorder
and an iso directory, you can choose in the OSD what actions the plugin will
take (create an ISO, burn on-the-fly, or do both). See vdr -P burn -h for
a syntax explanation.

To start a new DVD Project, you first have to mark one or several recordings
from inside the recordings menu. To do so, select a recording, press the "red" 
button and select "Mark for DVD-Writer". 

Now, you can start the Plugin "Write DVDs" from the main menu. You will see
an overview of the selected recordings along with some additional information.
You can edit the recording and disc titles by selecting such an entry and 
pressing the "right" button. Editing is done as known from other VDR menus
(like when editing channel names). Press "Ok" to confirm and save the title.

The title (T ), short/subtitle (S ) and description (D ) to be used on the sub-
pages per recording will be read from the respective info.vdr.
The desription (D ) may also hold extra parameters introduced with this version
as simple text strings on the very same line, formatted exactly as shown below:

||Zweikanalton LanguageLeft/LanguageRight
to have ProjectX split the left & right audio channels into separate mono files
(typical way of German-language stations additionally transmitting the original
soundtrack on a shared stereo channel - note that this is different from NICAM)

||Widescreen
to enforce an aspect ratio of 16:9 throughout an entire video on demultiplexing
(particularly useful on stations that do not properly switch to 16:9 before the
start of a movie or after breaking away to a block of commercial presentations)

You can also delete recordings from that list and change the order of 
recordingswith the "green" and "yellow" buttons. You can add recordings by 
leaving the plugin and selecting addigional recordings from the recordings
menu.

Between the recording titles and the disc info, you see a progressbar which 
shows how much space the recordings would consume on a 4,7GB DVD+-R(W). If 
space exceeds the limit, an additional warning "Recordings would be shrinked!"
is displayed.

You can choose between 3 DVD Types:
DVD with Menus / DVD without Menus / Archive Disc

The first two options will create a Video DVD compatible Disc with or without
menues. In this case the recording will be cutted according to the marks
during processing.

The third possible DVD type, "Archive-Disc", just burns the VDR recording
structure onto the DVD without shrinking and without cutting, useful in
conjunction with the Media-Detection plugin, which can detect and play such
discs.

Additionally the burn plugin can create "dvd.vdr" marks in the actual
recording directory which are compliant to the DVDArchive patch. After
archiving the recording to DVD you can delete 001.vdr, 002.vdr ... and
index.vdr (which will be done automatically by "handlearchived.sh -clean" -
see the reccmds.conf setup above). In the recording menu you can see the
recording as before. When you try to play the recording the DVDArchive
patch asks for the DVD with the index which has been written to dvd.vdr.
When you insert the DVD it is played as if it would have been on disc.

For an even further improved "WAF" ("woman acceptance factor", cf. illustration
at http://www.heise.de/ct/04/01/003/) you should apply the "enAIO-rm" patch to
vdr, which also displays if a recording is on hard disc or on DVD and if it 
is on DVD it tells you on which (see PLUGINS/src/burn/patches/*enAIO*diff).

Pressing "red" now starts the necessary processes. If you place an empty 
DVD+-R(W) into your drive, the job will run and finish, and after some time
(depending on the speed of your computer) the tray will open and the disc is
finished. Anyway, you will be asked to place an empty disc into the drive if
you forget it.

You will notice that the display changes after you pressed the "red" button.
You can switch between those displays using the "blue" button. This way you
can enqueue additional jobs while one job is processed. In the status display,
you can also see a hint on the progress (although the bar is not too precise)
and whether a job crashed for some reason. If a job is marked as "crashed", 
you could examine the logfiles in /video/.vdr-burn.XXXXX. All intermediate 
files (including logs) are deleted if you remove the erroneous job from the
status display (using the "yellow" button).

The content of finished jobs can be examined by pressing the "Ok" button an
such a job.


Caveats
-------

- No transcoding is done (will fail with non-DVD-compliant DVB-streams)

- The best way for cutting with ProjectX is not settled yet (presently unused):
  http://www.vdr-portal.de/board/thread.php?threadid=48264&page=3#post452937
  This version tentatively implements support for FireFly's marks2bytepos.pl -
  but with just 128 megs of RAM, attempting to cut with ProjectX puts more load
  on my tiny system than it can handle, triggering GPF exceptions caught by the 
  dreaded OOM killer: so it's up to you to keep testing; you've been warned ;-/

- If characters are missing from the output, try using a different font, e.g.
  cd /etc/vdr/plugins/burn
  mv helmetr.ttf helmet.backup.ttf
  ln -s /usr/share/fonts/ttf-bitstream-vera/Vera.ttf helmetr.ttf

- This version should be stable, but there's much room for further improvement: 
  http://www.vdr-portal.de/board/thread.php?threadid=48264&page=3#post452730
  (code it if you can ;-))
