diff -Naur scriptsold/mythburn.py scriptsnew/mythburn.py --- scriptsold/mythburn.py 2007-11-24 18:17:50.000000000 -0500 +++ scriptsnew/mythburn.py 2007-11-24 20:07:41.000000000 -0500 @@ -1268,6 +1268,70 @@ return True + +def runccget(filename, destination): + """Use ccget to get subtitles""" + + command = "ccextractor -srt -o %s %s " % (destination, filename) + + result = runCommand(command) + + if (result != 0): + write("Failed while running ccget to get subtitles.\n" + "Result: %d, Command was %s" % (result, command)) + return False; + + + return True + +def createsubxml(srtfile,subxml): + subdom = xml.dom.minidom.Document() + # Create the base element + subpictures = subdom.createElement("subpictures") + subdom.appendChild(subpictures) + # Create a element + stream = subdom.createElement("stream") + subpictures.appendChild(stream) + # Create the main element + textsub = subdom.createElement("textsub") + stream.appendChild(textsub) + textsub.setAttribute("filename", srtfile) + textsub.setAttribute("characterset", "ISO8859-1") + textsub.setAttribute("fontsize", "28.0") + textsub.setAttribute("font", "arial.ttf") + textsub.setAttribute("horizontal-alignment", "left") + textsub.setAttribute("vertical-alignment", "bottom") + textsub.setAttribute("left-margin", "60") + textsub.setAttribute("right-margin", "60") + textsub.setAttribute("top-margin", "20") + textsub.setAttribute("bottom-margin", "30") + textsub.setAttribute("subtitle-fps", "29.97") + textsub.setAttribute("movie-fps", "29.97") + textsub.setAttribute("movie-width", "720") + textsub.setAttribute("movie-height", "480") + #textsub.setAttribute("movie-width", videosize[0]) + #textsub.setAttribute("movie-height", videosize[1]) + # Print our newly created XML + # print subdom.toprettyxml(indent=" ") + #Save the file + WriteXMLToFile (subdom, subxml) + + + +def runccput(subxml, basempg, destination): + """Use ccput to put subtitles""" + command = "spumux %s < %s > %s" % (subxml, basempg, destination) + + result = runCommand(command) + + if (result != 0): + write("Failed while running ccput to put subtitles.\n" + "Result: %d, Command was %s" % (result, command)) + return False; + + + return True + def extractVideoFrame(source, destination, seconds): write("Extracting thumbnail image from %s at position %s" % (source, seconds)) write("Destination file %s" % destination) @@ -3114,6 +3178,14 @@ #If this is an mpeg2 myth recording and there is a cut list available and the user wants to use it #run mythtranscode to cut out commercials etc if file.attributes["type"].value == "recording": + + # filename=file.attributes["filename"].value + if runccget(mediafile, os.path.join(folder, 'newfile.srt')): + srtfile = os.path.join(folder, 'newfile.srt') + createsubxml(srtfile,os.path.join(folder, 'sub.xml')) + else: + write("Failed to run ccget to get subtitles") + #can only use mythtranscode to cut commercials on mpeg2 files write("File type is '%s'" % getFileType(folder)) write("Video codec is '%s'" % getVideoCodec(folder)) @@ -3467,8 +3539,13 @@ pid=multiplexMPEGStream(os.path.join(folder,'stream.mv2'), os.path.join(folder,'stream0'), os.path.join(folder,'stream1'), - os.path.join(folder,'final.mpg'), + os.path.join(folder,'finalt.mpg'), calcSyncOffset(filecount)) + #Add spumux here for subtitles + if runccput(os.path.join(folder, 'sub.xml'), os.path.join(folder, 'finalt.mpg'), os.path.join(folder, 'final.mpg')): + srtfile = os.path.join(folder, 'newfile.srt') + else: + write("Failed to run ccput to put subtitles") #Now all the files are completed and ready to be burnt runDVDAuthor()