Forums
Compression with VLAVILogger - Printable Version

+- Forums (http://mitov.com/forum)
+-- Forum: VCL Components (/forum-6.html)
+--- Forum: VideoLab (/forum-19.html)
+--- Thread: Compression with VLAVILogger (/thread-2959.html)



Compression with VLAVILogger - soitjes - 03-27-2013 05:37 AM

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.


RE: Compression with VLAVILogger - Dave - 03-27-2013 10:16 AM

Hi! Do you have a compression set for the logger and where do you create the GenericFilter and AVILogger?

Regards,
Dave


RE: Compression with VLAVILogger - soitjes - 03-28-2013 12:56 AM

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.


RE: Compression with VLAVILogger - Dave - 03-28-2013 10:14 PM

For the sync you could try putting a VLChangeRate, set to the expected or desired framerate, before the logger.


RE: Compression with VLAVILogger - soitjes - 03-29-2013 06:05 AM

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.


RE: Compression with VLAVILogger - Dave - 03-29-2013 11:57 AM

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


RE: Compression with VLAVILogger - BReeves - 03-29-2013 08:01 PM

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/