1 from Components.Task import Task, Job, job_manager, DiskspacePrecondition, Condition, ToolExistsPrecondition
2 from Screens.MessageBox import MessageBox
4 class png2yuvTask(Task):
5 def __init__(self, job, inputfile, outputfile):
6 Task.__init__(self, job, "Creating menu video")
7 self.setTool("/usr/bin/png2yuv")
8 self.args += ["-n1", "-Ip", "-f25", "-j", inputfile]
9 self.dumpFile = outputfile
12 def run(self, callback, task_progress_changed):
13 Task.run(self, callback, task_progress_changed)
14 self.container.stdoutAvail.get().remove(self.processStdout)
15 self.container.dumpToFile(self.dumpFile)
17 def processStderr(self, data):
18 print "[png2yuvTask]", data[:-1]
20 class mpeg2encTask(Task):
21 def __init__(self, job, inputfile, outputfile):
22 Task.__init__(self, job, "Encoding menu video")
23 self.setTool("/usr/bin/mpeg2enc")
24 self.args += ["-f8", "-np", "-a2", "-o", outputfile]
25 self.inputFile = inputfile
28 def run(self, callback, task_progress_changed):
29 Task.run(self, callback, task_progress_changed)
30 self.container.readFromFile(self.inputFile)
32 def processOutputLine(self, line):
33 print "[mpeg2encTask]", line[:-1]
35 class spumuxTask(Task):
36 def __init__(self, job, xmlfile, inputfile, outputfile):
37 Task.__init__(self, job, "Muxing buttons into menu")
38 self.setTool("/usr/bin/spumux")
39 self.args += [xmlfile]
40 self.inputFile = inputfile
41 self.dumpFile = outputfile
44 def run(self, callback, task_progress_changed):
45 Task.run(self, callback, task_progress_changed)
46 self.container.stdoutAvail.get().remove(self.processStdout)
47 self.container.dumpToFile(self.dumpFile)
48 self.container.readFromFile(self.inputFile)
50 def processStderr(self, data):
51 print "[spumuxTask]", data[:-1]
53 class MakeFifoNode(Task):
54 def __init__(self, job, number):
55 Task.__init__(self, job, "Make FIFO nodes")
56 self.setTool("/bin/mknod")
57 nodename = self.job.workspace + "/dvd_title_%d" % number + ".mpg"
58 self.args += [nodename, "p"]
62 def __init__(self, job, sourcefile, link_name):
63 Task.__init__(self, job, "Creating symlink for source titles")
64 self.setTool("/bin/ln")
65 self.args += ["-s", sourcefile, link_name]
69 def __init__(self, job, sourcefile):
70 Task.__init__(self, job, "Copy title meta files")
71 self.setTool("/bin/cp")
72 from os import listdir
73 path, filename = sourcefile.rstrip("/").rsplit("/",1)
74 tsfiles = listdir(path)
76 if file.startswith(filename+"."):
77 self.args += [path+'/'+file]
78 self.args += [self.job.workspace]
81 class DemuxTask(Task):
82 def __init__(self, job, inputfile):
83 Task.__init__(self, job, "Demux video into ES")
84 title = job.project.titles[job.i]
85 self.global_preconditions.append(DiskspacePrecondition(title.estimatedDiskspace))
86 self.setTool("/usr/bin/projectx")
87 self.generated_files = [ ]
91 self.cutfile = self.job.workspace + "/cut_%d.Xcl" % (job.i+1)
92 self.cutlist = title.cutlist
93 self.args += [inputfile, "-demux", "-out", self.job.workspace ]
94 if len(self.cutlist) > 1:
95 self.args += [ "-cut", self.cutfile ]
100 def processOutputLine(self, line):
102 MSG_NEW_FILE = "---> new File: "
103 MSG_PROGRESS = "[PROGRESS] "
105 if line.startswith(MSG_NEW_FILE):
106 file = line[len(MSG_NEW_FILE):]
109 self.haveNewFile(file)
110 elif line.startswith(MSG_PROGRESS):
111 progress = line[len(MSG_PROGRESS):]
112 self.haveProgress(progress)
114 def haveNewFile(self, file):
115 print "PRODUCED FILE [%s]" % file
116 self.generated_files.append(file)
118 def haveProgress(self, progress):
119 #print "PROGRESS [%s]" % progress
120 MSG_CHECK = "check & synchronize audio file"
122 if progress == "preparing collection(s)...":
124 elif progress[:len(MSG_CHECK)] == MSG_CHECK:
129 p = p - 1 + self.prog_state * 100
130 if p > self.progress:
136 def writeCutfile(self):
137 f = open(self.cutfile, "w")
138 f.write("CollectionPanel.CutMode=4\n")
139 for p in self.cutlist:
147 f.write("%02d:%02d:%02d\n" % (h, m, s))
150 def cleanup(self, failed):
153 for f in self.generated_files:
156 class MplexTaskPostcondition(Condition):
157 def check(self, task):
158 if task.error == task.ERROR_UNDERRUN:
160 return task.error is None
162 def getErrorMessage(self, task):
164 task.ERROR_UNDERRUN: ("Can't multiplex source video!"),
165 task.ERROR_UNKNOWN: ("An unknown error occured!")
168 class MplexTask(Task):
169 ERROR_UNDERRUN, ERROR_UNKNOWN = range(2)
170 def __init__(self, job, outputfile, inputfiles=None, demux_task=None):
171 Task.__init__(self, job, "Mux ES into PS")
173 self.demux_task = demux_task
174 self.postconditions.append(MplexTaskPostcondition())
175 self.setTool("/usr/bin/mplex")
176 self.args += ["-f8", "-o", outputfile, "-v1"]
178 self.args += inputfiles
180 def setTool(self, tool):
183 self.global_preconditions.append(ToolExistsPrecondition())
184 # we don't want the ReturncodePostcondition in this case because for right now we're just gonna ignore the fact that mplex fails with a buffer underrun error on some streams (this always at the very end)
189 self.args += self.demux_task.generated_files
191 def processOutputLine(self, line):
192 print "[MplexTask] ", line[:-1]
193 if line.startswith("**ERROR:"):
194 if line.find("Frame data under-runs detected") != -1:
195 self.error = self.ERROR_UNDERRUN
197 self.error = self.ERROR_UNKNOWN
199 class RemoveESFiles(Task):
200 def __init__(self, job, demux_task):
201 Task.__init__(self, job, "Remove temp. files")
202 self.demux_task = demux_task
203 self.setTool("/bin/rm")
207 self.args += self.demux_task.generated_files
208 self.args += [self.demux_task.cutfile]
210 class DVDAuthorTask(Task):
211 def __init__(self, job, diskspaceNeeded):
212 Task.__init__(self, job, "Authoring DVD")
214 self.global_preconditions.append(DiskspacePrecondition(diskspaceNeeded))
216 self.setTool("/usr/bin/dvdauthor")
217 self.CWD = self.job.workspace
218 self.args += ["-x", self.job.workspace+"/dvdauthor.xml"]
219 self.menupreview = job.menupreview
221 def processOutputLine(self, line):
222 print "[DVDAuthorTask] ", line[:-1]
223 if not self.menupreview and line.startswith("STAT: Processing"):
224 self.callback(self, [], stay_resident=True)
226 class DVDAuthorFinalTask(Task):
227 def __init__(self, job):
228 Task.__init__(self, job, "dvdauthor finalize")
229 self.setTool("/usr/bin/dvdauthor")
230 self.args += ["-T", "-o", self.job.workspace + "/dvd"]
232 class WaitForResidentTasks(Task):
233 def __init__(self, job):
234 Task.__init__(self, job, "waiting for dvdauthor to finalize")
236 def run(self, callback, task_progress_changed):
237 print "waiting for %d resident task(s) %s to finish..." % (len(self.job.resident_tasks),str(self.job.resident_tasks))
238 if self.job.resident_tasks == 0:
241 class BurnTaskPostcondition(Condition):
243 def check(self, task):
244 return task.error is None
246 def getErrorMessage(self, task):
248 task.ERROR_NOTWRITEABLE: _("Medium is not a writeable DVD!"),
249 task.ERROR_LOAD: _("Could not load Medium! No disc inserted?"),
250 task.ERROR_SIZE: _("Content does not fit on DVD!"),
251 task.ERROR_WRITE_FAILED: _("Write failed!"),
252 task.ERROR_DVDROM: _("No (supported) DVDROM found!"),
253 task.ERROR_ISOFS: _("Medium is not empty!"),
254 task.ERROR_UNKNOWN: _("An unknown error occured!")
257 class BurnTask(Task):
258 ERROR_NOTWRITEABLE, ERROR_LOAD, ERROR_SIZE, ERROR_WRITE_FAILED, ERROR_DVDROM, ERROR_ISOFS, ERROR_UNKNOWN = range(7)
259 def __init__(self, job, extra_args=[]):
260 Task.__init__(self, job, _("Burn to DVD..."))
263 self.end = 120 # 100 for writing, 10 for buffer flush, 10 for closing disc
264 self.postconditions.append(BurnTaskPostcondition())
265 self.setTool("/bin/growisofs")
266 volName = self.getASCIIname(job.project.settings.name.getValue())
267 self.args += [ "-dvd-compat", "-Z", "/dev/cdroms/cdrom0", "-V", volName, "-publisher", "Dreambox", "-use-the-force-luke=dummy" ]
268 self.args += extra_args
269 self.args += [ self.job.workspace + "/dvd" ]
271 def getASCIIname(self, name):
273 for char in name.decode("utf-8").encode("ascii","replace"):
274 if ord(char) <= 0x20 or ( ord(char) >= 0x3a and ord(char) <= 0x40 ):
283 def processOutputLine(self, line):
285 print "[GROWISOFS] %s" % line
286 if line[8:14] == "done, ":
287 self.progress = float(line[:6])
288 print "progress:", self.progress
289 elif line.find("flushing cache") != -1:
291 elif line.find("closing disc") != -1:
293 elif line.startswith(":-["):
294 if line.find("ASC=30h") != -1:
295 self.error = self.ERROR_NOTWRITEABLE
296 if line.find("ASC=24h") != -1:
297 self.error = self.ERROR_LOAD
299 self.error = self.ERROR_UNKNOWN
300 print "BurnTask: unknown error %s" % line
301 elif line.startswith(":-("):
302 if line.find("No space left on device") != -1:
303 self.error = self.ERROR_SIZE
304 elif line.find("write failed") != -1:
305 self.error = self.ERROR_WRITE_FAILED
306 elif line.find("unable to open64(\"/dev/cdroms/cdrom0\",O_RDONLY): No such file or directory") != -1: # fixme
307 self.error = self.ERROR_DVDROM
308 elif line.find("media is not recognized as recordable DVD") != -1:
309 self.error = self.ERROR_NOTWRITEABLE
311 self.error = self.ERROR_UNKNOWN
312 print "BurnTask: unknown error %s" % line
313 elif line.startswith("FATAL:"):
314 if line.find("already carries isofs!"):
315 self.error = self.ERROR_ISOFS
317 self.error = self.ERROR_UNKNOWN
318 print "BurnTask: unknown error %s" % line
320 class RemoveDVDFolder(Task):
321 def __init__(self, job):
322 Task.__init__(self, job, "Remove temp. files")
323 self.setTool("/bin/rm")
324 self.args += ["-rf", self.job.workspace]
326 class PreviewTask(Task):
327 def __init__(self, job):
328 Task.__init__(self, job, "Preview")
329 self.postconditions.append(PreviewTaskPostcondition())
332 def run(self, callback, task_progress_changed):
333 self.callback = callback
334 self.task_progress_changed = task_progress_changed
335 if self.job.menupreview:
336 self.previewProject()
338 self.job.project.session.openWithCallback(self.previewCB, MessageBox, _("Do you want to preview this DVD before burning?"), timeout = 60, default = False)
340 def previewCB(self, answer):
342 self.previewProject()
346 def playerClosed(self):
347 if self.job.menupreview:
350 self.job.project.session.openWithCallback(self.closedCB, MessageBox, _("Do you want to burn this collection to DVD medium?") )
352 def closedCB(self, answer):
354 Task.processFinished(self, 0)
356 Task.processFinished(self, 1)
358 def previewProject(self):
359 from Plugins.Extensions.DVDPlayer.plugin import DVDPlayer
360 self.job.project.session.openWithCallback(self.playerClosed, DVDPlayer, dvd_filelist= [ self.job.project.workspace + "/dvd/VIDEO_TS/" ])
362 class PreviewTaskPostcondition(Condition):
363 def check(self, task):
364 return task.returncode == 0
366 def getErrorMessage(self, task):
369 def formatTitle(template, title, track):
370 template = template.replace("$i", str(track))
371 template = template.replace("$t", title.name)
372 template = template.replace("$d", title.descr)
373 template = template.replace("$c", str(len(title.chaptermarks)+1))
374 template = template.replace("$A", str(title.audiotracks))
375 template = template.replace("$f", title.inputfile)
376 template = template.replace("$C", title.channel)
378 lengthstring = "%d:%02d:%02d" % (l/3600, l%3600/60, l%60)
379 template = template.replace("$l", lengthstring)
381 template = template.replace("$Y", str(title.timeCreate[0]))
382 template = template.replace("$M", str(title.timeCreate[1]))
383 template = template.replace("$D", str(title.timeCreate[2]))
384 timestring = "%d:%02d" % (title.timeCreate[3], title.timeCreate[4])
385 template = template.replace("$T", timestring)
387 template = template.replace("$Y", "").replace("$M", "").replace("$D", "").replace("$T", "")
388 return template.decode("utf-8")
390 class ImagingPostcondition(Condition):
391 def check(self, task):
392 return task.returncode == 0
394 def getErrorMessage(self, task):
395 return "python-imaging " + _("failed")
397 class ImagePrepareTask(Task):
398 def __init__(self, job):
399 Task.__init__(self, job, _("please wait, loading picture..."))
400 self.postconditions.append(ImagingPostcondition())
403 self.Menus = job.Menus
405 def run(self, callback, task_progress_changed):
406 self.callback = callback
407 self.task_progress_changed = task_progress_changed
408 # we are doing it this weird way so that the TaskView Screen actually pops up before the spinner comes
409 from enigma import eTimer
410 self.delayTimer = eTimer()
411 self.delayTimer.callback.append(self.conduct)
412 self.delayTimer.start(10,1)
416 from ImageFont import truetype
417 from Image import open as Image_open
418 s = self.job.project.settings
419 self.Menus.im_bg_orig = Image_open(s.menubg.getValue())
420 if self.Menus.im_bg_orig.size != (self.Menus.imgwidth, self.Menus.imgheight):
421 self.Menus.im_bg_orig = self.Menus.im_bg_orig.resize((720, 576))
422 self.Menus.fontsizes = s.font_size.getValue()
423 fontface = s.font_face.getValue()
424 self.Menus.fonts = [truetype(fontface, self.Menus.fontsizes[0]), truetype(fontface, self.Menus.fontsizes[1]), truetype(fontface, self.Menus.fontsizes[2])]
425 Task.processFinished(self, 0)
427 Task.processFinished(self, 1)
429 class MenuImageTask(Task):
430 def __init__(self, job, menu_count, spuxmlfilename, menubgpngfilename, highlightpngfilename):
431 Task.__init__(self, job, "Create Menu %d Image" % menu_count)
432 self.postconditions.append(ImagingPostcondition())
435 self.Menus = job.Menus
436 self.menu_count = menu_count
437 self.spuxmlfilename = spuxmlfilename
438 self.menubgpngfilename = menubgpngfilename
439 self.highlightpngfilename = highlightpngfilename
441 def run(self, callback, task_progress_changed):
442 self.callback = callback
443 self.task_progress_changed = task_progress_changed
445 import ImageDraw, Image, os
446 s = self.job.project.settings
447 fonts = self.Menus.fonts
448 im_bg = self.Menus.im_bg_orig.copy()
449 im_high = Image.new("P", (self.Menus.imgwidth, self.Menus.imgheight), 0)
450 im_high.putpalette(self.Menus.spu_palette)
451 draw_bg = ImageDraw.Draw(im_bg)
452 draw_high = ImageDraw.Draw(im_high)
453 if self.menu_count == 1:
454 headline = s.name.getValue().decode("utf-8")
455 textsize = draw_bg.textsize(headline, font=fonts[0])
456 if textsize[0] > self.Menus.imgwidth:
459 offset = (((self.Menus.imgwidth-textsize[0]) / 2) , 20)
460 draw_bg.text(offset, headline, fill=self.Menus.color_headline, font=fonts[0])
461 spuxml = """<?xml version="1.0" encoding="utf-8"?>
466 transparent="%02x%02x%02x"
468 force="yes" >""" % (self.highlightpngfilename, self.Menus.spu_palette[0], self.Menus.spu_palette[1], self.Menus.spu_palette[2])
469 s_top, s_rows, s_left = s.space.getValue()
470 rowheight = (self.Menus.fontsizes[1]+self.Menus.fontsizes[2]+s_rows)
471 menu_start_title = (self.menu_count-1)*self.job.titles_per_menu + 1
472 menu_end_title = (self.menu_count)*self.job.titles_per_menu + 1
473 nr_titles = len(self.job.project.titles)
474 if menu_end_title > nr_titles:
475 menu_end_title = nr_titles+1
477 for title_no in range( menu_start_title , menu_end_title ):
479 top = s_top + ( menu_i * rowheight )
481 title = self.job.project.titles[i]
482 titleText = formatTitle(s.titleformat.getValue(), title, title_no)
483 draw_bg.text((s_left,top), titleText, fill=self.Menus.color_button, font=fonts[1])
484 draw_high.text((s_left,top), titleText, fill=1, font=self.Menus.fonts[1])
485 subtitleText = formatTitle(s.subtitleformat.getValue(), title, title_no)
486 draw_bg.text((s_left,top+36), subtitleText, fill=self.Menus.color_button, font=fonts[2])
487 bottom = top+rowheight
488 if bottom > self.Menus.imgheight:
489 bottom = self.Menus.imgheight
491 <button name="button%s" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (str(title_no).zfill(2),s_left,self.Menus.imgwidth,top,bottom )
492 if self.menu_count < self.job.nr_menus:
493 next_page_text = ">>>"
494 textsize = draw_bg.textsize(next_page_text, font=fonts[1])
495 offset = ( self.Menus.imgwidth-textsize[0]-2*s_left, s_top + ( self.job.titles_per_menu * rowheight ) )
496 draw_bg.text(offset, next_page_text, fill=self.Menus.color_button, font=fonts[1])
497 draw_high.text(offset, next_page_text, fill=1, font=fonts[1])
499 <button name="button_next" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (offset[0],offset[0]+textsize[0],offset[1],offset[1]+textsize[1])
500 if self.menu_count > 1:
501 prev_page_text = "<<<"
502 textsize = draw_bg.textsize(prev_page_text, font=fonts[1])
503 offset = ( 2*s_left, s_top + ( self.job.titles_per_menu * rowheight ) )
504 draw_bg.text(offset, prev_page_text, fill=self.Menus.color_button, font=fonts[1])
505 draw_high.text(offset, prev_page_text, fill=1, font=fonts[1])
507 <button name="button_prev" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (offset[0],offset[0]+textsize[0],offset[1],offset[1]+textsize[1])
510 fd=open(self.menubgpngfilename,"w")
513 fd=open(self.highlightpngfilename,"w")
514 im_high.save(fd,"PNG")
521 f = open(self.spuxmlfilename, "w")
524 Task.processFinished(self, 0)
526 Task.processFinished(self, 1)
529 def __init__(self, job):
533 s = self.job.project.settings
538 self.color_headline = tuple(s.color_headline.getValue())
539 self.color_button = tuple(s.color_button.getValue())
540 self.color_highlight = tuple(s.color_highlight.getValue())
541 self.spu_palette = [ 0x60, 0x60, 0x60 ] + s.color_highlight.getValue()
543 ImagePrepareTask(job)
544 nr_titles = len(job.project.titles)
546 job.titles_per_menu = 5
548 job.titles_per_menu = 4
549 job.nr_menus = ((nr_titles+job.titles_per_menu-1)/job.titles_per_menu)
551 #a new menu_count every 4 titles (1,2,3,4->1 ; 5,6,7,8->2 etc.)
552 for menu_count in range(1 , job.nr_menus+1):
553 num = str(menu_count)
554 spuxmlfilename = job.workspace+"/spumux"+num+".xml"
555 menubgpngfilename = job.workspace+"/dvd_menubg"+num+".png"
556 highlightpngfilename = job.workspace+"/dvd_highlight"+num+".png"
557 MenuImageTask(job, menu_count, spuxmlfilename, menubgpngfilename, highlightpngfilename)
558 png2yuvTask(job, menubgpngfilename, job.workspace+"/dvdmenubg"+num+".yuv")
559 menubgm2vfilename = job.workspace+"/dvdmenubg"+num+".mv2"
560 mpeg2encTask(job, job.workspace+"/dvdmenubg"+num+".yuv", menubgm2vfilename)
561 menubgmpgfilename = job.workspace+"/dvdmenubg"+num+".mpg"
562 menuaudiofilename = s.menuaudio.getValue()
563 MplexTask(job, outputfile=menubgmpgfilename, inputfiles = [menubgm2vfilename, menuaudiofilename])
564 menuoutputfilename = job.workspace+"/dvdmenu"+num+".mpg"
565 spumuxTask(job, spuxmlfilename, menubgmpgfilename, menuoutputfilename)
567 def CreateAuthoringXML(job):
568 nr_titles = len(job.project.titles)
569 mode = job.project.settings.authormode.getValue()
571 authorxml.append('<?xml version="1.0" encoding="utf-8"?>\n')
572 authorxml.append(' <dvdauthor dest="' + (job.workspace+"/dvd") + '">\n')
573 authorxml.append(' <vmgm>\n')
574 authorxml.append(' <menus>\n')
575 authorxml.append(' <pgc>\n')
576 authorxml.append(' <vob file="' + job.project.settings.vmgm.getValue() + '" />\n', )
577 if mode.startswith("menu"):
578 authorxml.append(' <post> jump titleset 1 menu; </post>\n')
580 authorxml.append(' <post> jump title 1; </post>\n')
581 authorxml.append(' </pgc>\n')
582 authorxml.append(' </menus>\n')
583 authorxml.append(' </vmgm>\n')
584 authorxml.append(' <titleset>\n')
585 if mode.startswith("menu"):
586 authorxml.append(' <menus>\n')
587 authorxml.append(' <video aspect="4:3"/>\n')
588 for menu_count in range(1 , job.nr_menus+1):
590 authorxml.append(' <pgc entry="root">\n')
592 authorxml.append(' <pgc>\n')
593 menu_start_title = (menu_count-1)*job.titles_per_menu + 1
594 menu_end_title = (menu_count)*job.titles_per_menu + 1
595 if menu_end_title > nr_titles:
596 menu_end_title = nr_titles+1
597 for i in range( menu_start_title , menu_end_title ):
598 authorxml.append(' <button name="button' + (str(i).zfill(2)) + '"> jump title ' + str(i) +'; </button>\n')
600 authorxml.append(' <button name="button_prev"> jump menu ' + str(menu_count-1) + '; </button>\n')
601 if menu_count < job.nr_menus:
602 authorxml.append(' <button name="button_next"> jump menu ' + str(menu_count+1) + '; </button>\n')
603 menuoutputfilename = job.workspace+"/dvdmenu"+str(menu_count)+".mpg"
604 authorxml.append(' <vob file="' + menuoutputfilename + '" pause="inf"/>\n')
605 authorxml.append(' </pgc>\n')
606 authorxml.append(' </menus>\n')
607 authorxml.append(' <titles>\n')
608 for i in range( nr_titles ):
609 #for audiotrack in job.project.titles[i].audiotracks:
610 #authorxml.append(' <audio lang="'+audiotrack[0][:2]+'" format="'+audiotrack[1]+'" />\n')
611 chapters = ','.join(["%d:%02d:%02d.%03d" % (p / (90000 * 3600), p % (90000 * 3600) / (90000 * 60), p % (90000 * 60) / 90000, (p % 90000) / 90) for p in job.project.titles[i].chaptermarks])
613 title_filename = job.workspace + "/dvd_title_%d.mpg" % (title_no)
615 LinkTS(job, job.project.settings.vmgm.getValue(), title_filename)
617 MakeFifoNode(job, title_no)
618 if mode.endswith("linked") and title_no < nr_titles:
619 post_tag = "jump title %d;" % ( title_no+1 )
620 elif mode.startswith("menu"):
621 post_tag = "call vmgm menu 1;"
624 authorxml.append(' <pgc>\n')
625 authorxml.append(' <vob file="' + title_filename + '" chapters="' + chapters + '" />\n')
626 authorxml.append(' <post> ' + post_tag + ' </post>\n')
627 authorxml.append(' </pgc>\n')
629 authorxml.append(' </titles>\n')
630 authorxml.append(' </titleset>\n')
631 authorxml.append(' </dvdauthor>\n')
632 f = open(job.workspace+"/dvdauthor.xml", "w")
638 def __init__(self, project, menupreview=False):
639 Job.__init__(self, _("Burn DVD"))
640 self.project = project
641 from time import strftime
642 from Tools.Directories import SCOPE_HDD, resolveFilename, createDir
643 new_workspace = resolveFilename(SCOPE_HDD) + "tmp/" + strftime("%Y%m%d%H%M%S")
644 createDir(new_workspace, True)
645 self.workspace = new_workspace
646 self.project.workspace = self.workspace
647 self.menupreview = menupreview
651 if self.project.settings.authormode.getValue().startswith("menu") or self.menupreview:
653 CreateAuthoringXML(self)
655 totalsize = 50*1024*1024 # require an extra safety 50 MB
657 for title in self.project.titles:
658 titlesize = title.estimatedDiskspace
659 if titlesize > maxsize: maxsize = titlesize
660 totalsize += titlesize
661 diskSpaceNeeded = totalsize + maxsize
663 DVDAuthorTask(self, diskSpaceNeeded)
665 nr_titles = len(self.project.titles)
670 for self.i in range(nr_titles):
671 title = self.project.titles[self.i]
672 link_name = self.workspace + "/source_title_%d.ts" % (self.i+1)
673 title_filename = self.workspace + "/dvd_title_%d.mpg" % (self.i+1)
674 LinkTS(self, title.inputfile, link_name)
675 demux = DemuxTask(self, link_name)
676 MplexTask(self, outputfile=title_filename, demux_task=demux)
677 RemoveESFiles(self, demux)
678 WaitForResidentTasks(self)
680 BurnTask(self,["-dvd-video"])
681 RemoveDVDFolder(self)
683 class DVDdataJob(Job):
684 def __init__(self, project):
685 Job.__init__(self, "Data DVD Burn")
686 self.project = project
687 from time import strftime
688 from Tools.Directories import SCOPE_HDD, resolveFilename, createDir
689 new_workspace = resolveFilename(SCOPE_HDD) + "tmp/" + strftime("%Y%m%d%H%M%S") + "/dvd/"
690 createDir(new_workspace, True)
691 self.workspace = new_workspace
692 self.project.workspace = self.workspace
696 diskSpaceNeeded = 50*1024*1024 # require an extra safety 50 MB
697 for title in self.project.titles:
698 diskSpaceNeeded += title.filesize
699 nr_titles = len(self.project.titles)
701 for self.i in range(nr_titles):
702 title = self.project.titles[self.i]
703 filename = title.inputfile.rstrip("/").rsplit("/",1)[1]
704 link_name = self.workspace + filename
705 LinkTS(self, title.inputfile, link_name)
706 CopyMeta(self, title.inputfile)
708 RemoveDVDFolder(self)
710 def Burn(session, project):
712 job_manager.AddJob(j)
715 def PreviewMenu(session, project):
716 j = DVDJob(project, menupreview=True)
717 job_manager.AddJob(j)
720 def BurnDataTS(session, project):
721 j = DVDdataJob(project)
722 job_manager.AddJob(j)