Hi,
I'm using pymedia to build a movie from pictures. I use a modified version
of the standard example given everywhere, with python2.4 and pymedia 1.3.7.3
The issue is that I can't choose the size of my movie.
When I use a resolution of 640x480, it actually build a movie, but tend to
cut some part of my pictures(as they are 800x600).
If I try to build a 800x600 movie, it at first seems to build something, but
when I launch it, the player closes as soon as it opens without playing the
movie.
I get my encoder by calling e = getEncoder("mpeg2video", 480, 640) with:
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 )
then use this method:
def joinFrames(file_list, frame_size, encoder, file_dest):
t= time.time()
for img in file_list:
add_one_frame(img, frame_size, encoder, file_dest)
nb = len(file_list)
print '%d frames written in %.2f secs( %.2f fps )' % ( nb, time.time()-
t, float( nb )/ ( time.time()- t ) )
return file_dest
to eventually finish with this:
def add_one_frame(img, (h, w), encoder, file_dest):
# print img
assert h%2==0 , "height must be a multiple of 2"
assert w%2==0 , "width must be a multiple of 2"
s = pygame.image.load(img)
ss = pygame.image.tostring(s, "RGB")
# print "pygame stuff done"
bmpFrame = vcodec.VFrame( vcodec.formats.PIX_FMT_RGB24, (w, h),
(ss,None,None))
# print "bmpframe created"
yuvFrame = bmpFrame.convert( vcodec.formats.PIX_FMT_YUV420P, (640,480) )
# print "yuvframe created"
d = encoder.encode( yuvFrame )
file_dest.write( d.data )
The issue seems to be here. If I understand well, Vframe.convert should get
the frame at the right size. It never does, yuvframe always keeps having
the size of bmpFrame. And this way, a part of my picture is cut. I would
prefer to use another size for the movie, but when I change the size for the
encoder and the convert function, the movie doesn't work.
I haven't been able to find a solution to my problem, so I thought I could
maybe ask some help.
--
View this message in context:
http://www.nabble.com/video-resolution-issue-tp15542917p15542917.html
Sent from the pymedia-users mailing list archive at Nabble.com.
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Pymedia-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/pymedia-users