#!c:\perl\bin\perl.exe -w ############################################################################### # # Script for ProjektX # ----------------------------- # # @Filetype: Perl scipt # @Author: Werner Puenter # @Date: 12.04.2004 # @Version: 1.0 # @History # Version 1.0: Initial version # Version 1.1: Reworked version - put together # Version 1.2: Reworked version - optimize # Version 1.3: Documentation # Version 1.4: Ifoedit.ini adaption # # Description: # The script converts a topfield file (ending .rec) to the needed dvd files # It's using the tool chain from Gerti -> topfield forum (http://board.topfield.de/) # (Thanx to Gerti at this place) # # The script gets all settings (where are the tools of Gertis`tool chain, etc) from # T2DScript.ini. # # The script can be called in a DOS window (Start -> Ausführen -> CMD): (WINDOWS XP) # call perl T2DScript.pl topfieldfile.rec # A more comfortable method is a batch # T2DScript.bat # call perl T2DScript.pl %1 # Create a link to T2DScript.BAT in # C:\Dokumente und Einstellungen\\SendTo (WINDOWS XP) # Now you can use the right mouse key with "Senden an" -> T2DScript.BAT on the topfield.rec file # # # The chain in this script: # 01. Create all needed directories # a. Output directory of the tool ProjectX, e.g. 1_out_ProjectX # b. Output directory of the tool Mpeg2Schnitt, e.g. 2_out_Nach_Schnitt # c. Outputdirectoriy of the tool IfoEdit, e.g. DVD_OUT # 02. Call ProjectX to convert the given Topfield.rec file into directory (see 01a) # 03. Call Mpeg2Schnitt to cut the file. # The ini file of the Mpeg2Schnitt is prepared to set the topfield file as default, when # opening the Mpeg2Schnitt tool. # Needed steps: - Datei # - Video / Audio öffnen # - Use marked file (Topfield.mpv) # - Define IN and OUT -> Neu -> Schneiden -> Enter Titel: Interpret % Titel -> speichern # - Close tool -> Soll das Projekt gespeichert werden -> Nein # 04. Call the auhoring tool Ifoedit. The file celltimes.txt is copied temporarily into the DVD directory.. # 1st call: -> DVD Author -> Author new DVD # -> Video: Öffnen -> Choose path to topfield file in 2_out_Nach_Schnitt (see 01b) # -> Dateiname -> * -> Choose mpv file # -> Audio: Öffnen -> Choose mp2 file # -> Position: Öffnen -> * -> Choose path to ..\DVD_OUT\Interpret\VIDEO_TS\celltimes.txt # -> Destination: Öffnen -> Choose path to .. ..\DVD_OUT\Interpret\VIDEO_TS # -> "Ok" # -> "Quit" or close tool # 2nd call: -> Open "Video_TS.IFO" # -> Open "VTS_01__0.IFO" # -> Get VTS sectors -> "Do you want to process ALL IFO files ..: Ja -> Correct..: Ok/Ok.. # # 05. Convert the audio files MP2 to MP3 format, if T2DScript.ini contains the entry to convert. ############################################################################### # The script awaits a parameter. The parameter contains the path and name of # the topfield file xyz.rec. # E.g. call perl T2DScript.pl "M:\Video\tools\Topfieldfile.rec" # # The Ini-File contains the tool settings. # The settings are recognized through keywords (with a leading §) # e.g.:§ToolProjektXPath = Text # ############################################################################### use strict; use File::Path; use Win32::Shortcut; my $fileIni = "T2DScript.ini"; #################################### # Define Variables # #################################### # Define variables with default values => examples my $txtToolProjektXPath = ""; # Path to ProjectX tool e.g. "C:\\Programme\\Topfield\ to\ DVD\\Project\ X\\" my $txtSrcTopf_Path = ""; # Extract of Argument: e.g. "M:\\Video\\dvd\\1_out_DS_JAR" my $txtSrcTopf_File = ""; # Extract of Argument: e.g. "Topfieldfile" without ending ".rec" my $txtDstPathPrX = ""; # e.g. "M:\\Video\\dvd_tst\\1_out_ProjectX" my $txtDstPathCut = ""; # e.g. "M:\\Video\\dvd\\2_out_Nach_Schnitt" my $txtDstPathDVD = ""; # e.g. "M:\\Video\\dvd\\DVD_OUT" my $txtToolMPGCut_Path = ""; # e.g. "M:\\Programme\\Topfield to DVD\\Mpeg2Schnitt" my $txtToolMPGCut_File = "Mpeg2Schnitt.exe"; my $txtToolAuthor_Path = ""; # e.g. "M:\\Programme\\Topfield to DVD\\IfoEdit" my $txtToolAuthor_File = "IfoEdit.exe"; my $txtToolAuthor_PathIni = ""; # e.g. "C:\\windows" -> §DstPathIfoEditIni my $txtToolAuthor_FileIni = "IfoEdit.ini"; my $txtToolCelltimes_Path = ""; # e.g. "M:\\Video\\tools\\Topfield to DVD\\CellTimes" my $fConvertMP2_2_MP3 = 0; # #################################### # # # Lese Ini file # # # #################################### fReadIniFile(); # Read values from ini_file #################################### # # # Get argument # # stored in $txtSrcTopf_Path and # # $txtSrcTopf_File # # # #################################### if ( !fGetArgumentsTo_txtSrcTopf_Path_File() ) { exit; } #################################### # # # Create directories # # # #################################### print"txtDstPathPrX = $txtDstPathPrX\n"; mkpath("$txtDstPathPrX"."\\"."$txtSrcTopf_File", 1, 0711); mkpath("$txtDstPathCut"."\\"."$txtSrcTopf_File", 1, 0711); mkpath("$txtDstPathDVD"."\\"."$txtSrcTopf_File", 1, 0711); mkpath("$txtDstPathDVD"."\\"."$txtSrcTopf_File"."\\"."AUDIO_TS", 1, 0711); mkpath("$txtDstPathDVD"."\\"."$txtSrcTopf_File"."\\"."VIDEO_TS", 1, 0711); #################################### # # # Call ProjectX # # Output of ProjectX into # # $txtDstPath_File_tmp # # # # -> Topfield.mp2 # # -> Topfield.mpv # # # #################################### my $txtDstPath_File_tmp = "$txtDstPathPrX"."\\"."$txtSrcTopf_File"; print "call java -jar \"$txtToolProjektXPath\\ProjectX.jar\" -dvx1 -o \"$txtDstPath_File_tmp\" \"$txtSrcTopf_Path\\$txtSrcTopf_File.rec\"\n"; system "call java -jar \"$txtToolProjektXPath\\ProjectX.jar\" -dvx1 -o \"$txtDstPath_File_tmp\" \"$txtSrcTopf_Path\\$txtSrcTopf_File.rec\"" ; # <- OUTPATH -> | <- TopfieldFile-PATH\TopfieldFile -> #################################### # # # Call cut tool # # Output of ProjectX into # # $txtDstPath_File_tmp # # # #################################### my $txtMPGCut_Ini = "$txtToolMPGCut_Path"."\\"."Mpeg2Schnitt.ini"; my $txtMPGCut_Tmp = "$txtToolMPGCut_Path"."\\"."Mpeg2Schnitt.tmp"; my $txt_TmpLine = ""; system("copy \"$txtMPGCut_Ini\" \"$txtMPGCut_Tmp\""); open(FILE_TMP,"<$txtMPGCut_Tmp") or die "*** ERROR *** Not able to open $txtMPGCut_Tmp. $!"; open(FILE_INI,">$txtMPGCut_Ini") or die "*** ERROR *** Not able to open $txtMPGCut_Ini. $!"; while() { $txt_TmpLine = $_; chomp($txt_TmpLine); if ($txt_TmpLine =~ /VideoAudioVerzeichnis=(.*)/) { print FILE_INI "VideoAudioVerzeichnis=$txtDstPathPrX\\$txtSrcTopf_File\n"; } elsif ($txt_TmpLine =~ /ZielVerzeichnis=(.*)/) { print FILE_INI "ZielVerzeichnis=$txtDstPathCut\\$txtSrcTopf_File\n"; } else { print FILE_INI "$txt_TmpLine\n"; } } close (FILE_TMP); close (FILE_INI); #################################### # # # Delete all temporary files # # # #################################### #print "\"$txtToolMPGCut_Path"."\\"."$txtToolMPGCut_File\"\n"; system "\"$txtToolMPGCut_Path"."\\"."$txtToolMPGCut_File\""; #print "del \"$txtDstPathCut\\$txtSrcTopf_File\\*.idd\"\n"; system "del \"$txtDstPathCut\\$txtSrcTopf_File\\*.idd\""; #print "del \"$txtDstPath_File_tmp\\*.idd\""\n"; system "del \"$txtDstPath_File_tmp\\*.idd\""; #print "del \"$txtDstPath_File_tmp\\$txtSrcTopf_File.d2v\""\n"; system "del \"$txtDstPath_File_tmp\\$txtSrcTopf_File.d2v\""; #################################### # # # Call authoring tool # # # #################################### system "copy \"$txtToolCelltimes_Path\\Celltimes.txt\" \"$txtDstPathCut\\$txtSrcTopf_File\""; my $txtIfoEdit_Ini = "$txtToolAuthor_PathIni"."\\"."$txtToolAuthor_FileIni"; my $txt_tmpDstPathCutAndSrcTopf_File = "$txtDstPathCut"."\\"."$txtSrcTopf_File"; print "dir \"$txt_tmpDstPathCutAndSrcTopf_File\" > ifoedit_ini.txt\n"; system "dir \"$txt_tmpDstPathCutAndSrcTopf_File\" > ifoedit_ini.txt"; my $txt_NewNameFromCutTool = ""; open(FILE_TMP,") { $txt_TmpLine = $_; chomp($txt_TmpLine); if ($txt_TmpLine =~ /.*\d (.*\.mpv)/) { $txt_NewNameFromCutTool =$1; } } close (FILE_TMP); if ($txt_NewNameFromCutTool eq "") { print "*** ERROR: No mpv file found in $txt_tmpDstPathCutAndSrcTopf_File\n"; exit: } open(FILE_INI,">$txtIfoEdit_Ini") or die "*** ERROR *** Not able to open $txtIfoEdit_Ini. $!"; print FILE_INI "[IfoEditApp]\n"; print FILE_INI "WP=MCAAAAAACAAAAAAADAAAAAAAPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPPJCAAAAAANBAAAAAAINDAAAAAFMCAAAAA\n"; print FILE_INI "[VobExtras]\n"; print FILE_INI "AuthorPath=$txtDstPathCut\\$txtSrcTopf_File\\$txt_NewNameFromCutTool\n"; print FILE_INI "DestPath=$txtDstPathDVD\\$txtSrcTopf_File\\VIDEO_TS\n"; print FILE_INI "[Settings]\n"; print FILE_INI "X=304\n"; print FILE_INI "Y=303\n"; close (FILE_INI); system "call \"$txtToolAuthor_Path\\$txtToolAuthor_File\""; # 1st call system "call \"$txtToolAuthor_Path\\$txtToolAuthor_File\""; # 2nd call system "del \"$txtDstPathCut\\$txtSrcTopf_File\\celltimes.txt\""; system "del ifoedit_ini.txt"; # End of MAIN SCRIPT # ---------------------------------------------------------- # SUBROUTINES # ---------------------------------------------------------- # # ---------------------------------------------------------- # @Routine: fGetArgumentsTo_txtSrcTopf_Path_File # # Subroutine Get the arguments # stored in $txtSrcTopf_Path and $txtSrcTopf_File # ---------------------------------------------------------- sub fGetArgumentsTo_txtSrcTopf_Path_File { my $fRetVal = 1; if ( $ARGV[0] eq "-h" || $ARGV[0] eq "-?" || $ARGV[0] eq "h" || $ARGV[0] eq "?") { print" Help: ToDo\n"; print" 1st parameter is source file (including path)\n"; $fRetVal = 0; return $fRetVal; } if ($ARGV[0] eq "") { print "Enter the path to the topfield file:\n"; $txtSrcTopf_Path = ; chomp($txtSrcTopf_Path); print "\nEnter the name of the topfield file without the ending .rec:\n"; $txtSrcTopf_File = ; chomp($txtSrcTopf_File); return $fRetVal; } #################################### # # # Extract path and topfield file # # name from the argument # # # #################################### if ($ARGV[0] =~ /(.*)\\(.*).rec/) { $txtSrcTopf_Path = $1; # Path to topfield file $txtSrcTopf_File = $2; # topfield.rec } return $fRetVal; } # # ---------------------------------------------------------- # @Routine: fReadIniFile # # Subroutine reads the INI file # ---------------------------------------------------------- sub fReadIniFile { my $fRetVal = 1; my $string = ""; open(SOURCE, "<$fileIni") or die "Kann $fileIni nicht mit Leserechten oeffnen:$!\n"; while () { $string = $_; # String ist der Inhalt der gelesenen Zeile if ($string =~ /§ToolProjektXPath/) # Path to { if ( $string =~ m/.*=\s*(.+)/ ) { $txtToolProjektXPath = "$1"; } } if ($string =~ /§DstPathPrX/) # Path to Output of ProjectX { if ( $string =~ m/.*=\s*(.+)/ ) { $txtDstPathPrX = "$1"; } } if ($string =~ /§ToolMPGCutPath/) # Path to MPGCut tool { if ( $string =~ m/.*=\s*(.+)/ ) { $txtToolMPGCut_Path = "$1"; } } if ($string =~ /§ToolAuthorPath/) # Path to OutPut of Author tool { if ( $string =~ m/.*=\s*(.+)/ ) { $txtToolAuthor_Path = "$1"; } } if ($string =~ /§ToolCellTimesPath/) # Path to the file celltimes.txt { if ( $string =~ m/.*=\s*(.+)/ ) { $txtToolCelltimes_Path = "$1"; } } if ($string =~ /§DstPathCut/) # Path to OutPut of MPGCut tool { if ( $string =~ m/.*=\s*(.+)/ ) { $txtDstPathCut = "$1"; } } if ($string =~ /§DstPathDVD/) # Path to { if ( $string =~ m/.*=\s*(.+)/ ) { $txtDstPathDVD = "$1"; } } if ($string =~ /§DstPathIfoEditIni/) # Path to { if ( $string =~ m/.*=\s*(.+)/ ) { $txtToolAuthor_PathIni = "$1"; } } } close (SOURCE); return $fRetVal; } # End of SUBROUTINES