Python Video processing.

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ant

    #1

    Python Video processing.

    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


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

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

  • Fredrik Lundh

    #2
    Re: Python Video processing.

    "Ant" <antroy@gmail.c om> wrote:
    [color=blue]
    > 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.fr omstring( dd.data, dd.size, "RGB" )
    >
    > can be directly loaded into a PIL Image object (and back again?)?[/color]

    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.fromstrin g("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.pythonware.com/library/pi...book/image.htm

    hope this helps!

    </F>



    Comment

    • Ant

      #3
      Re: Python Video processing.

      > im = Image.fromstrin g("RGB", dd.size, dd.data)[color=blue]
      >
      > 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:[/color]

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

      Comment

      Working...