diff --git a/mythplugins/mytharchive/mytharchive/mythburn.cpp b/mythplugins/mytharchive/mytharchive/mythburn.cpp
index 5ef8122904..fadbb2db94 100644
|
a
|
b
|
|
| 29 | 29 | #include <mythsystemlegacy.h> |
| 30 | 30 | #include <mythmiscutil.h> |
| 31 | 31 | #include <exitcodes.h> |
| | 32 | #include <mythconfig.h> |
| 32 | 33 | |
| 33 | 34 | // mytharchive |
| 34 | 35 | #include "archiveutil.h" |
| … |
… |
void MythBurn::runScript()
|
| 909 | 910 | QFile::remove(logDir + "/mythburncancel.lck"); |
| 910 | 911 | |
| 911 | 912 | createConfigFile(configDir + "/mydata.xml"); |
| 912 | | commandline = "python " + GetShareDir() + "mytharchive/scripts/mythburn.py"; |
| | 913 | commandline = PYTHON_EXE; |
| | 914 | commandline += " " + GetShareDir() + "mytharchive/scripts/mythburn.py"; |
| 913 | 915 | commandline += " -j " + configDir + "/mydata.xml"; // job file |
| 914 | 916 | commandline += " -l " + logDir + "/progress.log"; // progress log |
| 915 | 917 | commandline += " > " + logDir + "/mythburn.log 2>&1 &"; // Logs |
diff --git a/mythplugins/mytharchive/mythburn/scripts/mythburn.py b/mythplugins/mytharchive/mythburn/scripts/mythburn.py
index 4f5a96d7ab..bb7f0f5033 100755
|
a
|
b
|
|
| 2 | 2 | # -*- coding: utf-8 -*- |
| 3 | 3 | from __future__ import unicode_literals |
| 4 | 4 | |
| | 5 | # python 3 doesn't have a unicode type |
| | 6 | try: |
| | 7 | unicode |
| | 8 | except: |
| | 9 | unicode = str |
| | 10 | |
| | 11 | # python 3 doesn't have a long type |
| | 12 | try: |
| | 13 | long |
| | 14 | except: |
| | 15 | long = int |
| | 16 | |
| | 17 | |
| 5 | 18 | # mythburn.py |
| 6 | 19 | # The ported MythBurn scripts which feature: |
| 7 | 20 | |
| … |
… |
from __future__ import unicode_literals
|
| 49 | 62 | |
| 50 | 63 | |
| 51 | 64 | # version of script - change after each update |
| 52 | | VERSION="0.1.20131119-1" |
| | 65 | VERSION="0.2.2020017-1" |
| 53 | 66 | |
| 54 | 67 | # keep all temporary files for debugging purposes |
| 55 | 68 | # set this to True before a first run through when testing |
| … |
… |
drivespeed = 0;
|
| 155 | 168 | #main menu aspect ratio (4:3 or 16:9) |
| 156 | 169 | mainmenuAspectRatio = "16:9" |
| 157 | 170 | |
| 158 | | #chapter menu aspect ratio (4:3, 16:9 or Video) |
| | 171 | #chapter menu aspect ratio (4:3, 16:9 or Video) |
| 159 | 172 | #video means same aspect ratio as the video title |
| 160 | 173 | chaptermenuAspectRatio = "Video" |
| 161 | 174 | |
| … |
… |
def encodeMenu(background, tempvideo, music, musiclength, tempmovie, xmlfile, fi
|
| 505 | 518 | command = quoteCmdArg(path_jpeg2yuv[0]) + " -n %s -v0 -I p -f %s -j %s | %s -b 5000 -a %s -v 1 -f 8 -o %s" \ |
| 506 | 519 | % (totalframes, framespersecond, quoteCmdArg(background), quoteCmdArg(path_mpeg2enc[0]), aspectratio, quoteCmdArg(tempvideo)) |
| 507 | 520 | result = runCommand(command) |
| 508 | | if result<>0: |
| | 521 | if result!=0: |
| 509 | 522 | fatalError("Failed while running jpeg2yuv - %s" % command) |
| 510 | 523 | |
| 511 | 524 | command = quoteCmdArg(path_mplex[0]) + " -f 8 -v 0 -o %s %s %s" % (quoteCmdArg(tempmovie), quoteCmdArg(tempvideo), quoteCmdArg(music)) |
| 512 | 525 | result = runCommand(command) |
| 513 | | if result<>0: |
| | 526 | if result!=0: |
| 514 | 527 | fatalError("Failed while running mplex - %s" % command) |
| 515 | 528 | |
| 516 | 529 | if xmlfile != "": |
| 517 | 530 | command = quoteCmdArg(path_spumux[0]) + " -m dvd -s 0 %s < %s > %s" % (quoteCmdArg(xmlfile), quoteCmdArg(tempmovie), quoteCmdArg(finaloutput)) |
| 518 | 531 | result = runCommand(command) |
| 519 | | if result<>0: |
| | 532 | if result!=0: |
| 520 | 533 | fatalError("Failed while running spumux - %s" % command) |
| 521 | 534 | else: |
| 522 | 535 | os.rename(tempmovie, finaloutput) |
| … |
… |
def encodeMenu(background, tempvideo, music, musiclength, tempmovie, xmlfile, fi
|
| 527 | 540 | os.remove(tempmovie) |
| 528 | 541 | |
| 529 | 542 | ############################################################# |
| 530 | | # Return an xml node from a re-encoding profile xml file for |
| | 543 | # Return an xml node from a re-encoding profile xml file for |
| 531 | 544 | # a given profile name |
| 532 | 545 | |
| 533 | 546 | def findEncodingProfile(profile): |
| … |
… |
def getLengthOfVideo(index):
|
| 606 | 619 | return duration |
| 607 | 620 | |
| 608 | 621 | ############################################################# |
| 609 | | # Gets the audio sample rate and number of channels of a video file |
| | 622 | # Gets the audio sample rate and number of channels of a video file |
| 610 | 623 | # from its stream info file |
| 611 | 624 | |
| 612 | 625 | def getAudioParams(folder): |
| … |
… |
def getVideoParams(folder):
|
| 643 | 656 | if video.attributes["aspectratio"].value != 'N/A': |
| 644 | 657 | aspect_ratio = video.attributes["aspectratio"].value |
| 645 | 658 | else: |
| 646 | | aspect_ratio = "1.77778" |
| | 659 | aspect_ratio = "1.77778" |
| 647 | 660 | |
| 648 | 661 | videores = video.attributes["width"].value + 'x' + video.attributes["height"].value |
| 649 | 662 | fps = video.attributes["fps"].value |
| … |
… |
def createVideoChapters(itemnum, numofchapters, lengthofvideo, getthumbnails):
|
| 801 | 814 | ############################################################# |
| 802 | 815 | # Creates some fixed length chapter marks |
| 803 | 816 | |
| 804 | | def createVideoChaptersFixedLength(itemnum, segment, lengthofvideo): |
| 805 | | """Returns chapter marks at cut list ends, |
| | 817 | def createVideoChaptersFixedLength(itemnum, segment, lengthofvideo): |
| | 818 | """Returns chapter marks at cut list ends, |
| 806 | 819 | or evenly spaced chapters 'segment' seconds through the file""" |
| 807 | 820 | |
| 808 | 821 | |
| … |
… |
def getDefaultParametersFromMythTVDB():
|
| 845 | 858 | sqlstatement="""SELECT value, data FROM settings WHERE value IN( |
| 846 | 859 | 'DBSchemaVer', |
| 847 | 860 | 'ISO639Language0', |
| 848 | | 'ISO639Language1') |
| | 861 | 'ISO639Language1') |
| 849 | 862 | OR (hostname=%s AND value IN( |
| 850 | 863 | 'VideoStartupDir', |
| 851 | 864 | 'GalleryDir', |
| … |
… |
def intelliDraw(drawer, text, font, containerWidth):
|
| 994 | 1007 | #write("containerWidth: %s" % containerWidth) |
| 995 | 1008 | words = text.split() |
| 996 | 1009 | lines = [] # prepare a return argument |
| 997 | | lines.append(words) |
| | 1010 | lines.append(words) |
| 998 | 1011 | finished = False |
| 999 | 1012 | line = 0 |
| 1000 | 1013 | while not finished: |
| … |
… |
def intelliDraw(drawer, text, font, containerWidth):
|
| 1008 | 1021 | if drawer.textsize(' '.join(thistext),font.getFont())[0] > containerWidth: |
| 1009 | 1022 | # this is the heart of the algorithm: we pop words off the current |
| 1010 | 1023 | # sentence until the width is ok, then in the next outer loop |
| 1011 | | # we move on to the next sentence. |
| | 1024 | # we move on to the next sentence. |
| 1012 | 1025 | if str(thistext).find(' ') != -1: |
| 1013 | 1026 | newline.insert(0,thistext.pop(-1)) |
| 1014 | 1027 | else: |
| … |
… |
def paintButton(draw, bgimage, bgimagemask, node, infoDOM, itemnum, page,
|
| 1133 | 1146 | ############################################################# |
| 1134 | 1147 | # Paint some theme text on to an image |
| 1135 | 1148 | |
| 1136 | | def paintText(draw, image, text, node, color = None, |
| | 1149 | def paintText(draw, image, text, node, color = None, |
| 1137 | 1150 | x = None, y = None, width = None, height = None): |
| 1138 | 1151 | """Takes a piece of text and draws it onto an image inside a bounding box.""" |
| 1139 | 1152 | #The text is wider than the width of the bounding box |
| 1140 | 1153 | |
| 1141 | 1154 | if x == None: |
| 1142 | | x = getScaledAttribute(node, "x") |
| | 1155 | x = getScaledAttribute(node, "x") |
| 1143 | 1156 | y = getScaledAttribute(node, "y") |
| 1144 | 1157 | width = getScaledAttribute(node, "w") |
| 1145 | 1158 | height = getScaledAttribute(node, "h") |
| … |
… |
def paintImage(filename, maskfilename, imageDom, destimage, stretch=True):
|
| 1230 | 1243 | (imgw, imgh) = picture.size |
| 1231 | 1244 | write("Image (%s, %s) into space of (%s, %s) at (%s, %s)" % (imgw, imgh, w, h, xpos, ypos), False) |
| 1232 | 1245 | |
| 1233 | | # the theme can override the default stretch behaviour |
| 1234 | | if imageDom.hasAttribute("stretch"): |
| | 1246 | # the theme can override the default stretch behaviour |
| | 1247 | if imageDom.hasAttribute("stretch"): |
| 1235 | 1248 | if imageDom.attributes["stretch"].value == "True": |
| 1236 | 1249 | stretch = True |
| 1237 | 1250 | else: |
| … |
… |
def paintImage(filename, maskfilename, imageDom, destimage, stretch=True):
|
| 1272 | 1285 | picture = picture.resize((imgw, imgh)) |
| 1273 | 1286 | picture = picture.convert("RGBA") |
| 1274 | 1287 | |
| 1275 | | if maskfilename <> None and doesFileExist(maskfilename): |
| | 1288 | if maskfilename != None and doesFileExist(maskfilename): |
| 1276 | 1289 | maskpicture = Image.open(maskfilename, "r").resize((imgw, imgh)) |
| 1277 | 1290 | maskpicture = maskpicture.convert("RGBA") |
| 1278 | 1291 | else: |
| … |
… |
def paintImage(filename, maskfilename, imageDom, destimage, stretch=True):
|
| 1280 | 1293 | |
| 1281 | 1294 | destimage.paste(picture, (xpos, ypos), maskpicture) |
| 1282 | 1295 | del picture |
| 1283 | | if maskfilename <> None and doesFileExist(maskfilename): |
| | 1296 | if maskfilename != None and doesFileExist(maskfilename): |
| 1284 | 1297 | del maskpicture |
| 1285 | 1298 | |
| 1286 | 1299 | write ("Added image %s" % filename) |
| … |
… |
def paintImage(filename, maskfilename, imageDom, destimage, stretch=True):
|
| 1294 | 1307 | def checkBoundaryBox(boundarybox, node): |
| 1295 | 1308 | # We work out how much space all of our graphics and text are taking up |
| 1296 | 1309 | # in a bounding rectangle so that we can use this as an automatic highlight |
| 1297 | | # on the DVD menu |
| | 1310 | # on the DVD menu |
| 1298 | 1311 | if getText(node.attributes["static"]) == "False": |
| 1299 | 1312 | if getScaledAttribute(node, "x") < boundarybox[0]: |
| 1300 | 1313 | boundarybox = getScaledAttribute(node, "x"), boundarybox[1], boundarybox[2], boundarybox[3] |
| … |
… |
def getFileInformation(file, folder):
|
| 1389 | 1402 | if file.attributes["type"].value=="recording": |
| 1390 | 1403 | filename = file.attributes["filename"].value |
| 1391 | 1404 | try: |
| 1392 | | rec = DB.searchRecorded(basename=os.path.basename(filename)).next() |
| | 1405 | rec = next(DB.searchRecorded(basename=os.path.basename(filename))) |
| 1393 | 1406 | except StopIteration: |
| 1394 | 1407 | fatalError("Failed to get recording details from the DB for %s" % filename) |
| 1395 | 1408 | |
| … |
… |
def getFileInformation(file, folder):
|
| 1412 | 1425 | elif file.attributes["type"].value=="recording": |
| 1413 | 1426 | filename = file.attributes["filename"].value |
| 1414 | 1427 | try: |
| 1415 | | rec = DB.searchRecorded(basename=os.path.basename(filename)).next() |
| | 1428 | rec = next(DB.searchRecorded(basename=os.path.basename(filename))) |
| 1416 | 1429 | except StopIteration: |
| 1417 | 1430 | fatalError("Failed to get recording details from the DB for %s" % filename) |
| 1418 | 1431 | |
| … |
… |
def getFileInformation(file, folder):
|
| 1443 | 1456 | elif file.attributes["type"].value=="video": |
| 1444 | 1457 | filename = file.attributes["filename"].value |
| 1445 | 1458 | try: |
| 1446 | | vid = MVID.searchVideos(file=filename).next() |
| | 1459 | vid = next(MVID.searchVideos(file=filename)) |
| 1447 | 1460 | except StopIteration: |
| 1448 | 1461 | vid = Video.fromFilename(filename) |
| 1449 | 1462 | |
| … |
… |
def getFileInformation(file, folder):
|
| 1489 | 1502 | |
| 1490 | 1503 | data.thumblist = ','.join(thumblist) |
| 1491 | 1504 | |
| 1492 | | for k,v in data.items(): |
| | 1505 | for k,v in list(data.items()): |
| 1493 | 1506 | write( "Node = %s, Data = %s" % (k, v)) |
| 1494 | 1507 | node = infoDOM.createElement(k) |
| 1495 | 1508 | # v may be either an integer. Therefore we have to |
| … |
… |
def multiplexMPEGStream(video, audio1, audio2, destination, syncOffset):
|
| 1588 | 1601 | |
| 1589 | 1602 | write("Multiplexing MPEG stream to %s" % destination) |
| 1590 | 1603 | |
| 1591 | | # no need to use a sync offset if projectx was used to demux the streams |
| | 1604 | # no need to use a sync offset if projectx was used to demux the streams |
| 1592 | 1605 | if useprojectx: |
| 1593 | 1606 | syncOffset = 0 |
| 1594 | 1607 | else: |
| … |
… |
def multiplexMPEGStream(video, audio1, audio2, destination, syncOffset):
|
| 1663 | 1676 | write("Checking integrity of subtitle pngs") |
| 1664 | 1677 | command = quoteCmdArg(os.path.join(scriptpath, "testsubtitlepngs.sh")) + " " + quoteCmdArg(os.path.dirname(destination) + "/stream.d/spumux.xml") |
| 1665 | 1678 | result = runCommand(command) |
| 1666 | | if result<>0: |
| | 1679 | if result!=0: |
| 1667 | 1680 | fatalError("Failed while running testsubtitlepngs.sh - %s" % command) |
| 1668 | 1681 | |
| 1669 | 1682 | write("Running spumux to add subtitles") |
| 1670 | 1683 | command = quoteCmdArg(path_spumux[0]) + " -P %s <%s >%s" % (quoteCmdArg(os.path.dirname(destination) + "/stream.d/spumux.xml"), quoteCmdArg(destination), quoteCmdArg(os.path.splitext(destination)[0] + "-sub.mpg")) |
| 1671 | 1684 | result = runCommand(command) |
| 1672 | | if result<>0: |
| | 1685 | if result!=0: |
| 1673 | 1686 | nonfatalError("Failed while running spumux.\n" |
| 1674 | 1687 | "Command was - %s.\n" |
| 1675 | 1688 | "Look in the full log to see why it failed" % command) |
| … |
… |
def getStreamInformation(filename, xmlFilename, lenMethod):
|
| 1691 | 1704 | |
| 1692 | 1705 | result = runCommand(command) |
| 1693 | 1706 | |
| 1694 | | if result <> 0: |
| | 1707 | if result != 0: |
| 1695 | 1708 | fatalError("Failed while running mytharchivehelper to get stream information.\n" |
| 1696 | 1709 | "Result: %d, Command was %s" % (result, command)) |
| 1697 | 1710 | |
| … |
… |
def runMythtranscode(chanid, starttime, destination, usecutlist, localfile):
|
| 1730 | 1743 | """Use mythtranscode to cut commercials and/or clean up an mpeg2 file""" |
| 1731 | 1744 | |
| 1732 | 1745 | try: |
| 1733 | | rec = DB.searchRecorded(chanid=chanid, starttime=starttime).next() |
| | 1746 | rec = next(DB.searchRecorded(chanid=chanid, starttime=starttime)) |
| 1734 | 1747 | cutlist = rec.markup.getcutlist() |
| 1735 | 1748 | except StopIteration: |
| 1736 | 1749 | cutlist = [] |
| … |
… |
def runMythtranscode(chanid, starttime, destination, usecutlist, localfile):
|
| 1770 | 1783 | def generateProjectXCutlist(chanid, starttime, folder): |
| 1771 | 1784 | """generate cutlist_x.txt for ProjectX""" |
| 1772 | 1785 | |
| 1773 | | rec = DB.searchRecorded(chanid=chanid, starttime=starttime).next() |
| | 1786 | rec = next(DB.searchRecorded(chanid=chanid, starttime=starttime)) |
| 1774 | 1787 | starttime = rec.starttime.utcisoformat() |
| 1775 | 1788 | cutlist = rec.markup.getcutlist() |
| 1776 | 1789 | |
| … |
… |
def generateProjectXCutlist(chanid, starttime, folder):
|
| 1781 | 1794 | for cut in cutlist: |
| 1782 | 1795 | # we need to reverse the cutlist because ProjectX wants to know |
| 1783 | 1796 | # the bits to keep not what to cut |
| 1784 | | |
| | 1797 | |
| 1785 | 1798 | if i == 0: |
| 1786 | 1799 | if cut[0] != 0: |
| 1787 | 1800 | cutlist_f.write('0\n%d\n' % cut[0]) |
| … |
… |
def extractVideoFrame(source, destination, seconds):
|
| 1979 | 1992 | |
| 1980 | 1993 | command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (quoteCmdArg(source), seconds, quoteCmdArg(destination)) |
| 1981 | 1994 | result = runCommand(command) |
| 1982 | | if result <> 0: |
| | 1995 | if result != 0: |
| 1983 | 1996 | fatalError("Failed while running mytharchivehelper to get thumbnails.\n" |
| 1984 | 1997 | "Result: %d, Command was %s" % (result, command)) |
| 1985 | 1998 | try: |
| 1986 | 1999 | myimage=Image.open(destination,"r") |
| 1987 | 2000 | |
| 1988 | | if myimage.format <> "JPEG": |
| | 2001 | if myimage.format != "JPEG": |
| 1989 | 2002 | write( "Something went wrong with thumbnail capture - " + myimage.format) |
| 1990 | | return (0L,0L) |
| | 2003 | return (long(0),long(0)) |
| 1991 | 2004 | else: |
| 1992 | 2005 | return myimage.size |
| 1993 | 2006 | except IOError: |
| 1994 | | return (0L, 0L) |
| | 2007 | return (long(0),long(0)) |
| 1995 | 2008 | |
| 1996 | 2009 | ############################################################# |
| 1997 | 2010 | # Grabs a list of single frames from a file |
| … |
… |
def extractVideoFrames(source, destination, thumbList):
|
| 2003 | 2016 | command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (quoteCmdArg(source), thumbList, quoteCmdArg(destination)) |
| 2004 | 2017 | write(command) |
| 2005 | 2018 | result = runCommand(command) |
| 2006 | | if result <> 0: |
| | 2019 | if result != 0: |
| 2007 | 2020 | fatalError("Failed while running mytharchivehelper to get thumbnails.\n" |
| 2008 | 2021 | "Result: %d, Command was %s" % (result, command)) |
| 2009 | 2022 | |
| … |
… |
def encodeNuvToMPEG2(chanid, starttime, mediafile, destvideofile, folder, profil
|
| 2117 | 2130 | profileNode = findEncodingProfile(profile) |
| 2118 | 2131 | parameters = profileNode.getElementsByTagName("parameter") |
| 2119 | 2132 | |
| 2120 | | # default values - will be overriden by values from the profile |
| | 2133 | # default values - will be overriden by values from the profile |
| 2121 | 2134 | outvideobitrate = "5000k" |
| 2122 | 2135 | if videomode == "ntsc": |
| 2123 | 2136 | outvideores = "720x480" |
| … |
… |
def encodeNuvToMPEG2(chanid, starttime, mediafile, destvideofile, folder, profil
|
| 2198 | 2211 | if cpuCount > 1: |
| 2199 | 2212 | command += "-threads %d " % cpuCount |
| 2200 | 2213 | |
| 2201 | | command += "-f s16le -ar %s -ac %s -i %s " % (samplerate, channels, quoteCmdArg(os.path.join(folder, "audout"))) |
| | 2214 | command += "-f s16le -ar %s -ac %s -i %s " % (samplerate, channels, quoteCmdArg(os.path.join(folder, "audout"))) |
| 2202 | 2215 | command += "-f rawvideo -pix_fmt yuv420p -s %s -aspect %s -r %s " % (videores, aspectratio, fps) |
| 2203 | 2216 | command += "-i %s " % quoteCmdArg(os.path.join(folder, "vidout")) |
| 2204 | 2217 | command += "-aspect %s -r %s " % (aspectratio, fps) |
| … |
… |
def runDVDAuthor():
|
| 2235 | 2248 | write( "Starting dvdauthor") |
| 2236 | 2249 | checkCancelFlag() |
| 2237 | 2250 | result=os.spawnlp(os.P_WAIT, path_dvdauthor[0],path_dvdauthor[1],'-x',os.path.join(getTempPath(),'dvdauthor.xml')) |
| 2238 | | if result<>0: |
| | 2251 | if result!=0: |
| 2239 | 2252 | fatalError("Failed while running dvdauthor. Result: %d" % result) |
| 2240 | 2253 | write( "Finished dvdauthor") |
| 2241 | 2254 | |
| … |
… |
def CreateDVDISO(title):
|
| 2252 | 2265 | |
| 2253 | 2266 | result = runCommand(command) |
| 2254 | 2267 | |
| 2255 | | if result<>0: |
| | 2268 | if result!=0: |
| 2256 | 2269 | fatalError("Failed while running mkisofs.\n" |
| 2257 | 2270 | "Command was %s" % command) |
| 2258 | 2271 | |
| 2259 | 2272 | write("Finished creating ISO image") |
| 2260 | 2273 | |
| 2261 | 2274 | ############################################################# |
| 2262 | | # Burns the contents of a directory to create a DVD |
| | 2275 | # Burns the contents of a directory to create a DVD |
| 2263 | 2276 | |
| 2264 | 2277 | |
| 2265 | 2278 | def BurnDVDISO(title): |
| … |
… |
def BurnDVDISO(title):
|
| 2314 | 2327 | except: |
| 2315 | 2328 | write("Sending command ", action, " to drive failed", False) |
| 2316 | 2329 | res = False |
| 2317 | | os.close(f) |
| 2318 | | return res |
| | 2330 | os.close(f) |
| | 2331 | return res |
| 2319 | 2332 | def waitForDrive(): |
| 2320 | 2333 | tries = 0 |
| 2321 | 2334 | while drivestatus() == CDROM.CDS_DRIVE_NOT_READY: |
| … |
… |
def BurnDVDISO(title):
|
| 2363 | 2376 | result = runCommand(command) |
| 2364 | 2377 | if result == 0: |
| 2365 | 2378 | finished = True |
| 2366 | | |
| | 2379 | |
| 2367 | 2380 | # Wait till the drive is not busy any longer |
| 2368 | 2381 | f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK) |
| 2369 | 2382 | busy = True |
| … |
… |
def deMultiplexMPEG2File(folder, mediafile, video, audio1, audio2):
|
| 2427 | 2440 | command = "mythreplex --demux --fix_sync -t TS -o %s " % quoteCmdArg(folder + "/stream") |
| 2428 | 2441 | command += "-v %d " % (video[VIDEO_ID]) |
| 2429 | 2442 | |
| 2430 | | if audio1[AUDIO_ID] != -1: |
| | 2443 | if audio1[AUDIO_ID] != -1: |
| 2431 | 2444 | if audio1[AUDIO_CODEC] == 'MP2': |
| 2432 | 2445 | command += "-a %d " % (audio1[AUDIO_ID]) |
| 2433 | 2446 | elif audio1[AUDIO_CODEC] == 'AC3': |
| … |
… |
def deMultiplexMPEG2File(folder, mediafile, video, audio1, audio2):
|
| 2435 | 2448 | elif audio1[AUDIO_CODEC] == 'EAC3': |
| 2436 | 2449 | command += "-c %d " % (audio1[AUDIO_ID]) |
| 2437 | 2450 | |
| 2438 | | if audio2[AUDIO_ID] != -1: |
| | 2451 | if audio2[AUDIO_ID] != -1: |
| 2439 | 2452 | if audio2[AUDIO_CODEC] == 'MP2': |
| 2440 | 2453 | command += "-a %d " % (audio2[AUDIO_ID]) |
| 2441 | 2454 | elif audio2[AUDIO_CODEC] == 'AC3': |
| … |
… |
def deMultiplexMPEG2File(folder, mediafile, video, audio1, audio2):
|
| 2447 | 2460 | command = "mythreplex --demux --fix_sync -o %s " % quoteCmdArg(folder + "/stream") |
| 2448 | 2461 | command += "-v %d " % (video[VIDEO_ID] & 255) |
| 2449 | 2462 | |
| 2450 | | if audio1[AUDIO_ID] != -1: |
| | 2463 | if audio1[AUDIO_ID] != -1: |
| 2451 | 2464 | if audio1[AUDIO_CODEC] == 'MP2': |
| 2452 | 2465 | command += "-a %d " % (audio1[AUDIO_ID] & 255) |
| 2453 | 2466 | elif audio1[AUDIO_CODEC] == 'AC3': |
| … |
… |
def deMultiplexMPEG2File(folder, mediafile, video, audio1, audio2):
|
| 2456 | 2469 | command += "-c %d " % (audio1[AUDIO_ID] & 255) |
| 2457 | 2470 | |
| 2458 | 2471 | |
| 2459 | | if audio2[AUDIO_ID] != -1: |
| | 2472 | if audio2[AUDIO_ID] != -1: |
| 2460 | 2473 | if audio2[AUDIO_CODEC] == 'MP2': |
| 2461 | 2474 | command += "-a %d " % (audio2[AUDIO_ID] & 255) |
| 2462 | 2475 | elif audio2[AUDIO_CODEC] == 'AC3': |
| … |
… |
def deMultiplexMPEG2File(folder, mediafile, video, audio1, audio2):
|
| 2470 | 2483 | |
| 2471 | 2484 | result = runCommand(command) |
| 2472 | 2485 | |
| 2473 | | if result<>0: |
| | 2486 | if result!=0: |
| 2474 | 2487 | fatalError("Failed while running mythreplex. Command was %s" % command) |
| 2475 | 2488 | |
| 2476 | 2489 | ############################################################# |
| … |
… |
def runM2VRequantiser(source,destination,factor):
|
| 2486 | 2499 | command += " %s " % M2Vsize0 |
| 2487 | 2500 | command += " < %s " % quoteCmdArg(source) |
| 2488 | 2501 | command += " > %s " % quoteCmdArg(destination) |
| 2489 | | |
| | 2502 | |
| 2490 | 2503 | write("Running: " + command) |
| 2491 | 2504 | result = runCommand(command) |
| 2492 | | if result<>0: |
| | 2505 | if result!=0: |
| 2493 | 2506 | fatalError("Failed while running M2VRequantiser. Command was %s" % command) |
| 2494 | 2507 | |
| 2495 | 2508 | M2Vsize1 = os.path.getsize(destination) |
| 2496 | | |
| | 2509 | |
| 2497 | 2510 | write("M2Vsize after requant is %.2f Mb " % (float(M2Vsize1)/mega)) |
| 2498 | 2511 | fac1=float(M2Vsize0) / float(M2Vsize1) |
| 2499 | 2512 | write("Factor demanded %.5f, achieved %.5f, ratio %.5f " % ( factor, fac1, fac1/factor)) |
| 2500 | 2513 | |
| 2501 | 2514 | ############################################################# |
| 2502 | | # Calculates the total size of all the video, audio and menu files |
| | 2515 | # Calculates the total size of all the video, audio and menu files |
| 2503 | 2516 | |
| 2504 | 2517 | def calculateFileSizes(files): |
| 2505 | 2518 | """ Returns the sizes of all video, audio and menu files""" |
| … |
… |
def calculateFileSizes(files):
|
| 2515 | 2528 | #Process this file |
| 2516 | 2529 | file=os.path.join(folder,"stream.mv2") |
| 2517 | 2530 | #Get size of vobfile in MBytes |
| 2518 | | totalvideosize+=os.path.getsize(file) |
| | 2531 | totalvideosize+=os.path.getsize(file) |
| 2519 | 2532 | |
| 2520 | 2533 | #Get size of audio track 1 |
| 2521 | 2534 | if doesFileExist(os.path.join(folder,"stream0.ac3")): |
| 2522 | | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream0.ac3")) |
| | 2535 | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream0.ac3")) |
| 2523 | 2536 | if doesFileExist(os.path.join(folder,"stream0.mp2")): |
| 2524 | | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream0.mp2")) |
| | 2537 | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream0.mp2")) |
| 2525 | 2538 | |
| 2526 | | #Get size of audio track 2 if available |
| | 2539 | #Get size of audio track 2 if available |
| 2527 | 2540 | if doesFileExist(os.path.join(folder,"stream1.ac3")): |
| 2528 | | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream1.ac3")) |
| | 2541 | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream1.ac3")) |
| 2529 | 2542 | if doesFileExist(os.path.join(folder,"stream1.mp2")): |
| 2530 | | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream1.mp2")) |
| | 2543 | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream1.mp2")) |
| 2531 | 2544 | |
| 2532 | 2545 | # add chapter menu if available |
| 2533 | 2546 | if doesFileExist(os.path.join(getTempPath(),"chaptermenu-%s.mpg" % filecount)): |
| 2534 | | totalmenusize+=os.path.getsize(os.path.join(getTempPath(),"chaptermenu-%s.mpg" % filecount)) |
| | 2547 | totalmenusize+=os.path.getsize(os.path.join(getTempPath(),"chaptermenu-%s.mpg" % filecount)) |
| 2535 | 2548 | |
| 2536 | 2549 | # add details page if available |
| 2537 | 2550 | if doesFileExist(os.path.join(getTempPath(),"details-%s.mpg" % filecount)): |
| … |
… |
def calculateFileSizes(files):
|
| 2547 | 2560 | ######################################## |
| 2548 | 2561 | #returns total size of bitrate-limited m2v files |
| 2549 | 2562 | |
| 2550 | | def total_mv2_brl(files,rate): |
| 2551 | | tvsize=0 |
| | 2563 | def total_mv2_brl(files,rate): |
| | 2564 | tvsize=0 |
| 2552 | 2565 | filecount=0 |
| 2553 | 2566 | for node in files: |
| 2554 | 2567 | filecount+=1 |
| … |
… |
def total_mv2_brl(files,rate):
|
| 2557 | 2570 | file=os.path.join(folder,"stream.mv2") |
| 2558 | 2571 | progvsize=os.path.getsize(file) |
| 2559 | 2572 | progvbitrate=progvsize/progduration |
| 2560 | | if progvbitrate>rate : |
| | 2573 | if progvbitrate>rate : |
| 2561 | 2574 | tvsize+=progduration*rate |
| 2562 | 2575 | else: |
| 2563 | 2576 | tvsize+=progvsize |
| 2564 | 2577 | |
| 2565 | | return tvsize |
| | 2578 | return tvsize |
| 2566 | 2579 | |
| 2567 | 2580 | ######################################### |
| 2568 | | # Uses requantiser if available to shrink the video streams so |
| | 2581 | # Uses requantiser if available to shrink the video streams so |
| 2569 | 2582 | # they will fit on a DVD |
| 2570 | 2583 | |
| 2571 | 2584 | def performMPEG2Shrink(files,dvdrsize): |
| … |
… |
def performMPEG2Shrink(files,dvdrsize):
|
| 2582 | 2595 | |
| 2583 | 2596 | #Subtract the audio, menus and packaging overhead from the size of the disk (we cannot shrink this further) |
| 2584 | 2597 | mv2space=((dvdrsize*mega-totalmenusize)/fudge_pack)-totalaudiosize |
| 2585 | | |
| | 2598 | |
| 2586 | 2599 | if mv2space<0: |
| 2587 | 2600 | fatalError("Audio and menu files are too big. No room for video. Giving up!") |
| 2588 | 2601 | |
| … |
… |
def performMPEG2Shrink(files,dvdrsize):
|
| 2602 | 2615 | vsize+=os.path.getsize(file) |
| 2603 | 2616 | duration+=getLengthOfVideo(filecount) |
| 2604 | 2617 | |
| 2605 | | #We need to shrink the video files to fit into the space available. It seems sensible |
| 2606 | | #to do this by imposing a common upper limit on the mean video bit-rate of each recording; |
| | 2618 | #We need to shrink the video files to fit into the space available. It seems sensible |
| | 2619 | #to do this by imposing a common upper limit on the mean video bit-rate of each recording; |
| 2607 | 2620 | #this will not further reduce the visual quality of any that were transmitted at lower bit-rates. |
| 2608 | 2621 | |
| 2609 | | #Now find the bit-rate limit by iteration between initially defined upper and lower bounds. |
| | 2622 | #Now find the bit-rate limit by iteration between initially defined upper and lower bounds. |
| 2610 | 2623 | #The code is based on 'rtbis' from Numerical Recipes by W H Press et al., CUP. |
| 2611 | | |
| | 2624 | |
| 2612 | 2625 | #A small multiple of the average input bit-rate should be ok as the initial upper bound, |
| 2613 | 2626 | #(although a fixed value or one related to the max value could be used), and zero as the lower bound. |
| 2614 | 2627 | #The function relating bit-rate upper limit to total file size is smooth and monotonic, |
| 2615 | | #so there should be no convergence problem. |
| 2616 | | |
| | 2628 | #so there should be no convergence problem. |
| | 2629 | |
| 2617 | 2630 | vrLo=0.0 |
| 2618 | 2631 | vrHi=3.0*float(vsize)/duration |
| 2619 | | |
| | 2632 | |
| 2620 | 2633 | vrate=vrLo |
| 2621 | 2634 | vrinc=vrHi-vrLo |
| 2622 | 2635 | count=0 |
| … |
… |
def performMPEG2Shrink(files,dvdrsize):
|
| 2628 | 2641 | testsize=total_mv2_brl(files,vrtest) |
| 2629 | 2642 | if (testsize<mv2space): |
| 2630 | 2643 | vrate=vrtest |
| 2631 | | |
| | 2644 | |
| 2632 | 2645 | write("vrate %.3f kb/s, testsize %.4f , mv2space %.4f Mb " % ((vrate)/1000.0, (testsize)/mega, (mv2space)/mega) ) |
| 2633 | 2646 | filecount=0 |
| 2634 | 2647 | for node in files: |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 2775 | 2788 | #g4 holds the menu page last displayed |
| 2776 | 2789 | pre = dvddom.createElement("pre") |
| 2777 | 2790 | pre.appendChild(dvddom.createTextNode("{button=g2*1024;g4=%s;}" % page)) |
| 2778 | | menupgc.appendChild(pre) |
| | 2791 | menupgc.appendChild(pre) |
| 2779 | 2792 | |
| 2780 | 2793 | vob = dvddom.createElement("vob") |
| 2781 | 2794 | vob.setAttribute("file",os.path.join(getTempPath(),"menu-%s.mpg" % page)) |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 2833 | 2846 | elif chaptermenuAspectRatio == "16:9": |
| 2834 | 2847 | video.setAttribute("aspect", "16:9") |
| 2835 | 2848 | video.setAttribute("widescreen", "nopanscan") |
| 2836 | | else: |
| | 2849 | else: |
| 2837 | 2850 | # use same aspect ratio as the video |
| 2838 | 2851 | if getAspectRatioOfVideo(itemnum) > aspectRatioThreshold: |
| 2839 | 2852 | video.setAttribute("aspect", "16:9") |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 2849 | 2862 | |
| 2850 | 2863 | pre = dvddom.createElement("pre") |
| 2851 | 2864 | mymenupgc.appendChild(pre) |
| 2852 | | if wantDetailsPage: |
| | 2865 | if wantDetailsPage: |
| 2853 | 2866 | pre.appendChild(dvddom.createTextNode("{button=s7 - 1 * 1024;}")) |
| 2854 | 2867 | else: |
| 2855 | 2868 | pre.appendChild(dvddom.createTextNode("{button=s7 * 1024;}")) |
| 2856 | 2869 | |
| 2857 | 2870 | vob = dvddom.createElement("vob") |
| 2858 | 2871 | vob.setAttribute("file",os.path.join(getTempPath(),"chaptermenu-%s.mpg" % itemnum)) |
| 2859 | | mymenupgc.appendChild(vob) |
| | 2872 | mymenupgc.appendChild(vob) |
| 2860 | 2873 | |
| 2861 | 2874 | #Loop menu forever |
| 2862 | 2875 | post = dvddom.createElement("post") |
| 2863 | 2876 | post.appendChild(dvddom.createTextNode("jump cell 1;")) |
| 2864 | 2877 | mymenupgc.appendChild(post) |
| 2865 | 2878 | |
| 2866 | | # the first chapter MUST be 00:00:00 if its not dvdauthor adds it which |
| | 2879 | # the first chapter MUST be 00:00:00 if its not dvdauthor adds it which |
| 2867 | 2880 | # throws of the chapter selection - so make sure we add it if needed so we |
| 2868 | | # can compensate for it in the chapter selection menu |
| | 2881 | # can compensate for it in the chapter selection menu |
| 2869 | 2882 | firstChapter = 0 |
| 2870 | 2883 | thumblist = createVideoChapters(itemnum, chapters, getLengthOfVideo(itemnum), False) |
| 2871 | 2884 | chapterlist = string.split(thumblist, ",") |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 2876 | 2889 | #Add this recording to this page's menu... |
| 2877 | 2890 | button = dvddom.createElement("button") |
| 2878 | 2891 | button.setAttribute("name","%s" % x) |
| 2879 | | if wantDetailsPage: |
| | 2892 | if wantDetailsPage: |
| 2880 | 2893 | button.appendChild(dvddom.createTextNode("jump title %s chapter %s;" % (1, firstChapter + x + 1))) |
| 2881 | 2894 | else: |
| 2882 | 2895 | button.appendChild(dvddom.createTextNode("jump title %s chapter %s;" % (1, firstChapter + x))) |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 2938 | 2951 | thumblist = '00:00:00,' + thumblist |
| 2939 | 2952 | vob.setAttribute("chapters", thumblist) |
| 2940 | 2953 | else: |
| 2941 | | vob.setAttribute("chapters", |
| | 2954 | vob.setAttribute("chapters", |
| 2942 | 2955 | createVideoChaptersFixedLength(itemnum, |
| 2943 | | chapterLength, |
| | 2956 | chapterLength, |
| 2944 | 2957 | getLengthOfVideo(itemnum))) |
| 2945 | 2958 | |
| 2946 | 2959 | vob.setAttribute("file",os.path.join(getItemTempPath(itemnum),"final.vob")) |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 3006 | 3019 | |
| 3007 | 3020 | pre = dvddom.createElement("pre") |
| 3008 | 3021 | pre.appendChild(dvddom.createTextNode(dvdcode)) |
| 3009 | | menupgc.appendChild(pre) |
| | 3022 | menupgc.appendChild(pre) |
| 3010 | 3023 | |
| 3011 | 3024 | if wantIntro: |
| 3012 | 3025 | #Menu creation is finished so we know how many pages were created |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 3018 | 3031 | dvdcode+="jump menu %s;" % (page + 1) |
| 3019 | 3032 | if (page>1): |
| 3020 | 3033 | dvdcode+=" else " |
| 3021 | | dvdcode+="}" |
| | 3034 | dvdcode+="}" |
| 3022 | 3035 | vmgm_pre_node.appendChild(dvddom.createTextNode(dvdcode)) |
| 3023 | 3036 | |
| 3024 | 3037 | #write(dvddom.toprettyxml()) |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 3026 | 3039 | WriteXMLToFile (dvddom,os.path.join(getTempPath(),"dvdauthor.xml")) |
| 3027 | 3040 | |
| 3028 | 3041 | #Destroy the DOM and free memory |
| 3029 | | dvddom.unlink() |
| | 3042 | dvddom.unlink() |
| 3030 | 3043 | |
| 3031 | 3044 | ############################################################# |
| 3032 | 3045 | # Creates the DVDAuthor xml file used to create a DVD with no main menu |
| … |
… |
def createDVDAuthorXMLNoMenus(screensize, numberofitems):
|
| 3220 | 3233 | dvddom.unlink() |
| 3221 | 3234 | |
| 3222 | 3235 | ############################################################# |
| 3223 | | # Creates the directory to hold the preview images for an animated menu |
| | 3236 | # Creates the directory to hold the preview images for an animated menu |
| 3224 | 3237 | |
| 3225 | 3238 | def createEmptyPreviewFolder(videoitem): |
| 3226 | 3239 | previewfolder = os.path.join(getItemTempPath(videoitem), "preview") |
| … |
… |
def generateVideoPreview(videoitem, itemonthispage, menuitem, starttime, menulen
|
| 3264 | 3277 | #see if this graphics item has a mask |
| 3265 | 3278 | if node.hasAttribute("mask"): |
| 3266 | 3279 | imagemaskfilename = getThemeFile(themeName, node.attributes["mask"].value) |
| 3267 | | if node.attributes["mask"].value <> "" and doesFileExist(imagemaskfilename): |
| | 3280 | if node.attributes["mask"].value != "" and doesFileExist(imagemaskfilename): |
| 3268 | 3281 | maskpicture = Image.open(imagemaskfilename,"r").resize((width, height)) |
| 3269 | 3282 | maskpicture = maskpicture.convert("RGBA") |
| 3270 | 3283 | |
| … |
… |
def generateVideoPreview(videoitem, itemonthispage, menuitem, starttime, menulen
|
| 3276 | 3289 | def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw, |
| 3277 | 3290 | bgimagemask, drawmask, highlightcolor, spumuxdom, spunode, |
| 3278 | 3291 | numberofitems, chapternumber, chapterlist): |
| 3279 | | """Draws text and graphics onto a dvd menu, called by |
| | 3292 | """Draws text and graphics onto a dvd menu, called by |
| 3280 | 3293 | createMenu and createChapterMenu""" |
| 3281 | 3294 | |
| 3282 | 3295 | #Get the XML containing information about this item |
| … |
… |
def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw,
|
| 3287 | 3300 | fatalError("The info.xml file (%s) doesn't look right" % |
| 3288 | 3301 | os.path.join(getItemTempPath(itemnum),"info.xml")) |
| 3289 | 3302 | |
| 3290 | | #boundarybox holds the max and min dimensions for this item |
| | 3303 | #boundarybox holds the max and min dimensions for this item |
| 3291 | 3304 | #so we can auto build a menu highlight box |
| 3292 | 3305 | boundarybox = 9999,9999,0,0 |
| 3293 | 3306 | wantHighlightBox = True |
| … |
… |
def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw,
|
| 3319 | 3332 | |
| 3320 | 3333 | # see if an image mask exists |
| 3321 | 3334 | maskfilename = None |
| 3322 | | if node.hasAttribute("mask") and node.attributes["mask"].value <> "": |
| | 3335 | if node.hasAttribute("mask") and node.attributes["mask"].value != "": |
| 3323 | 3336 | maskfilename = getThemeFile(themeName, node.attributes["mask"].value) |
| 3324 | 3337 | |
| 3325 | | # if this is a thumb image and is a MythVideo coverart image then preserve |
| | 3338 | # if this is a thumb image and is a MythVideo coverart image then preserve |
| 3326 | 3339 | # its aspect ratio unless overriden later by the theme |
| 3327 | 3340 | if (node.attributes["filename"].value == "%thumbnail" |
| 3328 | 3341 | and getText(infoDOM.getElementsByTagName("coverfile")[0]) !=""): |
| … |
… |
def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw,
|
| 3366 | 3379 | button.setAttribute("name","previous") |
| 3367 | 3380 | button.setAttribute("x0","%s" % getScaledAttribute(node, "x")) |
| 3368 | 3381 | button.setAttribute("y0","%s" % getScaledAttribute(node, "y")) |
| 3369 | | button.setAttribute("x1","%s" % (getScaledAttribute(node, "x") + |
| | 3382 | button.setAttribute("x1","%s" % (getScaledAttribute(node, "x") + |
| 3370 | 3383 | getScaledAttribute(node, "w"))) |
| 3371 | 3384 | button.setAttribute("y1","%s" % (getScaledAttribute(node, "y") + |
| 3372 | 3385 | getScaledAttribute(node, "h"))) |
| … |
… |
def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw,
|
| 3390 | 3403 | button.setAttribute("name","next") |
| 3391 | 3404 | button.setAttribute("x0","%s" % getScaledAttribute(node, "x")) |
| 3392 | 3405 | button.setAttribute("y0","%s" % getScaledAttribute(node, "y")) |
| 3393 | | button.setAttribute("x1","%s" % (getScaledAttribute(node, "x") + |
| | 3406 | button.setAttribute("x1","%s" % (getScaledAttribute(node, "x") + |
| 3394 | 3407 | getScaledAttribute(node, "w"))) |
| 3395 | | button.setAttribute("y1","%s" % (getScaledAttribute(node, "y") + |
| | 3408 | button.setAttribute("y1","%s" % (getScaledAttribute(node, "y") + |
| 3396 | 3409 | getScaledAttribute(node, "h"))) |
| 3397 | 3410 | spunode.appendChild(button) |
| 3398 | 3411 | |
| … |
… |
def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw,
|
| 3411 | 3424 | button.setAttribute("name","playall") |
| 3412 | 3425 | button.setAttribute("x0","%s" % getScaledAttribute(node, "x")) |
| 3413 | 3426 | button.setAttribute("y0","%s" % getScaledAttribute(node, "y")) |
| 3414 | | button.setAttribute("x1","%s" % (getScaledAttribute(node, "x") + |
| | 3427 | button.setAttribute("x1","%s" % (getScaledAttribute(node, "x") + |
| 3415 | 3428 | getScaledAttribute(node, "w"))) |
| 3416 | 3429 | button.setAttribute("y1","%s" % (getScaledAttribute(node, "y") + |
| 3417 | 3430 | getScaledAttribute(node, "h"))) |
| … |
… |
def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw,
|
| 3426 | 3439 | # draw background if required |
| 3427 | 3440 | paintBackground(bgimage, node) |
| 3428 | 3441 | |
| 3429 | | paintButton(draw, bgimage, bgimagemask, node, infoDOM, |
| 3430 | | itemnum, page, itemsonthispage, chapternumber, |
| | 3442 | paintButton(draw, bgimage, bgimagemask, node, infoDOM, |
| | 3443 | itemnum, page, itemsonthispage, chapternumber, |
| 3431 | 3444 | chapterlist) |
| 3432 | 3445 | |
| 3433 | 3446 | button = spumuxdom.createElement("button") |
| … |
… |
def createMenu(screensize, screendpi, numberofitems):
|
| 3621 | 3634 | |
| 3622 | 3635 | #now that the base background has been made and all the previews generated |
| 3623 | 3636 | #we need to add the previews to the background |
| 3624 | | #Assumption: We assume that there is nothing in the location of where the items go |
| | 3637 | #Assumption: We assume that there is nothing in the location of where the items go |
| 3625 | 3638 | #(ie, no text on the images) |
| 3626 | 3639 | |
| 3627 | 3640 | itemsonthispage = 0 |
| … |
… |
def createChapterMenu(screensize, screendpi, numberofitems):
|
| 3813 | 3826 | chapter+=1 |
| 3814 | 3827 | |
| 3815 | 3828 | drawThemeItem(page, itemsperpage, page, menuitem, |
| 3816 | | overlayimage, draw, |
| | 3829 | overlayimage, draw, |
| 3817 | 3830 | bgimagemask, drawmask, highlightcolor, |
| 3818 | 3831 | spumuxdom, spunode, |
| 3819 | 3832 | 999, chapter, chapterlist) |
| … |
… |
def createChapterMenu(screensize, screendpi, numberofitems):
|
| 3873 | 3886 | aspect_ratio = '2' |
| 3874 | 3887 | elif chaptermenuAspectRatio == "16:9": |
| 3875 | 3888 | aspect_ratio = '3' |
| 3876 | | else: |
| | 3889 | else: |
| 3877 | 3890 | if getAspectRatioOfVideo(page) > aspectRatioThreshold: |
| 3878 | 3891 | aspect_ratio = '3' |
| 3879 | 3892 | else: |
| … |
… |
def isMediaAVIFile(file):
|
| 4043 | 4056 | return Magic=="RIFF" |
| 4044 | 4057 | |
| 4045 | 4058 | ############################################################# |
| 4046 | | # checks to see if an audio stream need to be converted to ac3 |
| | 4059 | # checks to see if an audio stream need to be converted to ac3 |
| 4047 | 4060 | |
| 4048 | 4061 | def processAudio(folder): |
| 4049 | 4062 | """encode audio to ac3 for better compression and compatability with NTSC players""" |
| … |
… |
def processFile(file, folder, count):
|
| 4454 | 4467 | |
| 4455 | 4468 | ############################################################# |
| 4456 | 4469 | # process a single file ready for burning using mythtranscode/mythreplex |
| 4457 | | # to cut and demux |
| | 4470 | # to cut and demux |
| 4458 | 4471 | |
| 4459 | 4472 | def doProcessFile(file, folder, count): |
| 4460 | 4473 | """Process a single video/recording file ready for burning.""" |
| … |
… |
def doProcessFile(file, folder, count):
|
| 4510 | 4523 | write("Failed to run mythtranscode to remove unwanted segments") |
| 4511 | 4524 | else: |
| 4512 | 4525 | #does the user always want to run recordings through mythtranscode? |
| 4513 | | #may help to fix any errors in the file |
| 4514 | | if (alwaysRunMythtranscode == True or |
| | 4526 | #may help to fix any errors in the file |
| | 4527 | if (alwaysRunMythtranscode == True or |
| 4515 | 4528 | (getFileType(folder) == "mpegts" and isFileOkayForDVD(file, folder))): |
| 4516 | 4529 | # Run from local file? |
| 4517 | 4530 | if file.hasAttribute("localfilename"): |
| … |
… |
def doProcessFile(file, folder, count):
|
| 4527 | 4540 | write("Failed to run mythtranscode to fix any errors") |
| 4528 | 4541 | else: |
| 4529 | 4542 | #does the user always want to run mpeg2 files through mythtranscode? |
| 4530 | | #may help to fix any errors in the file |
| | 4543 | #may help to fix any errors in the file |
| 4531 | 4544 | write("File type is '%s'" % getFileType(folder)) |
| 4532 | 4545 | write("Video codec is '%s'" % getVideoCodec(folder)) |
| 4533 | 4546 | |
| … |
… |
def doProcessFile(file, folder, count):
|
| 4579 | 4592 | mediafile = -1 |
| 4580 | 4593 | chanid = getText(infoDOM.getElementsByTagName("chanid")[0]) |
| 4581 | 4594 | starttime = getText(infoDOM.getElementsByTagName("starttime")[0]) |
| 4582 | | usecutlist = (file.attributes["usecutlist"].value == "1" and |
| | 4595 | usecutlist = (file.attributes["usecutlist"].value == "1" and |
| 4583 | 4596 | getText(infoDOM.getElementsByTagName("hascutlist")[0]) == "yes") |
| 4584 | 4597 | else: |
| 4585 | 4598 | chanid = -1 |
| … |
… |
def doProcessFile(file, folder, count):
|
| 4612 | 4625 | else: |
| 4613 | 4626 | profile = defaultEncodingProfile |
| 4614 | 4627 | |
| 4615 | | #do the re-encode |
| | 4628 | #do the re-encode |
| 4616 | 4629 | encodeVideoToMPEG2(mediafile, os.path.join(folder, "newfile2.mpg"), video, |
| 4617 | 4630 | audio1, audio2, aspectratio, profile) |
| 4618 | 4631 | mediafile = os.path.join(folder, 'newfile2.mpg') |
| … |
… |
def doProcessFileProjectX(file, folder, count):
|
| 4677 | 4690 | |
| 4678 | 4691 | #As part of this routine we need to pre-process the video this MAY mean: |
| 4679 | 4692 | #1. encoding to mpeg2 (if its an avi for instance or isn't DVD compatible) |
| 4680 | | #2. removing commercials/cleaning up mpeg2 stream |
| | 4693 | #2. removing commercials/cleaning up mpeg2 stream |
| 4681 | 4694 | #3. selecting audio track(s) to use and encoding audio from mp2 into ac3 |
| 4682 | 4695 | #4. de-multiplexing into video and audio steams |
| 4683 | 4696 | |
| … |
… |
def doProcessFileProjectX(file, folder, count):
|
| 4733 | 4746 | mediafile = -1 |
| 4734 | 4747 | chanid = getText(infoDOM.getElementsByTagName("chanid")[0]) |
| 4735 | 4748 | starttime = getText(infoDOM.getElementsByTagName("starttime")[0]) |
| 4736 | | usecutlist = (file.attributes["usecutlist"].value == "1" and |
| | 4749 | usecutlist = (file.attributes["usecutlist"].value == "1" and |
| 4737 | 4750 | getText(infoDOM.getElementsByTagName("hascutlist")[0]) == "yes") |
| 4738 | 4751 | else: |
| 4739 | 4752 | chanid = -1 |
| … |
… |
def doProcessFileProjectX(file, folder, count):
|
| 4766 | 4779 | else: |
| 4767 | 4780 | profile = defaultEncodingProfile |
| 4768 | 4781 | |
| 4769 | | #do the re-encode |
| | 4782 | #do the re-encode |
| 4770 | 4783 | encodeVideoToMPEG2(mediafile, os.path.join(folder, "newfile2.mpg"), video, |
| 4771 | 4784 | audio1, audio2, aspectratio, profile) |
| 4772 | 4785 | mediafile = os.path.join(folder, 'newfile2.mpg') |
| … |
… |
def doProcessFileProjectX(file, folder, count):
|
| 4787 | 4800 | # now attempt to split the source file into video and audio parts |
| 4788 | 4801 | # using projectX |
| 4789 | 4802 | |
| 4790 | | # If this is an mpeg2 myth recording and there is a cut list available and the |
| | 4803 | # If this is an mpeg2 myth recording and there is a cut list available and the |
| 4791 | 4804 | # user wants to use it run projectx to cut out commercials etc |
| 4792 | 4805 | if file.attributes["type"].value == "recording": |
| 4793 | 4806 | if file.attributes["usecutlist"].value == "1" and getText(infoDOM.getElementsByTagName("hascutlist")[0]) == "yes": |
| … |
… |
def processJob(job):
|
| 4995 | 5008 | filecount+=1 |
| 4996 | 5009 | folder=getItemTempPath(filecount) |
| 4997 | 5010 | #Multiplex this file |
| 4998 | | #(This also removes non-required audio feeds inside mpeg streams |
| | 5011 | #(This also removes non-required audio feeds inside mpeg streams |
| 4999 | 5012 | #(through re-multiplexing) we only take 1 video and 1 or 2 audio streams) |
| 5000 | 5013 | pid=multiplexMPEGStream(os.path.join(folder,'stream.mv2'), |
| 5001 | 5014 | os.path.join(folder,'stream0'), |
| … |
… |
def main():
|
| 5238 | 5251 | except: |
| 5239 | 5252 | os.remove(lckpath) |
| 5240 | 5253 | raise |
| 5241 | | except OSError, e: |
| | 5254 | except OSError as e: |
| 5242 | 5255 | if e.errno == errno.EEXIST: |
| 5243 | 5256 | write("Lock file exists -- already running???") |
| 5244 | 5257 | sys.exit(1) |
| … |
… |
def main():
|
| 5281 | 5294 | # remove our lock file |
| 5282 | 5295 | os.remove(lckpath) |
| 5283 | 5296 | |
| 5284 | | # make sure the files we created are read/writable by all |
| | 5297 | # make sure the files we created are read/writable by all |
| 5285 | 5298 | os.system("chmod -R a+rw-x+X %s" % defaultsettings["MythArchiveTempDir"]) |
| 5286 | 5299 | except SystemExit: |
| 5287 | 5300 | write("Terminated") |