I hit the wall :/... I am trying to get preview from webcam and take snapshot (I still didn't make that far...), I am stuck at feeding live to winform for now... I don't want to use some unknown libraries or libs not allowed for commercial use. Anyway now I experiments with MS Expression Encoder, but I can not add source devices, when should be executed LiveJob.AddDeviceSource app get killed without any f***!@^%# error ;( ... there is my code:
private void startLivePreview()
{
try
{
// find audio devs
var a_Devices = EncoderDevices.FindDevices(EncoderDeviceType.Audio);
if (a_Devices.Count < 1)
{
throw new Exception("No avaiable audio devices. Sorry but there must be at least one...");
}
EncoderDevice a_Dev = a_Devices[1];
//camLiveSource = camLiveJob.AddDeviceSource(camDevice, null); // I do not need audio so null it...
camLiveSource = camLiveJob.AddDeviceSource(camDevice, a_Dev); // this line kills the app
camLiveSource.PickBestVideoFormat(new Size(640, 480), 15);
camLiveJob.OutputFormat.VideoProfile.Size = new Size(imgPrev.Size.Width, imgPrev.Size.Height);
SourceProperties sp = camLiveSource.SourcePropertiesSnapshot();
lblInfoPrev.Text = sp.Size.Width.ToString() + "x" + sp.Size.Height.ToString() + " @ " + sp.FrameRate.ToString("0.00") + "fps";
camLiveSource.PreviewWindow = new PreviewWindow(new HandleRef(imgPrev, imgPrev.Handle));
camLiveJob.ActivateSource(camLiveSource);
}
catch (Exception ee)
{
MessageBox.Show(ee.Message);
}
}
Nothing grand, just like all examples that can be found on internet... Anyone is able to help? I thought that MS libs would work fine but they don't (even LiveSourceSample not works, app get killed on that same line)...
I want to use something for grabbing picture from webcam that can be used in commercial app. And I do not need an audio at all (I would be happy if I could just pass "null" as audio device in AddDeviceSource :) )
Those are my A-V devices on system:
Video devices:
- [0] Name: >Screen Capture Source< *- this must been installed with MS Expression Encoder 4*
- [1] Name: >WebCam SC-03FFL11939N< *- built-in laptop camera*
Audio devices devices:
- [0] Name: >Microphone (Realtek High Definition Audio)<
- [1] Name: >Mix stereo (Realtek High Definition Audio)<
- [2] Name: >Speakers (Realtek High Definition Audio)<