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?
+ Reply to Thread
Results 1 to 19 of 19
-
-
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
Code:"g:\program files\ffmpeg\bin\ffmpeg.exe" -i %1 -vf fps=fps=0.1 pic%%05d.jpg
Last edited by jagabo; 16th Apr 2019 at 11:15.
-
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"
-
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? -
-
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
-
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.
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
-
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. -
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:
[Attachment 48685 - Click to enlarge]Last edited by jagabo; 16th Apr 2019 at 19:53.
-
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.) -
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
Just change the extension in the batch file. from .jpg to .bmp or .png.
Don't know. Don't care. -
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? -
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
I don't think ffmpeg can do that. -
Thanks Jagabo!
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. -
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"
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. -
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.
-
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
Similar Threads
-
is there any tool which joins 3 seconds intro to all 100 videos in batch
By gta5 in forum Newbie / General discussionsReplies: 5Last Post: 4th Sep 2020, 08:56 -
cut/delete first 5 seconds of 100s of videos
By gta5 in forum EditingReplies: 4Last Post: 22nd Nov 2018, 05:08 -
Videos Appear Streched Beyond TV Screen
By ConverterCrazy in forum Newbie / General discussionsReplies: 6Last Post: 19th Jan 2017, 16:21 -
Youtube videos pixelated every 5 seconds
By Warcraft3 in forum Video Streaming DownloadingReplies: 81Last Post: 11th Sep 2016, 02:58 -
PotPlayer - Screen becomes dimmer after 2 seconds of lecture
By jcgalland in forum Software PlayingReplies: 1Last Post: 12th Jul 2016, 16:02