View Full Version : mplayer, capture screenshot at 10%
smok3
17th August 2007, 16:09
how would i capture screenshot (png) of some video file at lets say 10% of the timeline? (using cmd, winxp)
rvm
17th August 2007, 17:47
mplayer video.avi -frames 1 -vo png -nosound -ss 20:00
will create a capture (00000001.png) from the time set in -ss.
smok3
17th August 2007, 20:08
but -ss must be in seconds right? (there is no way to setup time in percentages?)
rvm
17th August 2007, 22:09
According to the manual, yes, -ss specifies a time, not a percentage.
I don't know if there's an easier way, but the following works (at least in linux):
create a text file (commands.txt) with this content:
seek 20 1
screenshot
pause
quit
(the first value for seek is the percentage)
And then run:
mplayer video.avi -slave -nosound -vf screenshot < commands.txt
smok3
17th August 2007, 22:35
rmv, nope, does not work in win,
---
however this is kinda funny, if i do:
mplayer file.mp4 -ss 10 -vo png -nosound -frames 1
(it will return first frame of the video and not the frame at 10s)
but if i do:
mplayer file.mp4 -ss 10 -vo png -nosound -frames 2
then the 2nd captured frame is from the seek position.
smok3
18th August 2007, 17:53
ok, this seems to be close to what i want:
makethumb.bat
@echo off
MediaInfo --Inform=Video;%%FrameCount%% %1 > %1_framecount.txt
set /P framecount_var=<%1_framecount.txt
set /A seekto_var=framecount_var/10/25
echo %seekto_var%
MediaInfo --Inform=Video;%%Width%% %1 > %1_width.txt
MediaInfo --Inform=Video;%%Height%% %1 > %1_height.txt
set /P width_var=<%1_width.txt
set /P height_var=<%1_height.txt
if %width_var% GTR %height_var% (
set crop_var=%height_var%
) ELSE (
set crop_var=%width_var%
)
echo %crop_var%
call mplayer -vf crop=%crop_var%:%crop_var%,scale=150:150 -ss %seekto_var% -vo png:z=9 -nosound -frames 2 %1
del %1_framecount.txt
del 00000001.png
del %1_width.txt
del %1_height.txt
rename 00000002.png %~n1_t.png
:: here you can use pngcrush or something..
usage:
makethumb file.mp4
will (should) return png snapshot 150x150px from approximately 10% of the timeline (if the file is seekable enough)
required:
mplayer.exe
mediainfo.exe
todo:
make errorlog for thumbs that didn't make it
rvm
19th August 2007, 06:39
BTW, you can also use mplayer to get info about a video:
mplayer -identify any_video
Netuser
22nd August 2012, 03:55
ok, this seems to be close to what i want:
makethumb.bat
@echo off
MediaInfo --Inform=Video;%%FrameCount%% %1 > %1_framecount.txt
set /P framecount_var=<%1_framecount.txt
set /A seekto_var=framecount_var/10/25
echo %seekto_var%
MediaInfo --Inform=Video;%%Width%% %1 > %1_width.txt
MediaInfo --Inform=Video;%%Height%% %1 > %1_height.txt
set /P width_var=<%1_width.txt
set /P height_var=<%1_height.txt
if %width_var% GTR %height_var% (
set crop_var=%height_var%
) ELSE (
set crop_var=%width_var%
)
echo %crop_var%
call mplayer -vf crop=%crop_var%:%crop_var%,scale=150:150 -ss %seekto_var% -vo png:z=9 -nosound -frames 2 %1
del %1_framecount.txt
del 00000001.png
del %1_width.txt
del %1_height.txt
rename 00000002.png %~n1_t.png
:: here you can use pngcrush or something..
usage:
makethumb file.mp4
will (should) return png snapshot 150x150px from approximately 10% of the timeline (if the file is seekable enough)
required:
mplayer.exe
mediainfo.exe
todo:
make errorlog for thumbs that didn't make it
Sorry to bump this old post, but didn't find anything newer.
I would like to take multiple full screenshots from videos this script let me do 1 image (i modified it a little to get full screen delete the 150x150 part), however if I duplicate the following line I do get some more shots :
set /A seekto_var=framecount_var/10/15
echo %seekto_var%
call mplayer -vf crop=%crop_var%:%crop_var%, -ss %seekto_var% -vo png:z=9 -nosound -frames 2 %1
rename 00000002.png %~n1_2.png
But can anyone who know this language can tell me what does 10/25 values stand for ? I don't think it is a percentage because If i change it i get some other frame but doesn't correspond to that percentage.
So Anyone can please explain what it is ? and How I can easily add some code to get multiple screenshots, like 8 shots from a video.
Also is there any code that can let me loop through and entire folder and take screenshots of all videos ?
Thanks a lot for your help :)
smok3
22nd August 2012, 11:22
10 = 10 percents
25 = hardcoded value for framerate (obviously you need to get real info from file in question if you want some more precise results)
smok3
22nd August 2012, 11:25
p.s. (can't edit my own post), use mtn instead of mplayer
http://moviethumbnail.sourceforge.net/
smok3
22nd August 2012, 12:40
something i used for some time, using mtn and nconvert, main:
::echo off
title %1
echo.
echo %~n1%~x1 1st try
t:\utility\movie_thumbs\mtn\mtn.exe -i -c 1 -r 1 -t -P -o %~x1.jpg %1
:: next line assumes that width > height
t:\utility\movie_thumbs\nconvert\nconvert.exe -out jpeg -ratio -resize 0 200 -canvas 120 180 center %1.jpg && rename %1.jpg %~n1.jpg
if not exist %~n1.jpg (
echo %~n1%~x1 2nd try
t:\utility\movie_thumbs\mtn\mtn.exe -i -c 1 -r 1 -t -P -Z -o %~x1.jpg %1
:: next line assumes that width > height
t:\utility\movie_thumbs\nconvert\nconvert.exe -out jpeg -ratio -resize 0 -canvas 120 180 center %1.jpg && rename %1.jpg %~n1.jpg
)
if not exist %~n1.jpg (
echo %1 > %~f1.error
)
loop
@ECHO OFF
for /f "delims=+++++, tokens=*" %%i in (%1) DO t:\path\makethumb_NG_300.bat "%%i"
Netuser
22nd August 2012, 22:42
Thanks for the reply :)
I figured out about 10 and 25 myself :D thanks to google
Thanks for the new script but what my need are I want Full screen cap not a thumbnail and I want it in losseless format PNG not in JPG
Is it possible with mtn ?
If not the mplayer script work good for me except that I can only go upto 50% of movie as the last number I can enter is 2 (which 50%) how to go further ?
Thanks for the loop command it helped me at least worked in loop the mplayer script :D. I was unable to loop in folder before :( tried many commands, the issue was the long name wth spaces. Script worked good when I drag and drop but when I introduce loop it wont work. Now with your loop commands it wokr liek charm. Now only porblem is that 50% limit :(
Hope mtn can do what I need please do tell if it can ?
thanks :)
smok3
23rd August 2012, 08:18
I want Full screen cap not a thumbnail and I want it in losseless format PNG not in JPG
no idea, it should (based on ffmpeg).
smok3
23rd August 2012, 08:23
If not the mplayer script work good for me except that I can only go upto 50% of movie as the last number I can enter is 2 (which 50%) how to go further ?
Can you believe i don't have a single windows machine anymore, so not sure where to test.
Netuser
24th August 2012, 23:43
a virtual machine cant help ?
smok3
25th August 2012, 13:05
a virtual machine cant help ?
Just yesterday i was trying to find a win7 dvd install, but failed (mountain lion upgrades made my xp bootcamp non-bootable for some reason). But yes virtual machines rule.
Netuser
27th August 2012, 04:03
still waiting if you can do something to go further then 50%
Thanks :)
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.