Scripting VLC to capture first frame of a video - can't get command line to work

Go To StackoverFlow.com

3

I'm creating a script to pull a video off the web, create an image of the first frame, and save the image as a file. My script is handling grabbing a lot of videos and giving the file names a sequential number.

My problem is in using VLC to grab the video and actually save the file. Experimenting with the command-line and just a local file before I put it into my script, I've 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

-> uncaught 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

-> uncaught 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; looks like I can't do without a -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 vout display module matched "snapshot"; similarly for attempts with module "image", "scene", "opengl"

I'm running VLC 2.0.1 on Mac OS X 10.7.3. Has anybody got VLC to work on the command line (so it's scriptable) to do image capture from videos?

BTW, I've done extensive googling on this - the VLC documentation is hopelessly out of date and most suggestions on the web don't actually work with the latest version of VLC.

2012-04-05 14:48
by D Mac
[deleted] probably suitable as answe - David-SkyMesh 2012-04-06 04:11


2

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

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

The VIDEO-FILENAME can be a local file, or an HTTP URL.

To get the command-line mplayer on OSX, just install the graphical one then find the command-line binary in one of these 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
2012-04-06 04:12
by David-SkyMesh
mplayer could also be located in /Applications/MPlayerX.app/Contents/Resources/MPlayerX.mplayer.bundle/Contents/Resources/x86_64/mplayer nowaday - sleepless 2015-11-17 19:03
I think the first command should read mplayer -vo png:outdir=/tmp:prefix=frameN:z=0 -ao null -frames 1 VIDEO-FILENAME' Note the : instead of - Naumann 2017-06-05 16:47


3

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
2012-04-06 10:20
by D Mac
thanks dude, worked perfectly. With MacOSX it was just two commands. brew install ffmpeg, and then your magic command :) cheer - Joao Sousa 2013-10-14 12:38


1

In 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

It is worked.

2015-12-30 09:26
by Günay Gültekin
Ads