Logic flow : 
User presses CreateDVD:
qdvdauthor.ini read in by 
	QDVDAuthorInit -> Generates MenuBlocks, with variable-names
	then the ExecuteInterface - structure is built 
		Afterwards the list of ExecuteInterface is passed to DialogExecute
			The Dialog builds the GUI for the list based on the info in ExecuteInterface.

Note: 	We don't need to redesign the whole process to be recursive bc it is not expected to be extended beyond on sub-level
	Thus the addition of listSubExecute shall suffice to handle the task.
	
	
	Generate transcode.cpp
	Here is how it works :
	There are two main conversion types 
	1)	Video	-=> QDVDAuthorInit::blockMovieBackground
	2)	Audio	-=> QDVDAuthorInit::blockEmptySound

	-> Videos can have multiple templates for 
		a)	different conversion tools
		b)	different file formats

	Thus we use :
		blockMovieBackground
		+-> listSubBlocks [x]
		     +-> listCommands (non editable, but choose default)
			  +-> use transcode
			  +-> use mencoder
		     +-> listComments
			  +-> use transcode
			  +-> use mencoder
			  
		Once the user decides which tool to use, build the subBlocks of the subBlocks.
			  
	with [x] : 0 = AVI to DVD
	         : 1 =  DV to DVD

	+-[x] ConversionBlock------------------------------------------------------------------------------------+
	|  +-[x] Video funny.avi ------------------------------------------------------------------------------+ |
	|  |  +-Choose conversion tool ----------------------------------------------------------------------+ | |
	|  |  | +=- Transcode -=# funny.avi                                                            | [d] | | |
	|  |  ------------------------------------------------------------------------------------------     | | |
	|  |  | +------------------------------------------------------------------------------------------+ | | |
	|  |  | | |                         This line will clean the file                                  | | | |
	|  |  | | | transcode -x blah blah blah ...                                          | [e][d][man] | | | |
	|  |  | | ----------------------------------------------------------------------------             | | | |
	|  |  | |                          This line will generate the mpeg2                               | | | |
	|  |  | | | transcode -z blah blah blah ...                                          | [e][d][man] | | | |
	|  |  | | ----------------------------------------------------------------------------             | | | |
	|  |  | +------------------------------------------------------------------------------------------+ | | |
	|  |  +----------------------------------------------------------------------------------------------+ | |
	|  +---------------------------------------------------------------------------------------------------+ |
	|                                                                                                        |
	|  +-[X] Video test.dv --------------------------------------------------------------------------------+ |
	|  |  +-Choose conversion tool ----------------------------------------------------------------------+ | |
	|  |  | #=- MEncoder -=# test.dv                                                               | [d] | | |
	|  |  ------------------------------------------------------------------------------------------     | | |
	|  |  | +------------------------------------------------------------------------------------------+ | | |
	|  |  | | |                         This line will clean the file                                  | | | |
	|  |  | | | mencoder  -x blah blah blah ...                                          | [e][d][man] | | | |
	|  |  | | ----------------------------------------------------------------------------             | | | |
	|  |  | |                           This line will trim the file                                   | | | |
	|  |  | | | mencoder  -y blah blah blah ...                                          | [e][d][man] | | | |
	|  |  | | ----------------------------------------------------------------------------             | | | |
	|  |  | |                          This line will generate the mpeg2                               | | | |
	|  |  | | | mencoder  -z blah blah blah ...                                          | [e][d][man] | | | |
	|  |  | | ----------------------------------------------------------------------------             | | | |
	|  |  | +------------------------------------------------------------------------------------------+ | | |
	|  |  +----------------------------------------------------------------------------------------------+ | |
	|  +---------------------------------------------------------------------------------------------------+ |
	+--------------------------------------------------------------------------------------------------------+

 

transcode -i "mindfields_low_osx.avi" -x ffmpeg -V -w 8500 --encode_fields b --export_asr 2 -F 8,-c -q 6 -4 2 -2 1 -N 0.5 -E -10 -K tmpgenc -R 2 -y mpeg2enc,mp2enc -b 224 -m "mindfields_out_dvd.mpg" -o "mindfields_out_dvd.mpg" --print_status 10

ls -1 *.dv | while read file;
do
        echo handling $file
        transcode -i $file -V -y mpeg -F d -N 0x50 -Z 720x576 --export_fps 25 -J resample -E 48000 -o $file.mpeg2
        mplex -f 8 -o $file.mpeg2 $file.mpeg2.m2v $file.mpeg2.mpa
done;
vqcomp = 0.7
   vqblur = 0.3
   -J yuvdenoise
   9.5 fps 144996352 bytes
   (looks slightly better, but s..l..o..w.)

