allow burning videos (also H.264) to data DVDs
authorAndreas Frisch <andreas.frisch@multimedia-labs.de>
Tue, 16 Sep 2008 08:53:43 +0000 (08:53 +0000)
committerAndreas Frisch <andreas.frisch@multimedia-labs.de>
Tue, 16 Sep 2008 08:53:43 +0000 (08:53 +0000)
lib/python/Plugins/Extensions/DVDBurn/DVDProject.py
lib/python/Plugins/Extensions/DVDBurn/DVDTitle.py
lib/python/Plugins/Extensions/DVDBurn/Process.py
lib/python/Plugins/Extensions/DVDBurn/ProjectSettings.py
lib/python/Plugins/Extensions/DVDBurn/TitleCutter.py
lib/python/Plugins/Extensions/DVDBurn/TitleList.py

index 6aae5ba..73a2de5 100644 (file)
@@ -32,7 +32,7 @@ class DVDProject:
                self.target = None
                self.settings = ConfigSubsection()
                self.settings.name = ConfigText(fixed_size = False, visible_width = 40)
                self.target = None
                self.settings = ConfigSubsection()
                self.settings.name = ConfigText(fixed_size = False, visible_width = 40)
-               self.settings.authormode = ConfigSelection(choices = [("menu_linked", _("Linked titles with a DVD menu")), ("just_linked", _("Direct playback of linked titles without menu")), ("menu_seperate", _("Seperate titles with a main menu")), ])
+               self.settings.authormode = ConfigSelection(choices = [("menu_linked", _("Linked titles with a DVD menu")), ("just_linked", _("Direct playback of linked titles without menu")), ("menu_seperate", _("Seperate titles with a main menu")), ("data_ts", _("Dreambox format data DVD (HDTV compatible)"))])
                self.settings.menubg = ConfigFilename()
                self.settings.menuaudio = ConfigFilename()
                self.settings.titleformat = ConfigText(fixed_size = False, visible_width = 40)
                self.settings.menubg = ConfigFilename()
                self.settings.menuaudio = ConfigFilename()
                self.settings.titleformat = ConfigText(fixed_size = False, visible_width = 40)
index 67b410c..bfa2af5 100644 (file)
@@ -11,6 +11,7 @@ class DVDTitle:
                self.chaptermarks = [ ]
                self.audiotracks = [ ]
                self.timeCreate = None
                self.chaptermarks = [ ]
                self.audiotracks = [ ]
                self.timeCreate = None
+               self.sVideoType = -1
 
        def addService(self, service):
                from os import path
 
        def addService(self, service):
                from os import path
index 913e793..1851d87 100644 (file)
@@ -65,6 +65,19 @@ class LinkTS(Task):
                self.args += ["-s", sourcefile, link_name]
                self.weighting = 10
 
                self.args += ["-s", sourcefile, link_name]
                self.weighting = 10
 
+class CopyMeta(Task):
+       def __init__(self, job, sourcefile):
+               Task.__init__(self, job, "Copy title meta files")
+               self.setTool("/bin/cp")
+               from os import listdir
+               path, filename = sourcefile.rstrip("/").rsplit("/",1)
+               tsfiles = listdir(path)
+               for file in tsfiles:
+                       if file.startswith(filename+"."):
+                               self.args += [path+'/'+file]
+               self.args += [self.job.workspace]
+               self.weighting = 10
+
 class DemuxTask(Task):
        def __init__(self, job, inputfile):
                Task.__init__(self, job, "Demux video into ES")
 class DemuxTask(Task):
        def __init__(self, job, inputfile):
                Task.__init__(self, job, "Demux video into ES")
@@ -243,7 +256,7 @@ class BurnTaskPostcondition(Condition):
 
 class BurnTask(Task):
        ERROR_MEDIA, ERROR_SIZE, ERROR_WRITE_FAILED, ERROR_DVDROM, ERROR_ISOFS, ERROR_UNKNOWN = range(6)
 
 class BurnTask(Task):
        ERROR_MEDIA, ERROR_SIZE, ERROR_WRITE_FAILED, ERROR_DVDROM, ERROR_ISOFS, ERROR_UNKNOWN = range(6)
-       def __init__(self, job):
+       def __init__(self, job, extra_args=[]):
                Task.__init__(self, job, "burn")
 
                self.weighting = 500
                Task.__init__(self, job, "burn")
 
                self.weighting = 500
