Scripting VLC to capture the first frame of a video - cannot get command line to work

I am creating a script to pull a video from the internet, create an image of the first frame, and save the image as a file. My script handles capturing a lot of videos and gives the filenames a sequential number.

My problem is using VLC to capture the video and actually save the file. Experimenting with command line and local file only, before I put it in my script I tried:

vlc -vvv -I dummy --video-filter=scene --start-time=1 --stop-time=1 --scene-format=jpeg --scene-ratio=24 --scene-prefix=EXEC samp.mp4 vlc://quit

      

-> thrown exception

vlc -vvv -I dummy --no-audio --video-filter=scene --start-time=1 --stop-time=1 --scene-format=jpeg --scene-ratio=24 --scene-prefix=EXEC samp.mp4 vlc://quit

      

-> thrown exception

vlc -vvv -I rc --video-filter=scene --start-time=1 --stop-time=1 --scene-format=jpeg --scene-ratio=24 --scene-prefix=EXEC samp.mp4 vlc://quit

      

-> uncaught exception; it looks like I can't do without the -V option

vlc -vvv -I rc -V snapshot --video-filter=scene  --start-time=1 --stop-time=1 --scene-format=jpeg --scene-ratio=24 --scene-prefix=EXEC samp.mp4 vlc://quit

      

-> no display module vout matches "snapshot"; similarly for attempts with the module "image", "scene", "opengl"

I am running VLC 2.0.1 on Mac OS X 10.7.3. Has anyone got VLC to work on the command line (so it can be scripted) to capture images from videos?

By the way, I did an extensive search on this subject - the VLC documentation is hopelessly out of date and most of the suggestions on the internet don't actually work with the latest version of VLC.

+3


source to share


3 answers


If the result is important, but not the video player, you can do it with mplayer:

mplayer -vo png,outdir=/tmp,prefix=frameNo,z=0 -ao null -frames 1 VIDEO-FILENAME

      

VIDEO-FILENAME

can be a local file or an HTTP url.

To get the mplayer command line on OSX, just install the graphics file, then find the command line binary in one of the following locations:



/Applications/MPlayer OSX.app/Contents/Resources/External_Binaries/mplayer_intel.app/Contents/MacOS/mplayer

      

or

/Applications/MPlayer OS X 2.app/Contents/Resources/mplayer.app/Contents/MacOS/mplayer

      

+2


source


Another approach is to use ffmpeg - this worked for me:



ffmpeg -i http://example.com/directory/video.mp4  -ss 0 -vframes 1 -vcodec mjpeg -f image2 keyframe001.jpg

      

+3


source


On Windows: vlc C:\test.mp4 --rate=1 --video-filter=scene --vout=dummy --aout=dummy --start-time=10 --stop-time=11 --scene-replace --scene-format=jpg --scene-ratio=29.970029 --scene-prefix=snaphot --scene-path=C:\Users\Gi\Desktop\ vlc://quit

Works.

+1


source







All Articles