Mega Search
23.2 Million


Sign Up

Make a donation  
Is it possible to create a video file of bitmaps on the fly?  
News Group: embarcadero.public.delphi.multimedia

I hope the title is sufficient to give some sort of an idea of what I would like to do.  I have tried to do a search, but can't get anything useful.  Putting the term "during program execution" just brings up lots of videos, but a different sort of execution :-(

Anyway, I would like to experiment with creating a video of scrolling text by creating a bitmap of the text moving one pixel in each frame and then combining them into some sort of video file (avi, wmv etc) and playing it back to give a smooth text scroll.  My thoughts are to create a series of bitmaps when the text is first placed onto the form, each one representing the text appearance after a scroll of one pixel.  This should be quite quick to create, perhaps several hundred milliseconds.  I can then p
lace the video in the appropriate position and play it back, the scrolling should then be independent of any other processes the code is executing, at least as smooth as a normal video.  

Ultimately this may proove a waste of time, but I would like to see what the result looks like.  I have experimented with using the multimedia timer (as some earlier posts will attest), but the scrolling is still not as smooth as we would like, although MUCH better than using a TTimer (which was the first thought)!

Vote for best question.
Score: 0  # Vote:  0
Date Posted: 2-Jul-2012, at 9:24 PM EST
From: Trevor Hand
 
Re: Is it possible to create a video file of bitmaps on the  
News Group: embarcadero.public.delphi.multimedia
Further investigation:

Windows Media player says "...might not support the file type or the codec used to compress the file.".

When I created the avi file I did not select any compression.  If I try to add compression it says it is unable to open the temp file, I tried this with several choices and ended up with the same error.

I am using XE on W7 if that helps.


> {quote:title=Trevor Hand wrote:}{quote}
> I managed to find a Delphi component AviWriter_2 that looked promising, created an avi of a series of 474 bitmaps but when I tried to play the file just to see what the result looks like, it said the file was either corrupt or had a problem with a codec or something....grrrr!  I started to get excited too :-(  
> 
> Still searching, but haven't turned up anything yet.  Does anyone use something like this?
> 
> 
> 
> > {quote:title=Trevor Hand wrote:}{quote}
> > I hope the title is sufficient to give some sort of an idea of what I would like to do.  I have tried to do a search, but can't get anything useful.  Putting the term "during program execution" just brings up lots of videos, but a different sort of execution :-(
> > 
> > Anyway, I would like to experiment with creating a video of scrolling text by creating a bitmap of the text moving one pixel in each frame and then combining them into some sort of video file (avi, wmv etc) and playing it back to give a smooth text scroll.  My thoughts are to create a series of bitmaps when the text is first placed onto the form, each one representing the text appearance after a scroll of one pixel.  This should be quite quick to create, perhaps several hundred milliseconds.  I can th
en place the video in the appropriate position and play it back, the scrolling should then be independent of any other processes the code is executing, at least as smooth as a normal video.  
> > 
> > Ultimately this may proove a waste of time, but I would like to see what the result looks like.  I have experimented with using the multimedia timer (as some earlier posts will attest), but the scrolling is still not as smooth as we would like, although MUCH better than using a TTimer (which was the first thought)!

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 3-Jul-2012, at 1:36 AM EST
From: Trevor Hand
 
Re: Is it possible to create a video file of bitmaps on the  
News Group: embarcadero.public.delphi.multimedia
Yep, the bitmap size and other things are set in the code, I took all of this out of the snippet to try to show the "essence" of what I am doing.  I have slightly modified the code I have created with the help of yourself and a couple of other gurus from other earlier posts.  I found a utility called "Cecil_B" that allows me to create an avi file of the bitmaps and this works with them, however, I would like to be able to create the avi on the fly from inside the code as the text displayed and background 
can change every time it is displayed (it may contain an RSS feed for example).  It doesn't really matter if the avi is compressed or not as the file is only created once, played and then deleted.  I would expect that no compression would be faster to create....less "thinking" for the cpu?  

I would like to compare the smoothness of the "TimeSetEvent" and bitmap writing etc to a video file of the same thing.  Ultimately the text could be a foot high or more and so any jerkiness may become more obvious than when looking at it on a monitor, plus it is a bit of an experiment in "thinking outside the square" I guess :-)