@@ -251,7 +264,8 @@ class BurnTask(Task):
                self.postconditions.append(BurnTaskPostcondition())
                self.setTool("/bin/growisofs")
                volName = self.getASCIIname(job.project.settings.name.getValue())
                self.postconditions.append(BurnTaskPostcondition())
                self.setTool("/bin/growisofs")
                volName = self.getASCIIname(job.project.settings.name.getValue())
-               self.args += ["-dvd-video", "-dvd-compat", "-Z", "/dev/cdroms/cdrom0", "-V", volName, "-P", "Dreambox", "-use-the-force-luke=dummy", self.job.workspace + "/dvd"]
+               self.args += ["-dvd-compat", "-Z", "/dev/cdroms/cdrom0", "-V", volName, "-P", "Dreambox", "-use-the-force-luke=dummy", self.job.workspace + "/dvd"]
+               self.args += extra_args
 
        def getASCIIname(self, name):
                ASCIIname = ""
 
        def getASCIIname(self, name):
                ASCIIname = ""
@@ -619,7 +633,34 @@ class DVDJob(Job):
                                RemoveESFiles(self, demux)
                        WaitForResidentTasks(self)
                        PreviewTask(self)
                                RemoveESFiles(self, demux)
                        WaitForResidentTasks(self)
                        PreviewTask(self)
-                       BurnTask(self)
+                       BurnTask(self,["-dvd-video"])
+               RemoveDVDFolder(self)
+
+class DVDdataJob(Job):
+       def __init__(self, project):
+               Job.__init__(self, "Data DVD Burn")
+               self.project = project
+               from time import strftime
+               from Tools.Directories import SCOPE_HDD, resolveFilename, createDir
+               new_workspace = resolveFilename(SCOPE_HDD) + "tmp/" + strftime("%Y%m%d%H%M%S") + "/dvd/"
+               createDir(new_workspace, True)
+               self.workspace = new_workspace
+               self.project.workspace = self.workspace
+               self.conduct()
+
+       def conduct(self):
+               diskSpaceNeeded = 50*1024*1024 # require an extra safety 50 MB
+               for title in self.project.titles:
+                       diskSpaceNeeded += title.filesize
+               nr_titles = len(self.project.titles)
+
+               for self.i in range(nr_titles):
+                       title = self.project.titles[self.i]
+                       filename = title.inputfile.rstrip("/").rsplit("/",1)[1]
+                       link_name =  self.workspace + filename
+                       LinkTS(self, title.inputfile, link_name)
+                       CopyMeta(self, title.inputfile)
+               BurnTask(self)
                RemoveDVDFolder(self)
 
 def Burn(session, project):
                RemoveDVDFolder(self)
 
 def Burn(session, project):
@@ -631,3 +672,8 @@ def PreviewMenu(session, project):
        j = DVDJob(project, menupreview=True)
        job_manager.AddJob(j)
        return j
        j = DVDJob(project, menupreview=True)
        job_manager.AddJob(j)
        return j
+
+def BurnDataTS(session, project):
+       j = DVDdataJob(project)
+       job_manager.AddJob(j)
+       return j
\ No newline at end of file
index fc8672c..0dd77c2 100644 (file)
@@ -110,23 +110,9 @@ class ProjectSettings(Screen,ConfigListScreen):
                self["info"] = StaticText(infotext)
 
                self.settings = project.settings
                self["info"] = StaticText(infotext)
 
                self.settings = project.settings
