[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] pygame parachut/coredump on pygame image load.



what os is this? windows?

----------------------------------
If you wanna try and investigate further, I would suggest changing
add_one_frame like this:

def add_one_frame(img, encoder, file_dest):
   print "loading",img
   s = pygame.image.load(img)
   print "converting",s,"to string"
   ss = pygame.image.tostring(s, "RGB")
   print "adding frame"
   bmpFrame = vcodec.VFrame( vcodec.formats.PIX_FMT_RGB24,
s.get_size(), (ss,None,None))
   yuvFrame = bmpFrame.convert( vcodec.formats.PIX_FMT_YUV420P )
   d = encoder.encode( yuvFrame )
   file_dest.write( d.data )

then when it crashes/segfaults/parachuts, you'll be able to see
whether it threw a segfault on the load or on the tostring and on
which specific image it crashed on. Once you know which image, you can
try running it with just that one image and see if it crashes (so
you'd find out if it's something about the sequence of images or
something about specific images). If it's just a specific image, than
you could post the image to the list so somebody who can build pygame
from source can test it out, and narrow it down even more

---

If you just want to get things working, you could maybe try a
different file format (batch convert with photoshop or gimp or
something?), or maybe try updating the sdl_image dll to the latest
from libsdl.org, or possibly try some python image loader/processor
like PIL

On Dec 13, 2007 6:26 AM, Lionel Barret De Nazaris <lionel.bdn@xxxxxxx> wrote:
> Hi all,
>
> I am trying to join BMPs into one nice mpg and pygame do the parachute
> thing to me.
>
> It's quite puzzling because the first image is processed, but it crashes
> just after that...
>
> Any idea ? The images are over 4000 but I don't see how that could
> affect this code or cause this core dump...
>
> Lionel
> ----
>
> #! /bin/env python
> import sys, os, time
> import pygame
> import pymedia.video.vcodec as vcodec
> import glob
> from pprint import pprint
>
> def getEncoder(outCodec, height, width):
>     if outCodec== 'mpeg1video':
>         bitrate= 2700000
>     else :
>         bitrate= 9800000
>     #==
>     params= { \
>       'type': 0,
>       'gop_size': 12,
>       'frame_rate_base': 125,
>       'max_b_frames': 0,
>       'height': height,
>       'width': width,
>       'frame_rate': 2997,
>       'deinterlace': 0,
>       'bitrate': bitrate,
>       'id': vcodec.getCodecID( outCodec )
>     }
>     return vcodec.Encoder( params )
>
> def fileList(patterns):
>     return glob.glob(patterns)
>
> def add_one_frame(img, encoder, file_dest):
>     s = pygame.image.load(img)
>     ss = pygame.image.tostring(s, "RGB")
>     bmpFrame = vcodec.VFrame( vcodec.formats.PIX_FMT_RGB24,
> s.get_size(), (ss,None,None))
>     yuvFrame = bmpFrame.convert( vcodec.formats.PIX_FMT_YUV420P )
>     d = encoder.encode( yuvFrame )
>     file_dest.write( d.data )
>
> def joinFrames(file_list, encoder, file_dest):
>     start_time= time.time()
>     for img in file_list:
>         add_one_frame(img, encoder, file_dest)
>     nb = len(file_list)
>     time_elapsed = time.time() - start_time
>     print '%d frames written in %.2f secs( %.2f fps )' % ( nb,
> time_elapsed, float( nb )/ time_elapsed )
>     return file_dest
>
> def get_size_info(img_path):
>     s = pygame.image.load( img_path )
>     return s.get_height(), s.get_width()
>
> if __name__== '__main__':
>     pass
>     pygame.init()
>     fl = fileList("../../*.bmp")
>     assert fl, "filelist ok"
>     h, w = get_size_info(fl[0])
>     print "size ok"
>     e = getEncoder("mpeg2video", h, w)
>     print "encoder ok"
>     file = open("movie3.mpg", "wb")
>     joinFrames(fl, e, file)
>     file.close()
>     pygame.quit()
>