The My Opera forums have been replaced with forums.opera.com. Please head over there to discuss Opera's products and features

See the new Forums

Playing with HTML5 video and getUserMedia support

Forums » Dev.Opera » Archived Article Discussions

This topic has been closed. No new entries allowed.

Reason: You can now post comments on articles on Dev Opera

Forum rules and guidelines

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

19. October 2011, 09:30:20

Opera Software

tagawa

Posts: 143

Playing with HTML5 video and getUserMedia support

Building on the famous exploding video demo by Sean Christmann, we're going to see how we can explode the video stream from a camera. With a few performance tweaks, this works surprisingly well both in desktop browser and on mobile devices.

( Read the article )

19. October 2011, 22:30:55

BS-Harou

Posts: 232

Hi,
is there a way to get WebCam ratio?

20. October 2011, 05:59:26

Opera Software

tagawa

Posts: 143

You can get the webcam ratio by dividing the video's dimensions. Something like this should work:

// Assign the <video> element to a variable
var video = document.getElementById('sourcevid');

// Change the video source to the webcam 
if (navigator.getUserMedia) {
    navigator.getUserMedia('video', successCallback, errorCallback);
    function successCallback(stream) {
        video.src = stream;
    }
    function errorCallback(error) {
        console.error('An error occurred: [CODE ' + error.code + ']');
        return;
    }
} else {
    console.log('Native web camera streaming (getUserMedia) is not supported in this browser.');
    return;
}

// Calculate the webcam ratio
var ratio = video.videoWidth / video.videoHeight;

20. October 2011, 07:50:55

BS-Harou

Posts: 232

Great, thank you smile

20. October 2011, 12:52:27

edvakf

Posts: 762

According to the spec, you have to do
video.src = window.URL.getObjectURL(stream);

instead of just "stream". Is this a work in progress?

30. October 2011, 05:06:23

changc61

Posts: 2

can this handle 2 camera device? (sorry i did not read document first)

31. October 2011, 12:59:33

Duggis

Posts: 3

Looking good, Daniel! pirate

3. November 2011, 20:50:02

changc61

Posts: 2

try democam, photobooth and warhol:
only photobooth work on HTC Inspire 4G,
none work on LG Thrill 4G.

Forums » Dev.Opera » Archived Article Discussions