> {quote:title=Tom Brunberg wrote:}{quote}
> Trevor Hand wrote:
> 
> > I haven't done anything in the code to ensure anything about the bitmaps is set, so I will have
> > to investigate what they are stored as.  Is there a property of TBitMap that will set the color
> > depth?
> 
> Yes. PixelFormat
> TBitMap.pixelformat := pf24bit;
> for 24 -bit
> 
> > Essentially, the code to create the bitmaps is this (there is other code to set the size of the
> > bitmap, rectangles and lock the canvases which I have removed).  I call this to scroll the text
> > by one pixel so I end up with 474 numbered bitmaps.  I expect that if I create the series on the
> > fly and never actually display them, I may be able to simplify the code somewhat.  At the moment
> > I would like to create an avi which I can play alongside the scrolling label to see how they
> > compare for "smoothness".
> > 
> > bmpBackground := TBitMap.Create;  
> > inc(iImageNumber);   
> > bmpBackground.Canvas.CopyRect(rectDestinationImage, Form.Canvas, rectSourceImage);
> > bmpBackground.Canvas.TextOut(lblScrolling.Left, 0, lblScrolling.Caption);//write the text
> > bmpBackground.SaveToFile('C:\Temp\BackgroundBitmap' + IntToStr(iImageNumber) + '.bmp');
> > dec(lblScrolling.Left);
> > FreeAndNil(bmpBackground);
> 
> You also need to set the size of the bitmap:
> bmpBackground.SetZize(width, height);
> 
> 
> Cheers
> Tom
> 
> 
> 
> -- 
> Tom Brunberg
> firstname.surname@welho.com

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 4-Jul-2012, at 12:11 AM EST
From: Trevor Hand
 
Re: Is it possible to create a video file of bitmaps on the  
News Group: embarcadero.public.delphi.multimedia
I tried putting the bitmaps into an image list and attaching the list to a Jedi BmpAnimator.  The scrolling looked good at first, but after a few seconds the background started to flicker with a background color, even if I set the animator to transparent and setting the form to double buffered didn't helpl.  This was bringing back memories of my original attempts at creating a scrolling text label...been there already and I don't want to go there again!

I also tried opening the avi from AviWriter in a TAnimate and it refused to co-operate :-(

> {quote:title=David Taylor wrote:}{quote}
> "Trevor Hand" wrote in message news:482531@forums.embarcadero.com...
> 
> I have changed the pixel format to pf24, it would have been the default 
> before then.  If I select no compression, it creates the avi file but I 
> cannot play it.  I tried a few compression settings and they all seem to 
> return the same error, unable to open the temp file error 80040154.  A 
> search on this error code brings up several hits, COM class error or class 
> not registered error.
> 
> I am using the demo app that came with the download.  Once I can get this 
> working I can decide if creating an avi on the fly is suitable and I would 
> add the class to my code and run it directly.  Is there anything in the demo 
> that may be causing a problem?
> ================================================
> 
> Very strange that an AVI file with no compression can't be played.  The only 
> time I saw that was when I was using an 8-bit BMP with a colour palette - 
> and the support was left of of Vista SP0 for that format.  I would suggest a 
> couple of basic checks - is the size of the AVI file what you expect - 
> something just greater than the sum of the bitmaps? 
> (n_bitmap*3*height*width).  Can you post the AVI file somewhere?
> 
> Whilst I've not tried it, I wonder what simply zapping the individual 
> bitmaps onto a TImage might be.  Double-buffered, perhaps?
> 
> Cheers,
> David

Vote for best answer.
Score: 0  # Vote:  0
Date Posted: 5-Jul-2012, at 8:26 PM EST
From: Trevor Hand