Skip to content

Instantly share code, notes, and snippets.

@Microncode
Last active February 25, 2020 09:27
Show Gist options
  • Save Microncode/9489035535c4231a5457d6a8a367926d to your computer and use it in GitHub Desktop.
Save Microncode/9489035535c4231a5457d6a8a367926d to your computer and use it in GitHub Desktop.
Here is a snap example of using the CSWebCam in order save the camera activity to video file using C#:
//Set the video format
_Camera.VideoResolutionX = txtVideoResolutionX.Text;
_Camera.VideoResolutionY = txtVideoResolutionY.Text;
//Set the FPS
_Camera.VideoFPS = "30";
//Set the buffer size
_Camera.BufferSize = "100MB";
//In the MS camera I had to add this
//in order to display the camera
_Camera.DispWinPixFmt = "yuv420p";
//Set more properties of the
//destination video
//_Camera.VideoBitrate = "316k";
//_Camera.VideoCodec = "...";
//Audio:
//_Camera.AudioCodec = "...";
//_Camera.AudioBitrate = "128k";
//_Camera.AudioSamplerate = "44100";
//_Camera.AudioChannels = "2";
//Set the ID3 Tags
ID3Tags iD3Tags = new ID3Tags();
iD3Tags.Title = "Title";
iD3Tags.Comment = "Comment";
iD3Tags.Album = "Album";
iD3Tags.Artist = "Artist";
iD3Tags.Date = "2020";
_Camera.SetID3Tags(iD3Tags);
//Set the preview
_Camera.SetPicView(cameraPreviewWF1.Preview);
//Open the device and save the results to a media file
_Camera.OpenDevice(cboCamDevices.Text, cboAudioDevices.Text, saveFileDialog1.FileName);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment