Search code examples
batch-filevideo-capturevlc

How to take multiple screenshots using VLC Media Player and a batch file


I am having trouble creating a batch file (.bat) that will find all videos in particular folders and output screenshots automatically using VLC Media Player.

I have created the following script after hours of trial and error that somewhat works. It does open and close the videos one by one which is great! But I still have to manually take screenshots (Shift-S) for each video, and when I close a video it opens the next one in queue etc. This is the code I have so far that I run as a batch file (.bat) from a root folder:

setlocal enableextensions enabledelayedexpansion

SET VLCPATH=%PATH%;C:\Program Files (x86)\VideoLAN\VLC

SET PATH=%PATH%;%VLCPATH%
for /r %%f in ("*.flv") do vlc --scene-replace --snapshot-sequential --video-filter=scene --scene-ratio=18 --scene-width=160 --scene-height=120 --video-filter=scene --snapshot-format=png --start-time=280 --stop-time=281 --snapshot-path="%%~pf%%~nf.png" --snapshot-prefix="test-" "%%f"
pause

endlocal

Using the above code I'm looking for a way to change it so it automatically:

  1. Opens a video
  2. Navigates to a set start position
  3. Takes a screenshot of the video in this folder
  4. Closes this video, navigates out to the next folder and opens the next video
  5. Repeats from step 1.

Any advice would be much appreciated :)


Solution

  • Tested example:

    for /r %a in (*.flv) do start /wait "" "C:\Program Files (x86)\VideoLAN\VLC\vlc" --video-filter=scene --scene-ratio=18 --scene-width=160 --scene-height=120 --start-time=280 --stop-time=281 --scene-prefix="%~na-" --no-audio --play-and-exit --scene-path="%~dpa." "%~fa"