VideoHelp Forum

Our website is made possible by displaying online advertisements to our visitors. Consider supporting us by disable your adblocker or Try ConvertXtoDVD and convert all your movies to DVD. Free trial ! :)
+ Reply to Thread
Results 1 to 5 of 5
Thread
  1. I'm trying to take screen grabs every 2 seconds from a bunch of video files.

    Someone has already kindly provided me with this script for a .bat file:

    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -vf fps=fps=1.0/2.0 -qscale:v 2 "%~n1 - %%05d.jpg"
    pause
    However, when I drag multiple videos to this .bat file, it only processes the first one.

    Given that I know nothing about ffmpeg or scripting, could anyone please provide me with the exact code I need?

    Also, I don't know if it's possible, but I'd also like the resulting file names to include the date of the original video, and (if possible) the playback time the grab was taken from.
    Quote Quote  
  2. There is separate thread related to your question - for sure you will find there answer and solution.
    https://forum.videohelp.com/threads/356314-How-to-batch-convert-multiplex-any-files-with-ffmpeg
    Quote Quote  
  3. Originally Posted by Gameshow Host View Post
    I'm trying to take screen grabs every 2 seconds from a bunch of video files.

    Someone has already kindly provided me with this script for a .bat file:

    Code:
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -vf fps=fps=1.0/2.0 -qscale:v 2 "%~n1 - %%05d.jpg"
    pause
    However, when I drag multiple videos to this .bat file, it only processes the first one.
    "%1" means the first argument on the command line -- that is, the first file. The same is true for "%~n1". The rest of the files are ignored. A cheap and ugly way to do what you want is to repeat the same line for each file, specifying successive arguments on each line:

    Code:
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -vf fps=fps=1.0/2.0 -qscale:v 2 "%~n1 - %%05d.jpg"
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i %2 -vf fps=fps=1.0/2.0 -qscale:v 2 "%~n2 - %%05d.jpg"
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i %3 -vf fps=fps=1.0/2.0 -qscale:v 2 "%~n3 - %%05d.jpg"
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i %4 -vf fps=fps=1.0/2.0 -qscale:v 2 "%~n4 - %%05d.jpg"
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i %5 -vf fps=fps=1.0/2.0 -qscale:v 2 "%~n5 - %%05d.jpg"
    pause
    That will process up to 5 files. It's ugly because when you pass less than 5 files you will get error messages for the missing file names. You can add more lines to process more files but the limit is 9 using this method. You can make it a little cleaner by testing to see if the argument exist:

    Code:
    IF "%~1"=="" GOTO end
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -vf fps=fps=1.0/2.0 -qscale:v 2 "%~n1 - %%05d.jpg"
    IF "%~2"=="" GOTO end
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i %2 -vf fps=fps=1.0/2.0 -qscale:v 2 "%~n2 - %%05d.jpg"
    IF "%~3"=="" GOTO end
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i %3 -vf fps=fps=1.0/2.0 -qscale:v 2 "%~n3 - %%05d.jpg"
    IF "%~4"=="" GOTO end
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i %4 -vf fps=fps=1.0/2.0 -qscale:v 2 "%~n4 - %%05d.jpg"
    IF "%~5"=="" GOTO end
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i %5 -vf fps=fps=1.0/2.0 -qscale:v 2 "%~n5 - %%05d.jpg"
    
    :end
    pause
    If you want to process all the MP4 (or whatever extension) files in a folder you can use a for loop:

    Code:
    for %%F in (*.mp5) do (
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i "%%F" -vf fps=fps=1.0/2.0 -qscale:v 2 "%%~nF - %%05d.jpg"
    )
    Quote Quote  
  4. Thank you both so much!

    Jagabo's final script is just what I needed. I just changed the file extension in the code (to .mts) and it worked perfectly!
    Quote Quote  
  5. Oops, I just noticed I typed *.mp5 into that last script when I meant to type *.mp4. In any case, use whatever extension is appropriate for your file type.
    Quote Quote  



Similar Threads