VideoHelp Forum
+ Reply to Thread
Results 1 to 19 of 19
Thread
  1. I have a collection of video files and I simply want to take screen grabs from them every 5 or 10 seconds. (I want this to be an automated process, rather than having to play through each video.)

    I can't find any way to do it in PotPlayer - is there some program that can do this?
    Quote Quote  
  2. You can do this easily with ffmpeg. Put the following text in a batch file and you can drag/drop any video onto it to make the images at the specified interval:

    Code:
    ffmpeg -i %1 -vf fps=fps=0.1 pic%%05d.jpg
    If ffmpeg isn't in your search path use the full path to ffmpeg:

    Code:
    "g:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -vf fps=fps=0.1 pic%%05d.jpg
    The fps number should be 1/seconds, where seconds is the interval at which you want your images. For 10 seconds: 1/10 = 0.1. You can even use the equation within the script so you don't have to calculate the value: fps=fps=1.0/10.0. The images will be created with the form pic00001.jpg, pic00002.jpg, etc. The images will have the same dimensions as the video. So a 1920x1080 video will produce 1920x1080 images.
    Last edited by jagabo; 16th Apr 2019 at 12:15.
    Quote Quote  
  3. Most important part is provided bellow, on forum you can easily find scripts to process multiple files with single batch.
    Made some assumption, 5 second interval, resize video to thumbnail 160xautomod2, speedup 24 times, target APNG

    Code:
    ffmpeg.exe -y -hide_banner -v 32 -stats -i "%filename%" -an -sn -dn -vf "select='isnan(prev_selected_t)+gte(t-prev_selected_t\,5)',zscale=f=spline36:r=full:w=160:h=-2,setpts=PTS/24" -vsync 0 "%~n1_thumbnail_5sec.apng"
    Quote Quote  
  4. Originally Posted by jagabo View Post
    You can do this easily with ffmpeg. Put the following text in a batch file and you can drag/drop any video onto it to make the images at the specified interval:
    Thank you so much! I already had ffmpeg installed, though I can't remember why.

    Sorry to be a dummy, but I wasn't able to follow your instructions on using it. Do you think you could dumb it down even more? When I made a .bat file containing the script you gave, and ran it, nothing seemed to happen - it just popped up and disappeared instantly. And you mentioned dragging and dropping videos - where to?
    Quote Quote  
  5. Originally Posted by Gameshow Host View Post
    you mentioned dragging and dropping videos - where to?
    Drag a video file onto the bat file.
    Quote Quote  
  6. Originally Posted by jagabo View Post
    Originally Posted by Gameshow Host View Post
    you mentioned dragging and dropping videos - where to?
    Drag a video file onto the bat file.
    OK, nothing happened. A command prompt briefly flashed up then disappeared. This happens with either of the scripts you gave me - or Pandy's script.

    Incidentally, I don't know what you mean about ffmpeg being in my "search path"? What's that?
    Quote Quote  
  7. Code:
    @setlocal
    
    @set FF=C:\ffmpeg
    @set PATH=%FF%;%PATH%
    
    @set filename=%1
    
    @ffmpeg.exe -y -hide_banner -v 32 -stats -i "%filename%" -an -sn -dn -vf "select='isnan(prev_selected_t)+gte(t-prev_selected_t\,5)',zscale=f=spline36:r=full:w=320:h=-2,setpts=PTS/24" -vsync 0 "%~n1_thumbnail_5sec.apng"
    @endlocal
    @pause
    Assuming your ffmpeg.exe is located on C:\ffmpeg - if not then you need provide full path to ffmpeg.exe - easiest way to do this: find ffmpeg.exe, right mouse button click -> properties -> Location - select text filed with mouse and left mouse button then copy (ctrl+c) to clipboard then edit script and replace line @set FF='ffmpeg.exe location' after this your script should work correctly.
    Quote Quote  
  8. Originally Posted by Gameshow Host View Post
    Originally Posted by jagabo View Post
    Originally Posted by Gameshow Host View Post
    you mentioned dragging and dropping videos - where to?
    Drag a video file onto the bat file.
    OK, nothing happened. A command prompt briefly flashed up then disappeared. This happens with either of the scripts you gave me - or Pandy's script.
    Put Pause on the last line of the bat file so it doesn't close automatically. Then you'll be able to read any error messages.

    Originally Posted by Gameshow Host View Post
    Incidentally, I don't know what you mean about ffmpeg being in my "search path"? What's that?
    When type a program name without a full path windows looks through the search path to find it. You can see the search path by typing Path at a command prompt. But just use the full path to ffmpeg.exe as indicated in my example:

    Code:
    "g:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -vf fps=fps=1.0/10.0 pic%%05d.jpg
    pause
    Change the path to where ffmpeg.exe located is on your computer.
    Quote Quote  
  9. I really appreciate everyone's help, but this isn't working!

    No matter what I try, whenever I run the .bat file, a command prompt appears for a split second then disappears. Even the code with "pause" at the end doesn't seem to pause it.
    Quote Quote  
  10. ZIP up your bat file and upload it here. Also, navigate to your ffmpeg.exe with Explorer. Right click on it and select Properties from the context menu. Post an image of the General tab of the Properties dialog. For example:
    Image
    [Attachment 48685 - Click to enlarge]
    Last edited by jagabo; 16th Apr 2019 at 20:53.
    Quote Quote  
  11. OK I want to give a BIG THANKS to both of you for your help!

    I was all set to follow Jagabo's instructions, but I have now solved my problem…

    When DOS prompt flashed up, I captued the screen and was able to see the error: "'■r' is not recognized as an internal or external command". After a bit of searching, I realized that the problem is that the .bat file needs to be saved as ANSI encoding. I have Notepad2 set to Unicode by default (because ANSI doesn't allow many characters I use regularly).

    After I changed the file to ANSI, Jagabo's script worked perfectly!

    So now I just have three very minor, unimportant questions…

    1. The resulting JPEGs are quite small files. Do you happen to know if ffmpeg is matching the compression quality of the original video, or is it (somewhat more crudely) just re-compressing the image at a standard low quality setting?

    2. Is there any way to save as lossless images (BMP or PNG)?

    3. I find it curious that these screen grabs look different to PotPlayer's screen grabs. In fact, these look much higher quality than PotPlayers (even when PotPlayer captures lossless). Maybe PotPlayer is processing the images? (I find that concerning, as someone who cares about quality.)
    Quote Quote  
  12. Originally Posted by Gameshow Host View Post
    1. The resulting JPEGs are quite small files. Do you happen to know if ffmpeg is matching the compression quality of the original video, or is it (somewhat more crudely) just re-compressing the image at a standard low quality setting?
    Use -qscale:v (or the alias -q:v) as an output option. Effective range for JPEG is 2-31 with 2 being best quality, 31 being the worst quality

    Originally Posted by Gameshow Host View Post
    2. Is there any way to save as lossless images (BMP or PNG)?
    Just change the extension in the batch file. from .jpg to .bmp or .png.

    Originally Posted by Gameshow Host View Post
    3. I find it curious that these screen grabs look different to PotPlayer's screen grabs. In fact, these look much higher quality than PotPlayers (even when PotPlayer captures lossless). Maybe PotPlayer is processing the images? (I find that concerning, as someone who cares about quality.)
    Don't know. Don't care.
    Quote Quote  
  13. Two more questions: Is there any way to…

    1. Make the captured image filenames contain the video name and/or time reference?
    2. Make the captured image file date match the date of the original video?
    Quote Quote  
  14. Originally Posted by Gameshow Host View Post
    1. Make the captured image filenames contain the video name
    To generate files with the same name as the video (plus a five digit number and jpg extension):

    Code:
    "g:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -vf fps=fps=1.0/10.0 -qscale:v 10 "%~n1.%%05d.jpg"
    pause
    Originally Posted by Gameshow Host View Post
    and/or time reference?
    Do you want the images to contain a subtitle with the time at which the frame appears? Or do you want the filenames to include the time at which the frame appears? Or are you want the creation date/time of the original video file in the image/name?

    Originally Posted by Gameshow Host View Post
    2. Make the captured image file date match the date of the original video?
    I don't think ffmpeg can do that.
    Quote Quote  
  15. Thanks Jagabo!

    Originally Posted by jagabo View Post
    Do you want the images to contain a subtitle with the time at which the frame appears? Or do you want the filenames to include the time at which the frame appears? Or are you want the creation date/time of the original video file in the image/name?
    I definitely don't want subtitles thanks, only the image filename to be affected.

    Ideally I would like the image filename to be:
    [video title] [creation date/time of the video in YYYY-MM-DD HH-MM format] [time at which the frame appears].jpg

    But anything close to this would be good.
    Quote Quote  
  16. Off the top of my head I don't know how to get the creation date/time of a file in a batch file. You will probably have to use a few commands in the batch file to get it into an environment variable to use it as part of the output filename spec form ffmpeg.

    I know how to get the timecode of the video burned into the images but I don't know if you can use similar code to add that to the file names.

    Code:
    "g:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -vf "drawtext=fontfile='c\:\\windows\\fonts\\LiberationSans-Bold.ttf':x=10:y=10:fontsize=24:fontcolor=white:shadowcolor=black:shadowx=1:shadowy=1:timecode='00\:00\:00\:00':timecode_rate=50,fps=fps=0.1" -qscale:v 20 "%~n1.%%05d.jpg"
    That burns the timecode into the jpeg images. Maybe you can figure out how to get that timestamp info into the name of the file instead. But I don't know if you can even use a dynamically changing value in the name spec.

    One problem with that burning method is you have to specify the frame rate of the video (in the example code it's set to 50 fps). You can probably use ffprobe (with a little data manipulation) to get that before calling ffmpeg. Again, you'll probably have to put it into an environment variable to get it into the ffmpeg command line.
    Quote Quote  
  17. Thanks Jagabo, I really appreciate all your kind help! Not to worry about the small details, you've really helped me achieve what I was trying to. Thanks to Pandy, too.
    Quote Quote  
  18. OK I've just hit a problem with the script I was given. When I drag a batch of videos into the .bat file - it only processes the first one, not all of them.

    This is the code I'm using:
    "c:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -vf fps=fps=1.0/2.0 -qscale:v 2 "%~n1 - %%05d.jpg"
    pause
    Quote Quote  



Similar Threads

Visit our sponsor! Try DVDFab and backup Blu-rays!