Build Webcam and IP camera solutions efficiently in C#.Net
- Quick start
- Online manual
- Start Onvif programming
- C# Onvif.IP.Camera.Viewer
- C# Onvif IP Camera Viewer Git repository
- IP video camera viewer
- PTZ IP camera motion control
- Onvif network video recorder
- Record a stream into MPEG-4
- Take a picture snapshot
- Circular buffer video record
- Video settings for recording
- Record from more cameras
- Record audio stream from camera
- Motion detection and alarms
- IP camera to SIP video call
- Configure Onvif IP cam remotely
- Onvif IP camera video server
- Video stream on website
- Onvif Network Video Analytics
- Onvif IP Camera Manager
- Computer Vision Technology
- Motion recognition and analysis
- Object detection
- Object categorization
- Image Manipulation
- Ozeki SDK for Linux
- Commercial information
- Download the SDK
- Copy the C# code example into Visual Studio
- Build your IP Camera project
Did you know?
Did you know, that this SDK was used to build Ozeki Camera Recorder?
If you don't want to write code, it could be just what you need. Download it now from the follolwing page: Download Ozeki Camera Recorder.
How to implement circular buffer video recording in C#
This article presents a description of circular or ring buffer, explains the benefits of it and shows how to use this data structure in video recording.
What is circular buffer?
A circular buffer (or ring buffer) is a first-in first-out data structure that uses a single, fixed-size
buffer as if it were connected end-to-end.
It is a circular software queue. This queue has a first-in-first-out (FIFO) data characteristic which makes it capable to collect data continually. These buffers are quite common and are found in many embedded systems. Usually, most developers write these constructs from scratch on an as-needed basis.
Ring buffers are incredibly useful when processing asynchronous IO. They allow one side to receive data in random intervals and in random sizes, but feed cohesive chunks to the other side in set sizes or intervals.
Figure 1 - Circular buffer
How does it work?
Circular Buffers are used for data transfer between two processes. The Producer process places items into the
Circular Buffer and the Consumer process removes them. The variable capacity of the Circular Buffer accommodates
timing differences between the Producer and Consumer processes.
Circular buffers can implement the following functions:
- Create - Makes a new ring buffer.
- Destroy - Destroys an existing ring buffer.
- Connect - Connects to an existing ring buffer.
- Put - Inserts data into the ring buffer.
- Get - Retrieves data from the ring buffer.
- WaitUntil - Blocks until the ring buffer satisfies some condition or predicate.
- Peek - Exactly like get however the get pointer is not updated.
Circular buffer video recording
This data structure allows us to record only a specified length of video files (e.g. 5 minutes). It is very useful when you would like to launch a long-term recording process but your storage capacity is limited.
Below you can find the answers for the most frequently asked questions related to this topic:
How can I get the URL of the camera?
You can get the URL from the producer of the camera. (In the 10th tutorial you can find information on how to create an own IP camera discoverer program.)
I have not managed to build the solution. How to solve it?
- Please set the Target framework property of the project to .NET 4.0.
- You should add the OzekiSDK.dll to the references of the solution.
- Please import the missing classes.