2011-08-01 4 views
1

ウェブカメラのキャプチャコードは以下の通りです:Silverlight 4 OOBにWebcam Video RecordとWMVとして保存する方法?

Dim capturesource As New CaptureSource 
' Get the default video capture device 
Dim _videoCaptureDevice As VideoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice() 
Dim _AudioCaptureDevice As AudioCaptureDevice = CaptureDeviceConfiguration.GetDefaultAudioCaptureDevice() 
'Dim activeFile As New IsolatedStorageFile 
Dim _isf As IsolatedStorageFile 

Public Sub New() 
    InitializeComponent() 
    AddHandler capturesource.CaptureImageCompleted, AddressOf CaptureImageCompleted 

End Sub 

Private Sub VideoCapture_Loaded(ByVal sender As Object, ByVal e As System.Windows.RoutedEventArgs) Handles Me.Loaded 
    If _videoCaptureDevice Is Nothing Then 
     btnPlayCapture.IsEnabled = False 
     btnStopCapture.IsEnabled = False 
     btnCaptureDevice.IsEnabled = True 
     MessageBox.Show("You don't have any default capture device") 
    Else 
     btnPlayCapture.IsEnabled = False 
     btnStopCapture.IsEnabled = True 
     'Set the Capture Source to the VideoBrush of the rectangle 
     'capturesource.Start() 
     capturesource.VideoCaptureDevice = _videoCaptureDevice 
     capturesource.AudioCaptureDevice = _AudioCaptureDevice 

     Dim videoBrush As New VideoBrush() 
     videoBrush.SetSource(capturesource) 
     rectWebCamView.Fill = videoBrush 

     If CaptureDeviceConfiguration.AllowedDeviceAccess OrElse CaptureDeviceConfiguration.RequestDeviceAccess() Then 
      btnPlayCapture.IsEnabled = True 
      btnStopCapture.IsEnabled = False 
      btnCaptureDevice.IsEnabled = False 
     End If 
    End If 
End Sub 

Private Sub btnPlayCapture_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnPlayCapture.Click 
    If Not capturesource.State = CaptureState.Started Then 
     capturesource.Start() 
    End If 
    btnPlayCapture.IsEnabled = False 
    btnStopCapture.IsEnabled = True 
End Sub 

Private Sub btnStopCapture_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs) Handles btnStopCapture.Click 
    capturesource.Stop() 
    btnPlayCapture.IsEnabled = True 
    btnStopCapture.IsEnabled = False 
End Sub 

Public Sub CaptureImageCompleted(ByVal sender As System.Object, ByVal e As CaptureImageCompletedEventArgs) 
    capturesource.CaptureImageAsync() 
    Dim sfd As New SaveFileDialog() 
    If CBool(sfd.ShowDialog()) Then 
     'Dim sr As New StreamReader(e.Result) 
     'Dim str As String = sr.ReadToEnd() 
     'Dim sw As New StreamWriter(sfd.OpenFile()) 
     'sw.Write(str) 
    End If 
End Sub 

は、私がウェブカメラのキャプチャコードを持っています。その完璧な作業。しかし、私はビデオを作成し、サーバーに保存する必要があります。私は銀色でいくつかのオプションや方法が必要です。これだけhttp://www.silverlight.net/learn/graphics/webcam-and-mic/webcams-%28silverlight-quickstart%29

ほとんどのブログやサイトのリンクを - キャプチャ画像:: http://mtaulty.com/CommunityServer/blogs/mike_taultys_blog/archive/2009/12/28/silverlight-4-yet-more-on-capturing-video-from-webcams.aspx

その良いコードしかし、理解に努め、複雑ではないだろう..私はのような

ウェブ

でほとんどのコードを見つけます誰も私にその1つを教えて!

WEBCAMレコードの作成方法は?

RECORDファイルを特定の形式で保存する方法を教えてください。

答えて

2

「ビデオエンコードコード」を書いたくない場合(書き込むのはあまり楽しいことではありません)、Silverlight 5を待たなければなりません。Silverlight 4にはネイティブビデオがないためエンコードライブラリ、メソッド、またはそれが何であっても。 Mike Taultyの「複雑な」コードは、MVVMパターンで書かれていますが、Camを起動する方法を既に知っているので、ハードルであってはいけません。さて、単純な.aviファイル(恐ろしいほど巨大なサイズ)を生成するには、MainViewModelの "OnStartStopRecord"メソッド内のロジックが必要です。これは、録画ボタンのイベントハンドラの中に置く必要があります。ああ、「記録」フォルダ&をその中に含めることを忘れないでください。 :)

+0

あなたの答えをありがとう。私はその後何かをやっている。私はaviフォーマットを保存しましたが、オーディオはありません!!彼らは次のバージョンに簡単な方法を提供することがあります。私たちは待たなければなりません :) –

関連する問題