CH3COOH(酢酸)が.NET FrameworkやWindows Mobileの事を始め、日々情報を発信中!

CameraCaptureDialogを使って動画を撮影する

今回は、カメラを使って動画録画を行う方法をご紹介します。

Microsoft.WindowsMobile.Forms 名前空間の CameraCaptureDialog クラスを利用する事で
簡単に動画録画を行う事が出来ます。

    ' 以下の名前空間を指定します
    ' Imports Microsoft.WindowsMobile.Forms

    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

        Dim cameraCapture As New CameraCaptureDialog()

        cameraCapture.Owner = Nothing
        cameraCapture.InitialDirectory = "\My Documents"
        cameraCapture.DefaultFileName = "test.3gp"
        cameraCapture.Title = "Camera Demo"
        cameraCapture.Resolution = New Size(176, 144)
        cameraCapture.VideoTimeLimit = new TimeSpan(0, 0, 15)
        cameraCapture.Mode = CameraCaptureMode.VideoWithAudio
        cameraCapture.VideoTypes = CameraCaptureVideoTypes.Messaging

		' カメラアプリを起動します
        cameraCapture.ShowDialog()
        
    End Sub
    // 以下の名前空間を指定します
    // Using Microsoft.WindowsMobile.Forms;
    
    private void Button1_Click(System.Object sender, System.EventArgs e)
    {
        CameraCaptureDialog cameraCapture = new CameraCaptureDialog();
        
        cameraCapture.Owner = null;
        cameraCapture.InitialDirectory = "\\My Documents";
        cameraCapture.DefaultFileName = "test.3gp";
        cameraCapture.Title = "Camera Demo";
        cameraCapture.Resolution = new Size(176, 144);
        cameraCapture.VideoTimeLimit = new TimeSpan(0, 0, 15);
        cameraCapture.Mode = CameraCaptureMode.VideoWithAudio;
        cameraCapture.VideoTypes = CameraCaptureVideoTypes.Messaging;
        
        // カメラアプリを起動します
        cameraCapture.ShowDialog();
    }

ビデオのみを録画する

アテレコする等の目的で音声を録音せずに、動画のみ録画したい場合は、CameraCaptureDialog の Mode プロパティを CameraCaptureMode.VideoOnly に変更します。

        ' ビデオのみ録画するモードに設定する
        cameraCapture.Mode = CameraCaptureMode.VideoOnly
        // ビデオのみ録画するモードに設定する
        cameraCapture.Mode = CameraCaptureMode.VideoOnly;

参照:CameraCaptureMode Enumeration (Microsoft.WindowsMobile.Forms)

画質を選択する

上記の動画録画用のサンプルコードでは、Eメール添付用の動画を録画する設定になっていましたが、高品質の動画を録画したい場合、CameraCaptureDialog の VideoTypes プロパティを変更します。

        ' 高品質の画像の設定にする
        cameraCapture.VideoTypes = CameraCaptureVideoTypes.Standard
        // 高品質の画像の設定にする
        cameraCapture.VideoTypes = CameraCaptureVideoTypes.Standard;

設定可能な設定値は以下の通りです。

All なんでもOK!
Messaging Eメールに添付可能な品質のビデオ(3GPP)を録画します。
Standard 最も高品質のビデオを録画します。

参照:CameraCaptureVideoTypes Enumeration (Microsoft.WindowsMobile.Forms)


Copyright(C) since 2008 CH3COOH(酢酸). All Rights Reserved.