Hello folks,

I'm new to the list, and just joined to make this request.  I was
writing a python script to convert MKV video files to
iPad/iPod/PS3/360 compatible MP4 files and discovered kaa.metadata.
It's much nicer than parsing the output of mkvinfo - thanks!

The goal of my script is to avoid re-encoding the video where
possible.  One of the things I check is the H.264 Profile and Level to
determine compatibility with the target device
(http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC#Profiles).  For
example, the iPad supports Main Profile Level 3.1
(http://www.apple.com/ipad/specs/), whereas the PS3 supports Main
Profile Level 4.1
(http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC_products_and_implementations#Decoding).
 If the Profile/Level in the source file is too high, I need to
re-encode the video.

Since kaa.metadata.parse() does not provide the codec private data for
video tracks inside MKV containers, I've modified mkv.py on my local
machine to expose it (see diff below).  This seems like a simple way
to allow clients of the API to access this data without adding support
for parsing the private data directly (which is different for each
video codec).  I'd also suggest that the variable name be changed from
"codec_private_id" to "codec_private", but I wanted to keep my changes
minimal.

Hopefully you'll find this useful and incorporate it into
kaa.metadata, so my script can be run by others someday.

Thanks,
Mike.

P.S. I made my change on my Ubuntu box, using the version of
kaa.metadata provided in the standard repository (0.7.7-2).  The
version in SVN looks similar for this section, but I didn't try to
apply it there.

--- mkv.py.orig 2010-08-30 17:41:41.300467825 -0400
+++ mkv.py      2010-09-14 17:15:32.414917557 -0400
@@ -449,10 +449,10 @@

     def process_video_track(self, elements):
         track = core.VideoStream()
-        codec_private_id = ''
         # Defaults
         track.codec = u'Unknown'
         track.fps = 0
+        track.codec_private_id = ''

         for elem in elements:
             elem_id = elem.get_id()
@@ -485,7 +485,7 @@
                     track.aspect = float(d_width) / d_height

             elif elem_id == MATROSKA_CODEC_PRIVATE_ID:
-                codec_private_id = elem.get_data()
+                track.codec_private_id = elem.get_data()

             else:
                 self.process_track_common(elem, track)
@@ -496,8 +496,8 @@
             track.codec = FOURCCMap[track.codec]
         elif '/' in track.codec and track.codec.split('/')[0] + '/'
in FOURCCMap:
             track.codec = FOURCCMap[track.codec.split('/')[0] + '/']
-        elif track.codec.endswith('FOURCC') and len(codec_private_id) == 40:
-            track.codec = codec_private_id[16:20]
+        elif track.codec.endswith('FOURCC') and
len(track.codec_private_id) == 40:
+            track.codec = track.codec_private_id[16:20]
         elif track.codec.startswith('V_REAL/'):
             track.codec = track.codec[7:]
         elif track.codec.startswith('V_'):

------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing.
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
Freevo-devel mailing list
Freevo-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-devel

Reply via email to