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..444cc12c08 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.20200120-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 |
| … |
… |
import unicodedata
|
| 96 | 109 | import time |
| 97 | 110 | import tempfile |
| 98 | 111 | from fcntl import ioctl |
| 99 | | import CDROM |
| | 112 | |
| | 113 | try: |
| | 114 | import CDROM |
| | 115 | except: # not available on python3 |
| | 116 | class CDROM(object): |
| | 117 | CDROM_DRIVE_STATUS = 0x5326 |
| | 118 | CDROMEJECT = 0x5309 |
| | 119 | CDS_TRAY_OPEN = 2 |
| | 120 | CDROM_LOCKDOOR = 0x5329 |
| | 121 | CDS_DRIVE_NOT_READY = 3 |
| | 122 | CDROMRESET = 0x5312 |
| | 123 | CDS_DISC_OK = 4 |
| | 124 | CDS_NO_INFO = 0 |
| | 125 | |
| 100 | 126 | from shutil import copy |
| 101 | 127 | |
| 102 | 128 | import MythTV |
| … |
… |
drivespeed = 0;
|
| 155 | 181 | #main menu aspect ratio (4:3 or 16:9) |
| 156 | 182 | mainmenuAspectRatio = "16:9" |
| 157 | 183 | |
| 158 | | #chapter menu aspect ratio (4:3, 16:9 or Video) |
| | 184 | #chapter menu aspect ratio (4:3, 16:9 or Video) |
| 159 | 185 | #video means same aspect ratio as the video title |
| 160 | 186 | chaptermenuAspectRatio = "Video" |
| 161 | 187 | |
| … |
… |
class FontDef(object):
|
| 279 | 305 | def write(text, progress=True): |
| 280 | 306 | """Simple place to channel all text output through""" |
| 281 | 307 | |
| 282 | | sys.stdout.write((text + "\n").encode("utf-8", "replace")) |
| | 308 | if sys.version_info == 2: |
| | 309 | sys.stdout.write((text + "\n").encode("utf-8", "replace")) |
| | 310 | else: |
| | 311 | sys.stdout.write(text + "\n") |
| 283 | 312 | sys.stdout.flush() |
| 284 | 313 | |
| 285 | 314 | if progress == True and progresslog != "": |
| … |
… |
def encodeMenu(background, tempvideo, music, musiclength, tempmovie, xmlfile, fi
|
| 505 | 534 | 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 | 535 | % (totalframes, framespersecond, quoteCmdArg(background), quoteCmdArg(path_mpeg2enc[0]), aspectratio, quoteCmdArg(tempvideo)) |
| 507 | 536 | result = runCommand(command) |
| 508 | | if result<>0: |
| | 537 | if result!=0: |
| 509 | 538 | fatalError("Failed while running jpeg2yuv - %s" % command) |
| 510 | 539 | |
| 511 | 540 | command = quoteCmdArg(path_mplex[0]) + " -f 8 -v 0 -o %s %s %s" % (quoteCmdArg(tempmovie), quoteCmdArg(tempvideo), quoteCmdArg(music)) |
| 512 | 541 | result = runCommand(command) |
| 513 | | if result<>0: |
| | 542 | if result!=0: |
| 514 | 543 | fatalError("Failed while running mplex - %s" % command) |
| 515 | 544 | |
| 516 | 545 | if xmlfile != "": |
| 517 | 546 | command = quoteCmdArg(path_spumux[0]) + " -m dvd -s 0 %s < %s > %s" % (quoteCmdArg(xmlfile), quoteCmdArg(tempmovie), quoteCmdArg(finaloutput)) |
| 518 | 547 | result = runCommand(command) |
| 519 | | if result<>0: |
| | 548 | if result!=0: |
| 520 | 549 | fatalError("Failed while running spumux - %s" % command) |
| 521 | 550 | else: |
| 522 | 551 | os.rename(tempmovie, finaloutput) |
| … |
… |
def encodeMenu(background, tempvideo, music, musiclength, tempmovie, xmlfile, fi
|
| 527 | 556 | os.remove(tempmovie) |
| 528 | 557 | |
| 529 | 558 | ############################################################# |
| 530 | | # Return an xml node from a re-encoding profile xml file for |
| | 559 | # Return an xml node from a re-encoding profile xml file for |
| 531 | 560 | # a given profile name |
| 532 | 561 | |
| 533 | 562 | def findEncodingProfile(profile): |
| … |
… |
def getLengthOfVideo(index):
|
| 606 | 635 | return duration |
| 607 | 636 | |
| 608 | 637 | ############################################################# |
| 609 | | # Gets the audio sample rate and number of channels of a video file |
| | 638 | # Gets the audio sample rate and number of channels of a video file |
| 610 | 639 | # from its stream info file |
| 611 | 640 | |
| 612 | 641 | def getAudioParams(folder): |
| … |
… |
def getVideoParams(folder):
|
| 643 | 672 | if video.attributes["aspectratio"].value != 'N/A': |
| 644 | 673 | aspect_ratio = video.attributes["aspectratio"].value |
| 645 | 674 | else: |
| 646 | | aspect_ratio = "1.77778" |
| | 675 | aspect_ratio = "1.77778" |
| 647 | 676 | |
| 648 | 677 | videores = video.attributes["width"].value + 'x' + video.attributes["height"].value |
| 649 | 678 | fps = video.attributes["fps"].value |
| … |
… |
def createVideoChapters(itemnum, numofchapters, lengthofvideo, getthumbnails):
|
| 801 | 830 | ############################################################# |
| 802 | 831 | # Creates some fixed length chapter marks |
| 803 | 832 | |
| 804 | | def createVideoChaptersFixedLength(itemnum, segment, lengthofvideo): |
| 805 | | """Returns chapter marks at cut list ends, |
| | 833 | def createVideoChaptersFixedLength(itemnum, segment, lengthofvideo): |
| | 834 | """Returns chapter marks at cut list ends, |
| 806 | 835 | or evenly spaced chapters 'segment' seconds through the file""" |
| 807 | 836 | |
| 808 | 837 | |
| … |
… |
def getDefaultParametersFromMythTVDB():
|
| 845 | 874 | sqlstatement="""SELECT value, data FROM settings WHERE value IN( |
| 846 | 875 | 'DBSchemaVer', |
| 847 | 876 | 'ISO639Language0', |
| 848 | | 'ISO639Language1') |
| | 877 | 'ISO639Language1') |
| 849 | 878 | OR (hostname=%s AND value IN( |
| 850 | 879 | 'VideoStartupDir', |
| 851 | 880 | 'GalleryDir', |
| … |
… |
def getOptions(options):
|
| 939 | 968 | |
| 940 | 969 | def expandItemText(infoDOM, text, itemnumber, pagenumber, keynumber,chapternumber, chapterlist ): |
| 941 | 970 | """Replaces keywords in a string with variables from the XML and filesystem""" |
| 942 | | text=string.replace(text,"%page","%s" % pagenumber) |
| | 971 | text=text.replace("%page","%s" % pagenumber) |
| 943 | 972 | |
| 944 | 973 | #See if we can use the thumbnail/cover file for videos if there is one. |
| 945 | 974 | if getText( infoDOM.getElementsByTagName("coverfile")[0]) =="": |
| 946 | | text=string.replace(text,"%thumbnail", os.path.join( getItemTempPath(itemnumber), "title.jpg")) |
| | 975 | text=text.replace("%thumbnail", os.path.join( getItemTempPath(itemnumber), "title.jpg")) |
| 947 | 976 | else: |
| 948 | | text=string.replace(text,"%thumbnail", getText( infoDOM.getElementsByTagName("coverfile")[0]) ) |
| | 977 | text=text.replace("%thumbnail", getText( infoDOM.getElementsByTagName("coverfile")[0]) ) |
| 949 | 978 | |
| 950 | | text=string.replace(text,"%itemnumber","%s" % itemnumber ) |
| 951 | | text=string.replace(text,"%keynumber","%s" % keynumber ) |
| | 979 | text=text.replace("%itemnumber","%s" % itemnumber ) |
| | 980 | text=text.replace("%keynumber","%s" % keynumber ) |
| 952 | 981 | |
| 953 | | text=string.replace(text,"%title",getText( infoDOM.getElementsByTagName("title")[0]) ) |
| 954 | | text=string.replace(text,"%subtitle",getText( infoDOM.getElementsByTagName("subtitle")[0]) ) |
| 955 | | text=string.replace(text,"%description",getText( infoDOM.getElementsByTagName("description")[0]) ) |
| 956 | | text=string.replace(text,"%type",getText( infoDOM.getElementsByTagName("type")[0]) ) |
| | 982 | text=text.replace("%title",getText( infoDOM.getElementsByTagName("title")[0]) ) |
| | 983 | text=text.replace("%subtitle",getText( infoDOM.getElementsByTagName("subtitle")[0]) ) |
| | 984 | text=text.replace("%description",getText( infoDOM.getElementsByTagName("description")[0]) ) |
| | 985 | text=text.replace("%type",getText( infoDOM.getElementsByTagName("type")[0]) ) |
| 957 | 986 | |
| 958 | | text=string.replace(text,"%recordingdate",getText( infoDOM.getElementsByTagName("recordingdate")[0]) ) |
| 959 | | text=string.replace(text,"%recordingtime",getText( infoDOM.getElementsByTagName("recordingtime")[0]) ) |
| | 987 | text=text.replace("%recordingdate",getText( infoDOM.getElementsByTagName("recordingdate")[0]) ) |
| | 988 | text=text.replace("%recordingtime",getText( infoDOM.getElementsByTagName("recordingtime")[0]) ) |
| 960 | 989 | |
| 961 | | text=string.replace(text,"%duration", getFormatedLengthOfVideo(itemnumber)) |
| | 990 | text=text.replace("%duration", getFormatedLengthOfVideo(itemnumber)) |
| 962 | 991 | |
| 963 | | text=string.replace(text,"%myfolder",getThemeFile(themeName,"")) |
| | 992 | text=text.replace("%myfolder",getThemeFile(themeName,"")) |
| 964 | 993 | |
| 965 | 994 | if chapternumber>0: |
| 966 | | text=string.replace(text,"%chapternumber","%s" % chapternumber ) |
| 967 | | text=string.replace(text,"%chaptertime","%s" % chapterlist[chapternumber - 1] ) |
| 968 | | text=string.replace(text,"%chapterthumbnail", os.path.join( getItemTempPath(itemnumber), "chapter-%s.jpg" % chapternumber)) |
| | 995 | text=text.replace("%chapternumber","%s" % chapternumber ) |
| | 996 | text=text.replace("%chaptertime","%s" % chapterlist[chapternumber - 1] ) |
| | 997 | text=text.replace(text,"%chapterthumbnail", os.path.join( getItemTempPath(itemnumber), "chapter-%s.jpg" % chapternumber)) |
| 969 | 998 | |
| 970 | 999 | return text |
| 971 | 1000 | |
| … |
… |
def intelliDraw(drawer, text, font, containerWidth):
|
| 994 | 1023 | #write("containerWidth: %s" % containerWidth) |
| 995 | 1024 | words = text.split() |
| 996 | 1025 | lines = [] # prepare a return argument |
| 997 | | lines.append(words) |
| | 1026 | lines.append(words) |
| 998 | 1027 | finished = False |
| 999 | 1028 | line = 0 |
| 1000 | 1029 | while not finished: |
| … |
… |
def intelliDraw(drawer, text, font, containerWidth):
|
| 1008 | 1037 | if drawer.textsize(' '.join(thistext),font.getFont())[0] > containerWidth: |
| 1009 | 1038 | # this is the heart of the algorithm: we pop words off the current |
| 1010 | 1039 | # sentence until the width is ok, then in the next outer loop |
| 1011 | | # we move on to the next sentence. |
| | 1040 | # we move on to the next sentence. |
| 1012 | 1041 | if str(thistext).find(' ') != -1: |
| 1013 | 1042 | newline.insert(0,thistext.pop(-1)) |
| 1014 | 1043 | else: |
| … |
… |
def paintButton(draw, bgimage, bgimagemask, node, infoDOM, itemnum, page,
|
| 1133 | 1162 | ############################################################# |
| 1134 | 1163 | # Paint some theme text on to an image |
| 1135 | 1164 | |
| 1136 | | def paintText(draw, image, text, node, color = None, |
| | 1165 | def paintText(draw, image, text, node, color = None, |
| 1137 | 1166 | x = None, y = None, width = None, height = None): |
| 1138 | 1167 | """Takes a piece of text and draws it onto an image inside a bounding box.""" |
| 1139 | 1168 | #The text is wider than the width of the bounding box |
| 1140 | 1169 | |
| 1141 | 1170 | if x == None: |
| 1142 | | x = getScaledAttribute(node, "x") |
| | 1171 | x = getScaledAttribute(node, "x") |
| 1143 | 1172 | y = getScaledAttribute(node, "y") |
| 1144 | 1173 | width = getScaledAttribute(node, "w") |
| 1145 | 1174 | height = getScaledAttribute(node, "h") |
| … |
… |
def paintImage(filename, maskfilename, imageDom, destimage, stretch=True):
|
| 1230 | 1259 | (imgw, imgh) = picture.size |
| 1231 | 1260 | write("Image (%s, %s) into space of (%s, %s) at (%s, %s)" % (imgw, imgh, w, h, xpos, ypos), False) |
| 1232 | 1261 | |
| 1233 | | # the theme can override the default stretch behaviour |
| 1234 | | if imageDom.hasAttribute("stretch"): |
| | 1262 | # the theme can override the default stretch behaviour |
| | 1263 | if imageDom.hasAttribute("stretch"): |
| 1235 | 1264 | if imageDom.attributes["stretch"].value == "True": |
| 1236 | 1265 | stretch = True |
| 1237 | 1266 | else: |
| … |
… |
def paintImage(filename, maskfilename, imageDom, destimage, stretch=True):
|
| 1272 | 1301 | picture = picture.resize((imgw, imgh)) |
| 1273 | 1302 | picture = picture.convert("RGBA") |
| 1274 | 1303 | |
| 1275 | | if maskfilename <> None and doesFileExist(maskfilename): |
| | 1304 | if maskfilename != None and doesFileExist(maskfilename): |
| 1276 | 1305 | maskpicture = Image.open(maskfilename, "r").resize((imgw, imgh)) |
| 1277 | 1306 | maskpicture = maskpicture.convert("RGBA") |
| 1278 | 1307 | else: |
| … |
… |
def paintImage(filename, maskfilename, imageDom, destimage, stretch=True):
|
| 1280 | 1309 | |
| 1281 | 1310 | destimage.paste(picture, (xpos, ypos), maskpicture) |
| 1282 | 1311 | del picture |
| 1283 | | if maskfilename <> None and doesFileExist(maskfilename): |
| | 1312 | if maskfilename != None and doesFileExist(maskfilename): |
| 1284 | 1313 | del maskpicture |
| 1285 | 1314 | |
| 1286 | 1315 | write ("Added image %s" % filename) |
| … |
… |
def paintImage(filename, maskfilename, imageDom, destimage, stretch=True):
|
| 1294 | 1323 | def checkBoundaryBox(boundarybox, node): |
| 1295 | 1324 | # We work out how much space all of our graphics and text are taking up |
| 1296 | 1325 | # in a bounding rectangle so that we can use this as an automatic highlight |
| 1297 | | # on the DVD menu |
| | 1326 | # on the DVD menu |
| 1298 | 1327 | if getText(node.attributes["static"]) == "False": |
| 1299 | 1328 | if getScaledAttribute(node, "x") < boundarybox[0]: |
| 1300 | 1329 | boundarybox = getScaledAttribute(node, "x"), boundarybox[1], boundarybox[2], boundarybox[3] |
| … |
… |
def getFileInformation(file, folder):
|
| 1389 | 1418 | if file.attributes["type"].value=="recording": |
| 1390 | 1419 | filename = file.attributes["filename"].value |
| 1391 | 1420 | try: |
| 1392 | | rec = DB.searchRecorded(basename=os.path.basename(filename)).next() |
| | 1421 | rec = next(DB.searchRecorded(basename=os.path.basename(filename))) |
| 1393 | 1422 | except StopIteration: |
| 1394 | 1423 | fatalError("Failed to get recording details from the DB for %s" % filename) |
| 1395 | 1424 | |
| … |
… |
def getFileInformation(file, folder):
|
| 1397 | 1426 | data.recordingtime = rec.starttime.isoformat() |
| 1398 | 1427 | data.recordingdate = rec.starttime.isoformat() |
| 1399 | 1428 | |
| 1400 | | cutlist = rec.markup.getcutlist() |
| | 1429 | cutlist = list(rec.markup.getcutlist()) ### XXX should be fixed in Python Bindings for python3 |
| 1401 | 1430 | if len(cutlist): |
| 1402 | 1431 | data.hascutlist = 'yes' |
| 1403 | 1432 | if file.attributes["usecutlist"].value == "0" and addCutlistChapters == True: |
| … |
… |
def getFileInformation(file, folder):
|
| 1412 | 1441 | elif file.attributes["type"].value=="recording": |
| 1413 | 1442 | filename = file.attributes["filename"].value |
| 1414 | 1443 | try: |
| 1415 | | rec = DB.searchRecorded(basename=os.path.basename(filename)).next() |
| | 1444 | rec = next(DB.searchRecorded(basename=os.path.basename(filename))) |
| 1416 | 1445 | except StopIteration: |
| 1417 | 1446 | fatalError("Failed to get recording details from the DB for %s" % filename) |
| 1418 | 1447 | |
| … |
… |
def getFileInformation(file, folder):
|
| 1428 | 1457 | data.chanid = rec.chanid |
| 1429 | 1458 | data.starttime = rec.starttime.utcisoformat() |
| 1430 | 1459 | |
| 1431 | | cutlist = rec.markup.getcutlist() |
| | 1460 | cutlist = list(rec.markup.getcutlist()) ### XXX should be fixed in Python Bindings for python3 |
| 1432 | 1461 | if len(cutlist): |
| 1433 | 1462 | data.hascutlist = 'yes' |
| 1434 | 1463 | if file.attributes["usecutlist"].value == "0" and addCutlistChapters == True: |
| … |
… |
def getFileInformation(file, folder):
|
| 1443 | 1472 | elif file.attributes["type"].value=="video": |
| 1444 | 1473 | filename = file.attributes["filename"].value |
| 1445 | 1474 | try: |
| 1446 | | vid = MVID.searchVideos(file=filename).next() |
| | 1475 | vid = next(MVID.searchVideos(file=filename)) |
| 1447 | 1476 | except StopIteration: |
| 1448 | 1477 | vid = Video.fromFilename(filename) |
| 1449 | 1478 | |
| … |
… |
def getFileInformation(file, folder):
|
| 1489 | 1518 | |
| 1490 | 1519 | data.thumblist = ','.join(thumblist) |
| 1491 | 1520 | |
| 1492 | | for k,v in data.items(): |
| | 1521 | for k,v in list(data.items()): |
| 1493 | 1522 | write( "Node = %s, Data = %s" % (k, v)) |
| 1494 | 1523 | node = infoDOM.createElement(k) |
| 1495 | 1524 | # v may be either an integer. Therefore we have to |
| … |
… |
def getFileInformation(file, folder):
|
| 1507 | 1536 | # Write an xml file to disc |
| 1508 | 1537 | |
| 1509 | 1538 | def WriteXMLToFile(myDOM, filename): |
| | 1539 | |
| 1510 | 1540 | #Save the XML file to disk for use later on |
| 1511 | 1541 | f=open(filename, 'w') |
| 1512 | 1542 | |
| 1513 | | if sys.hexversion >= 0x020703F0: |
| | 1543 | if sys.hexversion >= 0x03000000: |
| | 1544 | f.write(myDOM.toprettyxml(indent=" ", encoding="UTF-8").decode()) |
| | 1545 | elif sys.hexversion >= 0x020703F0: |
| 1514 | 1546 | f.write(myDOM.toprettyxml(indent=" ", encoding="UTF-8")) |
| 1515 | 1547 | else: |
| 1516 | 1548 | f.write(myDOM.toxml(encoding="UTF-8")) |
| … |
… |
def multiplexMPEGStream(video, audio1, audio2, destination, syncOffset):
|
| 1588 | 1620 | |
| 1589 | 1621 | write("Multiplexing MPEG stream to %s" % destination) |
| 1590 | 1622 | |
| 1591 | | # no need to use a sync offset if projectx was used to demux the streams |
| | 1623 | # no need to use a sync offset if projectx was used to demux the streams |
| 1592 | 1624 | if useprojectx: |
| 1593 | 1625 | syncOffset = 0 |
| 1594 | 1626 | else: |
| … |
… |
def multiplexMPEGStream(video, audio1, audio2, destination, syncOffset):
|
| 1631 | 1663 | |
| 1632 | 1664 | if not doesFileExist(audio2): |
| 1633 | 1665 | write("Available streams - video and one audio stream") |
| | 1666 | write("running %s -M -f 8 -v 0 --sync-offset %sms -o %s %s %s" %(path_mplex[0], syncOffset, destination, video, audio1)) |
| 1634 | 1667 | result=os.spawnlp(mode, path_mplex[0], path_mplex[1], |
| 1635 | 1668 | '-M', |
| 1636 | 1669 | '-f', '8', |
| … |
… |
def multiplexMPEGStream(video, audio1, audio2, destination, syncOffset):
|
| 1663 | 1696 | write("Checking integrity of subtitle pngs") |
| 1664 | 1697 | command = quoteCmdArg(os.path.join(scriptpath, "testsubtitlepngs.sh")) + " " + quoteCmdArg(os.path.dirname(destination) + "/stream.d/spumux.xml") |
| 1665 | 1698 | result = runCommand(command) |
| 1666 | | if result<>0: |
| | 1699 | if result!=0: |
| 1667 | 1700 | fatalError("Failed while running testsubtitlepngs.sh - %s" % command) |
| 1668 | 1701 | |
| 1669 | 1702 | write("Running spumux to add subtitles") |
| 1670 | 1703 | 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 | 1704 | result = runCommand(command) |
| 1672 | | if result<>0: |
| | 1705 | if result!=0: |
| 1673 | 1706 | nonfatalError("Failed while running spumux.\n" |
| 1674 | 1707 | "Command was - %s.\n" |
| 1675 | 1708 | "Look in the full log to see why it failed" % command) |
| … |
… |
def getStreamInformation(filename, xmlFilename, lenMethod):
|
| 1691 | 1724 | |
| 1692 | 1725 | result = runCommand(command) |
| 1693 | 1726 | |
| 1694 | | if result <> 0: |
| | 1727 | if result != 0: |
| 1695 | 1728 | fatalError("Failed while running mytharchivehelper to get stream information.\n" |
| 1696 | 1729 | "Result: %d, Command was %s" % (result, command)) |
| 1697 | 1730 | |
| … |
… |
def runMythtranscode(chanid, starttime, destination, usecutlist, localfile):
|
| 1730 | 1763 | """Use mythtranscode to cut commercials and/or clean up an mpeg2 file""" |
| 1731 | 1764 | |
| 1732 | 1765 | try: |
| 1733 | | rec = DB.searchRecorded(chanid=chanid, starttime=starttime).next() |
| | 1766 | rec = next(DB.searchRecorded(chanid=chanid, starttime=starttime)) |
| 1734 | 1767 | cutlist = rec.markup.getcutlist() |
| 1735 | 1768 | except StopIteration: |
| 1736 | 1769 | cutlist = [] |
| 1737 | 1770 | |
| 1738 | 1771 | cutlist_s = "" |
| 1739 | | if usecutlist and len(cutlist): |
| | 1772 | if usecutlist and len(list(cutlist)): |
| 1740 | 1773 | cutlist_s = "'" |
| 1741 | 1774 | for cut in cutlist: |
| 1742 | 1775 | cutlist_s += ' %d-%d ' % cut |
| … |
… |
def runMythtranscode(chanid, starttime, destination, usecutlist, localfile):
|
| 1770 | 1803 | def generateProjectXCutlist(chanid, starttime, folder): |
| 1771 | 1804 | """generate cutlist_x.txt for ProjectX""" |
| 1772 | 1805 | |
| 1773 | | rec = DB.searchRecorded(chanid=chanid, starttime=starttime).next() |
| | 1806 | rec = next(DB.searchRecorded(chanid=chanid, starttime=starttime)) |
| 1774 | 1807 | starttime = rec.starttime.utcisoformat() |
| 1775 | 1808 | cutlist = rec.markup.getcutlist() |
| 1776 | 1809 | |
| 1777 | | if len(cutlist): |
| | 1810 | if len(list(cutlist)): |
| 1778 | 1811 | with codecs.open(os.path.join(folder, "cutlist_x.txt"), 'w', 'utf-8') as cutlist_f: |
| 1779 | 1812 | cutlist_f.write("CollectionPanel.CutMode=2\n") |
| 1780 | 1813 | i = 0 |
| 1781 | 1814 | for cut in cutlist: |
| 1782 | 1815 | # we need to reverse the cutlist because ProjectX wants to know |
| 1783 | 1816 | # the bits to keep not what to cut |
| 1784 | | |
| | 1817 | |
| 1785 | 1818 | if i == 0: |
| 1786 | 1819 | if cut[0] != 0: |
| 1787 | 1820 | cutlist_f.write('0\n%d\n' % cut[0]) |
| … |
… |
def extractVideoFrame(source, destination, seconds):
|
| 1979 | 2012 | |
| 1980 | 2013 | command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (quoteCmdArg(source), seconds, quoteCmdArg(destination)) |
| 1981 | 2014 | result = runCommand(command) |
| 1982 | | if result <> 0: |
| | 2015 | if result != 0: |
| 1983 | 2016 | fatalError("Failed while running mytharchivehelper to get thumbnails.\n" |
| 1984 | 2017 | "Result: %d, Command was %s" % (result, command)) |
| 1985 | 2018 | try: |
| 1986 | 2019 | myimage=Image.open(destination,"r") |
| 1987 | 2020 | |
| 1988 | | if myimage.format <> "JPEG": |
| | 2021 | if myimage.format != "JPEG": |
| 1989 | 2022 | write( "Something went wrong with thumbnail capture - " + myimage.format) |
| 1990 | | return (0L,0L) |
| | 2023 | return (long(0),long(0)) |
| 1991 | 2024 | else: |
| 1992 | 2025 | return myimage.size |
| 1993 | 2026 | except IOError: |
| 1994 | | return (0L, 0L) |
| | 2027 | return (long(0),long(0)) |
| 1995 | 2028 | |
| 1996 | 2029 | ############################################################# |
| 1997 | 2030 | # Grabs a list of single frames from a file |
| … |
… |
def extractVideoFrames(source, destination, thumbList):
|
| 2003 | 2036 | command = "mytharchivehelper -q -q --createthumbnail --infile %s --thumblist '%s' --outfile %s" % (quoteCmdArg(source), thumbList, quoteCmdArg(destination)) |
| 2004 | 2037 | write(command) |
| 2005 | 2038 | result = runCommand(command) |
| 2006 | | if result <> 0: |
| | 2039 | if result != 0: |
| 2007 | 2040 | fatalError("Failed while running mytharchivehelper to get thumbnails.\n" |
| 2008 | 2041 | "Result: %d, Command was %s" % (result, command)) |
| 2009 | 2042 | |
| … |
… |
def encodeVideoToMPEG2(source, destvideofile, video, audio1, audio2, aspectratio
|
| 2083 | 2116 | else: |
| 2084 | 2117 | passLog = os.path.join(getTempPath(), 'pass') |
| 2085 | 2118 | |
| 2086 | | pass1 = string.replace(command, "%passno","1") |
| 2087 | | pass1 = string.replace(pass1, "%passlogfile", quoteCmdArg(passLog)) |
| | 2119 | pass1 = command.replace("%passno","1") |
| | 2120 | pass1 = pass1.replace("%passlogfile", quoteCmdArg(passLog)) |
| 2088 | 2121 | write("Pass 1 - " + pass1) |
| 2089 | 2122 | result = runCommand(pass1) |
| 2090 | 2123 | |
| … |
… |
def encodeVideoToMPEG2(source, destvideofile, video, audio1, audio2, aspectratio
|
| 2095 | 2128 | if os.path.exists(destvideofile): |
| 2096 | 2129 | os.remove(destvideofile) |
| 2097 | 2130 | |
| 2098 | | pass2 = string.replace(command, "%passno","2") |
| 2099 | | pass2 = string.replace(pass2, "%passlogfile", passLog) |
| | 2131 | pass2 = command.replace("%passno","2") |
| | 2132 | pass2 = pass2.replace("%passlogfile", passLog) |
| 2100 | 2133 | write("Pass 2 - " + pass2) |
| 2101 | 2134 | result = runCommand(pass2) |
| 2102 | 2135 | |
| … |
… |
def encodeNuvToMPEG2(chanid, starttime, mediafile, destvideofile, folder, profil
|
| 2117 | 2150 | profileNode = findEncodingProfile(profile) |
| 2118 | 2151 | parameters = profileNode.getElementsByTagName("parameter") |
| 2119 | 2152 | |
| 2120 | | # default values - will be overriden by values from the profile |
| | 2153 | # default values - will be overriden by values from the profile |
| 2121 | 2154 | outvideobitrate = "5000k" |
| 2122 | 2155 | if videomode == "ntsc": |
| 2123 | 2156 | outvideores = "720x480" |
| … |
… |
def encodeNuvToMPEG2(chanid, starttime, mediafile, destvideofile, folder, profil
|
| 2198 | 2231 | if cpuCount > 1: |
| 2199 | 2232 | command += "-threads %d " % cpuCount |
| 2200 | 2233 | |
| 2201 | | command += "-f s16le -ar %s -ac %s -i %s " % (samplerate, channels, quoteCmdArg(os.path.join(folder, "audout"))) |
| | 2234 | command += "-f s16le -ar %s -ac %s -i %s " % (samplerate, channels, quoteCmdArg(os.path.join(folder, "audout"))) |
| 2202 | 2235 | command += "-f rawvideo -pix_fmt yuv420p -s %s -aspect %s -r %s " % (videores, aspectratio, fps) |
| 2203 | 2236 | command += "-i %s " % quoteCmdArg(os.path.join(folder, "vidout")) |
| 2204 | 2237 | command += "-aspect %s -r %s " % (aspectratio, fps) |
| … |
… |
def runDVDAuthor():
|
| 2235 | 2268 | write( "Starting dvdauthor") |
| 2236 | 2269 | checkCancelFlag() |
| 2237 | 2270 | result=os.spawnlp(os.P_WAIT, path_dvdauthor[0],path_dvdauthor[1],'-x',os.path.join(getTempPath(),'dvdauthor.xml')) |
| 2238 | | if result<>0: |
| | 2271 | if result!=0: |
| 2239 | 2272 | fatalError("Failed while running dvdauthor. Result: %d" % result) |
| 2240 | 2273 | write( "Finished dvdauthor") |
| 2241 | 2274 | |
| … |
… |
def CreateDVDISO(title):
|
| 2252 | 2285 | |
| 2253 | 2286 | result = runCommand(command) |
| 2254 | 2287 | |
| 2255 | | if result<>0: |
| | 2288 | if result!=0: |
| 2256 | 2289 | fatalError("Failed while running mkisofs.\n" |
| 2257 | 2290 | "Command was %s" % command) |
| 2258 | 2291 | |
| 2259 | 2292 | write("Finished creating ISO image") |
| 2260 | 2293 | |
| 2261 | 2294 | ############################################################# |
| 2262 | | # Burns the contents of a directory to create a DVD |
| | 2295 | # Burns the contents of a directory to create a DVD |
| 2263 | 2296 | |
| 2264 | 2297 | |
| 2265 | 2298 | def BurnDVDISO(title): |
| … |
… |
def BurnDVDISO(title):
|
| 2314 | 2347 | except: |
| 2315 | 2348 | write("Sending command ", action, " to drive failed", False) |
| 2316 | 2349 | res = False |
| 2317 | | os.close(f) |
| 2318 | | return res |
| | 2350 | os.close(f) |
| | 2351 | return res |
| 2319 | 2352 | def waitForDrive(): |
| 2320 | 2353 | tries = 0 |
| 2321 | 2354 | while drivestatus() == CDROM.CDS_DRIVE_NOT_READY: |
| … |
… |
def BurnDVDISO(title):
|
| 2363 | 2396 | result = runCommand(command) |
| 2364 | 2397 | if result == 0: |
| 2365 | 2398 | finished = True |
| 2366 | | |
| | 2399 | |
| 2367 | 2400 | # Wait till the drive is not busy any longer |
| 2368 | 2401 | f = os.open(dvddrivepath, os.O_RDONLY | os.O_NONBLOCK) |
| 2369 | 2402 | busy = True |
| … |
… |
def deMultiplexMPEG2File(folder, mediafile, video, audio1, audio2):
|
| 2427 | 2460 | command = "mythreplex --demux --fix_sync -t TS -o %s " % quoteCmdArg(folder + "/stream") |
| 2428 | 2461 | command += "-v %d " % (video[VIDEO_ID]) |
| 2429 | 2462 | |
| 2430 | | if audio1[AUDIO_ID] != -1: |
| | 2463 | if audio1[AUDIO_ID] != -1: |
| 2431 | 2464 | if audio1[AUDIO_CODEC] == 'MP2': |
| 2432 | 2465 | command += "-a %d " % (audio1[AUDIO_ID]) |
| 2433 | 2466 | elif audio1[AUDIO_CODEC] == 'AC3': |
| … |
… |
def deMultiplexMPEG2File(folder, mediafile, video, audio1, audio2):
|
| 2435 | 2468 | elif audio1[AUDIO_CODEC] == 'EAC3': |
| 2436 | 2469 | command += "-c %d " % (audio1[AUDIO_ID]) |
| 2437 | 2470 | |
| 2438 | | if audio2[AUDIO_ID] != -1: |
| | 2471 | if audio2[AUDIO_ID] != -1: |
| 2439 | 2472 | if audio2[AUDIO_CODEC] == 'MP2': |
| 2440 | 2473 | command += "-a %d " % (audio2[AUDIO_ID]) |
| 2441 | 2474 | elif audio2[AUDIO_CODEC] == 'AC3': |
| … |
… |
def deMultiplexMPEG2File(folder, mediafile, video, audio1, audio2):
|
| 2447 | 2480 | command = "mythreplex --demux --fix_sync -o %s " % quoteCmdArg(folder + "/stream") |
| 2448 | 2481 | command += "-v %d " % (video[VIDEO_ID] & 255) |
| 2449 | 2482 | |
| 2450 | | if audio1[AUDIO_ID] != -1: |
| | 2483 | if audio1[AUDIO_ID] != -1: |
| 2451 | 2484 | if audio1[AUDIO_CODEC] == 'MP2': |
| 2452 | 2485 | command += "-a %d " % (audio1[AUDIO_ID] & 255) |
| 2453 | 2486 | elif audio1[AUDIO_CODEC] == 'AC3': |
| … |
… |
def deMultiplexMPEG2File(folder, mediafile, video, audio1, audio2):
|
| 2456 | 2489 | command += "-c %d " % (audio1[AUDIO_ID] & 255) |
| 2457 | 2490 | |
| 2458 | 2491 | |
| 2459 | | if audio2[AUDIO_ID] != -1: |
| | 2492 | if audio2[AUDIO_ID] != -1: |
| 2460 | 2493 | if audio2[AUDIO_CODEC] == 'MP2': |
| 2461 | 2494 | command += "-a %d " % (audio2[AUDIO_ID] & 255) |
| 2462 | 2495 | elif audio2[AUDIO_CODEC] == 'AC3': |
| … |
… |
def deMultiplexMPEG2File(folder, mediafile, video, audio1, audio2):
|
| 2470 | 2503 | |
| 2471 | 2504 | result = runCommand(command) |
| 2472 | 2505 | |
| 2473 | | if result<>0: |
| | 2506 | if result!=0: |
| 2474 | 2507 | fatalError("Failed while running mythreplex. Command was %s" % command) |
| 2475 | 2508 | |
| 2476 | 2509 | ############################################################# |
| … |
… |
def runM2VRequantiser(source,destination,factor):
|
| 2486 | 2519 | command += " %s " % M2Vsize0 |
| 2487 | 2520 | command += " < %s " % quoteCmdArg(source) |
| 2488 | 2521 | command += " > %s " % quoteCmdArg(destination) |
| 2489 | | |
| | 2522 | |
| 2490 | 2523 | write("Running: " + command) |
| 2491 | 2524 | result = runCommand(command) |
| 2492 | | if result<>0: |
| | 2525 | if result!=0: |
| 2493 | 2526 | fatalError("Failed while running M2VRequantiser. Command was %s" % command) |
| 2494 | 2527 | |
| 2495 | 2528 | M2Vsize1 = os.path.getsize(destination) |
| 2496 | | |
| | 2529 | |
| 2497 | 2530 | write("M2Vsize after requant is %.2f Mb " % (float(M2Vsize1)/mega)) |
| 2498 | 2531 | fac1=float(M2Vsize0) / float(M2Vsize1) |
| 2499 | 2532 | write("Factor demanded %.5f, achieved %.5f, ratio %.5f " % ( factor, fac1, fac1/factor)) |
| 2500 | 2533 | |
| 2501 | 2534 | ############################################################# |
| 2502 | | # Calculates the total size of all the video, audio and menu files |
| | 2535 | # Calculates the total size of all the video, audio and menu files |
| 2503 | 2536 | |
| 2504 | 2537 | def calculateFileSizes(files): |
| 2505 | 2538 | """ Returns the sizes of all video, audio and menu files""" |
| … |
… |
def calculateFileSizes(files):
|
| 2515 | 2548 | #Process this file |
| 2516 | 2549 | file=os.path.join(folder,"stream.mv2") |
| 2517 | 2550 | #Get size of vobfile in MBytes |
| 2518 | | totalvideosize+=os.path.getsize(file) |
| | 2551 | totalvideosize+=os.path.getsize(file) |
| 2519 | 2552 | |
| 2520 | 2553 | #Get size of audio track 1 |
| 2521 | 2554 | if doesFileExist(os.path.join(folder,"stream0.ac3")): |
| 2522 | | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream0.ac3")) |
| | 2555 | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream0.ac3")) |
| 2523 | 2556 | if doesFileExist(os.path.join(folder,"stream0.mp2")): |
| 2524 | | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream0.mp2")) |
| | 2557 | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream0.mp2")) |
| 2525 | 2558 | |
| 2526 | | #Get size of audio track 2 if available |
| | 2559 | #Get size of audio track 2 if available |
| 2527 | 2560 | if doesFileExist(os.path.join(folder,"stream1.ac3")): |
| 2528 | | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream1.ac3")) |
| | 2561 | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream1.ac3")) |
| 2529 | 2562 | if doesFileExist(os.path.join(folder,"stream1.mp2")): |
| 2530 | | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream1.mp2")) |
| | 2563 | totalaudiosize+=os.path.getsize(os.path.join(folder,"stream1.mp2")) |
| 2531 | 2564 | |
| 2532 | 2565 | # add chapter menu if available |
| 2533 | 2566 | if doesFileExist(os.path.join(getTempPath(),"chaptermenu-%s.mpg" % filecount)): |
| 2534 | | totalmenusize+=os.path.getsize(os.path.join(getTempPath(),"chaptermenu-%s.mpg" % filecount)) |
| | 2567 | totalmenusize+=os.path.getsize(os.path.join(getTempPath(),"chaptermenu-%s.mpg" % filecount)) |
| 2535 | 2568 | |
| 2536 | 2569 | # add details page if available |
| 2537 | 2570 | if doesFileExist(os.path.join(getTempPath(),"details-%s.mpg" % filecount)): |
| … |
… |
def calculateFileSizes(files):
|
| 2547 | 2580 | ######################################## |
| 2548 | 2581 | #returns total size of bitrate-limited m2v files |
| 2549 | 2582 | |
| 2550 | | def total_mv2_brl(files,rate): |
| 2551 | | tvsize=0 |
| | 2583 | def total_mv2_brl(files,rate): |
| | 2584 | tvsize=0 |
| 2552 | 2585 | filecount=0 |
| 2553 | 2586 | for node in files: |
| 2554 | 2587 | filecount+=1 |
| … |
… |
def total_mv2_brl(files,rate):
|
| 2557 | 2590 | file=os.path.join(folder,"stream.mv2") |
| 2558 | 2591 | progvsize=os.path.getsize(file) |
| 2559 | 2592 | progvbitrate=progvsize/progduration |
| 2560 | | if progvbitrate>rate : |
| | 2593 | if progvbitrate>rate : |
| 2561 | 2594 | tvsize+=progduration*rate |
| 2562 | 2595 | else: |
| 2563 | 2596 | tvsize+=progvsize |
| 2564 | 2597 | |
| 2565 | | return tvsize |
| | 2598 | return tvsize |
| 2566 | 2599 | |
| 2567 | 2600 | ######################################### |
| 2568 | | # Uses requantiser if available to shrink the video streams so |
| | 2601 | # Uses requantiser if available to shrink the video streams so |
| 2569 | 2602 | # they will fit on a DVD |
| 2570 | 2603 | |
| 2571 | 2604 | def performMPEG2Shrink(files,dvdrsize): |
| … |
… |
def performMPEG2Shrink(files,dvdrsize):
|
| 2582 | 2615 | |
| 2583 | 2616 | #Subtract the audio, menus and packaging overhead from the size of the disk (we cannot shrink this further) |
| 2584 | 2617 | mv2space=((dvdrsize*mega-totalmenusize)/fudge_pack)-totalaudiosize |
| 2585 | | |
| | 2618 | |
| 2586 | 2619 | if mv2space<0: |
| 2587 | 2620 | fatalError("Audio and menu files are too big. No room for video. Giving up!") |
| 2588 | 2621 | |
| … |
… |
def performMPEG2Shrink(files,dvdrsize):
|
| 2602 | 2635 | vsize+=os.path.getsize(file) |
| 2603 | 2636 | duration+=getLengthOfVideo(filecount) |
| 2604 | 2637 | |
| 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; |
| | 2638 | #We need to shrink the video files to fit into the space available. It seems sensible |
| | 2639 | #to do this by imposing a common upper limit on the mean video bit-rate of each recording; |
| 2607 | 2640 | #this will not further reduce the visual quality of any that were transmitted at lower bit-rates. |
| 2608 | 2641 | |
| 2609 | | #Now find the bit-rate limit by iteration between initially defined upper and lower bounds. |
| | 2642 | #Now find the bit-rate limit by iteration between initially defined upper and lower bounds. |
| 2610 | 2643 | #The code is based on 'rtbis' from Numerical Recipes by W H Press et al., CUP. |
| 2611 | | |
| | 2644 | |
| 2612 | 2645 | #A small multiple of the average input bit-rate should be ok as the initial upper bound, |
| 2613 | 2646 | #(although a fixed value or one related to the max value could be used), and zero as the lower bound. |
| 2614 | 2647 | #The function relating bit-rate upper limit to total file size is smooth and monotonic, |
| 2615 | | #so there should be no convergence problem. |
| 2616 | | |
| | 2648 | #so there should be no convergence problem. |
| | 2649 | |
| 2617 | 2650 | vrLo=0.0 |
| 2618 | 2651 | vrHi=3.0*float(vsize)/duration |
| 2619 | | |
| | 2652 | |
| 2620 | 2653 | vrate=vrLo |
| 2621 | 2654 | vrinc=vrHi-vrLo |
| 2622 | 2655 | count=0 |
| … |
… |
def performMPEG2Shrink(files,dvdrsize):
|
| 2628 | 2661 | testsize=total_mv2_brl(files,vrtest) |
| 2629 | 2662 | if (testsize<mv2space): |
| 2630 | 2663 | vrate=vrtest |
| 2631 | | |
| | 2664 | |
| 2632 | 2665 | write("vrate %.3f kb/s, testsize %.4f , mv2space %.4f Mb " % ((vrate)/1000.0, (testsize)/mega, (mv2space)/mega) ) |
| 2633 | 2666 | filecount=0 |
| 2634 | 2667 | for node in files: |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 2775 | 2808 | #g4 holds the menu page last displayed |
| 2776 | 2809 | pre = dvddom.createElement("pre") |
| 2777 | 2810 | pre.appendChild(dvddom.createTextNode("{button=g2*1024;g4=%s;}" % page)) |
| 2778 | | menupgc.appendChild(pre) |
| | 2811 | menupgc.appendChild(pre) |
| 2779 | 2812 | |
| 2780 | 2813 | vob = dvddom.createElement("vob") |
| 2781 | 2814 | vob.setAttribute("file",os.path.join(getTempPath(),"menu-%s.mpg" % page)) |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 2833 | 2866 | elif chaptermenuAspectRatio == "16:9": |
| 2834 | 2867 | video.setAttribute("aspect", "16:9") |
| 2835 | 2868 | video.setAttribute("widescreen", "nopanscan") |
| 2836 | | else: |
| | 2869 | else: |
| 2837 | 2870 | # use same aspect ratio as the video |
| 2838 | 2871 | if getAspectRatioOfVideo(itemnum) > aspectRatioThreshold: |
| 2839 | 2872 | video.setAttribute("aspect", "16:9") |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 2849 | 2882 | |
| 2850 | 2883 | pre = dvddom.createElement("pre") |
| 2851 | 2884 | mymenupgc.appendChild(pre) |
| 2852 | | if wantDetailsPage: |
| | 2885 | if wantDetailsPage: |
| 2853 | 2886 | pre.appendChild(dvddom.createTextNode("{button=s7 - 1 * 1024;}")) |
| 2854 | 2887 | else: |
| 2855 | 2888 | pre.appendChild(dvddom.createTextNode("{button=s7 * 1024;}")) |
| 2856 | 2889 | |
| 2857 | 2890 | vob = dvddom.createElement("vob") |
| 2858 | 2891 | vob.setAttribute("file",os.path.join(getTempPath(),"chaptermenu-%s.mpg" % itemnum)) |
| 2859 | | mymenupgc.appendChild(vob) |
| | 2892 | mymenupgc.appendChild(vob) |
| 2860 | 2893 | |
| 2861 | 2894 | #Loop menu forever |
| 2862 | 2895 | post = dvddom.createElement("post") |
| 2863 | 2896 | post.appendChild(dvddom.createTextNode("jump cell 1;")) |
| 2864 | 2897 | mymenupgc.appendChild(post) |
| 2865 | 2898 | |
| 2866 | | # the first chapter MUST be 00:00:00 if its not dvdauthor adds it which |
| | 2899 | # the first chapter MUST be 00:00:00 if its not dvdauthor adds it which |
| 2867 | 2900 | # 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 |
| | 2901 | # can compensate for it in the chapter selection menu |
| 2869 | 2902 | firstChapter = 0 |
| 2870 | 2903 | thumblist = createVideoChapters(itemnum, chapters, getLengthOfVideo(itemnum), False) |
| 2871 | 2904 | chapterlist = string.split(thumblist, ",") |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 2876 | 2909 | #Add this recording to this page's menu... |
| 2877 | 2910 | button = dvddom.createElement("button") |
| 2878 | 2911 | button.setAttribute("name","%s" % x) |
| 2879 | | if wantDetailsPage: |
| | 2912 | if wantDetailsPage: |
| 2880 | 2913 | button.appendChild(dvddom.createTextNode("jump title %s chapter %s;" % (1, firstChapter + x + 1))) |
| 2881 | 2914 | else: |
| 2882 | 2915 | button.appendChild(dvddom.createTextNode("jump title %s chapter %s;" % (1, firstChapter + x))) |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 2938 | 2971 | thumblist = '00:00:00,' + thumblist |
| 2939 | 2972 | vob.setAttribute("chapters", thumblist) |
| 2940 | 2973 | else: |
| 2941 | | vob.setAttribute("chapters", |
| | 2974 | vob.setAttribute("chapters", |
| 2942 | 2975 | createVideoChaptersFixedLength(itemnum, |
| 2943 | | chapterLength, |
| | 2976 | chapterLength, |
| 2944 | 2977 | getLengthOfVideo(itemnum))) |
| 2945 | 2978 | |
| 2946 | 2979 | vob.setAttribute("file",os.path.join(getItemTempPath(itemnum),"final.vob")) |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 3006 | 3039 | |
| 3007 | 3040 | pre = dvddom.createElement("pre") |
| 3008 | 3041 | pre.appendChild(dvddom.createTextNode(dvdcode)) |
| 3009 | | menupgc.appendChild(pre) |
| | 3042 | menupgc.appendChild(pre) |
| 3010 | 3043 | |
| 3011 | 3044 | if wantIntro: |
| 3012 | 3045 | #Menu creation is finished so we know how many pages were created |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 3018 | 3051 | dvdcode+="jump menu %s;" % (page + 1) |
| 3019 | 3052 | if (page>1): |
| 3020 | 3053 | dvdcode+=" else " |
| 3021 | | dvdcode+="}" |
| | 3054 | dvdcode+="}" |
| 3022 | 3055 | vmgm_pre_node.appendChild(dvddom.createTextNode(dvdcode)) |
| 3023 | 3056 | |
| 3024 | 3057 | #write(dvddom.toprettyxml()) |
| … |
… |
def createDVDAuthorXML(screensize, numberofitems):
|
| 3026 | 3059 | WriteXMLToFile (dvddom,os.path.join(getTempPath(),"dvdauthor.xml")) |
| 3027 | 3060 | |
| 3028 | 3061 | #Destroy the DOM and free memory |
| 3029 | | dvddom.unlink() |
| | 3062 | dvddom.unlink() |
| 3030 | 3063 | |
| 3031 | 3064 | ############################################################# |
| 3032 | 3065 | # Creates the DVDAuthor xml file used to create a DVD with no main menu |
| … |
… |
def createDVDAuthorXMLNoMenus(screensize, numberofitems):
|
| 3220 | 3253 | dvddom.unlink() |
| 3221 | 3254 | |
| 3222 | 3255 | ############################################################# |
| 3223 | | # Creates the directory to hold the preview images for an animated menu |
| | 3256 | # Creates the directory to hold the preview images for an animated menu |
| 3224 | 3257 | |
| 3225 | 3258 | def createEmptyPreviewFolder(videoitem): |
| 3226 | 3259 | previewfolder = os.path.join(getItemTempPath(videoitem), "preview") |
| … |
… |
def generateVideoPreview(videoitem, itemonthispage, menuitem, starttime, menulen
|
| 3264 | 3297 | #see if this graphics item has a mask |
| 3265 | 3298 | if node.hasAttribute("mask"): |
| 3266 | 3299 | imagemaskfilename = getThemeFile(themeName, node.attributes["mask"].value) |
| 3267 | | if node.attributes["mask"].value <> "" and doesFileExist(imagemaskfilename): |
| | 3300 | if node.attributes["mask"].value != "" and doesFileExist(imagemaskfilename): |
| 3268 | 3301 | maskpicture = Image.open(imagemaskfilename,"r").resize((width, height)) |
| 3269 | 3302 | maskpicture = maskpicture.convert("RGBA") |
| 3270 | 3303 | |
| … |
… |
def generateVideoPreview(videoitem, itemonthispage, menuitem, starttime, menulen
|
| 3276 | 3309 | def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw, |
| 3277 | 3310 | bgimagemask, drawmask, highlightcolor, spumuxdom, spunode, |
| 3278 | 3311 | numberofitems, chapternumber, chapterlist): |
| 3279 | | """Draws text and graphics onto a dvd menu, called by |
| | 3312 | """Draws text and graphics onto a dvd menu, called by |
| 3280 | 3313 | createMenu and createChapterMenu""" |
| 3281 | 3314 | |
| 3282 | 3315 | #Get the XML containing information about this item |
| … |
… |
def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw,
|
| 3287 | 3320 | fatalError("The info.xml file (%s) doesn't look right" % |
| 3288 | 3321 | os.path.join(getItemTempPath(itemnum),"info.xml")) |
| 3289 | 3322 | |
| 3290 | | #boundarybox holds the max and min dimensions for this item |
| | 3323 | #boundarybox holds the max and min dimensions for this item |
| 3291 | 3324 | #so we can auto build a menu highlight box |
| 3292 | 3325 | boundarybox = 9999,9999,0,0 |
| 3293 | 3326 | wantHighlightBox = True |
| … |
… |
def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw,
|
| 3319 | 3352 | |
| 3320 | 3353 | # see if an image mask exists |
| 3321 | 3354 | maskfilename = None |
| 3322 | | if node.hasAttribute("mask") and node.attributes["mask"].value <> "": |
| | 3355 | if node.hasAttribute("mask") and node.attributes["mask"].value != "": |
| 3323 | 3356 | maskfilename = getThemeFile(themeName, node.attributes["mask"].value) |
| 3324 | 3357 | |
| 3325 | | # if this is a thumb image and is a MythVideo coverart image then preserve |
| | 3358 | # if this is a thumb image and is a MythVideo coverart image then preserve |
| 3326 | 3359 | # its aspect ratio unless overriden later by the theme |
| 3327 | 3360 | if (node.attributes["filename"].value == "%thumbnail" |
| 3328 | 3361 | and getText(infoDOM.getElementsByTagName("coverfile")[0]) !=""): |
| … |
… |
def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw,
|
| 3366 | 3399 | button.setAttribute("name","previous") |
| 3367 | 3400 | button.setAttribute("x0","%s" % getScaledAttribute(node, "x")) |
| 3368 | 3401 | button.setAttribute("y0","%s" % getScaledAttribute(node, "y")) |
| 3369 | | button.setAttribute("x1","%s" % (getScaledAttribute(node, "x") + |
| | 3402 | button.setAttribute("x1","%s" % (getScaledAttribute(node, "x") + |
| 3370 | 3403 | getScaledAttribute(node, "w"))) |
| 3371 | 3404 | button.setAttribute("y1","%s" % (getScaledAttribute(node, "y") + |
| 3372 | 3405 | getScaledAttribute(node, "h"))) |
| … |
… |
def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw,
|
| 3390 | 3423 | button.setAttribute("name","next") |
| 3391 | 3424 | button.setAttribute("x0","%s" % getScaledAttribute(node, "x")) |
| 3392 | 3425 | button.setAttribute("y0","%s" % getScaledAttribute(node, "y")) |
| 3393 | | button.setAttribute("x1","%s" % (getScaledAttribute(node, "x") + |
| | 3426 | button.setAttribute("x1","%s" % (getScaledAttribute(node, "x") + |
| 3394 | 3427 | getScaledAttribute(node, "w"))) |
| 3395 | | button.setAttribute("y1","%s" % (getScaledAttribute(node, "y") + |
| | 3428 | button.setAttribute("y1","%s" % (getScaledAttribute(node, "y") + |
| 3396 | 3429 | getScaledAttribute(node, "h"))) |
| 3397 | 3430 | spunode.appendChild(button) |
| 3398 | 3431 | |
| … |
… |
def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw,
|
| 3411 | 3444 | button.setAttribute("name","playall") |
| 3412 | 3445 | button.setAttribute("x0","%s" % getScaledAttribute(node, "x")) |
| 3413 | 3446 | button.setAttribute("y0","%s" % getScaledAttribute(node, "y")) |
| 3414 | | button.setAttribute("x1","%s" % (getScaledAttribute(node, "x") + |
| | 3447 | button.setAttribute("x1","%s" % (getScaledAttribute(node, "x") + |
| 3415 | 3448 | getScaledAttribute(node, "w"))) |
| 3416 | 3449 | button.setAttribute("y1","%s" % (getScaledAttribute(node, "y") + |
| 3417 | 3450 | getScaledAttribute(node, "h"))) |
| … |
… |
def drawThemeItem(page, itemsonthispage, itemnum, menuitem, bgimage, draw,
|
| 3426 | 3459 | # draw background if required |
| 3427 | 3460 | paintBackground(bgimage, node) |
| 3428 | 3461 | |
| 3429 | | paintButton(draw, bgimage, bgimagemask, node, infoDOM, |
| 3430 | | itemnum, page, itemsonthispage, chapternumber, |
| | 3462 | paintButton(draw, bgimage, bgimagemask, node, infoDOM, |
| | 3463 | itemnum, page, itemsonthispage, chapternumber, |
| 3431 | 3464 | chapterlist) |
| 3432 | 3465 | |
| 3433 | 3466 | button = spumuxdom.createElement("button") |
| … |
… |
def createMenu(screensize, screendpi, numberofitems):
|
| 3621 | 3654 | |
| 3622 | 3655 | #now that the base background has been made and all the previews generated |
| 3623 | 3656 | #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 |
| | 3657 | #Assumption: We assume that there is nothing in the location of where the items go |
| 3625 | 3658 | #(ie, no text on the images) |
| 3626 | 3659 | |
| 3627 | 3660 | itemsonthispage = 0 |
| … |
… |
def createChapterMenu(screensize, screendpi, numberofitems):
|
| 3813 | 3846 | chapter+=1 |
| 3814 | 3847 | |
| 3815 | 3848 | drawThemeItem(page, itemsperpage, page, menuitem, |
| 3816 | | overlayimage, draw, |
| | 3849 | overlayimage, draw, |
| 3817 | 3850 | bgimagemask, drawmask, highlightcolor, |
| 3818 | 3851 | spumuxdom, spunode, |
| 3819 | 3852 | 999, chapter, chapterlist) |
| … |
… |
def createChapterMenu(screensize, screendpi, numberofitems):
|
| 3873 | 3906 | aspect_ratio = '2' |
| 3874 | 3907 | elif chaptermenuAspectRatio == "16:9": |
| 3875 | 3908 | aspect_ratio = '3' |
| 3876 | | else: |
| | 3909 | else: |
| 3877 | 3910 | if getAspectRatioOfVideo(page) > aspectRatioThreshold: |
| 3878 | 3911 | aspect_ratio = '3' |
| 3879 | 3912 | else: |
| … |
… |
def isMediaAVIFile(file):
|
| 4043 | 4076 | return Magic=="RIFF" |
| 4044 | 4077 | |
| 4045 | 4078 | ############################################################# |
| 4046 | | # checks to see if an audio stream need to be converted to ac3 |
| | 4079 | # checks to see if an audio stream need to be converted to ac3 |
| 4047 | 4080 | |
| 4048 | 4081 | def processAudio(folder): |
| 4049 | 4082 | """encode audio to ac3 for better compression and compatability with NTSC players""" |
| … |
… |
def selectStreams(folder):
|
| 4135 | 4168 | for node in nodes: |
| 4136 | 4169 | index = int(node.attributes["ffmpegindex"].value) |
| 4137 | 4170 | lang = node.attributes["language"].value |
| 4138 | | format = string.upper(node.attributes["codec"].value) |
| | 4171 | format = node.attributes["codec"].value.upper() |
| 4139 | 4172 | pid = int(node.attributes["id"].value) |
| 4140 | 4173 | if lang == preferredlang1 and format == "AC3": |
| 4141 | 4174 | if found: |
| … |
… |
def selectStreams(folder):
|
| 4150 | 4183 | for node in nodes: |
| 4151 | 4184 | index = int(node.attributes["ffmpegindex"].value) |
| 4152 | 4185 | lang = node.attributes["language"].value |
| 4153 | | format = string.upper(node.attributes["codec"].value) |
| | 4186 | format = node.attributes["codec"].value.upper() |
| 4154 | 4187 | pid = int(node.attributes["id"].value) |
| 4155 | 4188 | if lang == preferredlang1 and format == "MP2": |
| 4156 | 4189 | if found: |
| … |
… |
def selectStreams(folder):
|
| 4164 | 4197 | if not found: |
| 4165 | 4198 | for node in nodes: |
| 4166 | 4199 | index = int(node.attributes["ffmpegindex"].value) |
| 4167 | | format = string.upper(node.attributes["codec"].value) |
| | 4200 | format = node.attributes["codec"].value.upper() |
| 4168 | 4201 | pid = int(node.attributes["id"].value) |
| 4169 | 4202 | if not found: |
| 4170 | 4203 | audio1 = (index, format, pid, lang) |
| … |
… |
def selectStreams(folder):
|
| 4183 | 4216 | for node in nodes: |
| 4184 | 4217 | index = int(node.attributes["ffmpegindex"].value) |
| 4185 | 4218 | lang = node.attributes["language"].value |
| 4186 | | format = string.upper(node.attributes["codec"].value) |
| | 4219 | format = node.attributes["codec"].value.upper() |
| 4187 | 4220 | pid = int(node.attributes["id"].value) |
| 4188 | 4221 | if lang == preferredlang2 and format == "AC3": |
| 4189 | 4222 | if found: |
| … |
… |
def selectStreams(folder):
|
| 4198 | 4231 | for node in nodes: |
| 4199 | 4232 | index = int(node.attributes["ffmpegindex"].value) |
| 4200 | 4233 | lang = node.attributes["language"].value |
| 4201 | | format = string.upper(node.attributes["codec"].value) |
| | 4234 | format = node.attributes["codec"].value.upper() |
| 4202 | 4235 | pid = int(node.attributes["id"].value) |
| 4203 | 4236 | if lang == preferredlang2 and format == "MP2": |
| 4204 | 4237 | if found: |
| … |
… |
def selectStreams(folder):
|
| 4212 | 4245 | if not found: |
| 4213 | 4246 | for node in nodes: |
| 4214 | 4247 | index = int(node.attributes["ffmpegindex"].value) |
| 4215 | | format = string.upper(node.attributes["codec"].value) |
| | 4248 | format = node.attributes["codec"].value.upper() |
| 4216 | 4249 | pid = int(node.attributes["id"].value) |
| 4217 | 4250 | if not found: |
| 4218 | 4251 | # make sure we don't choose the same stream as audio1 |
| … |
… |
def selectSubtitleStream(folder):
|
| 4266 | 4299 | for node in nodes: |
| 4267 | 4300 | index = int(node.attributes["ffmpegindex"].value) |
| 4268 | 4301 | lang = node.attributes["language"].value |
| 4269 | | format = string.upper(node.attributes["codec"].value) |
| | 4302 | format = node.attributes["codec"].value.upper() |
| 4270 | 4303 | pid = int(node.attributes["id"].value) |
| 4271 | 4304 | if not found and lang == preferredlang1 and format == "dvbsub": |
| 4272 | 4305 | subtitle = (index, format, pid, lang) |
| … |
… |
def selectSubtitleStream(folder):
|
| 4277 | 4310 | for node in nodes: |
| 4278 | 4311 | index = int(node.attributes["ffmpegindex"].value) |
| 4279 | 4312 | lang = node.attributes["language"].value |
| 4280 | | format = string.upper(node.attributes["codec"].value) |
| | 4313 | format = node.attributes["codec"].value.upper() |
| 4281 | 4314 | pid = int(node.attributes["id"].value) |
| 4282 | 4315 | if not found and lang == preferredlang2 and format == "dvbsub": |
| 4283 | 4316 | subtitle = (index, format, pid, lang) |
| … |
… |
def selectSubtitleStream(folder):
|
| 4287 | 4320 | if not found: |
| 4288 | 4321 | for node in nodes: |
| 4289 | 4322 | index = int(node.attributes["ffmpegindex"].value) |
| 4290 | | format = string.upper(node.attributes["codec"].value) |
| | 4323 | format = node.attributes["codec"].value.upper() |
| 4291 | 4324 | pid = int(node.attributes["id"].value) |
| 4292 | 4325 | if not found: |
| 4293 | 4326 | subtitle = (index, format, pid, lang) |
| … |
… |
def getStreamList(folder):
|
| 4414 | 4447 | def isFileOkayForDVD(file, folder): |
| 4415 | 4448 | """return true if the file is dvd compliant""" |
| 4416 | 4449 | |
| 4417 | | if not string.lower(getVideoCodec(folder)).startswith("mpeg2video"): |
| | 4450 | if not getVideoCodec(folder).lower().startswith("mpeg2video"): |
| 4418 | 4451 | return False |
| 4419 | 4452 | |
| | 4453 | |
| 4420 | 4454 | # if string.lower(getAudioCodec(folder)) != "ac3" and encodeToAC3: |
| 4421 | 4455 | # return False |
| 4422 | 4456 | |
| … |
… |
def processFile(file, folder, count):
|
| 4454 | 4488 | |
| 4455 | 4489 | ############################################################# |
| 4456 | 4490 | # process a single file ready for burning using mythtranscode/mythreplex |
| 4457 | | # to cut and demux |
| | 4491 | # to cut and demux |
| 4458 | 4492 | |
| 4459 | 4493 | def doProcessFile(file, folder, count): |
| 4460 | 4494 | """Process a single video/recording file ready for burning.""" |
| … |
… |
def doProcessFile(file, folder, count):
|
| 4494 | 4528 | #can only use mythtranscode to cut commercials on mpeg2 files |
| 4495 | 4529 | write("File type is '%s'" % getFileType(folder)) |
| 4496 | 4530 | write("Video codec is '%s'" % getVideoCodec(folder)) |
| 4497 | | if string.lower(getVideoCodec(folder)).startswith("mpeg2video"): |
| | 4531 | if (getVideoCodec(folder)).lower().startswith("mpeg2video"): |
| 4498 | 4532 | if file.attributes["usecutlist"].value == "1" and getText(infoDOM.getElementsByTagName("hascutlist")[0]) == "yes": |
| 4499 | 4533 | # Run from local file? |
| 4500 | 4534 | if file.hasAttribute("localfilename"): |
| … |
… |
def doProcessFile(file, folder, count):
|
| 4510 | 4544 | write("Failed to run mythtranscode to remove unwanted segments") |
| 4511 | 4545 | else: |
| 4512 | 4546 | #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 |
| | 4547 | #may help to fix any errors in the file |
| | 4548 | if (alwaysRunMythtranscode == True or |
| 4515 | 4549 | (getFileType(folder) == "mpegts" and isFileOkayForDVD(file, folder))): |
| 4516 | 4550 | # Run from local file? |
| 4517 | 4551 | if file.hasAttribute("localfilename"): |
| … |
… |
def doProcessFile(file, folder, count):
|
| 4527 | 4561 | write("Failed to run mythtranscode to fix any errors") |
| 4528 | 4562 | else: |
| 4529 | 4563 | #does the user always want to run mpeg2 files through mythtranscode? |
| 4530 | | #may help to fix any errors in the file |
| | 4564 | #may help to fix any errors in the file |
| 4531 | 4565 | write("File type is '%s'" % getFileType(folder)) |
| 4532 | 4566 | write("Video codec is '%s'" % getVideoCodec(folder)) |
| 4533 | 4567 | |
| 4534 | 4568 | if (alwaysRunMythtranscode == True and |
| 4535 | | string.lower(getVideoCodec(folder)).startswith("mpeg2video") and |
| | 4569 | getVideoCodec(folder).lower().startswith("mpeg2video") and |
| 4536 | 4570 | isFileOkayForDVD(file, folder)): |
| 4537 | 4571 | if file.hasAttribute("localfilename"): |
| 4538 | 4572 | localfile = file.attributes["localfilename"].value |
| … |
… |
def doProcessFile(file, folder, count):
|
| 4579 | 4613 | mediafile = -1 |
| 4580 | 4614 | chanid = getText(infoDOM.getElementsByTagName("chanid")[0]) |
| 4581 | 4615 | starttime = getText(infoDOM.getElementsByTagName("starttime")[0]) |
| 4582 | | usecutlist = (file.attributes["usecutlist"].value == "1" and |
| | 4616 | usecutlist = (file.attributes["usecutlist"].value == "1" and |
| 4583 | 4617 | getText(infoDOM.getElementsByTagName("hascutlist")[0]) == "yes") |
| 4584 | 4618 | else: |
| 4585 | 4619 | chanid = -1 |
| … |
… |
def doProcessFile(file, folder, count):
|
| 4612 | 4646 | else: |
| 4613 | 4647 | profile = defaultEncodingProfile |
| 4614 | 4648 | |
| 4615 | | #do the re-encode |
| | 4649 | #do the re-encode |
| 4616 | 4650 | encodeVideoToMPEG2(mediafile, os.path.join(folder, "newfile2.mpg"), video, |
| 4617 | 4651 | audio1, audio2, aspectratio, profile) |
| 4618 | 4652 | mediafile = os.path.join(folder, 'newfile2.mpg') |
| … |
… |
def doProcessFileProjectX(file, folder, count):
|
| 4677 | 4711 | |
| 4678 | 4712 | #As part of this routine we need to pre-process the video this MAY mean: |
| 4679 | 4713 | #1. encoding to mpeg2 (if its an avi for instance or isn't DVD compatible) |
| 4680 | | #2. removing commercials/cleaning up mpeg2 stream |
| | 4714 | #2. removing commercials/cleaning up mpeg2 stream |
| 4681 | 4715 | #3. selecting audio track(s) to use and encoding audio from mp2 into ac3 |
| 4682 | 4716 | #4. de-multiplexing into video and audio steams |
| 4683 | 4717 | |
| … |
… |
def doProcessFileProjectX(file, folder, count):
|
| 4733 | 4767 | mediafile = -1 |
| 4734 | 4768 | chanid = getText(infoDOM.getElementsByTagName("chanid")[0]) |
| 4735 | 4769 | starttime = getText(infoDOM.getElementsByTagName("starttime")[0]) |
| 4736 | | usecutlist = (file.attributes["usecutlist"].value == "1" and |
| | 4770 | usecutlist = (file.attributes["usecutlist"].value == "1" and |
| 4737 | 4771 | getText(infoDOM.getElementsByTagName("hascutlist")[0]) == "yes") |
| 4738 | 4772 | else: |
| 4739 | 4773 | chanid = -1 |
| … |
… |
def doProcessFileProjectX(file, folder, count):
|
| 4766 | 4800 | else: |
| 4767 | 4801 | profile = defaultEncodingProfile |
| 4768 | 4802 | |
| 4769 | | #do the re-encode |
| | 4803 | #do the re-encode |
| 4770 | 4804 | encodeVideoToMPEG2(mediafile, os.path.join(folder, "newfile2.mpg"), video, |
| 4771 | 4805 | audio1, audio2, aspectratio, profile) |
| 4772 | 4806 | mediafile = os.path.join(folder, 'newfile2.mpg') |
| … |
… |
def doProcessFileProjectX(file, folder, count):
|
| 4787 | 4821 | # now attempt to split the source file into video and audio parts |
| 4788 | 4822 | # using projectX |
| 4789 | 4823 | |
| 4790 | | # If this is an mpeg2 myth recording and there is a cut list available and the |
| | 4824 | # If this is an mpeg2 myth recording and there is a cut list available and the |
| 4791 | 4825 | # user wants to use it run projectx to cut out commercials etc |
| 4792 | 4826 | if file.attributes["type"].value == "recording": |
| 4793 | 4827 | if file.attributes["usecutlist"].value == "1" and getText(infoDOM.getElementsByTagName("hascutlist")[0]) == "yes": |
| … |
… |
def processJob(job):
|
| 4995 | 5029 | filecount+=1 |
| 4996 | 5030 | folder=getItemTempPath(filecount) |
| 4997 | 5031 | #Multiplex this file |
| 4998 | | #(This also removes non-required audio feeds inside mpeg streams |
| | 5032 | #(This also removes non-required audio feeds inside mpeg streams |
| 4999 | 5033 | #(through re-multiplexing) we only take 1 video and 1 or 2 audio streams) |
| 5000 | 5034 | pid=multiplexMPEGStream(os.path.join(folder,'stream.mv2'), |
| 5001 | 5035 | os.path.join(folder,'stream0'), |
| … |
… |
def main():
|
| 5166 | 5200 | videopath = defaultsettings.get("VideoStartupDir", None) |
| 5167 | 5201 | gallerypath = defaultsettings.get("GalleryDir", None) |
| 5168 | 5202 | musicpath = defaultsettings.get("MusicLocation", None) |
| 5169 | | videomode = string.lower(defaultsettings["MythArchiveVideoFormat"]) |
| | 5203 | videomode = defaultsettings["MythArchiveVideoFormat"].lower() |
| 5170 | 5204 | temppath = os.path.join(defaultsettings["MythArchiveTempDir"], "work") |
| 5171 | 5205 | logpath = os.path.join(defaultsettings["MythArchiveTempDir"], "logs") |
| 5172 | 5206 | write("temppath: " + temppath) |
| … |
… |
def main():
|
| 5233 | 5267 | try: |
| 5234 | 5268 | fd = os.open(lckpath, os.O_WRONLY | os.O_CREAT | os.O_EXCL) |
| 5235 | 5269 | try: |
| 5236 | | os.write(fd, "%d\n" % os.getpid()) |
| | 5270 | os.write(fd, b"%d\n" % os.getpid()) |
| 5237 | 5271 | os.close(fd) |
| 5238 | 5272 | except: |
| 5239 | 5273 | os.remove(lckpath) |
| 5240 | 5274 | raise |
| 5241 | | except OSError, e: |
| | 5275 | except OSError as e: |
| 5242 | 5276 | if e.errno == errno.EEXIST: |
| 5243 | 5277 | write("Lock file exists -- already running???") |
| 5244 | 5278 | sys.exit(1) |
| … |
… |
def main():
|
| 5281 | 5315 | # remove our lock file |
| 5282 | 5316 | os.remove(lckpath) |
| 5283 | 5317 | |
| 5284 | | # make sure the files we created are read/writable by all |
| | 5318 | # make sure the files we created are read/writable by all |
| 5285 | 5319 | os.system("chmod -R a+rw-x+X %s" % defaultsettings["MythArchiveTempDir"]) |
| 5286 | 5320 | except SystemExit: |
| 5287 | 5321 | write("Terminated") |