Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I want to take a frame of a video at a certain percentage of time (for example, 25%, 50% and 75%) and save it somewhere.

I need this to be done from the command-line so I can automate it. Also, this needs to be done in Windows.

Does anyone know how to do this?

share|improve this question
    
Which file format is the video(s) encoded in? –  iglvzx Jan 30 '12 at 19:34
    
Oh, sorry. They're in XviD (in AVI) and h264 (in MKV) mostly, they're videos from different TV series. Thanks! –  brott Jan 30 '12 at 19:39
    
possible duplicate of Take a screen shot from command line in Windows –  Ƭᴇcʜιᴇ007 Jan 30 '12 at 20:15
2  
@techie007 NOT a duplicate... This is basically about taking a frame from a video file and saving it as an image... Not about taking a screen shot of the entire screen. –  BloodPhilia Jan 30 '12 at 21:09

1 Answer 1

up vote 4 down vote accepted

You might want to use ffmpeg for Windows with the following command:

ffmpeg -i <INPUT FILE> -ss 10 -f image2 -r 25 <OUTPUT FILE>
  • -i <INPUT FILE> Specifies the input file. E.g. movie.mp4.
  • -ss <TIME> Specifies time position in seconds. "hh:mm:ss[.xxx]" is also supported.
  • -f image2 Force/Set format.
  • -r 25 Set frame rate (in Hz. Can either be a fraction or a number, default = 25).
  • <OUTPUT FILE> Set output file. E.g. image1.jpg.

If your source video has a fixed frame rate, you can capture a specific frame using this formula:

<FRAME NUMBER> / <FRAME RATE> = <NUMBER OF SECONDS>

So if you want to capture frame 250 at a 25Hz frame rate, you set -ss to 10.

share|improve this answer
1  
You can probably use wmi to pull the time length property from the video file, do some division on the output, then use that as the input for -ss. –  Mechaflash Jan 30 '12 at 21:26
1  
Thank you very much! Although it didn't quite work (I got this and it never stopped: pastebin.com/raw.php?i=2nA04Uua), it pointed me here: stackoverflow.com/questions/3827611/… and that worked. Thanks! @Mechaflash What is wmi? It sounds very useful! Thanks! –  brott Jan 30 '12 at 22:03
1  
@brott wmi is apart of the windows envrionmement that deals with windows objects and their properties. In your case the object is the video file and the property is the time length of the video. Information on WMI: msdn.microsoft.com/en-us/library/windows/desktop/…. Information on using WMI in windows batch-file scripting: technet.microsoft.com/en-us/library/bb742610.aspx –  Mechaflash Jan 30 '12 at 22:26
    
That's very useful, thanks, @Mechaflash! –  brott Jan 30 '12 at 22:30
    
Try the following command on your video file: wmic datafile where name='C:\\Path\\To\\Video.xvid' > WMIoutput.txt Please note the double \ and single quotes. Check the WMIoutput.txt file that it created and see if it shows some sort of time or duration of the video. I tested this on a mp3 file and it didn't return that sort of field for me. –  Mechaflash Jan 30 '12 at 22:54

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.