Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Recently my boss came to the team of developers with a new project:

"It is necessary to store videos in a database in order to perform queries on them".

We currently have many videos on DVDs and when we need something, we need to search in all of them.

What we need is to store videos and metadata of single frames in a database, in order to by able of perform queries upon the metadata and retrieve just the extracts of the video that fulfill the search criteria.

Could you please help me about which tools can we use to accomplish our target?

We develop using C#.
Among other things metadata can contain text, dates, geospatial data, etc.
We need to process the videos using H.264.
Posted

1 solution

I would suggest storing video in files and storing the only the file name and perhaps some part of metadata in the database. Of course you could store the video in the database, too, as blobs, but I don't see much sense in it.

Now, I would not mess up with retrieving metadata from media files myself. You think that you just deal with H.264 only. This is not how it really works. H.264 is just one of the algorithms, but there are also media container formats. The media file or stream type is a container type; and it can combine several different streams (such as audio, video, captions, video streams with different compressions or even pixel sizes, etc.) of some different types; and each container type support many, or some limited subset of streams/codecs. In essence, there is no such thing as just "H.264 file". To get some idea, please see:
http://en.wikipedia.org/wiki/Digital_container_format[^],
http://en.wikipedia.org/wiki/H.264/MPEG-4_AVC[^].

So, what to do? I usually advise to use one available library, or utility:
FFMpeg or libavcodec: http://en.wikipedia.org/wiki/Ffmpeg[^],
http://ffmpeg.org/[^],
http://en.wikipedia.org/wiki/Libavcodec[^],
http://libav.org/[^].

In both cases, you can get free open-source utilities which can make nearly everything.

Now, how to use it programmatically in a .NET application? First, you can use the available utility by running it using System.Diagnostics.Process.Start:
http://msdn.microsoft.com/en-us/library/system.diagnostics.process.start.aspx[^].

If this is not good enough, you can wrap the library in a .NET assembly by yourself or find appropriate wrapper. Please see:
http://www.ffmpeg-csharp.com/[^],
http://sourceforge.net/projects/sharpffmpeg/[^],
http://vbffmpegwrapper.codeplex.com/[^].

After all, try to find some more: http://bit.ly/VpboUJ[^].

If you wish to work at such wrapper by yourself but don't know how, ask a question, I'll give you the basic ideas (using P/Invoke or C++/CLI "mixed-mode" project).

See also my past answers:
How to trim the video using Directshow!?[^],
HTML5 and Mime, Streaming a video?[^].

Good luck,
—SA
 
Share this answer
 
v3
Comments
Maciej Los 10-Dec-14 16:21pm    
WOW!
Sergey Alexandrovich Kryukov 10-Dec-14 16:30pm    
Thank you, Maciej.
—SA
cass3000 10-Dec-14 16:53pm    
Thanks for that answer Sergey, very complete.

Technically, we need to process the video with H.264 and embed our own metadata, which later we need to store in the DB.
Sergey Alexandrovich Kryukov 10-Dec-14 17:13pm    
You are welcome. My advice will really help you; I always had a lot of help from this software product in many different cases.
Are you going to accept the answer formally (green "Accept" button)? In all cases, you follow-up questions will be welcome.
—SA

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