简体   繁体   中英

Video capture for Windows 8 desktop App (HTML + javascript). Not from webcam

I´m developing a Windows 8.1 App for desktop using HTML and Javascript. I have a video grabber card and i would like to view the video being captured in real-time at my App. Searching the internet i´ve found some examples and tutorial of capturing video for a Windows 8 App, but all of them are with the webcam, and i would like to know if that should be applicable to any "capture device" like my capture card.

I´ve followed this MSDN tutorial with no success.

http://msdn.microsoft.com/en-us/library/windows/apps/hh452791.aspx

EDIT (adding some more info):

If you follow the tutorial, the detection of capture devices whith the code bellow is ok, it properly detects my capture card.

var deviceInfo = Windows.Devices.Enumeration.DeviceInformation;
    deviceInfo.findAllAsync(Windows.Devices.Enumeration.DeviceClass.videoCapture).then(function (devices) {

        // Add the devices to deviceList

        if (devices.length > 0) {

            for (var i = 0; i < devices.length; i++) {
                deviceList.push(devices[i]);              
            }

            initCaptureSettings();
            initMediaCapture();
            document.getElementById("message").innerHTML = "Initialization complete.";

        } else {
            document.getElementById("error").innerHTML("No video device is found ");
        }
    }, errorHandler);

But then, it throws an "Access denied" exception at the "oMediaCapture.initializeAsync(captureInitSettings)" at the following section of code:

// Create and initialze the MediaCapture object.
function initMediaCapture() {
    oMediaCapture = null;
    oMediaCapture = new Windows.Media.Capture.MediaCapture();
    oMediaCapture.initializeAsync(captureInitSettings).then (function (result) {
       createProfile();
    }, errorHandler);
}

I think this could be because of some kind of access permission to the capture device ¿?¿? Any help?

Thanks in advance!!

If you only care about the video and do not want to use the audio, just make sure that the settings passed to InitializeAsync() specifies StreamingCaptureMode correctly:

            mediaCapture = new MediaCapture();

            MediaCaptureInitializationSettings initSettings = new MediaCaptureInitializationSettings();
            initSettings.VideoDeviceId = Webcam.Id;
            initSettings.StreamingCaptureMode = StreamingCaptureMode.Video;  // <----

            await mediaCapture.InitializeAsync(initSettings);

Kudos to Slimacik.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM