Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Compression with VLAVILogger
03-27-2013, 05:37 AM
Post: #1
Compression with VLAVILogger
Hi,

I trying to create AVI files, using the VLRecordedBitmapDemo as example (and using BMDThread instead of TThread). I manage the code in a separate unit so I instantiate the component in code :

VLGenericFilter := TVLGenericFilter.Create(nil);
VLAVILogger := TVLAVILogger.Create(nil);
VLGenericFilter.OutputPin.Connect(VLAVILogger.InputPin);
VLAVILogger.Compression.Enabled := True;

Then I use a similar loop as in the demo to write the frames

while not Thread.Terminated do
begin

// Sync with VCL to get the currenty image
Thread.Synchronize(RecThreadSync);

// Write it to the AVI
// Create a image buffer.
ABuffer := TVLImageBuffer.CreateBmp(FRecImage);

// Send the buffer.
VLGenericFilter.SendData( ABuffer );

end;

However this generates, even with the compression enabled, very big files. I tried to slow down the sending of the frames by adding a Sleep(40) command in the loop. Then the files are effectively smaller, but synchronization is wrong (they movie plays too fast).

What is the proper way to slow down the frame pumping, and still to keep the timing correct ?

Thanks,

soitjes.
Find all posts by this user
Quote this message in a reply
03-27-2013, 10:16 AM
Post: #2
RE: Compression with VLAVILogger
Hi! Do you have a compression set for the logger and where do you create the GenericFilter and AVILogger?

Regards,
Dave
Quote this message in a reply
03-28-2013, 12:56 AM
Post: #3
RE: Compression with VLAVILogger
I create the GenericFilter and AVILogger in the method that is called when I click the record button. In that method I also enable compression in the logger. As a last statement I then execute the thread.

The loop that sends the frame is located in the execute method of the thread.

It's actually working, but either the files are too big (even with compression), or synchronization is wrong when I add sleep statements to slow down frame rate.

Soitjes.
Find all posts by this user
Quote this message in a reply
03-28-2013, 10:14 PM
Post: #4
RE: Compression with VLAVILogger
For the sync you could try putting a VLChangeRate, set to the expected or desired framerate, before the logger.
Quote this message in a reply
03-29-2013, 06:05 AM
Post: #5
RE: Compression with VLAVILogger
Hello Dave,

That improved the situation a lot. After some experimenting I have put VLChangeRate.FrameRate to 1, and left a sleep(20) in the loop. That gives me reasonable small files with the correct sync.

Of course, that is a very slow framerate, but as this is a surveillance application that is ok for me. I don't need fluent movements.

Would it make a difference in size if I put also a VLVideoCompressor in as well, or is the VLAVILogger.Compressor sufficient ?

Thanks,

Soitjes.
Find all posts by this user
Quote this message in a reply
03-29-2013, 11:57 AM
Post: #6
RE: Compression with VLAVILogger
That would be double encoding, you'd probably lose quality (even more). I'd stick with single compression (the logger) and tune parameters for the codec of your choice to suit your needs.

Regards,
Dave
Quote this message in a reply
03-29-2013, 08:01 PM
Post: #7
RE: Compression with VLAVILogger
I did allot of experimenting with codecs when developing my Photo Booth app and came to the conclusion the best quality for file size was with the Xvid codec. It's freeware and can be freely distributed. Installation files can be found here.. http://www.xvid.org/
Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)