cancel
Showing results for 
Search instead for 
Did you mean: 

Any ideas? - video stream stored in a database

Community Veteran
Posts: 13,925
Thanks: 515
Fixes: 8
Registered: 01-08-2007

Any ideas? - video stream stored in a database

Hey gang..
Not a thread for most folks but i know we have some talented people here onb the PN forum who know their stuff!
So.. i was looking at saving a video stream from a live device (security camera or webcam that is watching over a car). Now I've had some breif experience with CCTV in the past and remember that they could look back precisely at any date / time of footage in the database.
Now I'm wanting to do something similar but with my own software / features and i'm wondering just how a video stream can be stored like that in a database with precise time / date markers?
One thing I thought of was perhaps every second was stored as its own unique blob and the database pulls out say 60 blobs at a time for the main program to stitch together and play? But then that raises a new question of the blob not containing file / meta data etc?
So.. anyone in the know out there?
I need a new signature... i'm bored of the old one!
7 REPLIES
Community Veteran
Posts: 4,773
Thanks: 1,055
Fixes: 27
Registered: 16-10-2014

Re: Any ideas? - video stream stored in a database

Hi 7up,
What format is the video in? Most of the time I think you'll find that the time stamp data is stored in frames in the video. So what you'd need to do so you could query the database is to extract this information from the stream and use these values to insert the blob. Doing it every second IMHO is pointless, as the granularity is to fine, I'd be inclined to do it maybe on the minute but more likely every 5 minutes.

Community Veteran
Posts: 26,378
Thanks: 634
Fixes: 8
Registered: 10-04-2007

Re: Any ideas? - video stream stored in a database

Must it be stored in the database? I'd be inclined to store it as files on a shared drive and store the UNC path to the file in the database with the date time indexing information. That way the file/meta data will not be lost.
jelv (a.k.a Spoon Whittler)
   Why I have left Plusnet (warning: long post!)   
Broadband: Andrews & Arnold Home::1 (FTTC 80/20)
Line rental: Pulse 8 Home Line Rental (£13/month)
Mobile: iD mobile (£4/month)
Community Veteran
Posts: 4,773
Thanks: 1,055
Fixes: 27
Registered: 16-10-2014

Re: Any ideas? - video stream stored in a database

Storing the data on a shared drive does have advantages as it allows you to view the footage without using the database, but it also means that you now have two points of failure. By storing data in the database all you need to do is backup the database and you have a complete archive that can be restored to a new instance or hardware with minimal grief.
Also, by storing the UNC path in the database means that the files can never be moved to another location without the database being updated, that may not be the end of the world but a point worth considering.
While I'm typing a couple of other questions come to mind. What database were you wanting to use? Also is this CCTV a proper CCTV system; i.e. multi-cam or is it a single IP / USB camera?
Community Veteran
Posts: 13,925
Thanks: 515
Fixes: 8
Registered: 01-08-2007

Re: Any ideas? - video stream stored in a database

Quote from: jelv
Must it be stored in the database? I'd be inclined to store it as files on a shared drive and store the UNC path to the file in the database with the date time indexing information. That way the file/meta data will not be lost.

Databases take care of user access / multi read / file locking issues.
Quote from: Mook
What format is the video in? Most of the time I think you'll find that the time stamp data is stored in frames in the video. So what you'd need to do so you could query the database is to extract this information from the stream and use these values to insert the blob.

Well not much point in taking the time / date values from a live stream using OCR if i can take it from the system clock or get the database to insert it using its own internal time is there?   Undecided You're trying to answer a different question to what i'm asking I'm afraid  Wink
I'm not asking how to store the time / date, i know how to do that, what i'm asking is how do security programs store their live stream going back weeks and be able to recall it so quickly using a timeline like this:

