5,534,119 members and growing! (16,963 online)
Email Password   helpLost your password?
Multimedia » Audio and Video » Multimedia     Intermediate License: The Code Project Open License (CPOL)

Capture Activities on Screen in a Movie

By Armoghan Asif

An article on how to capture activities on screen as a movie file using Microsoft Windows Media Encoder 9.
VB, Windows, .NET 1.1, .NETVisual Studio, VS.NET2003, Dev

Posted: 24 Nov 2004
Updated: 24 Nov 2004
Views: 131,500
Bookmarked: 81 times
Announcements
Want a new Job?



Search    
Advanced Search
Sitemap
29 votes for this Article.
Popularity: 6.78 Rating: 4.63 out of 5
1 vote, 3.4%
1
1 vote, 3.4%
2
0 votes, 0.0%
3
5 votes, 17.2%
4
22 votes, 75.9%
5

Sample Image - CaptureScreenAsVideo.jpg

Introduction

bkniazi asked me a question on experts-exchange.com, about how to capture the activities going on on a machine as a movie. I found the question interesting, so looked for it, but could not find any good solution for it. Though, I found some software which do this kind of work. I found Windows Media Encoder 9 very interesting. While looking into it, I found its SDK and I started looking into it. It is quite interesting. So I made this small sample after looking into the API and seeing some samples.

Prerequisites

You will be needing Windows Media Encoder 9 Series and SDK.

Using the code

Best thing about this API is that it is totally interface based. WMEncoder is the main class. Set its parameters and start the encoder to start encoding. Stop it to save in file.

Encoder = New WMEncoder

Create a Source Group named SG_1 in Encoder's Collection.

Dim SrcGrp As IWMEncSourceGroup2
Dim SrcGrpColl As IWMEncSourceGroupCollection
SrcGrpColl = Encoder.SourceGroupCollection
SrcGrp = SrcGrpColl.Add("SG_1")

Specify the input types for Video and Audio. Specify the screen capture plug-in to set up the video source.

SrcVid.SetInput("ScreenCap://ScreenCapture1")
SrcAud.SetInput("Device://Default_Audio_Device")

Find the profile and set Encoder's group profile from all the profiles available.

ProColl = Encoder.ProfileCollection
lLength = ProColl.Count
For i = 0 To lLength - 1
    Pro = ProColl.Item(i)
    If Pro.Name = "Windows Media Video 8 for Local Area Network (384 Kbps)" Then
        SrcGrp.Profile = Pro
        Exit For
    End If
Next

Specify header information of the Encoder. I.e., description or attributes.

Dim Descr As IWMEncDisplayInfo
Descr = Encoder.DisplayInfo
Descr.Author = "Armoghan Asif"
Descr.Copyright = "Copyright information"
Descr.Description = "Text description of encoded content"
Descr.Rating = "Rating information"
Descr.Title = "Title of encoded content"

' Add an attribute to the collection.

Dim Attr As IWMEncAttributes
Attr = Encoder.Attributes
Attr.Add("URL", "IP address")

You may do some cropping of the Encoder if required.

' Crop 2 pixels from each edge of the video image.

SrcVid.CroppingBottomMargin = 2
SrcVid.CroppingTopMargin = 2
SrcVid.CroppingLeftMargin = 2
SrcVid.CroppingRightMargin = 2

Specify the Local File as output. You may also set additional fields of the file, like size of file, seconds of file etc.

Dim File As IWMEncFile
File = Encoder.File
File.LocalFileName = "C:\OutputFile.avi"

Start the encoding process:

' Start the encoding process.

Encoder.Start()

Stop the encoding process:

' Stop the encoding process.

Encoder.Stop()

Points of Interest

No fancy things are placed in the demo. It just illustrates the screen capture. It can be easily added in any existing application. Nothing else :)

License

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

About the Author

Armoghan Asif



Occupation: Architect
Location: Pakistan Pakistan

Other popular Audio and Video articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 25 of 152 (Total in Forum: 152) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralHow do WMencoder WorksmemberNiyaHere23:13 19 Aug '08  
AnswerRe: How do WMencoder WorksmemberArmoghan Asif23:51 19 Aug '08  
GeneralRe: How do WMencoder Works [modified]memberNiyaHere20:23 20 Aug '08  
GeneralRe: How do WMencoder WorksmemberArmoghan Asif19:42 24 Aug '08  
GeneralWTF doe "System.Runtime.InteropServices.COMException" meanmemberbrian drwecki4:55 13 Jul '08  
Questioncapture areamemberWeb cam1:52 26 Apr '08  
GeneralBut how I can get the vedio screen in webmembercscrazy21:18 16 Mar '08  
GeneralCOM class errormemberdebiannerd14:52 15 Mar '08  
GeneralRe: COM class errormemberdebiannerd2:33 16 Mar '08  
GeneralNot capturing balloon tips.memberAdamPound4:48 3 Mar '08  
GeneralRe: Not capturing balloon tips.memberArmoghan Asif23:32 3 Mar '08  
GeneralConverted the project to VS 2008 caused a problem.memberozonic12:26 22 Nov '07  
GeneralRe: Converted the project to VS 2008 caused a problem.memberozonic14:37 22 Nov '07  
GeneralHelp Bug Fixing !!!memberTauhid Shaikh1:41 21 Sep '07  
GeneralRe: Help Bug Fixing !!!memberArmoghan Asif19:03 21 Sep '07  
GeneralRe: Help Bug Fixing !!!memberTauhid Shaikh20:38 21 Sep '07  
GeneralRe: Help Bug Fixing !!!memberArmoghan Asif2:38 22 Sep '07  
GeneralAudio Out Capture !!!memberTauhid Shaikh1:11 21 Sep '07  
GeneralRe: Audio Out Capture !!!memberArmoghan Asif19:00 21 Sep '07  
GeneralRe: Audio Out Capture !!!memberTauhid Shaikh20:58 21 Sep '07  
GeneralRe: Audio Out Capture !!!memberArmoghan Asif2:41 22 Sep '07  
GeneralRe: Audio Out Capture !!!memberTauhid Shaikh2:47 22 Sep '07  
GeneralVideo Quality !!!memberTauhid Shaikh22:13 19 Sep '07  
GeneralRe: Video Quality !!!memberArmoghan Asif23:32 19 Sep '07  
GeneralRe: Video Quality !!!memberTauhid Shaikh1:07 21 Sep '07  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 24 Nov 2004
Editor: Smitha Vijayan
Copyright 2004 by Armoghan Asif
Everything else Copyright © CodeProject, 1999-2008
Web09 | Advertise on the Code Project