Ticket #8247: mythburn-streamorder-20100329.diff

File mythburn-streamorder-20100329.diff, 4.0 KB (added by Alex Butcher, 14 years ago)

patch to improve stream ordering

  • /usr/share/mythtv/mytharchive

    old new  
    21032103    logdata = logf.readlines()
    21042104    logf.close()
    21052105
    2106     # find stream PIDs
     2106    # find stream PIDs and Files
    21072107    streamIds = []
     2108    streamFiles = []   
    21082109    for line in logdata:
    21092110         tokens = line.split()
    21102111         if len(tokens) > 0:
    2111             if tokens[0] == "ok>":
    2112                 write("found stream %s" % tokens[2], False)
    2113                 streamIds.append(int(tokens[2], 16))
    2114 
    2115     sortedstreamIds = []
    2116     sortedstreamIds = sorted(streamIds)
    2117     streamIds = sortedstreamIds
    2118 
    2119     # if we haven't found any PIDs look for PES-IDs
    2120     if len(streamIds) == 0:
    2121          for line in logdata:
    2122             if line.startswith("-> found PES-ID"):
    2123                 index = line.find("(SubID 0x")
    2124                 if index > 0:
    2125                     streamId = line[index + 7:index + 11]
    2126                     write("found stream %s" % streamId, False)
    2127                     streamIds.append(int(streamId, 16))
    2128                 else:
    2129                     tokens = line.split()
    2130                     if len(tokens) > 0:
    2131                         write("found stream %s" % tokens[3], False)
    2132                         streamIds.append(int(tokens[3], 16))
    2133 
    2134     # find files
    2135     streamFiles = []
    2136     for line in logdata:
    2137         if line.startswith("---> new File: "):
    2138             file = line[15:-1]
    2139             # strip any ' chars from start/end
    2140             if file.startswith("'"):
    2141                 file = file[1: -1]
    2142             if file.endswith("'"):
    2143                 file = file[0: -2]
    2144             write(file, False)
    2145             streamFiles.append(file)
    2146 
    2147         if line.startswith("--> stream omitted"):
    2148             file = ""
    2149             write(line, False)
    2150             streamFiles.append(file)
     2112            if tokens[0] == "++>":
     2113              # From ProjectX/resources/pjxresources_en.properties:
     2114              if tokens[1] == "Mpg":
     2115                if tokens[2] == "Video:":
     2116                  write("found MPEG video stream %s" % tokens[4], False)
     2117                  streamIds.append(int(tokens[4], 16))
     2118                if tokens[2] == "Audio:":
     2119                  write("found MPEG audio stream %s" % tokens[4], False)
     2120                  streamIds.append(int(tokens[4], 16))
     2121              if tokens[1] == "AC3/DTS":
     2122                write("found AC3/DTS audio stream %s" % tokens[4], False)
     2123                streamIds.append(int(tokens[4], 16))             
     2124              if tokens[1] == "LPCM":
     2125                write("found LPCM audio stream %s" % tokens[4], False)
     2126                streamIds.append(int(tokens[4], 16))             
     2127              if tokens[1] == "Teletext:":
     2128                write("found Teletext stream %s" % tokens[3], False)
     2129                streamIds.append(int(tokens[3], 16))             
     2130              if tokens[1] == "Subpicture:":
     2131                write("found Subpicture stream %s" % tokens[3], False)
     2132                streamIds.append(int(tokens[3], 16))
     2133              if tokens[1] == "Generic_VBI:":
     2134                write("found Generic_VBI stream %s" % tokens[3], False)
     2135                streamIds.append(int(tokens[3], 16))                                           
     2136            if tokens[0] == "--->":
     2137              if tokens[1] == "new":
     2138                if tokens[2] == "File:":
     2139                  write("found file for stream 0x%x, %s" % (streamIds[len(streamIds)-1], tokens[3]), False)
     2140                  streamFiles.append(tokens[3].replace("'","")) # let's hope the path never has a space in it
     2141            if tokens[0] == "-->":
     2142              if tokens[1] == "stream":
     2143                if tokens[2] == "omitted":
     2144                  write("stream 0x%x omitted" % streamIds[len(streamIds)-1], False)
     2145                  streamFiles.append("")
     2146                 
     2147    write("streadmIds=%s" % streamIds)
     2148    write("streamFiles=%s" % streamFiles)
    21512149
    21522150    # choose which streams we need
    21532151    video, audio1, audio2 = selectStreams(folder)