Python Video processing.

A

Ant

Hi all,

I have a specific task I want to automate - rotating a video file
through 90 degrees.

I've used the PIL library quite a bit to perform batch processing on
images, and would like to do similar on video. Can anyone see a problem
with the following:

1) Use pymedia to convert the video into a sequence of stills (e.g.
http://pymedia.org/tut/src/dump_video.py.html)
2) Use PIL to process each still
3) Use pymedia to re-pack the still into video format.

In particular, does anyone know whether the data obtained from decoding
the video frame as in the following snippet from
http://pymedia.org/tut/src/dump_video.py.html:

dd= d.convert( fmt )
img= pygame.image.fromstring( dd.data, dd.size, "RGB" )

can be directly loaded into a PIL Image object (and back again?)?
 
F

Fredrik Lundh

Ant said:
In particular, does anyone know whether the data obtained from decoding
the video frame as in the following snippet from
http://pymedia.org/tut/src/dump_video.py.html:

dd= d.convert( fmt )
img= pygame.image.fromstring( dd.data, dd.size, "RGB" )

can be directly loaded into a PIL Image object (and back again?)?

iirc, the pygame fromstring/tostring methods are designed to be data-compatible
with PIL's corresponding methods, so you should be able to do

im = Image.fromstring("RGB", dd.size, dd.data)

instead of doing that pygame.image call (not that the argument order is different).

for details, see the pygame tostring/fromstring docs, and the corresponding PIL
methods:

http://www.pygame.org/docs/ref/image.html
http://www.pythonware.com/library/pil/handbook/image.htm

hope this helps!

</F>
 
A

Ant

im = Image.fromstring("RGB", dd.size, dd.data)
instead of doing that pygame.image call (not that the argument order is different).

for details, see the pygame tostring/fromstring docs, and the corresponding PIL
methods:

That's starting to look promising, yes - thanks! I'll give it a shot
this evening and see what happens...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,010
Latest member
MerrillEic

Latest Threads

Top