[mythtvnz] mythburn.py stream order
Brett
mythicalbeast at slingshot.co.nz
Mon Nov 1 05:09:25 GMT 2010
More appropriately attached as a diff file suitable for patch (I think)
-------------- next part --------------
--- mythburn.py.original 2010-10-30 22:16:45.161504188 +1300
+++ mythburn.py 2010-11-01 18:00:11.214911201 +1300
@@ -2385,6 +2385,7 @@
#make sure we get the correct stream(s) that we want
command += " -map 0:%d -map 0:%d " % (video[VIDEO_INDEX], audio1[AUDIO_INDEX])
+
if audio2[AUDIO_ID] != -1:
command += "-map 0:%d" % (audio2[AUDIO_INDEX])
@@ -4262,6 +4263,9 @@
AUDIO_ID = 2
AUDIO_LANG = 3
+AUDIO_LATM = "LIBFAAD_LATM"
+INDEX_TYPE = "streamindex" # "ffmpegindex"
+
def selectStreams(folder):
"""Choose the streams we want from the source file"""
@@ -4275,7 +4279,6 @@
if infoDOM.documentElement.tagName != "file":
fatalError("This does not look like a stream info file (%s)" % os.path.join(folder, 'streaminfo.xml'))
-
#get video ID, CODEC
nodes = infoDOM.getElementsByTagName("video")
if nodes.length == 0:
@@ -4285,13 +4288,15 @@
if nodes.length > 1:
write("Found more than one video element in stream info file.!!!")
node = nodes[0]
- video = (int(node.attributes["ffmpegindex"].value), node.attributes["codec"].value, int(node.attributes["id"].value))
+ video = (int(node.attributes[INDEX_TYPE].value), node.attributes["codec"].value, int(node.attributes["id"].value))
+
+ write("video stream indexes: ffmpegindex %s streamindex %s" % (node.attributes["ffmpegindex"].value, node.attributes["streamindex"].value))
#get audioID's - we choose the best 2 audio streams using this algorithm
# 1. if there is one or more stream(s) using the 1st preferred language we use that
# 2. if there is one or more stream(s) using the 2nd preferred language we use that
# 3. if we still haven't found a stream we use the stream with the lowest PID
- # 4. we prefer ac3 over mp2
+ # 4. we prefer ac3 over AUDIO_LATM
# 5. if there are more that one stream with the chosen language we use the one with the lowest PID
write("Preferred audio languages %s and %s" % (preferredlang1, preferredlang2))
@@ -4306,7 +4311,7 @@
found = False
# first try to find a stream with ac3 and preferred language 1
for node in nodes:
- index = int(node.attributes["ffmpegindex"].value)
+ index = int(node.attributes[INDEX_TYPE].value)
lang = node.attributes["language"].value
format = string.upper(node.attributes["codec"].value)
pid = int(node.attributes["id"].value)
@@ -4318,14 +4323,14 @@
audio1 = (index, format, pid, lang)
found = True
- # second try to find a stream with mp2 and preferred language 1
+ # second try to find a stream with AUDIO_LATM and preferred language 1
if not found:
for node in nodes:
- index = int(node.attributes["ffmpegindex"].value)
+ index = int(node.attributes[INDEX_TYPE].value)
lang = node.attributes["language"].value
format = string.upper(node.attributes["codec"].value)
pid = int(node.attributes["id"].value)
- if lang == preferredlang1 and format == "MP2":
+ if lang == preferredlang1 and format == AUDIO_LATM:
if found:
if pid < audio1[AUDIO_ID]:
audio1 = (index, format, pid, lang)
@@ -4333,17 +4338,17 @@
audio1 = (index, format, pid, lang)
found = True
- # finally use the stream with the lowest pid, prefer ac3 over mp2
+ # finally use the stream with the lowest pid, prefer ac3 over AUDIO_LATM
if not found:
for node in nodes:
- index = int(node.attributes["ffmpegindex"].value)
+ index = int(node.attributes[INDEX_TYPE].value)
format = string.upper(node.attributes["codec"].value)
pid = int(node.attributes["id"].value)
if not found:
audio1 = (index, format, pid, lang)
found = True
else:
- if format == "AC3" and audio1[AUDIO_CODEC] == "MP2":
+ if format == "AC3" and audio1[AUDIO_CODEC] == AUDIO_LATM:
audio1 = (index, format, pid, lang)
else:
if pid < audio1[AUDIO_ID]:
@@ -4354,7 +4359,7 @@
found = False
# first try to find a stream with ac3 and preferred language 2
for node in nodes:
- index = int(node.attributes["ffmpegindex"].value)
+ index = int(node.attributes[INDEX_TYPE].value)
lang = node.attributes["language"].value
format = string.upper(node.attributes["codec"].value)
pid = int(node.attributes["id"].value)
@@ -4369,11 +4374,11 @@
# second try to find a stream with mp2 and preferred language 2
if not found:
for node in nodes:
- index = int(node.attributes["ffmpegindex"].value)
+ index = int(node.attributes[INDEX_TYPE].value)
lang = node.attributes["language"].value
format = string.upper(node.attributes["codec"].value)
pid = int(node.attributes["id"].value)
- if lang == preferredlang2 and format == "MP2":
+ if lang == preferredlang2 and format == AUDIO_LATM:
if found:
if pid < audio2[AUDIO_ID]:
audio2 = (index, format, pid, lang)
@@ -4384,7 +4389,7 @@
# finally use the stream with the lowest pid, prefer ac3 over mp2
if not found:
for node in nodes:
- index = int(node.attributes["ffmpegindex"].value)
+ index = int(node.attributes[INDEX_TYPE].value)
format = string.upper(node.attributes["codec"].value)
pid = int(node.attributes["id"].value)
if not found:
@@ -4393,18 +4398,19 @@
audio2 = (index, format, pid, lang)
found = True
else:
- if format == "AC3" and audio2[AUDIO_CODEC] == "MP2" and pid != audio1[AUDIO_ID]:
+ if format == "AC3" and audio2[AUDIO_CODEC] == AUDIO_LATM and pid != audio1[AUDIO_ID]:
audio2 = (index, format, pid, lang)
else:
if pid < audio2[AUDIO_ID] and pid != audio1[AUDIO_ID]:
audio2 = (index, format, pid, lang)
- write("Video id: 0x%x, Audio1: [%d] 0x%x (%s, %s), Audio2: [%d] - 0x%x (%s, %s)" % \
- (video[VIDEO_ID], audio1[AUDIO_INDEX], audio1[AUDIO_ID], audio1[AUDIO_CODEC], audio1[AUDIO_LANG], \
+ write("Video id: [%d] 0x%x (%s), Audio1: [%d] 0x%x (%s, %s), Audio2: [%d] - 0x%x (%s, %s)" % \
+ (video[VIDEO_INDEX], video[VIDEO_ID], video[VIDEO_CODEC], \
+ audio1[AUDIO_INDEX], audio1[AUDIO_ID], audio1[AUDIO_CODEC], audio1[AUDIO_LANG], \
audio2[AUDIO_INDEX], audio2[AUDIO_ID], audio2[AUDIO_CODEC], audio2[AUDIO_LANG]))
return (video, audio1, audio2)
-
+
#############################################################
# chooses which subtitle stream from a file to include on the DVD
More information about the mythtvnz
mailing list