This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: plat-mac/videoreader.py not working on OS X
Type: Stage:
Components: macOS Versions: Python 2.6, Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: jackjansen Nosy List: dinu_gherman, jackjansen, ronaldoussoren
Priority: normal Keywords:

Created on 2004-02-20 08:52 by dinu_gherman, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
getMovieInfo.py dinu_gherman, 2004-02-20 08:52 Sample script for extracting first image frame of a movie
Messages (3)
msg20072 - (view) Author: Dinu C. Gherman (dinu_gherman) Date: 2004-02-20 08:52
plat-mac/videoreader.py uses modules like "img" which 
used to be in Mac OS 9 builds, but are no longer in OS X 
builds. I suggest replacing the pieces with code writing 
images using PIL, if available.

The critical new pieces (whithout checks for PIL) in methods 
ReadVideo/_getpixmapcontent are:

#-----------------------------
from PIL import Image
...
# convert from ARGB to RGBA (faster/better anyone?)
data = []
for i in xrange(0, width*height*4, 4):
        a, r, g, b = rv[i:i+4]
        data.append(r + g + b + a)
data = ''.join(data)
# save image using PIL
img = Image.fromstring("RGBA", (width, height), data)
img.save(<<some filename>>+".jpg", "JPEG")
#-----------------------------

See also my posting on the pythonmac list and its attached 
script:

http://mail.python.org/pipermail/pythonmac-sig/2004-
February/010282.html

or see the attached file (which does not do exactly the same 
as videoreader.py!)...

Dinu

PS: This is on Py 2.3.3 on Mac OS X 10.2.8...
msg20073 - (view) Author: Dinu C. Gherman (dinu_gherman) Date: 2004-02-21 17:09
Logged In: YES 
user_id=12190

Also note that a using ''.join() as in the function I'm using below is 
much faster than repeated string concatenation as in 
videoreader.py:

def convertPixmapToARGB(pixmap, width, height):
    rowbytes = Qdoffs.GetPixRowBytes(pixmap)
    start = 0
    rv = []
    getBytes = Qdoffs.GetPixMapBytes
    for i in xrange(height):
        nextline = getBytes(pixmap, start, width*4)
        start = start + rowbytes
        rv.append(nextline)
    rv = ''.join(rv)
    return rv
msg78803 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-01-02 14:46
Fixed in r68158.
History
Date User Action Args
2022-04-11 14:56:02adminsetgithub: 39959
2009-01-02 14:46:39ronaldoussorensetstatus: open -> closed
nosy: + ronaldoussoren
resolution: fixed
messages: + msg78803
2008-01-05 18:10:10christian.heimessetversions: + Python 2.6, Python 2.5
2004-02-20 08:52:02dinu_ghermancreate