Having used this software myself in a former job I am pretty sure it wasn't using files stored on a disk and then joining them together for playback that and multiple users could search for a specific time and date very quickly just like it were using a database that has the entire thing time and date indexed. Now I know what you're thinking, take the file size and divide by the seconds that it contains but that will not work because some frames will contain more or less data than others (eg night scenes will contain little until a car drives up with headlights on etc) so file size division will not work. Plus for a video of several hundred MB it would take a while to calculate how many frames are in it etc... Indigo control centre does instant playback with no calculation times etc so it IS possible... somehow  Huh
I've heard of real time databases but i'd have no idea where to start with one of those.
Like I said theoretically individual frames could be stored sequentially in a database and selected by their insertion order but I find myself thinking that the video format (as yet unknown as I'm just mulling this over as a project) won't support this? - Presumably it contains some sort of metadata in the file like many jpeg pictures?
I need a new signature... i'm bored of the old one!
Community Veteran
Posts: 4,773
Thanks: 1,055
Fixes: 27
Registered: 16-10-2014

Re: Any ideas? - video stream stored in a database

Quote
You're trying to answer a different question to what i'm asking I'm afraid  Wink

Sorry I don't quite follow what you mean?
Quote
I'm not asking how to store the time / date, i know how to do that, what i'm asking is how do security programs store their live stream going back weeks and be able to recall it so quickly using a timeline like this:

I think you'll find that these programs read the control frames embedded in the video stream and create a catalog. This catalog will index the byte positions within the file allowing the software to seek directly a given offset in the file.
Remember, once you have this data in the database you'll need to get it out again to view it this may mean gluing blobs together in order to do this.
Also, can I ask what your development environment will be when doing this?

Community Veteran
Posts: 13,925
Thanks: 515
Fixes: 8
Registered: 01-08-2007

Re: Any ideas? - video stream stored in a database

Quote from: Mook
Quote
I'm not asking how to store the time / date, i know how to do that, what i'm asking is how do security programs store their live stream going back weeks and be able to recall it so quickly using a timeline like this:

I think you'll find that these programs read the control frames embedded in the video stream and create a catalog. This catalog will index the byte positions within the file allowing the software to seek directly a given offset in the file.

Ok that sounds plausible but then how would multiple clients programs / viewers access that file at the same time? Supposing x amount of days worth of video needs to be deleted (eg the last week every 7 days) when there are clients with that file stream open? - How does that work?
Quote from: Mook
Remember, once you have this data in the database you'll need to get it out again to view it this may mean gluing blobs together in order to do this.

Now I'm confused! Are you talking about the current software using a database or me using it? If the latter I'm aware of that but what i'm trying to get at is can i just split a video file up into blobs (or do any codecs support this) or must it be one long continous stream / file? I'm ok with gluing them back together but can the actual breaking down of a video stream be done and stored like that in the first place? - This to me seems the better way forward purely because it allows the database to take charge with clients viewing / deleting etc unlike a file system lock which would be a pain..
I need a new signature... i'm bored of the old one!
Community Veteran
Posts: 4,773
Thanks: 1,055
Fixes: 27
Registered: 16-10-2014

Re: Any ideas? - video stream stored in a database

Quote
Ok that sounds plausible but then how would multiple clients programs / viewers access that file at the same time? Supposing x amount of days worth of video needs to be deleted (eg the last week every 7 days) when there are clients with that file stream open? - How does that work?

You can have any number of process read a file (up to the max supported by the OS) it's writing data that requires locks to prevent contention.
Regarding the deleting what context are we talking about here? Your scenario or one of an existing product from Joe Bloggs Inc?
Quote
Now I'm confused! Are you talking about the current software using a database or me using it? If the latter I'm aware of that but what i'm trying to get at is can i just split a video file up into blobs (or do any codecs support this) or must it be one long continous stream / file?

I was referring to yourself. No the blobs can be of any size you want, you could even split the video file down to the byte level and store each one of these. The 'trick' is putting them back in the correct order.
Quote
I'm ok with gluing them back together but can the actual breaking down of a video stream be done and stored like that in the first place? - This to me seems the better way forward purely because it allows the database to take charge with clients viewing / deleting etc unlike a file system lock which would be a pain..

Yes, as mentioned above it does not matter how you store these or in what size the portions are, the key to it all is the re-constitution of the portions in the correct order.
I know of no database that will allow you to 'view' blob data (in the context I assume you mean). In order for a user to actually watch a video stored in a database the client software must be capable of converting the byte array provided by the database and applying an applicable codec to it in order to render it as video, otherwise it its nothing more than an array of unsigned integers or chars etc.