//
//============================================================================
//= BatchMux - version 1.0: Wrapper to use MuxMan 0.15R as a CLI application =
//= --> Limited functionalities but - No scripting + CLI interface :-)       =
//============================================================================
//
// Version 1.0   16-05-2007
// Version 0.9   24-04-2007
// Version 0.8   18-01-2007
// Version 0.7   15-12-2006
// Version 0.6   03-10-2006
// Version 0.5   24-09-2006
// Version 0.4   11-09-2006
// Version 0.3   19-08-2006
// Version 0.2   26-07-2006
// First release 18-07-2006
//
// Changelog:
// 16-05-2007 - First release supporting menues, hardcoded organisation
//              and navigation
//            - Added -hcn1 and -hcn2 argument
// 24-04-2007 - Introduced the "Content Section" and the "Organisation and
//              Navigation Section" concepts, as first steps to support menus
//            - Added highlight items in the structure of Segments to support
//              highlight streams
//            - Added -[SEGi]hlstart[_j] hh:mm:ss:ff argument
//            - Added -[SEGi]hldurat[_j] hh:mm:ss:ff argument
//            - Added -[SEGi]hlmnu[_j] filename argument
//            - Added -[SEGi]hlbset[_j] hh:mm:ss:ff argument
//            - Added -[SEGi]hlbutm{l}[_j] argument
//            - Added -[SEGi]hloffsbutnr[_j] argument
//            - Added -[SEGi]hlnumselbut[_j] argument
//            - Added -[SEGi]hlfselbutnr[_j] argument
//            - Added -[SEGi]hlfactbutnr[_j] argument
//            - Added -[SEGi]hlcsm[_j] filename argument
//            - Added -[SEGi]but{k}g{l}[_j] filename argument
//            - Bugfix. File list composer was broken. The bug was introduced
//              in the reworking and cleaning up of release 0.8
// 18-01-2007 - Huge cleanup and significant improvements aimed at preparing
//              for the implementation of menus within BatchMux
//            - Bugfix. Not all 32 subtitle streams were properly implemented
//              in release 0.7. Arguments accepted but the mxp content was
//              limited to 8
//            - Bugfix. -norun option was not properly implemented
//            - Bugfix. -ailang option was not properly implemented
//            - Bugfix. -aidelay option was not properly implemented
//            - Reworked, once more, the segment structures (now everything
//              is dynamic)
//            - Changed, with significant simplifications, the whole error
//              handling concept and procedures
//            - Extended to 999 the max number of segments supported by the
//              application
//            - Added support to BMP as valid assets for the video segments
//            - Added -[SEGi]vduration[_j] argument
// 15-12-2006 - Improved. Supporting now up to 8 audio streams and 32 subtitle
//              streams.
//            - Removed "BatchMux:" from the printout text of many params
//            - Added support of file lists to compose the video and audio
//              assets for each segment; this should be helpful for avoiding
//              copy operations and speed up things in multicore environments
//            - Added the -arglist argument, in order to enable an easier
//              handling of the argument list (especially useful for long, or
//              very long argument lists)
// 03-10-2006 - Bugfix. In case no celltimes is specified, an invalid time
//              reference is generated in the mxp file
//            - Bugfix. Missing "break" statement after parsing of "vidmode"
//              argument
//            - Improved. In case DvdPreparer not set, then no need to change
//              VIDEO_TS.IFO and VIDEO_TS.BUP
// 24-09-2006 - Completely reworked the memory usage. Now many structures are
//              allocated dinamically
//            - Reworked and reordered arguments in order to support multi VTS
//              authoring (with navigation hardcoded...). If not present, the
//              optional "SEGi" prefix of the segment arguments, with i in the
//              range 2 ... 99, represents a compatibility mode with previous
//              releases of BatchMux.exe. This simplifies the syntax in case
//              just a single VTS is needed. If present, the tag enables the
//              authoring of additional segments, other than the first, in a
//              simple authoring structure (each additional segment lead to an
//              additional separate VTS, with a single title, and a single pgc
//              per segment)
// 11-09-2006 - Added the -preparer argument; Note: it is overridden by -norun
//            - Improved formatting of log information
// 19-08-2006 - Changed stdout to stderr for the error messages...
//            - Changed the default assignement of subpicture streams display
//              mode; now it is depending on the actual Video Stream AR (both
//              MPEG-2 and MPEG-1): in case the AR is 4:3 it is not harmful to
//              leave the default display mode as unspecified; on the other
//              hand, if the Video Stream AR is 16:9, the DEFAULT subpicture
//              stream display mode is set as WIDE_LB. This should prevent
//              possible unwanted skipping of subpicture streams in the
//              authoring due to not setting of their display mode...
//            - Added the -palette argument, pointing to an ascii file
//              containing the palette colour entries to redefine the default
//              palette of MuxMan.
// 26-07-2006 - Version 0.2
//            - Added the revision history - also in the help printout.
//            - Added the -muxman argument, in order to specify
//              the location of the MuxMan.exe executable.
// 18-07-2006 - First Release
//
// Arguments:
//
// ---------------------------------------------------------------------------
// ----------------------- General Arguments ---------------------------------
// ---------------------------------------------------------------------------
// -arglist file_name, optional; if this mode (and argument) is used, no other
//    arguments should be present; file_name should be a text file containing
//    all of the other BatchMux arguments, ONE SINGLE LINE CONTAINING two
//    strings ([arg] [val]) separated by spaces and optionally delimited by "
// -d destination_folder, mandatory
// -mxp target script_file, optional; default to C:BatchMux.mxp
// -l log_file, optional; default to C:MuxMan.log
// -muxman folder, place where to look for the MuxMan.exe file, optional,
//    default NULL string, meaning the same folder where BatchMux is executed
// -palette palette_file, optional; PgcEdit compatible ascii file containing
//    16 colour entries (index, red, green, blue) adopted for redefining the
//    default color palette used by MuxMan
// -preparer "32_char_string"; optional copyright string setting the DVD
//    preparer field in the VIDEO_TS.IFO and VIDEO_TS.BUP files. Note: it is
//    overridden by the -norun option
// -norun allows to open the MuxMan GUI, to load the script file and to stop
// ---------------------------------------------------------------------------
// ----------------------- Content Section Arguments -------------------------
// ---------------------------------------------------------------------------
// ======== VIDEO ========
// -[SEGi]v[_j] video_file[s], mandatory; note: in all of the arguments with
//    the "SEGi" prefix, the i index should be an integer value, in the range
//    [2...999]; also, segments sequence should be progressive: e.g if segment
//    4 is missed, all segment arguments from 5 to 999, if present, are
//    ignored; the [_j] extension, with j in the range [2..99], allows to join
//    a file list (in a plain, sequential way), to compose the asset of the
//    given segment
// -[SEGi]vidmode 4:3 | PS_LB | PS | LB display mode for the video asset,
//    optional, if present and compatible with the actual video mode, it is
//    honored, based on the authoring application rules; if not present, it is
//    not included in the script
// -[SEGi]vduration[_j] ACTUAL | DEFAULT | hh:mm:ss:ff, duration of the video
//    play item, optional; default DEFAULT. Duration=ACTUAL is valid for
//    motion video only. For the last file of the list Duration=DEFAULT means
//    until the audio track ends. For other positions in the list it means:
//    15 frames for stills (image or single frame mpeg); 5 sec. for stillshow
//    video (multiple I frames with a sequence end code for each frame);
//    actual duration for motion video
// ======== AUDIO ========
// -[SEGi]a1[_j] audio1_file[s] ... -[SEGi]a8[_j] audio8_file[s]; all
//    optional; the [_j] extension, with j in the range [2..99], allows to
//    join a file list (in a plain, sequential way), to compose the asset[s]
//    of the given segment
// -[SEGi]a1lang xx ... -[SEGi]a8lang xx two characters language code for the
//    audio assets, all optional; default unspecified
// -[SEGi]a1ext 0|1|2|3|4 ... -[SEGi]a8ext 0|1|2|3|4 language extensions for
//    the audio assets, where 0 --> unspecified, 1 --> normal, 2 --> visually
//    impaired, 3 --> director comments, 4 --> alternate director comments;
//    all optional; default 1 - normal
// -[SEGi]a1delay xxx ... -[SEGi]a8delay xxx audio delays, positive and
//    negative values, in ms, in the range [-300...300]; all optional;
//    default 0
// ======== SUBPICTURES ========
// -[SEGi]s1 subpic1_file ... -[SEGi]s32 subpic32_file; all optional
// -[SEGi]s1lang xx ... -[SEGi]s32lang xx two characters language code for the
//    subpic files, default unspecified
// -[SEGi]s1ext 0|1|2|3|5|6|7|9|13|14|15 ...
//    -[SEGi]s32ext 0|1|2|3|5|6|7|9|13|14|15
//    language extensions for the subpicture files, where 0 --> unspecified,
//    1 --> normal, 2 --> large, 3 --> children 5 --> normal captions,
//    6 --> large captions, 7 --> children captions, 9 --> forced,
//    13 --> director comments, 14 --> large director comments,
//    15 --> children director comments; all optional; default 1 - normal
// -[SEGi]s1dmode LB | PAN | LB_PAN | WIDE | WIDE_LB | WIDE_PAN | WIDE_LB_PAN
//    ... -[SEGi]s32dmode LB | PAN | LB_PAN | WIDE | WIDE_LB | WIDE_PAN |
//    WIDE_LB_PAN display modes and track assignement for the subpicture
//    streams; all optional; default --> WIDE_LB if video A/R is 16:9,
//    unspecified if video A/R is 4:3
// ======== HIGHLIGHTS =========
// -[SEGi]hlstart[_j] hh:mm:ss:ff; highlight start time, relative to start of
//    video segment; default 00:00:00:00
// -[SEGi]hldurat[_j] hh:mm:ss:ff; highlight duration, relative to start of
//    highlight; default 00:00:00:00
// -[SEGi]hlmnu[_j] menu_file; in PgcEdit mnu format; all mnu items may be
//    overridden by other hl arguments (see below), if present
// -[SEGi]hlbset[_j] hh:mm:ss:ff; button selection end time, relative to
//    start of highlight; default 00:00:00:00
// -[SEGi]hlbutm{l}[_j] NORMAL | LB | PAN | WIDE; display mode for group {l}
//    buttons; l=1,2,3; default --> NORMAL, i.e. unspecified
// -[SEGi]hloffsbutnr[_j] 0..36; highlight start button number; default 0
// -[SEGi]hlnumselbut[_j] 0..36; number of buttons selectable with the remote;
//    default 0
// -[SEGi]hlfselbutnr[_j] 0..36; force selected button number; default 0
// -[SEGi]hlfactbutnr[_j] 0..36; force activated button number; default 0
// -[SEGi]hlcsm[_j] color_scheme_file; in PgcEdit csm format
// -[SEGi]but{k}g{l}[_j] button_file; in PgcEdit gbv format, where {k} is the
//    button ID and {l} is the group ID --> {k} == 1 ... 36 and {l} == 1, 2, 3
// ======== CHAPTERS ========
// -[SEGi]celltc timecode_file; optional file containing chapter points in the
//    hh:mm:ss:ff - 11 char fixed ndtc format
// -[SEGi]cellfr celltimes_file; optional file containing chapter points in
//    the "usual" CellTimes format - plain frame indexes
// ---------------------------------------------------------------------------
// ----------------------- Organisation and Navigation Section Arguments -----
// ---------------------------------------------------------------------------
// -hcn1; hard coded navigation with static menu; interim solution providing
//    the placement of last segment in the VMG domain as title menu, with
//    hardcoded navigation;
// -hcn2; hard coded navigation with motion menu; similiar to the above one


Rationale for this tool:
1. Simplicity and straight usage. Even though MuxMan fully supports command
   line arguments, the usage of the whole set of parameters available in the
   GUI is only possible through scripting. The compilation of a MuxMan script
   is very easy indeed - it is sufficient to load files and parametes in the
   GUI and save the project. Anyway the straight command line control provided
   by BatchMux is direct, simple, and it should like to users not familiar or
   not interested in mxp scripting.
2. Enabling of automation for existing applications. The usage of MuxMan as
   a reference authoring application should be encouraged as much as possible.
   The quality of its output is significantly better respect to other authoring
   packages, getting rid - definitely - of "stuttering", "freezing" and other
   sad effects, mostly caused by the bad quality of the mux and authoring.
   The direct integration of MuxMan, as authoring engine into thirdy party
   applications, may turn out as being not possible (or too complex, due to
   the need of creating the mxp MuxMan script).
   BatchMux may be helpful in this scenario...

Usage: launc BatchMux with the above arguments... No argument, or -help for
   printing out the above listing of the CLI arguments... 
