VLC silent capture of video or snapshots from a webcam

For questions and discussion that is NOT (I repeat NOT) specific to a certain Operating System.
Hibou
New Cone
New Cone
Posts: 9
Joined: 12 May 2009 09:28
VLC version: 1.0.1
Operating System: Windows-XP
Location: Grenoble, France
Contact:

VLC silent capture of video or snapshots from a webcam

Postby Hibou » 05 Aug 2009 05:53

Using a VLC command-line to silently capture video from a webcam, or to capture a series of frames as images, is not well documented IMHO. I have therefore given examples and simple explanations below. The same commands should apply for Windows (tested with VLC 1.0.1), linux or the Mac-OS. (To open a DOS window under Windows, click Start/Run, type in "cmd" and use the DOS command "CD" to navigate to the VLC directory, or use the MicroSoft CmdHerePowertoySetup gadget).

++++++++++++++++++++++++++++++++++++++++
VLC silent capture of an AVI video from a webcam

First determine the :sout string to transcode the video. In the VLC GUI, select Media/Open CaptureDevice, select Direct Show and the Video Device name eg "Monitor Webcam". At the bottom, instead of "Play" select "Stream" in the pull-down menu to the left. The Stream Output dialogue shows the source as dshow:// Click on Destinations, select File, click Add and enter the filename eg D:\temp\test.avi Select Activate Transcoding with the default Profile "Video - H.264 + AAC (TS)" Finally, click on Options and copy the :sout string to a single VLC command line at the end of the other switches (below).

vlc dshow:// :dshow-vdev="Monitor Webcam" :dshow-adev="none" :dshow-size="640x480" :dshow-caching=1000 --run-time=2 -V dummy --intf=dummy --dummy-quiet :sout=#transcode{vcodec=h264,vb=800,scale=1,acodec=mp4a,ab=128,channels=2,samplerate=44100}:std{access=file,mux=ts,dst=D:\temp\mytest.avi}

Explanation of the less obvious switches (see http://wiki.videolan.org/VLC_command-line_help )
dshow:// : outputs with direct show
:dshow-vdev="Monitor Webcam" : this defines the input as the direct show device "Monitor Webcam"
:dshow-adev="none" : there is no audio device (the default will be used if we omit this switch)
:dshow-caching=1000 : the cache time is 1000 milliseconds
--run-time=2 : runs for 2 seconds (corresponding to only a ~1 second capture)
-V dummy : this suppresses the actual video window
--intf=dummy : this also suppresses the VLC interface window
--dummy-quiet : this suppresses the progress log window, so nothing at all pops up
:sout=#transcode{...}:std{...} : this specifies the output transcode and file as found from the VLC stream interface setup

Note that switch prefixes -- or : or - simply determine the extent of the switch and can often be interchanged.

++++++++++++++++++++++++++++++++++++++++++
VLC silent capture of a jpg snapshot from a webcam

I posted this under another heading, but include it here for completeness. Silently capturing a snapshot from a webcam, or a series of frames as images, can be done with the single VLC command-line:

vlc --dshow-vdev="Monitor Webcam" --dshow-size=640x480 -V dummy --intf=dummy --dummy-quiet --video-filter=scene --no-audio --scene-path=D:\temp --scene-format=jpeg --scene-prefix=snap --scene-replace --run-time=1 --scene-ratio=24 "dshow://" vlc://quit

Explanation of the less obvious switches (see http://wiki.videolan.org/VLC_command-line_help )
--dshow-vdev="Monitor Webcam" : this defines the input as the direct show device "Monitor Webcam"
-V dummy : this suppresses the actual video window
--intf=dummy : this also suppresses the VLC interface window
--dummy-quiet : this suppresses the progress log window, so nothing at all pops up
--video-filter=scene : scene apparently replaces the earlier image, which no longer works
--scene-replace : is supposed to replace an existing snapshot snap.jpeg, but instead it creates snap.jpeg.swp
--run-time=1 : inputs for 1 second
--scene-ratio=24 : outputs every 24th frame (ie 1 frame for 25 fps PAL)
"dshow://" : outputs with direct show
vlc://quit : quits silently after finishing; the user sees nothing but snap.jpeg appearing in D:\temp

Some of these switches are not really needed eg removing --scene-replace and setting --scene-ratio=3 will give a series of snapshots of every 3rd frame.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Remaining requirements for complete command line control of VLC capture

1. We still need a command line switch that will list the available direct show devices.
2. We still need a command line switch that will list the permitted resolutions of these devices.

Hibou
New Cone
New Cone
Posts: 9
Joined: 12 May 2009 09:28
VLC version: 1.0.1
Operating System: Windows-XP
Location: Grenoble, France
Contact:

Re: VLC silent capture of video or snapshots from a webcam

Postby Hibou » 05 Aug 2009 10:51

:sout=#transcode{vcodec=h264,vb=800,scale=1,acodec=mp4a,ab=128,channels=2,samplerate=44100}:std{access=file,mux=ts,dst=D:\temp\mytest.avi}
Dommage ! This does not produce a standard AVI file, though the file does play with VLC. Apparently I should use mux=avi and without audio, sout should look something like this:
:sout "#transcode{venc=MPEG-TS,vcodec=MPEG-2,vb=1200}:std{mux=avi,access=file,dst=D:\temp\video.avi}"

Unfortunately this produces a tiny file that VLC can't recognise. I spent hours trying various options for venc= and vcodec= and reading the voluminous VLC literature, before finally finding a couple of posts by arite saying that the VLC AVI writer (muxer) is broken.

This is the latest VLC-1.0.1 and has apparently been the case for some time, though I would have thought that writing standard AVI is a pretty basic requirement. I need to be able to extract individual frames, so all these fancy compression codecs are no good to me. And since the whole point of running VLC via the command-line is to automate my application, I don't want to have to run something else to transcode it after capture.

So I have come full circle, back to VirtualDub, which will capture 2sec of standard AVI from a Webcam with simply:
vdub /capture /capdevice Monitor Webcam /capfile D:\temp\video.avi /capstart 2s /x


Return to “General VLC media player Troubleshooting”

Who is online

Users browsing this forum: No registered users and 23 guests