[mythtv-users] User script that takes cutlist & runs project-x?
Kingsley Turner
krt at krt.com.au
Thu Jul 15 23:58:09 UTC 2010
On 05/07/10 02:04, John Pilkington wrote:
> Or you might like to look at
>
> http://www.mythtv.org/wiki/Mythcutprojectx, which does the job for mpeg2
> recordings but needs user intervention to select the desired audio
> stream.
Here's a code snippet I wrote that takes the project-x demux output (and
log), and finds the English audio track. Perhaps it might be useful to someone.
###
### Try to read the De-multiplexing log, and find the english audio track
###
def findEnglishAudioTrack(tmp):
english_audio = ''
logs = glob.glob(tmp+'/*.txt')
if (len(logs) >= 1):
log_filename = logs[0] ### Should only be one
wood = ''
try:
fin = open(log_filename,"r")
log_data = fin.read()
fin.close()
except:
sys.stderr.write(" Failed to open Log\n");
### Looking for something like:
### Video:
### PID: 0xA1(#1)
### Audio:
### PID: 0x54(#2)(fra)
### PID: 0x55(#3)(eng) <--- LOOKING FOR THIS!
### PID: 0x56(#4)(mul)
### Teletext:
### PID: 0x31(#5)(fra_i100 fra_s777 )
### Subpict.:
### n/a
english_pid = None
try:
wood = log_data.split('Audio:',1)[1]
wood = wood.split('Teletext:',1)[0]
wood = wood.split('PID: ')
for i in range(0,len(wood)):
if (wood[i].find('(eng)') != -1):
english_pid = wood[i].split('(eng)')[0].strip()
sys.stdout.write(" English Audio Track at PID
#"+english_pid+"\n")
break
except:
sys.stdout.write(" Failed to examine track list ... using first
audio track\n")
if (english_pid != None):
wood = log_data.split('\n')
### Try to find the descriptor for PID <english_pid>
### Which is like:
### --> MPEG Audio (0xC3) on PID 0x5D
for i in range(len(wood)):
if (wood[i].strip().endswith("on PID "+english_pid)):
### We have found the start of the block, now search for
the end
### Which is like:
### ---> new File:
'/tmp/repairDVB.2008-12-27_11:25:34.13760.tmp/Blah.mp2'
for j in range(i,len(wood)):
if (wood[j].strip().find("new File:") != -1):
english_audio = wood[j].split("'")[1]
sys.stdout.write(" English Audio is
'"+english_audio+"'\n")
break
if (english_audio != ''):
break # already found
#print "RETURNING AUDIO FILE is ["+english_audio+"]"
return english_audio
More information about the mythtv-users
mailing list