📜 ⬆️ ⬇️

Get a snapshot of a webcam and a screenshot of the screen using VLC

Prehistory


It all started with the fact that someone constantly took my tablet, and without my knowledge. ASUS VivoTab Smart tablet with Windows 8 on board. It was decided to make a fake label on the desktop that runs a script that will take pictures from the camera, a screenshot of the screen, send the whole thing to my e-mail, and then, as if nothing had happened, will launch the explorer.

We write a script


Once installed a full-fledged Windows, then you can get by with the capabilities of WSH.
To watch the video on the machine is installed VLC . The player can capture video signal from various sources.

Video sources


The tablet has two cameras: the back and front. We will take photos from both.
image

Each camera supports certain resolutions, they can be viewed in the settings of the ASUS YouCam application:
Screenshots
image
')
image


You can test the selected parameters through the batch file:
C:\\Progra~1\\VideoLAN\\VLC\\vlc.exe dshow:// :dshow-vdev="" :dshow-size= 

Examples
 C:\\Progra~1\\VideoLAN\\VLC\\vlc.exe dshow:// :dshow-vdev="Vimicro USB Camera (Altair)" :dshow-size=640x480 

 C:\\Progra~1\\VideoLAN\\VLC\\vlc.exe dshow:// :dshow-vdev="IMX175" :dshow-size=1280x720 


If the player is open, the video is broadcast and there are no errors - great, the camera and resolution are right.

Screenshot


VLC and it can do. By the way, everything is pretty well written in their wiki .
 C:\\Progra~1\\VideoLAN\\VLC\\vlc.exe "screen://" 


Getting Started for WSH


So that the command prompt window does not appear, we will execute the commands using the Exec method:
 var WSH = new ActiveXObject('WScript.Shell'); WSH.Exec('C:\\Progra~1\\VideoLAN\\VLC\\vlc.exe dshow:// :dshow-vdev="IMX175" :dshow-size=1280x720'); 


Great, but we need to save the image, not output it. To do this, we add the necessary parameters :
 WSH.Exec('C:\\Progra~1\\VideoLAN\\VLC\\vlc.exe --dshow-vdev="IMX175" --dshow-size=1280x720 -V dummy --intf=dummy --dummy-quiet --video-filter=scene --no-audio --scene-path=C:\\ --scene-format=jpg --scene-prefix=Shot --scene-replace --run-time=1 --scene-ratio=25 "dshow://" vlc://quit'); 

The image from the camera will be saved to the file C: \\ Shot.jpg

Similarly for the screenshot:
 WSH.Exec('C:\\Progra~1\\VideoLAN\\VLC\\vlc.exe -V dummy --dshow-vdev=none --intf=dummy --dummy-quiet --video-filter=scene --no-audio --scene-path=C:\\ --scene-format=jpg --scene-prefix=screen --scene-replace --run-time=1 --scene-ratio=25 "screen://" "dshow://" vlc://quit'); 


What happened


In general, a solution using VLC is cross-platform. I just showed the implementation to fit my needs.
Here is the archive with the finished script.
What happened
Shortcut Launch Script
image

Images from both cameras and a screenshot are created:
image

And here is the letter
image

Source: https://habr.com/ru/post/211927/


All Articles