Click here to Skip to main content
11,429,687 members (76,478 online)
Click here to Skip to main content

Capture Activities on Screen in a Movie

, 24 Nov 2004 CPOL
Rate this:
Please Sign up or sign in to vote.
An article on how to capture activities on screen as a movie file using Microsoft Windows Media Encoder 9.

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 Smile | :)

License

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

Share

About the Author

Armoghan Asif
Architect
Pakistan Pakistan
No Biography provided

Comments and Discussions

 
GeneralWTF doe "System.Runtime.InteropServices.COMException" mean Pin
brian drwecki13-Jul-08 4:55
memberbrian drwecki13-Jul-08 4:55 
Questioncapture area Pin
Web cam26-Apr-08 1:52
memberWeb cam26-Apr-08 1:52 
GeneralBut how I can get the vedio screen in web Pin
cscrazy16-Mar-08 21:18
membercscrazy16-Mar-08 21:18 
GeneralCOM class error Pin
debiannerd15-Mar-08 14:52
memberdebiannerd15-Mar-08 14:52 
GeneralRe: COM class error Pin
debiannerd16-Mar-08 2:33
memberdebiannerd16-Mar-08 2:33 
GeneralNot capturing balloon tips. Pin
AdamPound3-Mar-08 4:48
memberAdamPound3-Mar-08 4:48 
GeneralRe: Not capturing balloon tips. Pin
Armoghan Asif3-Mar-08 23:32
memberArmoghan Asif3-Mar-08 23:32 
GeneralConverted the project to VS 2008 caused a problem. Pin
ozonic22-Nov-07 12:26
memberozonic22-Nov-07 12:26 
GeneralRe: Converted the project to VS 2008 caused a problem. Pin
ozonic22-Nov-07 14:37
memberozonic22-Nov-07 14:37 
GeneralHelp Bug Fixing !!! Pin
Tauhid Shaikh21-Sep-07 1:41
memberTauhid Shaikh21-Sep-07 1:41 
GeneralRe: Help Bug Fixing !!! Pin
Armoghan Asif21-Sep-07 19:03
memberArmoghan Asif21-Sep-07 19:03 
GeneralRe: Help Bug Fixing !!! Pin
Tauhid Shaikh21-Sep-07 20:38
memberTauhid Shaikh21-Sep-07 20:38 
GeneralRe: Help Bug Fixing !!! Pin
Armoghan Asif22-Sep-07 2:38
memberArmoghan Asif22-Sep-07 2:38 
GeneralAudio Out Capture !!! Pin
Tauhid Shaikh21-Sep-07 1:11
memberTauhid Shaikh21-Sep-07 1:11 
GeneralRe: Audio Out Capture !!! Pin
Armoghan Asif21-Sep-07 19:00
memberArmoghan Asif21-Sep-07 19:00 
GeneralRe: Audio Out Capture !!! Pin
Tauhid Shaikh21-Sep-07 20:58
memberTauhid Shaikh21-Sep-07 20:58 
GeneralRe: Audio Out Capture !!! Pin
Armoghan Asif22-Sep-07 2:41
memberArmoghan Asif22-Sep-07 2:41 
GeneralRe: Audio Out Capture !!! Pin
Tauhid Shaikh22-Sep-07 2:47
memberTauhid Shaikh22-Sep-07 2:47 
GeneralVideo Quality !!! Pin
Tauhid Shaikh19-Sep-07 22:13
memberTauhid Shaikh19-Sep-07 22:13 
GeneralRe: Video Quality !!! Pin
Armoghan Asif19-Sep-07 23:32
memberArmoghan Asif19-Sep-07 23:32 
GeneralRe: Video Quality !!! Pin
Tauhid Shaikh21-Sep-07 1:07
memberTauhid Shaikh21-Sep-07 1:07 
GeneralRe: Video Quality !!! Pin
Armoghan Asif21-Sep-07 18:54
memberArmoghan Asif21-Sep-07 18:54 
GeneralRe: Video Quality !!! Pin
Tauhid Shaikh21-Sep-07 19:49
memberTauhid Shaikh21-Sep-07 19:49 
QuestionDouble-click Pin
dennisss8015-Aug-07 1:59
memberdennisss8015-Aug-07 1:59 
AnswerRe: Double-click Pin
Armoghan Asif16-Aug-07 23:54
memberArmoghan Asif16-Aug-07 23:54 
GeneralRe: Double-click Pin
dennisss8017-Aug-07 3:22
memberdennisss8017-Aug-07 3:22 
QuestionError Running Code Pin
Prachodaya6-Jul-07 19:18
memberPrachodaya6-Jul-07 19:18 
AnswerRe: Error Running Code Pin
Armoghan Asif10-Jul-07 21:30
memberArmoghan Asif10-Jul-07 21:30 
GeneralCapture quality Pin
Timotei_Younge3-Jul-07 0:04
memberTimotei_Younge3-Jul-07 0:04 
GeneralRe: Capture quality Pin
Timotei_Younge3-Jul-07 7:09
memberTimotei_Younge3-Jul-07 7:09 
QuestionRe: Capture quality Pin
micheals5-Aug-07 19:48
membermicheals5-Aug-07 19:48 
GeneralError on "encoder.start()" Pin
Mcdonger21-Jun-07 13:29
memberMcdonger21-Jun-07 13:29 
GeneralRe: Error on "encoder.start()" Pin
Armoghan Asif21-Jun-07 19:58
memberArmoghan Asif21-Jun-07 19:58 
QuestionUsing VB6 Pin
Prachodaya20-Jun-07 0:20
memberPrachodaya20-Jun-07 0:20 
AnswerRe: Using VB6 Pin
Armoghan Asif20-Jun-07 21:20
memberArmoghan Asif20-Jun-07 21:20 
GeneralunHandle comException occured Pin
supun_nimesh17-May-07 19:24
membersupun_nimesh17-May-07 19:24 
AnswerRe: unHandle comException occured Pin
Armoghan Asif23-May-07 21:20
memberArmoghan Asif23-May-07 21:20 
GeneralRe: unHandle comException occured Pin
supun_nimesh24-May-07 2:43
membersupun_nimesh24-May-07 2:43 
GeneralRemote Encoding Pin
Armoghan Asif28-May-07 6:33
memberArmoghan Asif28-May-07 6:33 
GeneralResizing the Video Pin
dsfugabanjr5-May-07 1:19
memberdsfugabanjr5-May-07 1:19 
GeneralRe: Resizing the Video Pin
Armoghan Asif6-May-07 21:01
memberArmoghan Asif6-May-07 21:01 
QuestionRe: Resizing the Video Pin
thenucklehead24-Aug-07 21:12
memberthenucklehead24-Aug-07 21:12 
AnswerRe: Resizing the Video Pin
Armoghan Asif27-Aug-07 2:31
memberArmoghan Asif27-Aug-07 2:31 
GeneralRe: Resizing the Video Pin
thenucklehead27-Aug-07 21:40
memberthenucklehead27-Aug-07 21:40 
Questionunhandled exception Pin
cannalane28-Apr-07 10:58
membercannalane28-Apr-07 10:58 
AnswerRe: unhandled exception Pin
Armoghan Asif2-May-07 21:31
memberArmoghan Asif2-May-07 21:31 
AnswerRe: unhandled exception Pin
windrago12-Sep-07 9:02
memberwindrago12-Sep-07 9:02 
GeneralError Pin
shakti538526-Mar-07 22:44
membershakti538526-Mar-07 22:44 
GeneralRe: Error [modified] Pin
Armoghan Asif10-Apr-07 20:54
memberArmoghan Asif10-Apr-07 20:54 
QuestionPlayback Pin
Jarrod Retzloff16-Mar-07 21:58
memberJarrod Retzloff16-Mar-07 21:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150428.2 | Last Updated 24 Nov 2004
Article Copyright 2004 by Armoghan Asif
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid