How can I correctly provide a mock webcam video to Chrome?

How Can I Correctly Provide A Mock Webcam Video To Chrome?

How can I correctly provide a mock webcam video to Chrome?

After studying the hyperlink you supplied I seen that we can additionally provide an mjpeg.

Depending on what your check necessities – this can be adequate for you. As a terminal command with ffmpeg put in:

ffmpeg -i oldfile.mp4 newfile.mjpeg

then I examined by operating Google Chrome from the terminal utilizing:

google-chrome --use-fake-device-for-media-stream --use-file-for-fake-video-capture=newfile.mjpeg

After navigating to Tracking JS I may see the video being performed again.

I hope that works for you!

If somebody ever wants to mock a video dynamically, that is what Ive used (forked from here)

await web page.consider(() => {
        const video = doc.createElement(video);

        video.setAttribute(id, video-mock);
        video.setAttribute(src, https://woolyss.com/f/spring-vp9-vorbis.webm);
        video.setAttribute(crossorigin, nameless);
        video.setAttribute(controls, );

        video.oncanplay = () => {
            const stream = video.captureStream();

            navigator.mediaDevices.getUserMedia = () => Promise.resolve(stream);
        };

        doc.querySelector(physique).appendChild(video);
    });

This flags are nonetheless essential:

--use-fake-ui-for-media-stream,
--use-fake-device-for-media-stream,

In the tip, with this script completely different digicam mocks are attainable for each web page – particularly helpful when utilizing browserless!

How can I correctly provide a mock webcam video to Chrome?

Use y4m in order for you uncooked frames with out Chrome having to run a decoder:

ffmpeg -i authentic.avi -pix_fmt yuv420p video-for-chrome.y4m

Then, begin Chrome:

chrome.exe --use-fake-device-for-media-stream --use-file-for-fake-video-capture=video-for-chrome.y4m

Note: There is not any motive to have to modify your y4m information header. Chrome has since been fastened.

READ :  How To Get The Current Year For Copyright In Javascript

This technique makes use of much less CPU, however will take up a whole lot of onerous drive house for the uncooked video. Keep your video file quick. Chrome will loop it.

Related posts on Chrome :

Leave a Reply

Your email address will not be published. Required fields are marked *