-               self.list = []
-               self.list.append(getConfigListEntry(_("Collection name"), self.settings.name))
-               self.list.append(getConfigListEntry(_("Authoring mode"), self.settings.authormode))
-               self.list.append(getConfigListEntry(_("Menu")+' '+_("background image"), self.settings.menubg))
-               self.list.append(getConfigListEntry(_("Menu")+' '+_("Title"), self.settings.titleformat))
-               self.list.append(getConfigListEntry(_("Menu")+' '+_("Subtitles"), self.settings.subtitleformat))
-               self.list.append(getConfigListEntry(_("Menu")+' '+_("headline")+' '+_("color"), self.settings.color_headline))
-               self.list.append(getConfigListEntry(_("Menu")+' '+_("text")+' '+_("color"), self.settings.color_button))
-               self.list.append(getConfigListEntry(_("Menu")+' '+_("highlighted button")+' '+_("color"), self.settings.color_highlight))
-               self.list.append(getConfigListEntry(_("Menu")+' '+_("font face"), self.settings.font_face))
-               self.list.append(getConfigListEntry(_("Font size")+' ('+_("headline")+', '+_("Title")+', '+_("Subtitles")+')', self.settings.font_size))
-               self.list.append(getConfigListEntry(_("Menu")+' '+_("spaces (top, between rows, left)"), self.settings.space))
-               self.list.append(getConfigListEntry(_("Menu")+' '+_("Audio"), self.settings.menuaudio))
-               self.list.append(getConfigListEntry(_("VMGM (intro trailer)"), self.settings.vmgm))
-               self.list.append(getConfigListEntry(_("Auto chapter split every ? minutes (0=never)"), self.settings.autochapter))
-               ConfigListScreen.__init__(self, self.list)
-               
+               ConfigListScreen.__init__(self, [])
+               self.initConfigList(self.settings.authormode.getValue())
+                       
                self.keydict = {}
                for key, val in self.settings.dict().iteritems():
                        self.keydict[val] = key
                self.keydict = {}
                for key, val in self.settings.dict().iteritems():
                        self.keydict[val] = key
@@ -140,7 +126,42 @@ class ProjectSettings(Screen,ConfigListScreen):
                    "cancel": self.cancel,
                    "ok": self.ok,
                }, -2)
                    "cancel": self.cancel,
                    "ok": self.ok,
                }, -2)
-       
+
+       def changedConfigList(self):
+               if self.keydict[self["config"].getCurrent()[1]] == "authormode":
+                       self.initConfigList(self.settings.authormode.getValue())
+               
+       def initConfigList(self, authormode=""):
+               print "initConfigList(%s)" % authormode
+               self.list = []
+               self.list.append(getConfigListEntry(_("Collection name"), self.settings.name))
+               self.list.append(getConfigListEntry(_("Authoring mode"), self.settings.authormode))
+               if authormode.startswith("menu"):
+                       self.list.append(getConfigListEntry(_("Menu")+' '+_("background image"), self.settings.menubg))
+                       self.list.append(getConfigListEntry(_("Menu")+' '+_("Title"), self.settings.titleformat))
+                       self.list.append(getConfigListEntry(_("Menu")+' '+_("Subtitles"), self.settings.subtitleformat))
+                       self.list.append(getConfigListEntry(_("Menu")+' '+_("headline")+' '+_("color"), self.settings.color_headline))
+                       self.list.append(getConfigListEntry(_("Menu")+' '+_("text")+' '+_("color"), self.settings.color_button))
+                       self.list.append(getConfigListEntry(_("Menu")+' '+_("highlighted button")+' '+_("color"), self.settings.color_highlight))
+                       self.list.append(getConfigListEntry(_("Menu")+' '+_("font face"), self.settings.font_face))
+                       self.list.append(getConfigListEntry(_("Font size")+' ('+_("headline")+', '+_("Title")+', '+_("Subtitles")+')', self.settings.font_size))
+                       self.list.append(getConfigListEntry(_("Menu")+' '+_("spaces (top, between rows, left)"), self.settings.space))
+                       self.list.append(getConfigListEntry(_("Menu")+' '+_("Audio"), self.settings.menuaudio))
+               if authormode != "data_ts":
+                       self.list.append(getConfigListEntry(_("VMGM (intro trailer)"), self.settings.vmgm))
+                       self.list.append(getConfigListEntry(_("Auto chapter split every ? minutes (0=never)"), self.settings.autochapter))
+               self["config"].setList(self.list)
+
+       def keyLeft(self):
+               ConfigListScreen.keyLeft(self)
+               if self.keydict[self["config"].getCurrent()[1]] == "authormode":
+                       self.initConfigList(self.settings.authormode.getValue())
+
+       def keyRight(self):
+               ConfigListScreen.keyRight(self)
+               if self.keydict[self["config"].getCurrent()[1]] == "authormode":
+                       self.initConfigList(self.settings.authormode.getValue())
+
        def exit(self):
                self.applySettings()
                self.close(True)
        def exit(self):
                self.applySettings()
                self.close(True)
