Speed up Image Manipulation if only 2% affected
Posted: 2012-09-03T11:53:37-07:00
Hello!
I have an internet project which creates videos on the fly with individual inputs like images which are displayed in the video. Until now I realized this basing on flash technology because I could do a lot of video manipulation on client side. But now I need a h.264 solution what means that I must render and encode a 60 seconds clip (25 fps, 640x360) in less than 2 seconds on server side. The sources for the video are 1,500 images (jpg or else). One image for every frame. It is a question of less than a second to encode this 1,500 images with IM into a h.264 video clip (wow!). The perfomance issue is elsewhere: I have to manipulate this 1,500 images before I can encode them to the video. And I couldn't find a solution which is fast enough. The fastest was 50 seconds. But it must be MUCH faster! The point is that the special way of image manipulation I need in my imagination does not really need a complete new image rendering but obviously IM does it anyway. For every single image I need to paste a small image onto it to a given x,y coordinates. The image size and the coordinates are different for every small image which must be pasted to the large images each but this parameters are always the same for every process of rendering the 1,500 source images. (I mean, if i.e. the small image is 80x62 and must be paste with the left top edge to x=112, y=80 on source image number 423, then in every other video generation process the small image is sized and positioned all the same to source image number 423. The only difference is what the small image shows)
So, only about 2% of the image surface is changed in every source image but IM obviously renders also the other 98%. Does anyone has an idea or knows a trick how to render only the necessary part of the source images which is changed? I also tried to paste together the source image with a transparent area with another same sized image where the small image is overlaying the transparent area of the source image (composite -compose In) trusting that IM quit rendering all other area than the transparent one but obvioulsy it renders the complete image.
Or is the problem not in the rendering process but in the way of sequential batch processing in a loop? All source and target images are stored in a RAM disk so there cannot be a problem with i/o access timing.
Best regards from Germany
Marc
I have an internet project which creates videos on the fly with individual inputs like images which are displayed in the video. Until now I realized this basing on flash technology because I could do a lot of video manipulation on client side. But now I need a h.264 solution what means that I must render and encode a 60 seconds clip (25 fps, 640x360) in less than 2 seconds on server side. The sources for the video are 1,500 images (jpg or else). One image for every frame. It is a question of less than a second to encode this 1,500 images with IM into a h.264 video clip (wow!). The perfomance issue is elsewhere: I have to manipulate this 1,500 images before I can encode them to the video. And I couldn't find a solution which is fast enough. The fastest was 50 seconds. But it must be MUCH faster! The point is that the special way of image manipulation I need in my imagination does not really need a complete new image rendering but obviously IM does it anyway. For every single image I need to paste a small image onto it to a given x,y coordinates. The image size and the coordinates are different for every small image which must be pasted to the large images each but this parameters are always the same for every process of rendering the 1,500 source images. (I mean, if i.e. the small image is 80x62 and must be paste with the left top edge to x=112, y=80 on source image number 423, then in every other video generation process the small image is sized and positioned all the same to source image number 423. The only difference is what the small image shows)
So, only about 2% of the image surface is changed in every source image but IM obviously renders also the other 98%. Does anyone has an idea or knows a trick how to render only the necessary part of the source images which is changed? I also tried to paste together the source image with a transparent area with another same sized image where the small image is overlaying the transparent area of the source image (composite -compose In) trusting that IM quit rendering all other area than the transparent one but obvioulsy it renders the complete image.
Or is the problem not in the rendering process but in the way of sequential batch processing in a loop? All source and target images are stored in a RAM disk so there cannot be a problem with i/o access timing.
Best regards from Germany
Marc