Ticket #6236: mythburn.py.4.diff

File mythburn.py.4.diff, 25.3 KB (added by brandons@…, 11 years ago)

Updated patch

  • mythburn.py

    old new  
    6767#*********************************************************************************
    6868#Dont change the stuff below!!
    6969#*********************************************************************************
    70 import os, string, socket, sys, getopt, traceback, signal
     70import os, popen2, string, socket, sys, getopt, traceback, signal
    7171import xml.dom.minidom
    7272import Image, ImageDraw, ImageFont, ImageColor
    7373import MySQLdb, codecs, unicodedata
     
    18211821        os.remove(sourcefile)
    18221822
    18231823#############################################################
     1824# Re-encodes a mv2 video stream
     1825
     1826def encodeVideo(sourcefile, destinationfile, aspectratio, profile, deletesourceafterencode):
     1827    """Encodes an mv2 source file use ffmpeg"""
     1828
     1829    profileNode = findEncodingProfile(profile)
     1830
     1831    passes = int(getText(profileNode.getElementsByTagName("passes")[0]))
     1832
     1833    command = path_ffmpeg[0]
     1834
     1835    if cpuCount > 1:
     1836        command += " -threads %d" % cpuCount
     1837
     1838
     1839    parameters = profileNode.getElementsByTagName("parameter")
     1840
     1841    for param in parameters:
     1842        name = param.attributes["name"].value
     1843        value = param.attributes["value"].value
     1844
     1845        # do some parameter substitution
     1846        if value == "%inputfile":
     1847            value = quoteFilename(sourcefile)
     1848        if value == "%outputfile":
     1849            #Encode elementry stream only
     1850            command += " -f mpeg2video"
     1851            value = quoteFilename(destinationfile)
     1852        if value == "%aspect":
     1853            value = aspectratio
     1854
     1855        if name != "":
     1856            command += " " + name
     1857
     1858        if value != "":
     1859            command += " " + value
     1860
     1861    if passes == 1:
     1862        write(command)
     1863        result = runCommand(command)
     1864        if result!=0:
     1865            fatalError("Failed while running ffmpeg to re-encode video.\n"
     1866                       "Command was %s" % command)
     1867
     1868    else:
     1869        passLog = os.path.join(getTempPath(), 'pass')
     1870
     1871        pass1 = string.replace(command, "%passno","1")
     1872        pass1 = string.replace(pass1, "%passlogfile", passLog)
     1873        write("Pass 1 - " + pass1)
     1874        result = runCommand(pass1)
     1875
     1876        if result!=0:
     1877            fatalError("Failed while running ffmpeg (Pass 1) to re-encode video.\n"
     1878                       "Command was %s" % command)
     1879
     1880        if os.path.exists(destinationfile):
     1881            os.remove(destinationfile)
     1882
     1883        pass2 = string.replace(command, "%passno","2")
     1884        pass2 = string.replace(pass2, "%passlogfile", passLog)
     1885        write("Pass 2 - " + pass2)
     1886        result = runCommand(pass2)
     1887
     1888        if result!=0:
     1889            fatalError("Failed while running ffmpeg (Pass 2) to re-encode video.\n"
     1890                       "Command was %s" % command)
     1891
     1892    if deletesourceafterencode==True:
     1893        os.remove(sourcefile)
     1894
     1895
     1896#############################################################
    18241897# Recombines a video and one or two audio streams back together
    18251898# adding in the NAV packets required to create a DVD
    18261899
     
    20412114            write("Failed to generate Project-X cutlist.")
    20422115            return False
    20432116
    2044     pxbasename = os.path.splitext(os.path.basename(file))[0]
    2045 
    20462117    if os.path.exists(file) != True:
    20472118        write("Error: input file doesn't exist on local filesystem")
    20482119        return False
    20492120
     2121    # Projectx does not like spaces in file names,
     2122    # create a symbolic link in destination folder.
     2123    if os.path.exists(os.path.join(folder, "inputfile" )):
     2124        os.remove(os.path.join(folder, "inputfile" ))
     2125    os.symlink(file, os.path.join(folder, "inputfile" ))
     2126
     2127    file = os.path.join(folder, "inputfile" )
     2128    pxbasename = "inputfile"
    20502129
    20512130    qdestdir = quoteFilename(folder)
    20522131    qpxbasename = quoteFilename(pxbasename)
    20532132    qfile = quoteFilename(file)
    2054     qcutlist = os.path.join(folder, "cutlist_x.txt")
     2133    qcutlist = quoteFilename(os.path.join(folder, "cutlist_x.txt"))
    20552134
    20562135    command = path_projectx[0] + " -id %s" % getStreamList(folder)
     2136
     2137    if addSubtitles:
     2138        (txtindex, txtpage) = findTeletextSubtitles(folder, file)
     2139        createProjectxIni(folder, txtpage)
     2140        if txtpage != "-1":
     2141            command += ",%s -ini %s" % (txtindex,os.path.join(folder, "projectx.ini"))
     2142        else:
     2143            command += " -ini %s" % (os.path.join(folder, "projectx.ini"))
     2144
    20572145    if usecutlist == True:
    20582146        command += " -cut %s -out %s -name %s %s" % (qcutlist, qdestdir, qpxbasename, qfile)
    20592147    else:
     
    21022190    logf = open(os.path.join(folder, pxbasename + "_log.txt"))
    21032191    logdata = logf.readlines()
    21042192    logf.close()
    2105 
    21062193    # find stream PIDs
    21072194    streamIds = []
    21082195    for line in logdata:
     
    21122199                write("found stream %s" % tokens[2], False)
    21132200                streamIds.append(int(tokens[2], 16))
    21142201
    2115     sortedstreamIds = []
    2116     sortedstreamIds = sorted(streamIds)
    2117     streamIds = sortedstreamIds
    2118 
    21192202    # if we haven't found any PIDs look for PES-IDs
    21202203    if len(streamIds) == 0:
    21212204         for line in logdata:
     
    21632246
    21642247    # sanity check - we should have a file for each ID
    21652248    if len(streamIds) == len(streamFiles):
     2249        # move video id to start of array
     2250        tmp = 0
     2251        tmp = streamIds.pop(streamIds.index(videoID))
     2252        if tmp != 0:
     2253            streamIds.insert(0,tmp)
     2254
    21662255        # loop thought the available streams looking for the ones we want
    21672256        for stream in streamIds:
    21682257            write("got stream: %d" % stream, False)
     
    21902279                    else:
    21912280                        os.rename(streamFiles[streamIds.index(stream)], os.path.join(folder, "stream1.mp2"))
    21922281
     2282        # loop thought the available files looking for subtitles
     2283        for file in streamFiles:
     2284            if file.endswith(".sup"):
     2285                if os.path.exists(file):
     2286                    write("found subtitle stream file", False)
     2287                    os.rename(file, os.path.join(folder, "stream.sup"))
     2288                    if os.path.exists(file + ".IFO"):
     2289                        os.rename(file + ".IFO", os.path.join(folder, "stream.sup.IFO"))
     2290               
    21932291    # final chance to find the correct stream files
    21942292    if not os.path.exists(os.path.join(folder, "stream.mv2")):
    21952293        if os.path.exists(os.path.join(folder, pxbasename + ".m2v")):
     
    22172315    write("renameProjectXFiles end -----------------------------------------", False)
    22182316
    22192317#############################################################
     2318# Run projectx to look for teletext pages that hold subtitles
     2319
     2320def findTeletextSubtitles(folder, file):
     2321
     2322    # find captions
     2323    firststreamId = '-1'
     2324    firstlanguage = "N/A"
     2325    firstpage = '-1'
     2326
     2327    txtstreamId = '-1'
     2328    txtlanguage = "N/A"
     2329    txtpage = '-1'
     2330
     2331    streamId = '-1'
     2332    language = "N/A"
     2333    page = '-1'
     2334
     2335    qdestdir = quoteFilename(folder)
     2336    qfile = quoteFilename(file)
     2337
     2338    command = path_projectx[0] + " -out %s -name teletext_temp  %s" % (qdestdir, qfile)
     2339
     2340    projectx = popen2.Popen4(command,1)
     2341   
     2342    while projectx.poll() == -1:
     2343        line = projectx.fromchild.readline()
     2344
     2345        if len(line) == 0:
     2346            continue
     2347        if line.startswith("Teletext:"):
     2348            # we have found the teletext section
     2349            while 1:
     2350                line = projectx.fromchild.readline()
     2351                if line.startswith("Subpict.:"):
     2352                    break
     2353                index = line.find("PID: 0x")
     2354                if index >= 0:
     2355                    # found a stream
     2356                    streamId = line[index + 5:index + 10]
     2357                    write("Found Teletext stream: %s" % streamId, False)
     2358                    # get list of available pages
     2359                    pages = line[index + 11:-1]
     2360                    # strip trailing )
     2361                    closebrace = pages.find(")")
     2362                    if closebrace > 0:
     2363                        pages = pages[0:closebrace]
     2364                    # convert into array of pages
     2365                    pagelist = pages.split()
     2366   
     2367                    for pagedetails in pagelist:
     2368                        # look for caption pages
     2369                        index = pagedetails.find("_s")
     2370                        if index > 0:
     2371                            language = pagedetails[0:index]
     2372                            page = pagedetails[index+2:index+5]
     2373                            write("Found %s subtitles in page %s" % (language, page), False)
     2374                            if firstlanguage == "N/A":
     2375                                #retain first subtitles as fall back
     2376                                firstlanguage = language
     2377                                firstpage = page
     2378                                firststreamId = streamId
     2379                            if language == preferredlang1:
     2380                                txtlanguage = language
     2381                                txtpage = page
     2382                                txtstreamId = streamId
     2383                            else:
     2384                                if preferredlang1 != preferredlang2:
     2385                                    if language == preferredlang2 and txtlanguage == "N/A":
     2386                                        txtlanguage = language
     2387                                        txtpage = page
     2388                                        txtstreamId = streamId
     2389                               
     2390        if line.startswith("Subpict.:"):
     2391            break
     2392
     2393        if txtlanguage == preferredlang1:
     2394            break
     2395
     2396    if txtlanguage == "N/A":
     2397        txtlanguage = firstlanguage
     2398        txtpage = firstpage
     2399        txtstreamId = firststreamId
     2400
     2401    if txtlanguage != "N/A":
     2402        write("Found %s subtitles in PID: %s, at page %s" % (txtlanguage, txtstreamId, txtpage))
     2403    else:
     2404        write("Did not find any teletext subtitles")
     2405
     2406    #kill the projectx process, this is all we need from this run
     2407    os.system("pkill -P %d" % projectx.pid)
     2408    os.kill(projectx.pid,15)
     2409    projectx.wait()
     2410    return (streamId, txtpage)
     2411
     2412#############################################################
     2413# create an ini file
     2414
     2415def createProjectxIni(folder, txtpage):
     2416    if os.path.exists(os.path.join(folder, "projectx.ini" )):
     2417        os.remove(os.path.join(folder, "projectx.ini" ))
     2418    inif = open(os.path.join(folder, "projectx.ini"),"w")
     2419   
     2420    if txtpage != "-1":
     2421        inif.write("SubtitlePanel.TtxPage1=%s\n" % txtpage)
     2422        inif.write("SubtitlePanel.decodeHiddenRows=0\n")
     2423    inif.write("SubtitlePanel.SubtitleExportFormat=SUP\n")
     2424
     2425    inif.close()
     2426
     2427#############################################################
    22202428# convert time stamp to pts
    22212429
    22222430def ts2pts(time):
     
    48695077
    48705078    #do we need to re-encode the file to make it DVD compliant?
    48715079    if not isFileOkayForDVD(file, folder):
    4872         if getFileType(folder) == 'nuv':
    4873             #file is a nuv file which ffmpeg has problems reading so use mythtranscode to pass
    4874             #the video and audio streams to ffmpeg to do the reencode
    4875 
    4876             #we need to re-encode the file, make sure we get the right video/audio streams
    4877             #would be good if we could also split the file at the same time
    4878             getStreamInformation(mediafile, os.path.join(folder, "streaminfo.xml"), 0)
     5080        if string.lower(getVideoCodec(folder)) == "mpeg2video":
     5081            #we need to demultiplex the file using projectx,
     5082            #make sure we get the right video/audio streams,
     5083            #re-encode the video elementary stream to be dvd complient.
     5084            getStreamInformation(mediafile, os.path.join(folder, "streaminfo.xml"), 1)
    48795085
    48805086            #choose which streams we need
    48815087            video, audio1, audio2 = selectStreams(folder)
     
    48835089            #choose which aspect ratio we should use
    48845090            aspectratio = selectAspectRatio(folder)
    48855091
    4886             write("Re-encoding audio and video from nuv file")
     5092            # Run from local file?
     5093            if file.hasAttribute("localfilename"):
     5094                mediafile = file.attributes["localfilename"].value
     5095
     5096            # now attempt to split the source file into video and audio parts
     5097            # using projectX
     5098
     5099            # If this is a myth recording and there is a cut list available and the
     5100            # user wants to use it run projectx to cut out commercials etc
     5101            if file.attributes["type"].value == "recording":
     5102                if file.attributes["usecutlist"].value == "1" and getText(infoDOM.getElementsByTagName("hascutlist")[0]) == "yes":
     5103                    chanid = getText(infoDOM.getElementsByTagName("chanid")[0])
     5104                    starttime = getText(infoDOM.getElementsByTagName("starttime")[0])
     5105                    write("File has a cut list - running Project-X to remove unwanted segments")
     5106                    if not runProjectX(chanid, starttime, folder, True, mediafile):
     5107                        fatalError("Failed to run Project-X to remove unwanted segments and demux")
     5108                else:
     5109                    # no cutlist so just demux this file
     5110                    chanid = getText(infoDOM.getElementsByTagName("chanid")[0])
     5111                    starttime = getText(infoDOM.getElementsByTagName("starttime")[0])
     5112                    write("Using Project-X to demux file")
     5113                    if not runProjectX(chanid, starttime, folder, False, mediafile):
     5114                        fatalError("Failed to run Project-X to demux file")
     5115            else:
     5116                # just demux this file
     5117                chanid = -1
     5118                starttime = -1
     5119                write("Running Project-X to demux file")
     5120                if not runProjectX(chanid, starttime, folder, False, mediafile):
     5121                    fatalError("Failed to run Project-X to demux file")
     5122
     5123            write("Re-encoding video")
    48875124
    48885125            # what encoding profile should we use
    48895126            if file.hasAttribute("encodingprofile"):
     
    48915128            else:
    48925129                profile = defaultEncodingProfile
    48935130
    4894             if file.hasAttribute("localfilename"):
    4895                 mediafile = file.attributes["localfilename"].value
    4896                 chanid = -1
    4897                 starttime = -1
    4898                 usecutlist = -1
    4899             elif file.attributes["type"].value == "recording":
    4900                 mediafile = -1
    4901                 chanid = getText(infoDOM.getElementsByTagName("chanid")[0])
    4902                 starttime = getText(infoDOM.getElementsByTagName("starttime")[0])
    4903                 usecutlist = (file.attributes["usecutlist"].value == "1" and
    4904                             getText(infoDOM.getElementsByTagName("hascutlist")[0]) == "yes")
    4905             else:
    4906                 chanid = -1
    4907                 starttime = -1
    4908                 usecutlist = -1
    4909 
    4910             encodeNuvToMPEG2(chanid, starttime, mediafile, os.path.join(folder, "newfile2.mpg"), folder,
    4911                          profile, usecutlist)
    4912             mediafile = os.path.join(folder, 'newfile2.mpg')
     5131            #do the re-encode
     5132            encodeVideo(os.path.join(folder, "stream.mv2"), os.path.join(folder, "stream2.mv2"), aspectratio, profile, True)
     5133            if os.path.exists(os.path.join(folder, "stream2.mv2")):
     5134                os.rename(os.path.join(folder, "stream2.mv2"), os.path.join(folder, "stream.mv2"))
    49135135        else:
    4914             #we need to re-encode the file, make sure we get the right video/audio streams
    4915             #would be good if we could also split the file at the same time
    4916             getStreamInformation(mediafile, os.path.join(folder, "streaminfo.xml"), 0)
     5136            if getFileType(folder) == 'nuv':
     5137                #file is a nuv file which ffmpeg has problems reading so use mythtranscode to pass
     5138                #the video and audio streams to ffmpeg to do the reencode
    49175139
    4918             #choose which streams we need
    4919             video, audio1, audio2 = selectStreams(folder)
     5140                #we need to re-encode the file, make sure we get the right video/audio streams
     5141                #would be good if we could also split the file at the same time
     5142                getStreamInformation(mediafile, os.path.join(folder, "streaminfo.xml"), 0)
    49205143
    4921             #choose which aspect ratio we should use
    4922             aspectratio = selectAspectRatio(folder)
     5144                #choose which streams we need
     5145                video, audio1, audio2 = selectStreams(folder)
    49235146
    4924             write("Re-encoding audio and video")
     5147                #choose which aspect ratio we should use
     5148                aspectratio = selectAspectRatio(folder)
    49255149
    4926             # Run from local file?
    4927             if file.hasAttribute("localfilename"):
    4928                 mediafile = file.attributes["localfilename"].value
     5150                write("Re-encoding audio and video from nuv file")
    49295151
    4930             # what encoding profile should we use
    4931             if file.hasAttribute("encodingprofile"):
    4932                 profile = file.attributes["encodingprofile"].value
     5152                # what encoding profile should we use
     5153                if file.hasAttribute("encodingprofile"):
     5154                    profile = file.attributes["encodingprofile"].value
     5155                else:
     5156                    profile = defaultEncodingProfile
     5157
     5158                if file.hasAttribute("localfilename"):
     5159                    mediafile = file.attributes["localfilename"].value
     5160                    chanid = -1
     5161                    starttime = -1
     5162                    usecutlist = -1
     5163                elif file.attributes["type"].value == "recording":
     5164                    mediafile = -1
     5165                    chanid = getText(infoDOM.getElementsByTagName("chanid")[0])
     5166                    starttime = getText(infoDOM.getElementsByTagName("starttime")[0])
     5167                    usecutlist = (file.attributes["usecutlist"].value == "1" and
     5168                                getText(infoDOM.getElementsByTagName("hascutlist")[0]) == "yes")
     5169                else:
     5170                    chanid = -1
     5171                    starttime = -1
     5172                    usecutlist = -1
     5173
     5174                encodeNuvToMPEG2(chanid, starttime, mediafile, os.path.join(folder, "newfile2.mpg"), folder,
     5175                             profile, usecutlist)
     5176                mediafile = os.path.join(folder, 'newfile2.mpg')
    49335177            else:
    4934                 profile = defaultEncodingProfile
     5178                #we need to re-encode the file, make sure we get the right video/audio streams
     5179                #would be good if we could also split the file at the same time
     5180                getStreamInformation(mediafile, os.path.join(folder, "streaminfo.xml"), 0)
    49355181
    4936             #do the re-encode
    4937             encodeVideoToMPEG2(mediafile, os.path.join(folder, "newfile2.mpg"), video,
    4938                             audio1, audio2, aspectratio, profile)
    4939             mediafile = os.path.join(folder, 'newfile2.mpg')
     5182                #choose which streams we need
     5183                video, audio1, audio2 = selectStreams(folder)
    49405184
    4941     #remove an intermediate file
    4942     if os.path.exists(os.path.join(folder, "newfile1.mpg")):
    4943         os.remove(os.path.join(folder,'newfile1.mpg'))
     5185                #choose which aspect ratio we should use
     5186                aspectratio = selectAspectRatio(folder)
    49445187
    4945     # the file is now DVD compliant now we need to remove commercials
    4946     # and split it into video, audio, subtitle parts
     5188                write("Re-encoding audio and video")
    49475189
    4948     # find out what streams we have available now
    4949     getStreamInformation(mediafile, os.path.join(folder, "streaminfo.xml"), 1)
     5190                # Run from local file?
     5191                if file.hasAttribute("localfilename"):
     5192                    mediafile = file.attributes["localfilename"].value
    49505193
    4951     # choose which streams we need
    4952     video, audio1, audio2 = selectStreams(folder)
     5194                # what encoding profile should we use
     5195                if file.hasAttribute("encodingprofile"):
     5196                    profile = file.attributes["encodingprofile"].value
     5197                else:
     5198                    profile = defaultEncodingProfile
    49535199
    4954     # now attempt to split the source file into video and audio parts
    4955     # using projectX
     5200                #do the re-encode
     5201                encodeVideoToMPEG2(mediafile, os.path.join(folder, "newfile2.mpg"), video,
     5202                                audio1, audio2, aspectratio, profile)
     5203                mediafile = os.path.join(folder, 'newfile2.mpg')
    49565204
    4957     # If this is an mpeg2 myth recording and there is a cut list available and the
    4958     # user wants to use it run projectx to cut out commercials etc
    4959     if file.attributes["type"].value == "recording":
    4960         if file.attributes["usecutlist"].value == "1" and getText(infoDOM.getElementsByTagName("hascutlist")[0]) == "yes":
    4961             chanid = getText(infoDOM.getElementsByTagName("chanid")[0])
    4962             starttime = getText(infoDOM.getElementsByTagName("starttime")[0])
    4963             write("File has a cut list - running Project-X to remove unwanted segments")
    4964             if not runProjectX(chanid, starttime, folder, True, mediafile):
    4965                 fatalError("Failed to run Project-X to remove unwanted segments and demux")
    4966         else:
    4967             # no cutlist so just demux this file
    4968             chanid = getText(infoDOM.getElementsByTagName("chanid")[0])
    4969             starttime = getText(infoDOM.getElementsByTagName("starttime")[0])
    4970             write("Using Project-X to demux file")
     5205            #remove an intermediate file
     5206            if os.path.exists(os.path.join(folder, "newfile1.mpg")):
     5207                os.remove(os.path.join(folder,'newfile1.mpg'))
     5208
     5209            # the file is now DVD compliant split it into video and audio parts
     5210
     5211            # find out what streams we have available now
     5212            getStreamInformation(mediafile, os.path.join(folder, "streaminfo.xml"), 1)
     5213
     5214            # choose which streams we need
     5215            video, audio1, audio2 = selectStreams(folder)
     5216
     5217            # now attempt to split the source file into video and audio parts
     5218            # using projectX
     5219
     5220            # If this is an mpeg2 myth recording and there is a cut list available and the
     5221            # user wants to use it run projectx to cut out commercials etc
     5222            if file.attributes["type"].value == "recording":
     5223                # no cutlist so just demux this file
     5224                chanid = getText(infoDOM.getElementsByTagName("chanid")[0])
     5225                starttime = getText(infoDOM.getElementsByTagName("starttime")[0])
     5226                write("Using Project-X to demux file")
     5227                if not runProjectX(chanid, starttime, folder, False, mediafile):
     5228                    fatalError("Failed to run Project-X to demux file")
     5229            else:
     5230                # just demux this file
     5231                chanid = -1
     5232                starttime = -1
     5233                write("Running Project-X to demux file")
     5234                if not runProjectX(chanid, starttime, folder, False, mediafile):
     5235                    fatalError("Failed to run Project-X to demux file")
     5236
     5237       
     5238    else:
     5239        #remove an intermediate file
     5240        if os.path.exists(os.path.join(folder, "newfile1.mpg")):
     5241            os.remove(os.path.join(folder,'newfile1.mpg'))
     5242
     5243        # the file is now DVD compliant now we need to remove commercials
     5244        # and split it into video, audio, subtitle parts
     5245
     5246        # find out what streams we have available now
     5247        getStreamInformation(mediafile, os.path.join(folder, "streaminfo.xml"), 1)
     5248
     5249        # choose which streams we need
     5250        video, audio1, audio2 = selectStreams(folder)
     5251
     5252        # now attempt to split the source file into video and audio parts
     5253        # using projectX
     5254
     5255        # If this is an mpeg2 myth recording and there is a cut list available and the
     5256        # user wants to use it run projectx to cut out commercials etc
     5257        if file.attributes["type"].value == "recording":
     5258            if file.attributes["usecutlist"].value == "1" and getText(infoDOM.getElementsByTagName("hascutlist")[0]) == "yes":
     5259                chanid = getText(infoDOM.getElementsByTagName("chanid")[0])
     5260                starttime = getText(infoDOM.getElementsByTagName("starttime")[0])
     5261                write("File has a cut list - running Project-X to remove unwanted segments")
     5262                if not runProjectX(chanid, starttime, folder, True, mediafile):
     5263                    fatalError("Failed to run Project-X to remove unwanted segments and demux")
     5264            else:
     5265                # no cutlist so just demux this file
     5266                chanid = getText(infoDOM.getElementsByTagName("chanid")[0])
     5267                starttime = getText(infoDOM.getElementsByTagName("starttime")[0])
     5268                write("Using Project-X to demux file")
     5269                if not runProjectX(chanid, starttime, folder, False, mediafile):
     5270                    fatalError("Failed to run Project-X to demux file")
     5271        else:
     5272            # just demux this file
     5273            chanid = -1
     5274            starttime = -1
     5275            write("Running Project-X to demux file")
    49715276            if not runProjectX(chanid, starttime, folder, False, mediafile):
    49725277                fatalError("Failed to run Project-X to demux file")
    4973     else:
    4974         # just demux this file
    4975         chanid = -1
    4976         starttime = -1
    4977         write("Running Project-X to demux file")
    4978         if not runProjectX(chanid, starttime, folder, False, mediafile):
    4979             fatalError("Failed to run Project-X to demux file")
    49805278
    49815279    # we now have a video stream and one or more audio streams
    49825280    # check if we need to convert any of the audio streams to ac3