3. vqcomp = 0.7
   vqblur = 0.3
   -J hqdn3d
   23 fps 134307840 bytes
   (WHOAH! Much smaller file size, and even better
   quality improvement than with yuvde

   
   
transcode -i "mindfields_low_osx.avi" -x ffmpeg -V -w 8500 --encode_fields b --export_asr 2 -F 8,-c -q 6 -4 2 -2 1 -N 0.5 -E -10 -K tmpgenc -R 2 -y mpeg2enc,mp2enc -b 224 -m "mindfields_out_dvd.mpg" -o "mindfields_out_dvd.mpg" --print_status 10

ls -1 *.dv | while read file;
do
        echo handling $file
        transcode -i $file -V -y mpeg -F d -N 0x50 -Z 720x576 --export_fps 25 -J resample -E 48000 -o $file.mpeg2
        mplex -f 8 -o $file.mpeg2 $file.mpeg2.m2v $file.mpeg2.mpa
done;
vqcomp = 0.7
   vqblur = 0.3
   -J yuvdenoise
   9.5 fps 144996352 bytes
   (looks slightly better, but s..l..o..w.)

3. vqcomp = 0.7
   vqblur = 0.3
   -J hqdn3d
   23 fps 134307840 bytes
   (WHOAH! Much smaller file size, and even better
   quality improvement than with yuvde

   
	qsConversionScript = QString ("!/bin/sh\n\n"

		"#Always do this, clean crappy avi's \n"
		"nice -19 mencoder -oac copy -ovc copy -ofps 25 -o output.avi $1 \n"
		"nice -19 mplayer -ao pcm -vo null -vc dummy output.avi  \n\n"
 
		"# if the incoming sound is at 44100 \n"
		"# upsample the sound to 48000. \n"
		"# here we rely on the fact that sox will abort if the input \n"
		"# frequency is 48000. \n"
		"if sox audiodump.wav -r 48000 output.wav resample; \n"
		"then \n"
			"# add -e 48000,16,2 to the transcode command \n"
			"# so the sync adjustment is set by transcode to -1600@1000 \n"
			"sound='-e 48000,16,2' \n"
			"# and make it into toolame mp2 format, nice! \n"
			"nice -19 toolame -p 2 -b 384 output.wav output.mp2 > /dev/null 2>&1  \n"
			"rm -f audiodump.wav output.wav \n"
		"else \n"
			"# otherwise sound is 48000 \n"
			"sound= \n"
			"nice -19 toolame -p 2 -b 384 audiodump.wav output.mp2 > /dev/null 2>&1 \n"
			"# there will be a stub 44 byte long output.wav from the failed sox \n"
//			"rm -f output.wav audiodump.wav \n"
		"fi \n\n"
 
		"# note the use of '-x mplayer,null' to remove export restrictions \n"
		"# imposed by bugs in ffmpeg which sometimes cause segfaults, boo! \n"
		"#transcode --nice 20 --print_status 500 -x mplayer,null -y ffmpeg,null -F mpeg2video $sound --export-prof dvd-pal -Z 720x576 -o output -i output.avi \n\n"
 
		"# WdW Mp2Enc \n"
		"transcode --nice 20 --print_status 100 -x mplayer,null -y mpeg2enc,null -V -w 8000 -F 8,\"-E -10 -q 6 -R 0 -K tmpgenc\" --export_asr 2 -Z 720x576 -o output -i output.avi \n\n"
 
//		"rm -f output.avi \n"
 
		"# leave only .mpg files \n"
		"nice -19 mplex -f 8 -o ${file}.vob output.m2v output.mp2 \n"
//		"rm -f output.m2v output.mp2 ;\n"
	);

void StartMenuRender::renderMovieObject ()
{
	QTime zeroTime;
	QFileInfo fileInfo;
	int iStatusCheck;
	
	QString qsFullPath, qsMenuName, qsCommand, qsOffset, qsDuration, qsFormat;
	qsFormat = QString ("hh:mm:s.zzz");
	// This is the separate thread which extracts the images of the movie clips for this menu
	// (after generating the status / xml - files)
	// First we should generate the directories to store the data in ...
	createDirectories ();
	// then we create the images
	qsMenuName = QString ("NoMenuError");
	if (m_pMovieObject->dvdMenu())
		qsMenuName = m_pMovieObject->dvdMenu()->getInterface()->qsMenuName;

	qsFullPath = QString ("%1/%2/%3/%4").arg(Global::qsTempPath).arg(Global::qsProjectName).arg(qsMenuName).arg(m_pMovieObject->name());

	// Okay we should check the status file ...
	iStatusCheck = checkStatusFile (qsFullPath);

	// First we move the current status file to a backup file.
	qsCommand = QString ("mv \"%1/%2\" \"%3/%4.prev\"").arg(qsFullPath).arg(QString (STATUS_FILE_NAME)).arg(qsFullPath).arg(QString (STATUS_FILE_NAME));
	system (qsCommand);

	QFile statusFile (qsFullPath + QString ("/") + QString (STATUS_FILE_NAME));
	// Now we read in the status ...
	if ( !statusFile.open( IO_ReadWrite ) ) 
		return;
	QTextStream statusStream ( &statusFile );

	statusStream << QString ("-+-+-+-+-+-+ Starting new extraction of file %1 -+-+-+-+-+-+ \n").arg(m_pMovieObject->fileName());

	qsOffset   = m_pMovieObject->offset  ().toString (qsFormat);
	qsDuration = m_pMovieObject->duration().toString (qsFormat);
	statusStream << "[00] " << qsOffset << " " << qsDuration << "\n";
	statusFile.flush();

	// 1) Cleaning the movie material ...
	//    mencoder -oac pcm -ovc lavc -o "snl/clean.avi" "./snl.mpg" 
	qsCommand = QString ("mencoder -oac pcm -ovc lavc -o \"%1/clean.avi\" \"%2\" 2>/dev/null").arg(qsFullPath).arg(m_pMovieObject->fileName());
	statusStream << "[01] " << QDate::currentDate().toString() << " " << QTime::currentTime().toString() << " cmd > " << qsCommand << "\n";
	statusFile.flush();
	if (iStatusCheck < 1)
		system (qsCommand);
	fileInfo.setFile(qsFullPath + QString ("/clean.avi"));
	if ( (fileInfo.exists()) || (iStatusCheck > 0) )
		statusStream << "[02] Okay.\n";
	else
		statusStream << "[02] Error.\n";

	// 2) extracting the wanted time frame ...
	//    mencoder -oac pcm -ovc lavc -ss 0 -endpos 10 -o "snl/clip.avi" "snl/clean.avi"
	qsCommand = QString ("mencoder -oac pcm -ovc lavc -ss %1 -endpos %2 -o \"%3/clip.avi\" \"%4/clean.avi\" 2>/dev/null").arg(qsOffset).arg(qsDuration).arg(qsFullPath).arg(qsFullPath);
	statusStream << "[03] " << QDate::currentDate().toString() << " " << QTime::currentTime().toString() << " cmd > " << qsCommand << "\n";
	statusFile.flush();
	if (iStatusCheck < 2)
		system (qsCommand);
	fileInfo.setFile(qsFullPath + QString ("/clip.avi"));
	if (fileInfo.exists())
		statusStream << "[04] Okay.\n";
	else
		statusStream << "[04] Error.\n";

	// 3) extracting audio (audiodump.wav) : 
	//    mplayer -ao pcm -vo null -vc dummy -aofile "snl/clip.wav" "snl/clip.avi"
	qsCommand = QString ("mplayer -ao pcm -vo null -vc dummy -aofile \"%1/clip.wav\" \"%2/clip.avi\" 2>/dev/null").arg(qsFullPath).arg(qsFullPath);
	statusStream  << "[05] " << QDate::currentDate().toString() << " " << QTime::currentTime().toString() << " cmd > " << qsCommand << "\n";
	statusFile.flush();
	if (iStatusCheck < 3)
		system (qsCommand);
	fileInfo.setFile(qsFullPath + QString ("/clip.wav"));
	if (fileInfo.exists())
		statusStream << "[06] Okay.\n";
	else
		statusStream << "[06] Error.\n";
   
	// 4) extracting 300 frames from background.mwv
	//    mplayer -ao null -vo jpeg:outdir="./snl" "snl/clip.avi"
	qsCommand = QString ("rm \"%1/*.jpg\"").arg(qsFullPath);
	if (iStatusCheck < 4)
		system (qsCommand);
	qsCommand = QString ("mplayer -ao null -vo jpeg:outdir=\"%1\" \"%2/clip.avi\" 2>/dev/null").arg(qsFullPath).arg(qsFullPath);
	statusStream  << "[07] " << QDate::currentDate().toString() << " " << QTime::currentTime().toString() << " cmd > " << qsCommand << "\n";
	statusFile.flush();
	if (iStatusCheck < 4)
		system (qsCommand);
	QDir theDir (qsFullPath);
	theDir.setNameFilter ("*.jpg");
	if (theDir.count() > 0)
		statusStream << "[08] Okay.\n";
	else
		statusStream << "[08] Error.\n";

	// 5) rm snl/clip.avi snl/clean.avi
//	qsCommand = QString ("rm \"%1/clip.avi\" \"%2/clean.avi\" 2>/dev/null").arg(qsFullPath).arg(qsFullPath);
	qsCommand = QString ("rm \"%1/clean.avi\" 2>/dev/null").arg(qsFullPath);
	statusStream  << "[09] " << QDate::currentDate().toString() << " " << QTime::currentTime().toString() << " cmd > " << qsCommand << "\n";
	statusFile.flush();
	if (iStatusCheck < 5)
		system (qsCommand);
	fileInfo.setFile(qsFullPath + QString ("/clip.avi"));
	if (fileInfo.exists())
		statusStream << "[10] Okay.\n";
	else
		statusStream << "[10] Error.\n";

	m_pMovieObject->setExtracted(true);
	statusStream  << "[11] Done.\n";
	statusFile.flush();
	// And last but not least we close the status file again.
	statusFile.close();
}
