By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,352 Members | 1,593 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,352 IT Pros & Developers. It's quick & easy.

Python Video processing.

P: n/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?)?

Jun 13 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Ant" <an****@gmail.com> wrote:
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/pi...book/image.htm

hope this helps!

</F>

Jun 13 '06 #2

P: n/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...

Jun 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.