Hi all,
Id like to use this old example code snippet from VRED 2023 Help | Video grabbing example | Autodesk that makes use of the API v1 class 'vrVideoGrab' (VRED 2023 Help | vrVideoGrab | Autodesk).
screen = findNode("Screen")
if not screen.isValid():
screen = createPlane(2000, 1000, 1, 1, 0,0,0)
screen.setName("Screen")
screen.setRotation(90,0,0)
screen.setTranslation(0, 0, 500)
# (node, parameter, xres, yres, material, parameter, material, parameter, xres, yres)
vg = vrVideoGrab(screen.getMaterial(), "OBS Virtual Camera", 768, 432)
# specify a resolution.
vg.setActive(true)
# define key s to toggle videograbbing
keyS = vrKey(Key_S)
keyS.connect(vg, SWITCH_TOGGLE)
vrLogInfo("Press key s to toggle videograbbing")
Unfortunately, the "OBS Virtual Camera" can't be used:
Found device 0 'OBS Virtual Camera'
vrFrameGrabber::init : Couldn't get capture output pin!
Press key s to toggle videograbbing
Other forum posts that didn't help:
Hallo Clemens,
eventuell hätte ich einen Workaround. Mit einer HTML die die Webcam anzeigt. Diese HTML lädst du dann in den MediaEditor -> WebEngine.
Kann es leider auf Grund fehlender Berechtigung nicht testen.
Viele Grüße
Andreas
<!DOCTYPE html>
<html lang="en">
<head>
</head>
<body>
<video id="video" width="640" height="480" autoplay></video>
<canvas id="canvas" width="640" height="480"></canvas>
<script>
// Grab elements, create settings, etc.
var video = document.getElementById('video');
// Get access to the camera!
if(navigator.mediaDevices && navigator.mediaDevices.getUserMedia) {
// Not adding `{ audio: true }` since we only want video now
navigator.mediaDevices.getUserMedia({ video: true }).then(function(stream) {
//video.src=window.URL.createObjectURL(stream);
video.srcObject = stream;
video.play();
});
}
/* Legacy code below: getUserMedia
else if(navigator.getUserMedia) { // Standard
navigator.getUserMedia({ video: true }, function(stream) {
video.src=stream;
video.play();
}, errBack);
} else if(navigator.webkitGetUserMedia) { // WebKit-prefixed
navigator.webkitGetUserMedia({ video: true }, function(stream){
video.src=window.webkitURL.createObjectURL(stream);
video.play();
}, errBack);
} else if(navigator.mozGetUserMedia) { // Mozilla-prefixed
navigator.mozGetUserMedia({ video: true }, function(stream){
video.srcObject = stream;
video.play();
}, errBack);
}
*/
</script>
</body>
</html>
Hi Andreas,
danke für deinen Tipp, den Media-Editor mit einem eingebetteten Videostream zu nutzen! Ist eigentlich eine gute Idee. Leider bin ich zuvor mit einem ähnlichen Skript ebenfalls an fehlender Berechtigung gescheitert:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Display Webcam Stream</title>
<style>
#container {
margin: 0px auto;
width: 1920px;
height: 1080px;
border: 0px;
}
#videoElement {
width: 1920px;
height: 1080px;
background-color: #555555;
}
</style>
</head>
<body>
<div id="container">
<video autoplay="true"
id="videoElement">
</video>
</div>
<script>
var video = document.querySelector("#videoElement");
if (navigator.mediaDevices.getUserMedia) {
navigator.mediaDevices.getUserMedia({ video: true })
.then(function (stream) {
video.srcObject = stream;
})
.catch(function (err0r) {
console.log("Something went wrong!");
});
}
</script>
</body>
</html>
Im edge Browser desselben Rechners funktioniert sowohl dein Code, als auch der Code hier.
Leider erscheint in VRED kein Popup, in welchem ich zur Freigabe des Webcam-Zugriffs aufgefordert werden würde.
Schöne Feiertage!
The VRED WebEngine used in 2024.1 should be able to use Webcams in general. I've opened
https://html5test.com/ with the MediaEditor and it claims that the Qt 6.2.8 Browser should be capable to use "Input - Access the webcam". I assume that VRED 2024.1 uses Chromium version 102.0.5005.177.
Another idea, to create a webcam server in python and then connect in mediaeditor via websocket.
Can't find what you're looking for? Ask the community or share your knowledge.