strangelights.com

Main F# Site

Edit Edit
Print Print
Recent Changes Recent Changes
Subscriptions Subscriptions
Lost and Found Lost and Found
Find References Find References
Rename Rename
Search
List all versions List all versions
WM Encoder Snippet
.
  // This F# sample is coded after reading a VB sample from code project.
  // See http://www.codeproject.com/vb/net/CaptureScreenAsVideo.asp


  #r "obj/Debug/Interop.WMDEVICECONTROLLib.dll";;
  #r "obj/Debug/Interop.WMEncAgentLocatorLib.dll";;
  #r "obj/Debug/Interop.WMEncAgtLib.dll";;
  #r "obj/Debug/Interop.WMEncoderLib.dll";;
  #r "obj/Debug/Interop.WMPREVIEWLib.dll";;


  open System.Collections
  open System.Collections.Generic


  open WMEncoderLib
  let encoder = new WMEncoderClass() :> WMEncoder


  let srcs = encoder.SourceGroupCollection
  let sg1  = srcs.Add("SG_1")


  let srcAud = sg1.AddSource(WMENC_SOURCE_TYPE.WMENC_AUDIO) :?> IWMEncAudioSource
  let srcVid = sg1.AddSource(WMENC_SOURCE_TYPE.WMENC_VIDEO) :?> IWMEncVideoSource2


  do srcVid.SetInput("ScreenCap://ScreenCapture1"   ,null,null) 
  do srcAud.SetInput("Device://Default_Audio_Device",null,null)


  let proCollIE = encoder.ProfileCollection :> IEnumerable 
  let proColl   : IEnumerable<IWMEncProfile> = IEnumerable.untyped_to_typed proCollIE
  do  proColl |> IEnumerable.iter (fun pro -> printf "%s\n" pro.Name)


  let proNameA = "Windows Media Video 8 for Local Area Network (384 Kbps)"
  let profileA = proColl |> IEnumerable.find (fun p -> p.Name = proNameA) 
  do  sg1.Profile <- profileA


  let descr = encoder.DisplayInfo
  do  descr.Author      <- "Author by F#"
  do  descr.Copyright   <- "Copyright XYZ"
  do  descr.Description <- "Capture"
  do  descr.Rating      <- "Rating information"
  do  descr.Title       <- "Title of encoded content"


  do  encoder.Attributes.Add("URL","IP address")


  do srcVid.CroppingBottomMargin <- 2
  do srcVid.CroppingTopMargin    <- 2
  do srcVid.CroppingLeftMargin   <- 2
  do srcVid.CroppingRightMargin  <- 2


  do encoder.File.LocalFileName <- @"C:\Temp\TestFile.avi"


  do encoder.Start()
  do encoder.Stop()
Welcome to F Sharp Wiki, view the HomePage

This site supports the new NoFollow anti-spam initiative.

Recent Topics

Copyright 2005, Robert Pickering (Others where credited) | Terms of Use