@@ -162,7 +183,7 @@ class ProjectSettings(Screen,ConfigListScreen):
 
        def saveProject(self):
                self.applySettings()
 
        def saveProject(self):
                self.applySettings()
-               ret = self.project.saveProject(resolveFilename(SCOPE_PLAYLIST))
+               ret = self.project.saveProject(resolveFilename(SCOPE_PLUGINS)+"Extensions/DVDBurn/")
                if ret.startswith:
                        text = _("Save")+' '+_('OK')+':\n'+ret
                        self.session.open(MessageBox,text,type = MessageBox.TYPE_INFO)
                if ret.startswith:
                        text = _("Save")+' '+_('OK')+':\n'+ret
                        self.session.open(MessageBox,text,type = MessageBox.TYPE_INFO)
index 016eb71..ce6bce9 100644 (file)
@@ -28,10 +28,8 @@ class TitleCutter(CutListEditor):
                                        description = "MP2"
                                self.t.audiotracks.append((language, description))
                print "[DVDBurn getAudioTracks]", self.t.audiotracks
                                        description = "MP2"
                                self.t.audiotracks.append((language, description))
                print "[DVDBurn getAudioTracks]", self.t.audiotracks
-               sVideoType = service.info().getInfo(iServiceInformation.sVideoType)
-               print "[DVDBurn getVideoType]", sVideoType
-               if sVideoType != 0:
-                       self.close(False)
+               self.t.sVideoType = service.info().getInfo(iServiceInformation.sVideoType)
+               print "[DVDBurn getVideoType]", self.t.sVideoType
 
        def exit(self):
                self.session.nav.stopService()
 
        def exit(self):
                self.session.nav.stopService()
index f446770..353efe6 100644 (file)
@@ -161,11 +161,17 @@ class TitleList(Screen):
                        return False
 
        def burnProject(self):
                        return False
 
        def burnProject(self):
-               autochapter = self.project.settings.autochapter.getValue()
-               if autochapter > 0:
-                       for title in self.project.titles:
-                               title.produceAutoChapter(autochapter)
-               self.project.waitboxref = self.project.session.open(ProjectSettings.WaitBox,self.burnProjectCB)
+               if self.project.settings.authormode.getValue() == "data_ts":
+                       import Process
+                       job = Process.BurnDataTS(self.session, self.project)
+                       from Screens.TaskView import JobView
+                       self.session.open(JobView, job)
+               else:
+                       autochapter = self.project.settings.autochapter.getValue()
+                       if autochapter > 0:
+                               for title in self.project.titles:
+                                       title.produceAutoChapter(autochapter)
+                       self.project.waitboxref = self.project.session.open(ProjectSettings.WaitBox,self.burnProjectCB)
 
        def burnProjectCB(self):
                import Process
 
        def burnProjectCB(self):
                import Process
@@ -221,14 +227,21 @@ class TitleList(Screen):
                                self.session.openWithCallback(self.titleEditDone, TitleCutter.TitleCutter, t)
 
        def titleEditDone(self, cutlist):
                                self.session.openWithCallback(self.titleEditDone, TitleCutter.TitleCutter, t)
 
        def titleEditDone(self, cutlist):
-               if cutlist != False:
-                       t = self.current_edit_title
-                       t.cuesheet = cutlist
-                       t.produceFinalCuesheet()
+               t = self.current_edit_title
+               t.cuesheet = cutlist
+               t.produceFinalCuesheet()
+               if t.sVideoType != 0:
+                       self.session.openWithCallback(self.DVDformatCB,MessageBox,text = _("The DVD standard doesn't support H.264 (HDTV) video streams. Do you want to create a Dreambox format data DVD (which will not play in stand-alone DVD players) instead?"), type = MessageBox.TYPE_YESNO)
+               else:
+                       self.updateTitleList()
+
+       def DVDformatCB(self, answer):
+               t = self.current_edit_title
+               if answer == True:
+                       self.project.settings.authormode.setValue("data_ts")
                        self.updateTitleList()
                else:
                        self.updateTitleList()
                else:
-                       self.session.open(MessageBox,text = _("The DVD standard doesn't support H.264 (HDTV) video streams!"),type = MessageBox.TYPE_ERROR)
-                       self.removeTitle(self.current_edit_title)
+                       self.removeTitle(t)
 
        def leave(self):
                self.close()
 
        def leave(self):
                self.close()