b9710d5ade3b727b16fb48aa0ee3cd46198557aa
[enigma2.git] / lib / python / Plugins / Extensions / DVDBurn / Process.py
1 from Components.Task import Task, Job, job_manager, DiskspacePrecondition, Condition
2 from Screens.MessageBox import MessageBox
3
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
10                 self.weighting = 10
11
12         def run(self, callback, task_progress_changed):
13                 Task.run(self, callback, task_progress_changed)
14                 self.container.dumpToFile(self.dumpFile)
15
16         def processStderr(self, data):
17                 print "[png2yuvTask]", data
18
19         def processStdout(self, data):
20                 pass
21
22 class mpeg2encTask(Task):
23         def __init__(self, job, inputfile, outputfile):
24                 Task.__init__(self, job, "Encoding menu video")
25                 self.setTool("/usr/bin/mpeg2enc")
26                 self.args += ["-f8", "-np", "-a2", "-o", outputfile]
27                 self.inputFile = inputfile
28                 self.weighting = 10
29                 
30         def run(self, callback, task_progress_changed):
31                 Task.run(self, callback, task_progress_changed)
32                 self.container.readFromFile(self.inputFile)
33
34         def processOutputLine(self, line):
35                 print "[mpeg2encTask]", line
36
37 class spumuxTask(Task):
38         def __init__(self, job, xmlfile, inputfile, outputfile):
39                 Task.__init__(self, job, "Muxing buttons into menu")
40                 self.setTool("/usr/bin/spumux")
41                 self.args += [xmlfile]
42                 self.inputFile = inputfile
43                 self.dumpFile = outputfile
44                 self.weighting = 10
45
46         def run(self, callback, task_progress_changed):
47                 Task.run(self, callback, task_progress_changed)
48                 self.container.dumpToFile(self.dumpFile)
49                 self.container.readFromFile(self.inputFile)
50
51         def processStderr(self, data):
52                 print "[spumuxTask]", data
53
54         def processStdout(self, data):
55                 pass
56
57 class MakeFifoNode(Task):
58         def __init__(self, job, number):
59                 Task.__init__(self, job, "Make FIFO nodes")
60                 self.setTool("/bin/mknod")
61                 nodename = self.job.workspace + "/dvd_title_%d" % number + ".mpg"
62                 self.args += [nodename, "p"]
63                 self.weighting = 10
64
65 class LinkTS(Task):
66         def __init__(self, job, sourcefile, link_name):
67                 Task.__init__(self, job, "Creating symlink for source titles")
68                 self.setTool("/bin/ln")
69                 self.args += ["-s", sourcefile, link_name]
70                 self.weighting = 10
71
72 class DemuxTask(Task):
73         def __init__(self, job, inputfile):
74                 Task.__init__(self, job, "Demux video into ES")
75                 title = job.project.titles[job.i]
76                 self.global_preconditions.append(DiskspacePrecondition(title.estimatedDiskspace))
77                 self.setTool("/usr/bin/projectx")
78                 self.generated_files = [ ]
79                 self.end = 300
80                 self.prog_state = 0
81                 self.weighting = 1000
82                 self.cutfile = self.job.workspace + "/cut_%d.Xcl" % (job.i+1)
83                 self.cutlist = title.cutlist
84                 self.args += [inputfile, "-demux", "-out", self.job.workspace ]
85                 if len(self.cutlist) > 1:
86                         self.args += [ "-cut", self.cutfile ]
87
88         def prepare(self):
89                 self.writeCutfile()
90
91         def processOutputLine(self, line):
92                 line = line[:-1]
93                 MSG_NEW_FILE = "---> new File: "
94                 MSG_PROGRESS = "[PROGRESS] "
95
96                 if line.startswith(MSG_NEW_FILE):
97                         file = line[len(MSG_NEW_FILE):]
98                         if file[0] == "'":
99                                 file = file[1:-1]
100                         self.haveNewFile(file)
101                 elif line.startswith(MSG_PROGRESS):
102                         progress = line[len(MSG_PROGRESS):]
103                         self.haveProgress(progress)
104
105         def haveNewFile(self, file):
106                 print "PRODUCED FILE [%s]" % file
107                 self.generated_files.append(file)
108
109         def haveProgress(self, progress):
110                 print "PROGRESS [%s]" % progress
111                 MSG_CHECK = "check & synchronize audio file"
112                 MSG_DONE = "done..."
113                 if progress == "preparing collection(s)...":
114                         self.prog_state = 0
115                 elif progress[:len(MSG_CHECK)] == MSG_CHECK:
116                         self.prog_state += 1
117                 else:
118                         try:
119                                 p = int(progress)
120                                 p = p - 1 + self.prog_state * 100
121                                 if p > self.progress:
122                                         self.progress = p
123                         except ValueError:
124                                 print "val error"
125                                 pass
126
127         def writeCutfile(self):
128                 f = open(self.cutfile, "w")
129                 f.write("CollectionPanel.CutMode=4\n")
130                 for p in self.cutlist:
131                         s = p / 90000
132                         m = s / 60
133                         h = m / 60
134
135                         m %= 60
136                         s %= 60
137
138                         f.write("%02d:%02d:%02d\n" % (h, m, s))
139                 f.close()
140
141         def cleanup(self, failed):
142                 if failed:
143                         import os
144                         for f in self.generated_files:
145                                 os.remove(f)
146
147 class MplexTask(Task):
148         def __init__(self, job, outputfile, inputfiles=None, demux_task=None):
149                 Task.__init__(self, job, "Mux ES into PS")
150                 self.weighting = 500
151                 self.demux_task = demux_task
152                 self.setTool("/usr/bin/mplex")
153                 self.args += ["-f8", "-o", outputfile, "-v1"]
154                 if inputfiles:
155                         self.args += inputfiles
156
157         def prepare(self):
158                 if self.demux_task:
159                         self.args += self.demux_task.generated_files
160
161         def processOutputLine(self, line):
162                 print "[MplexTask] processOutputLine=", line
163
164 class RemoveESFiles(Task):
165         def __init__(self, job, demux_task):
166                 Task.__init__(self, job, "Remove temp. files")
167                 self.demux_task = demux_task
168                 self.setTool("/bin/rm")
169
170         def prepare(self):
171                 self.args += ["-f"]
172                 self.args += self.demux_task.generated_files
173                 self.args += [self.demux_task.cutfile]
174
175 class DVDAuthorTask(Task):
176         def __init__(self, job, diskspaceNeeded):
177                 Task.__init__(self, job, "Authoring DVD")
178
179                 self.global_preconditions.append(DiskspacePrecondition(diskspaceNeeded))
180                 self.weighting = 300
181                 self.setTool("/usr/bin/dvdauthor")
182                 self.CWD = self.job.workspace
183                 self.args += ["-x", self.job.workspace+"/dvdauthor.xml"]
184                 self.menupreview = job.menupreview
185
186         def processOutputLine(self, line):
187                 print "[DVDAuthorTask] processOutputLine=", line
188                 if not self.menupreview and line.startswith("STAT: Processing"):
189                         self.callback(self, [], stay_resident=True)
190
191 class DVDAuthorFinalTask(Task):
192         def __init__(self, job):
193                 Task.__init__(self, job, "dvdauthor finalize")
194                 self.setTool("/usr/bin/dvdauthor")
195                 self.args += ["-T", "-o", self.job.workspace + "/dvd"]
196
197 class WaitForResidentTasks(Task):
198         def __init__(self, job):
199                 Task.__init__(self, job, "waiting for dvdauthor to finalize")
200                 
201         def run(self, callback, task_progress_changed):
202                 print "waiting for %d resident task(s) %s to finish..." % (len(self.job.resident_tasks),str(self.job.resident_tasks))
203                 if self.job.resident_tasks == 0:
204                         callback(self, [])
205
206 class BurnTaskPostcondition(Condition):
207         def check(self, task):
208                 return task.error is None
209
210         def getErrorMessage(self, task):
211                 return {
212                         task.ERROR_MEDIA: ("Medium is not a writeable DVD!"),
213                         task.ERROR_SIZE: ("Content does not fit on DVD!"),
214                         task.ERROR_WRITE_FAILED: ("Write failed!"),
215                         task.ERROR_DVDROM: ("No (supported) DVDROM found!"),
216                         task.ERROR_UNKNOWN: ("An unknown error occured!")
217                 }[task.error]
218
219 class BurnTask(Task):
220         ERROR_MEDIA, ERROR_SIZE, ERROR_WRITE_FAILED, ERROR_DVDROM, ERROR_UNKNOWN = range(5)
221         def __init__(self, job):
222                 Task.__init__(self, job, "burn")
223
224                 self.weighting = 500
225                 self.end = 120 # 100 for writing, 10 for buffer flush, 10 for closing disc
226                 self.postconditions.append(BurnTaskPostcondition())
227                 self.setTool("/bin/growisofs")
228                 
229                 self.args += ["-dvd-video", "-dvd-compat", "-Z", "/dev/cdroms/cdrom0", "-V", self.getASCIIname(job.project.name), "-P", "Dreambox", "-use-the-force-luke=dummy", self.job.workspace + "/dvd"]
230
231         def getASCIIname(self, name):
232                 ASCIIname = ""
233                 for char in name.decode("utf-8").encode("ascii","replace"):
234                         if ord(char) <= 0x20 or ( ord(char) >= 0x3a and ord(char) <= 0x40 ):
235                                 ASCIIname += '_'
236                         else:
237                                 ASCIIname += char
238                 return ASCIIname
239                 
240         def prepare(self):
241                 self.error = None
242
243         def processOutputLine(self, line):
244                 line = line[:-1]
245                 print "[GROWISOFS] %s" % line
246                 if line[8:14] == "done, ":
247                         self.progress = float(line[:6])
248                         print "progress:", self.progress
249                 elif line.find("flushing cache") != -1:
250                         self.progress = 100
251                 elif line.find("closing disc") != -1:
252                         self.progress = 110
253                 elif line.startswith(":-["):
254                         if line.find("ASC=30h") != -1:
255                                 self.error = self.ERROR_MEDIA
256                         else:
257                                 self.error = self.ERROR_UNKNOWN
258                                 print "BurnTask: unknown error %s" % line
259                 elif line.startswith(":-("):
260                         if line.find("No space left on device") != -1:
261                                 self.error = self.ERROR_SIZE
262                         elif line.find("write failed") != -1:
263                                 self.error = self.ERROR_WRITE_FAILED
264                         elif line.find("unable to open64(\"/dev/cdroms/cdrom0\",O_RDONLY): No such file or directory") != -1: # fixme
265                                 self.error = self.ERROR_DVDROM
266                         elif line.find("media is not recognized as recordable DVD") != -1:
267                                 self.error = self.ERROR_MEDIA
268                         else:
269                                 self.error = self.ERROR_UNKNOWN
270                                 print "BurnTask: unknown error %s" % line
271
272 class RemoveDVDFolder(Task):
273         def __init__(self, job):
274                 Task.__init__(self, job, "Remove temp. files")
275                 self.setTool("/bin/rm")
276                 self.args += ["-rf", self.job.workspace]
277
278 class PreviewTask(Task):
279         def __init__(self, job):
280                 Task.__init__(self, job, "Preview")
281                 self.job = job
282
283         def run(self, callback, task_progress_changed):
284                 self.callback = callback
285                 self.task_progress_changed = task_progress_changed
286                 if self.job.project.waitboxref:
287                         self.job.project.waitboxref.close()
288                 if self.job.menupreview:
289                         self.waitAndOpenPlayer()
290                 else:
291                         self.job.project.session.openWithCallback(self.previewCB, MessageBox, _("Do you want to preview this project before burning?"), timeout = 60, default = False)
292         
293         def previewCB(self, answer):
294                 if answer == True:
295                         self.waitAndOpenPlayer()
296                 else:
297                         self.closedCB(True)
298
299         def playerClosed(self):
300                 if self.job.menupreview:
301                         self.closedCB(True)
302                 else:
303                         self.job.project.session.openWithCallback(self.closedCB, MessageBox, _("Do you want to burn this project to DVD medium?") )
304
305         def closedCB(self, answer):
306                 if answer == True:
307                         Task.processFinished(self, 0)
308                 else:
309                         Task.processFinished(self, 1)
310
311         def waitAndOpenPlayer(self):
312                 from enigma import eTimer
313                 self.delayTimer = eTimer()
314                 self.delayTimer.callback.append(self.previewProject)
315                 self.delayTimer.start(10,1)
316                 
317         def previewProject(self):
318                 from Plugins.Extensions.DVDPlayer.plugin import DVDPlayer
319                 self.job.project.session.openWithCallback(self.playerClosed, DVDPlayer, dvd_filelist= [ self.job.project.workspace + "/dvd/VIDEO_TS/" ])
320
321 def getTitlesPerMenu(nr_titles):
322         if nr_titles < 6:
323                 titles_per_menu = 5
324         else:
325                 titles_per_menu = 4
326         return titles_per_menu
327
328 def CreateMenus(job):
329         import os, Image, ImageDraw, ImageFont, re
330         imgwidth = 720
331         imgheight = 576
332         
333         im_bg_orig = Image.open(job.project.menubg)
334         if im_bg_orig.size != (imgwidth, imgheight):
335                 im_bg_orig = im_bg_orig.resize((720, 576))
336
337         font0 = ImageFont.truetype(job.project.font_face, job.project.font_size[0])
338         font1 = ImageFont.truetype(job.project.font_face, job.project.font_size[1])
339         font2 = ImageFont.truetype(job.project.font_face, job.project.font_size[2])
340         spu_palette = [ 0x60, 0x60, 0x60 ] + list(job.project.color_highlight)
341
342         nr_titles = len(job.project.titles)
343         titles_per_menu = getTitlesPerMenu(nr_titles)
344         job.nr_menus = ((nr_titles+titles_per_menu-1)/titles_per_menu)
345
346         #a new menu_count every 5 titles (1,2,3,4,5->1 ; 6,7,8,9,10->2 etc.)
347         for menu_count in range(1 , job.nr_menus+1):
348                 im_bg = im_bg_orig.copy()
349                 im_high = Image.new("P", (imgwidth, imgheight), 0)
350                 im_high.putpalette(spu_palette)
351                 draw_bg = ImageDraw.Draw(im_bg)
352                 draw_high = ImageDraw.Draw(im_high)
353
354                 if menu_count == 1:
355                         headline = job.project.name.decode("utf-8")
356                         textsize = draw_bg.textsize(headline, font=font0)
357                         if textsize[0] > imgwidth:
358                                 offset = (0 , 20)
359                         else:
360                                 offset = (((imgwidth-textsize[0]) / 2) , 20)
361                         draw_bg.text(offset, headline, fill=job.project.color_headline, font=font0)
362                 
363                 menubgpngfilename = job.workspace+"/dvd_menubg"+str(menu_count)+".png"
364                 highlightpngfilename = job.workspace+"/dvd_highlight"+str(menu_count)+".png"
365                 spuxml = """<?xml version="1.0" encoding="utf-8"?>
366         <subpictures>
367         <stream>
368         <spu 
369         highlight="%s"
370         transparent="%02x%02x%02x"
371         start="00:00:00.00"
372         force="yes" >""" % (highlightpngfilename, spu_palette[0], spu_palette[1], spu_palette[2])
373
374                 rowheight = (job.project.font_size[1]+job.project.font_size[2]+job.project.space_rows)
375                 menu_start_title = (menu_count-1)*titles_per_menu + 1
376                 menu_end_title = (menu_count)*titles_per_menu + 1
377                 if menu_end_title > nr_titles:
378                         menu_end_title = nr_titles+1
379                 menu_i = 0
380                 for title_no in range( menu_start_title , menu_end_title ):
381                         i = title_no-1
382                         top = job.project.space_top + ( menu_i * rowheight )
383                         menu_i += 1
384                         title = job.project.titles[i]
385                         titlename = title.name.decode("utf-8")
386                         menuitem = "%d. %s" % (title_no, titlename)
387                         draw_bg.text((job.project.space_left,top), menuitem, fill=job.project.color_button, font=font1)
388                         draw_high.text((job.project.space_left,top), menuitem, fill=1, font=font1)
389                         res = re.search("(?:/.*?).*/(?P<year>\d{4})(?P<month>\d{2})(?P<day>\d{2}).(?P<hour>\d{2})(?P<minute>\d{2}).-.*.?.ts", title.inputfile)
390                         subtitle = ""
391                         if res:
392                                 subtitle = "%s-%s-%s, %s:%s. " % (res.group("year"),res.group("month"),res.group("day"),res.group("hour"),res.group("minute"))
393                         if len(title.descr) > 1:
394                                 subtitle += title.descr.decode("utf-8") + ". "
395                         if len(title.chaptermarks) > 1:
396                                 subtitle += (" (%d %s)" % (len(title.chaptermarks)+1, _("chapters")))
397                         draw_bg.text((job.project.space_left,top+36), subtitle, fill=job.project.color_button, font=font2)
398         
399                         bottom = top+rowheight
400                         if bottom > imgheight:
401                                 bottom = imgheight
402                         spuxml += """
403         <button name="button%s" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (str(title_no).zfill(2),job.project.space_left,imgwidth,top,bottom )
404                 if menu_count > 1:
405                         prev_page_text = "<<<"
406                         textsize = draw_bg.textsize(prev_page_text, font=font1)
407                         offset = ( 2*job.project.space_left, job.project.space_top + ( titles_per_menu * rowheight ) )
408                         draw_bg.text(offset, prev_page_text, fill=job.project.color_button, font=font1)
409                         draw_high.text(offset, prev_page_text, fill=1, font=font1)
410                         spuxml += """
411         <button name="button_prev" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (offset[0],offset[0]+textsize[0],offset[1],offset[1]+textsize[1])
412
413                 if menu_count < job.nr_menus:
414                         next_page_text = ">>>"
415                         textsize = draw_bg.textsize(next_page_text, font=font1)
416                         offset = ( imgwidth-textsize[0]-2*job.project.space_left, job.project.space_top + ( titles_per_menu * rowheight ) )
417                         draw_bg.text(offset, next_page_text, fill=job.project.color_button, font=font1)
418                         draw_high.text(offset, next_page_text, fill=1, font=font1)
419                         spuxml += """
420         <button name="button_next" x0="%d" x1="%d" y0="%d" y1="%d"/>""" % (offset[0],offset[0]+textsize[0],offset[1],offset[1]+textsize[1])
421                                 
422                 del draw_bg
423                 del draw_high
424                 fd=open(menubgpngfilename,"w")
425                 im_bg.save(fd,"PNG")
426                 fd.close()
427                 fd=open(highlightpngfilename,"w")
428                 im_high.save(fd,"PNG")
429                 fd.close()
430         
431                 png2yuvTask(job, menubgpngfilename, job.workspace+"/dvdmenubg"+str(menu_count)+".yuv")
432                 menubgm2vfilename = job.workspace+"/dvdmenubg"+str(menu_count)+".mv2"
433                 mpeg2encTask(job, job.workspace+"/dvdmenubg"+str(menu_count)+".yuv", menubgm2vfilename)
434                 menubgmpgfilename = job.workspace+"/dvdmenubg"+str(menu_count)+".mpg"
435                 MplexTask(job, outputfile=menubgmpgfilename, inputfiles = [menubgm2vfilename, job.project.menuaudio])
436         
437                 spuxml += """
438         </spu>
439         </stream>
440         </subpictures>"""
441                 spuxmlfilename = job.workspace+"/spumux"+str(menu_count)+".xml"
442                 f = open(spuxmlfilename, "w")
443                 f.write(spuxml)
444                 f.close()
445                 
446                 menuoutputfilename = job.workspace+"/dvdmenu"+str(menu_count)+".mpg"
447                 spumuxTask(job, spuxmlfilename, menubgmpgfilename, menuoutputfilename)
448                 
449 def CreateAuthoringXML(job):
450         nr_titles = len(job.project.titles)
451         titles_per_menu = getTitlesPerMenu(nr_titles)
452         authorxml = """<?xml version="1.0" encoding="utf-8"?>
453 <dvdauthor dest="%s">
454    <vmgm>
455       <menus>
456          <pgc>
457             <vob file="%s" />
458             <post> jump titleset 1 menu; </post>
459          </pgc>
460       </menus>
461    </vmgm>
462    <titleset>
463       <menus>
464          <video aspect="4:3"/>"""% (job.workspace+"/dvd", job.project.vmgm)
465         for menu_count in range(1 , job.nr_menus+1):
466                 if menu_count == 1:
467                         authorxml += """
468          <pgc entry="root">"""
469                 else:
470                         authorxml += """
471          <pgc>"""
472                 menu_start_title = (menu_count-1)*titles_per_menu + 1
473                 menu_end_title = (menu_count)*titles_per_menu + 1
474                 if menu_end_title > nr_titles:
475                         menu_end_title = nr_titles+1
476                 for i in range( menu_start_title , menu_end_title ):
477                         authorxml += """
478             <button name="button%s">jump title %d;</button>""" % (str(i).zfill(2), i)
479                 
480                 if menu_count > 1:
481                         authorxml += """
482             <button name="button_prev">jump menu %d;</button>""" % (menu_count-1)
483                         
484                 if menu_count < job.nr_menus:
485                         authorxml += """
486             <button name="button_next">jump menu %d;</button>""" % (menu_count+1)
487
488                 menuoutputfilename = job.workspace+"/dvdmenu"+str(menu_count)+".mpg"
489                 authorxml += """
490             <vob file="%s" pause="inf"/>
491          </pgc>""" % menuoutputfilename
492         authorxml += """
493       </menus>
494       <titles>"""
495         for i in range( nr_titles ):
496                 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])
497
498                 title_no = i+1
499                 title_filename = job.workspace + "/dvd_title_%d.mpg" % (title_no)
500                 
501                 if job.menupreview:
502                         LinkTS(job, job.project.vmgm, title_filename)
503                 else:
504                         MakeFifoNode(job, title_no)
505                 
506                 vob_tag = """file="%s" chapters="%s" />""" % (title_filename, chapters)
507                                         
508                 if title_no < nr_titles:
509                         post_tag = "jump title %d;" % ( title_no+1 )
510                 else:
511                         post_tag = "call vmgm menu 1;"
512                 authorxml += """
513          <pgc>
514             <vob %s
515             <post> %s </post>
516          </pgc>""" % (vob_tag, post_tag)
517          
518         authorxml += """
519      </titles>
520    </titleset>
521 </dvdauthor>
522 """
523         f = open(job.workspace+"/dvdauthor.xml", "w")
524         f.write(authorxml)
525         f.close()
526
527 class DVDJob(Job):
528         def __init__(self, project, menupreview=False):
529                 Job.__init__(self, "DVD Burn")
530                 self.project = project
531                 from time import strftime
532                 from Tools.Directories import SCOPE_HDD, resolveFilename, createDir
533                 new_workspace = resolveFilename(SCOPE_HDD) + "tmp/" + strftime("%Y%m%d%H%M%S")
534                 createDir(new_workspace)
535                 self.workspace = new_workspace
536                 self.project.workspace = self.workspace
537                 self.menupreview = menupreview
538                 self.conduct()
539
540         def conduct(self):
541                 CreateMenus(self)
542                 CreateAuthoringXML(self)
543
544                 totalsize = 50*1024*1024 # require an extra safety 50 MB
545                 maxsize = 0
546                 for title in self.project.titles:
547                         titlesize = title.estimatedDiskspace
548                         if titlesize > maxsize: maxsize = titlesize
549                         totalsize += titlesize
550                 diskSpaceNeeded = totalsize + maxsize
551                 print "diskSpaceNeeded:", diskSpaceNeeded
552
553                 DVDAuthorTask(self, diskSpaceNeeded)
554                 
555                 nr_titles = len(self.project.titles)
556                 
557                 if self.menupreview:
558                         PreviewTask(self)
559                 else:
560                         for self.i in range(nr_titles):
561                                 title = self.project.titles[self.i]
562                                 link_name =  self.workspace + "/source_title_%d.ts" % (self.i+1)
563                                 title_filename = self.workspace + "/dvd_title_%d.mpg" % (self.i+1)
564                                 LinkTS(self, title.inputfile, link_name)
565                                 demux = DemuxTask(self, link_name)
566                                 MplexTask(self, outputfile=title_filename, demux_task=demux)
567                                 RemoveESFiles(self, demux)
568                         WaitForResidentTasks(self)
569                         PreviewTask(self)
570                         BurnTask(self)
571                 #RemoveDVDFolder(self)
572
573 def Burn(session, project):
574         print "burning cuesheet!"
575         j = DVDJob(project)
576         job_manager.AddJob(j)
577         return j
578
579 def PreviewMenu(session, project):
580         print "preview DVD menu!"
581         j = DVDJob(project, menupreview=True)
582         job_manager.AddJob(j)
583         return j