[mythtv-users] mythburn.py with cutlist: ERR: Cannot jump to chapter 7 of title 1, only 6 exist
Will Dormann
wdormann at gmail.com
Wed Mar 5 21:09:16 UTC 2014
On 3/5/14, 11:08 AM, Will Dormann wrote:
> On 3/5/14, 10:42 AM, Will Dormann wrote:
>> getLengthOfVideo() is parsing streaminfo.xml to determine the video
>> length, and streaminfo.xml does not reflect the post-cut size:
>> <file duration="21" cutduration="21" type="mpeg"
>> filename="/var/lib/mytharchive/temp/work/1/newfile2.mpg">
>
> Or more specifically, the "cutduration" property gets lost by the time
> it makes it to newfile2.mpg:
Attached is a patch made against mythburn.py with the last patch I
posted
<http://www.mythtv.org/pipermail/mythtv-users/2014-March/361359.html>
applied.
If the filename is "newfile2.mpg", the length of the video is obtained
via streaminfo_orig.xml instead of streaminfo.xml. This way, size
difference applied by the cutting is enabled.
-WD
-------------- next part --------------
--- mythburn.py.mythtranscode 2014-03-03 22:29:43.772490696 -0500
+++ mythburn.py 2014-03-05 15:35:51.395730418 -0500
@@ -605,6 +605,26 @@
duration = 0;
return duration
+
+#############################################################
+# Gets the duration of a video file from its stream info file
+
+def getOrigLengthOfVideo(index):
+ """Returns the length of a video file (in seconds)"""
+
+ #open the XML containing information about this file
+ infoDOM = xml.dom.minidom.parse(os.path.join(getItemTempPath(index), 'streaminfo_orig.xml'))
+
+ #error out if its the wrong XML
+ if infoDOM.documentElement.tagName != "file":
+ fatalError("Stream info file doesn't look right (%s)" % os.path.join(getItemTempPath(index), 'streaminfo_orig.xml'))
+ file = infoDOM.getElementsByTagName("file")[0]
+ if file.attributes["cutduration"].value != 'N/A':
+ duration = int(file.attributes["cutduration"].value)
+ else:
+ duration = 0;
+
+ return duration
#############################################################
# Gets the audio sample rate and number of channels of a video file
@@ -1698,6 +1718,16 @@
# print out the streaminfo.xml file to the log
infoDOM = xml.dom.minidom.parse(xmlFilename)
+ if os.path.basename(filename) == "newfile2.mpg":
+ # This is a newly-written video file, and mytharchivehelper isn't going to find the cutlist
+ write("Obtaining cutlist details from original recording")
+ index = int(os.path.split(os.path.dirname(filename))[-1])
+ cutduration = str(getOrigLengthOfVideo(index))
+ write("Cut duration: %s" % cutduration)
+ file = infoDOM.getElementsByTagName("file")[0]
+ file.attributes['cutduration'].value = cutduration
+ WriteXMLToFile (infoDOM, xmlFilename)
+
write(xmlFilename + ":-\n" + infoDOM.toprettyxml(" ", ""), False)
#############################################################
More information about the mythtv-users
mailing list