samedi 16 décembre 2006

[Win] Command line : recording a live video from a webcam or another video device

I use Microsoft Windows Media Encoder 9 Series which is free as in beer (I didn't need to download the free SDK).

In "Program Files\Windows Media Components\Encoder" it installs in particular a script called WMCmd.vbs.

You can run this script with cscript.exe which should already be in "Windows\system32" :

cscript.exe WMCmd.vbs -adevice X -vdevice Y -output C:\test.wmv -duration Z


X= the number of the audio device (I used 1 in my case for my webcam)
Y= the number of the video device (I also used 1 for my webcam here)
Z= the duration in seconds (you can always kill the process on the go if the video is shorter)

For command-line options type "cscript.exe wmcmd.vbs" in the shell.

If I want the video to be shorter than the given duration and want to control this from a Python script I use the DOS taskkill command.

More informations also here.