Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Browse files

Fix the simple example so that it can be executed from anywhere

  • Loading branch information...
commit 0ef8dbe094122732426780dc709cc5c0a7b94b23 1 parent 24c1b8d
Nicolas Pinto authored
Showing with 9 additions and 4 deletions.
  1. +9 −4 examples/
13 examples/
@@ -1,13 +1,18 @@
import pyffmpeg
import Image
+import os
+mypath = os.path.dirname(os.path.realpath(__file__)) + '/'
+video_fname = os.path.join(mypath, 'myvideo.flv')
stream = pyffmpeg.VideoStream()'myvideo.flv')
# Get the first frame as a PIL image
image = stream.GetFrameNo(0)
print "Retrivied frame number 0 from the video stream as PIL Image"
# Save it to a PNG file'firstframe.png'), 'firstframe.png'))
print "Saved to firstframe.png."
# Change the frame format to numpy.
@@ -26,7 +31,7 @@
# Convert the numpy array into a PIL image.
image = Image.frombuffer("RGB",nimage.shape[0:2],,"raw","RGB",nimage.shape[0] * nimage.shape[2],1)
# Save it to a PNG file as well'numpy_frame.png'), 'numpy_frame.png'))
print "Wrote numpy frame to numpy_frame.png by converting to PIL image"
# And now a cairo image surface
@@ -35,7 +40,7 @@
surf = stream.GetFrameNo(128)
print "Got cairo surface with type %s" % type(surf)
+surf.write_to_png(os.path.join(mypath, "cairo_frame.png"))
print "Wrote to file cairo_frame.png using write_to_png()"
Please sign in to comment.
Something went wrong with that request. Please try again.