Click to See Complete Forum and Search --> : Text to AVI


egarcia8484
June 16th, 2006, 04:19 PM
Hi!
I need to write some text to the frames of an AVI file;
(The video will play and the image will show some text plus the original image)
Anyone knows how to do it?

Thanks in advance :wave:

Volantiz
June 17th, 2006, 08:30 AM
How do you draw the AVI? Manually? DirectShow? Something else?

egarcia8484
June 20th, 2006, 11:24 AM
I have a capture board (a frame grabber) that captures at 25 fps from an analog video camera. Then I compress the frames using Morgan's MJPEG Codec. That is the way I produce the AVI Files.
Once created I must open them and draw some text on it; to identify each video, before saving it somewhere or delivering to the customer.
I still haven't achivied it... (the text part), any help?

:wave:

macklin01
June 21st, 2006, 03:50 PM
This won't be C++-based, but I'd just use VirtualDub. (http://www.virtualdub.org.) It's an open-source program for editing AVI files, and in particular, you can add a watermark or logo (such as some copyright text, or a video name) to a movie. I believe you can do this as

Video -> Filters ... -> Add ... -> logo

Then, choose an image (of the same size as your frames) that contains your image. You may need to make a second copy of your image in white/black to use as alpha. (So that it only copies the text onto the frames, and not the whole image.)

An alternative (but a little tougher) way to do it is to use some stuff I've written. If you can get the individual frames as a sequence of bmp files, you could draw the text onto an extra image file (say as white text on an all-black image), and then selectively copy all the white text onto the image. You could readily do this with a simple EasyBMP (http://easybmp.sourceforge.net) program, for instance.

I could add support to EasyBMPtoAVI (http://easybmptoavi.sourceforge.net) to overlay an image, too, I suppose. (I hadn't thought of that until I read your post.)

Please let me know if you need any more help, and best wishes. -- Paul

egarcia8484
June 22nd, 2006, 03:49 PM
Thanks for your help. I have solved it. I simply decompress the frames, then use the GDI functions to write the text and finally recompress it. If someone needs the code just ask!

:wave:

macklin01
June 23rd, 2006, 08:45 AM
Ah, thanks for the follow-up! :)

I always appreciate seeing code to learn from, since I tend not to program in win32. (More of a cross-platform guy myself.) Thanks :) -- Paul

egarcia8484
June 26th, 2006, 04:15 PM
I now have another problem, maybe you can help me (Or anyone!!!):
I am compressing with the Cinepak Codec. The idea is to use a codec that anyone would have already installed... and that one seems to be pretty "universal" (is installed by default with Windows). The problem is that it takes really a long time to compress... something like 1 second per frame!!! Am I doing something wrong or is it the codec???

See ya and thanks again for your help,
:wave:

macklin01
June 27th, 2006, 09:41 AM
Hmmm, that's strange. You don't have anything unusual going on, like extra-large frames or anything like that, do you?

I actually don't ever compress on my own (aside through using VirtualDub), so I can't really speak on optimizing GDI calls. However, posting your code for the compression function calls could be helpful, and maybe somebody else here could chime in and help! :)

Have you tried another codec to see if it is just Cinepak? Depending upon your intended audience and application, it may not be too much to ask to use another codec, such as DivX or xvid, and post links for the codec download alongside your content.

What kind of settings are you using for compression? Also, does it make a difference if you change the dimensions of the frame? (e.g., so that the width and/or height are divisible by 4?)

Lastly, as an experiment, you might consider not compressing the frames and using a secondary application like virtualdub to do the compression. If it's substantially faster, then you probably have problems with the implementation, and if not, then it's probably the codec. :)

Best of luck! -- Paul

egarcia8484
June 27th, 2006, 01:43 PM
Thanks! That was a good idea; indeed the VirtualDub compresses just like my code so I guess I can't be to wrong... :D

There is nothing else to do...

:wave:

PS: I read you are studying for your Ph.D. ("Estudiando para el doctorado" en espaņol). I am studying Physics here in Rosario, Argentina and I hope I get my Ph.D. someday :) So good luck!!! :)

macklin01
June 30th, 2006, 11:46 AM
Thanks! That was a good idea; indeed the VirtualDub compresses just like my code so I guess I can't be to wrong... :D

There is nothing else to do...

:wave:

PS: I read you are studying for your Ph.D. ("Estudiando para el doctorado" en espaņol). I am studying Physics here in Rosario, Argentina and I hope I get my Ph.D. someday :) So good luck!!! :)

Good luck in your studies! It's a long road to the Ph.D., but well worthwhile. :) Thanks for the Spanish translation, btw. I don't see phrases quite like those on Univsion y Telemunde here in Southern California. ;) (Not that I speak Spanish, but I like to try to understand TV every now and then.) -- Paul