Click here to Skip to main content
16,004,479 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am recording video using DirectShow.NET[^]. The Video size is too large like 9sec video is 364MB. Please help me how to reduce the Video size.
Posted

1 solution

You are receiving raw video from an analog camera as opposed to compressed video from an IP camera. What you need to look at is applying video compression to your raw video frames.

You should search CodeProject and the web for tips and ideas on this subject and start considering the following basic issues when you take on a project like this:

- The purpose of your application. It is very important to be realistic when you decide on the issues listed below. It is great to have high resolution at high frame rate, but that translates directly into large video files as you have discovered. There is a big difference in the requirements between video surveillance, movie recording and video chat applications.

- The minimum image size needed. A good place to start is looking at a 320x240 image. This can look fine if you are using a good camera, but these days it is most likely not going to cut it. Next step is a 640x480 image which obviously gives you higher detail, but 4 times as much video data to handle compared to 320x240 and once you get to 640x480 resolution, the video will be interlaced and you have to decide how you are going to handle that - start by looking here: www.100fps.com[^].

- The minimum frame rate needed. If your video format is NTSC you should be receiving the video at 30 frames per second (PAL at 25 FPS). People always start out wanting the highest possible frame rate, but for many uses you can easily cut the rate to 15 FPS and still find it useable, in some cases you can go as low as 8 FPS and it will be fine.

- The video encoding to use. This is a huge topic and goes back to what the purpose of your application is. There are many different video CODECs out there and you have to decide which one suits you best. If you are developing a commercial application, you might have to deal with royalty fees if you pick the "wrong" encoder.
If you want to start with something simple, try getting this JPEG encoder working in order to record Motion JPEG video A Simple JPEG Encoder in C#[^]. I do not recommend that you settle with a MJPEG video format, but it is probably a good way for you to get your feet wet.
Roman Ginzburg[^] has implemented a .NET API for the libVLC interface. I have not tried this out myself, but it could be a relatively easy way to do some advanced video compression: nVLC[^].

- File recording. You have to decide how you are going to organize your files. If your application is used for something simple like a "Christmas greeting" for your family, you can probably get away with a single file, but you should consider issues with file size limits (as an example see http://neuron2.net/LVG/filesize.html[^]) and be prepared to store your video in multiple files. If you plan on doing continous recording, you also have to implement logic that deletes the oldest video files when you are running out of space on your drive or when the total size of the stored video reaches a preset threshold.

I hope this helps you get started.


Soren Madsen
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900