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