This post originated from an RSS feed registered with .NET Buzz
by Brendan Tompkins.
Original Post: Dynamically Generate Windows Media Videos in .NET
Feed Title: Brendan Tompkins
Feed URL: /error.htm?aspxerrorpath=/blogs/brendan.tompkins/Rss.aspx
Feed Description: Blog First. Ask Questions Later.
I recently worked on a project here at the port archiving our gate camera images in
SQL Server. The cool thing about having these images archived is
that we can do all sorts of cool things with the raw bytes, such as
stream them as slideshow, pull up a specific image from a given
date, or combine multiple frames to dynamically create a video from a
given time period.
Combining images into a WMV movie from .NET turned out to be quite an interesting project. Kirk Marple,
expert in all things media,graciously donated a bunch of wrapper code
to the WMF SDK, which he says he took inspiration from this article here at CodeProject.
Iâve taken a lot of this code and put together a library which you
can use to generate WMV videos on the fly, from a variety of different
input types 1) A list of image files 2) An array of Bitmap objects
and 3) A SQL DataReader containing the raw image bytes. Iâve put
together a small console app that can be used as a
utility (MovieMaker.exe) for combining multiple files into a
WMV movie, it can be run via the command line, like so:
The only tricky part of this is creating the appropriate Windows
Media Encoder Profile (prx) file. To do this, youâll need to
download the free Microsoft Windows Media - Windows Media Encoder 9 Series.
Youâll also need this installed on any machine running this, since
the code uses the WMEncoder to extract the profile information it needs
to write the video.
The console app demonstrates how to quickly write images to a WMV
file, but youâll probably find the WMVLib class itself more useful in
your applications. Using the WMVLib class is easy,
the most straight-forward usage is to call SaveVideo with the
output file name, profile file name, and list of bitmap files to write
to the video: