]> git.sesse.net Git - mlt/commitdiff
Convert Python examples to new frame method.
authorDan Dennedy <dan@dennedy.org>
Sat, 28 May 2011 07:33:41 +0000 (00:33 -0700)
committerDan Dennedy <dan@dennedy.org>
Sat, 28 May 2011 07:33:41 +0000 (00:33 -0700)
src/swig/python/getimage.py [new file with mode: 0755]
src/swig/python/waveforms.py

diff --git a/src/swig/python/getimage.py b/src/swig/python/getimage.py
new file mode 100755 (executable)
index 0000000..51e042d
--- /dev/null
@@ -0,0 +1,30 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+import mlt
+import sys
+from PIL import Image
+
+# setup
+mlt.Factory.init()
+profile = mlt.Profile('square_pal_wide')
+prod = mlt.Producer(profile, sys.argv[1])
+
+# This builds a profile from the attributes of the producer: auto-profile.
+profile.from_producer(prod)
+
+# Ensure the image is square pixels - optional.
+profile.set_width(int(profile.width() * profile.sar()))
+profile.set_sample_aspect(1, 0)
+
+# Seek to 10% and get a Mlt frame.
+prod.seek(int(prod.get_length() * 0.1))
+frame = prod.get_frame()
+
+# And make sure we deinterlace if input is interlaced - optional.
+frame.set("consumer_deinterlace", 1)
+
+# Now we are ready to get the image and save it.
+size = (profile.width(), profile.height())
+rgb = frame.get_image(mlt.mlt_image_rgb24, *size)
+img = Image.fromstring('RGB', size, rgb)
+img.save(sys.argv[1] + '.png')
index c65fdd7732efc02058847571485032a3f5aad023..e39d0f27e0bf67062825e9ed277d25362f0b39b9 100755 (executable)
@@ -9,6 +9,6 @@ prod = mlt.Producer(profile, 'test.wav')
 size = (320, 240)
 for i in range(0, prod.get_length()):
   frm = prod.get_frame()
-  wav = mlt.frame_get_waveform(frm, size[0], size[1])
+  wav = frm.get_waveform(size[0], size[1])
   img = Image.fromstring('L', size, wav)
   img.save('test-%04d.pgm' % (i))