0

I am successfully capturing a screen shot every 15 seconds with the command below but I need to correlate the images to where in the video the screen shot is from.

The %d gives me an integer, but is there a similar variable, filter, or otherwise to include or somehow capture the timestamp of the image in the output file name?

c:\ffmpeg\bin>ffmpeg -i c:\files\video.mp4 -vf fps=1/15 c:\images\image_%d.png";

Current output is :

c:\images\image1.png
c:\images\image2.png
c:\images\image3.png
...
c:\images\image999.png

Desired output is something like:

c:\images\image_00-00-00.png    // Capture at start of video
c:\images\image_00-00-15.png    // Capture at 00:00:15
c:\images\image_00-00-30.png    // Capture at 00:00:30
c:\images\image_00-00-45.png    // Capture at 00:00:45
c:\images\image_00-01-00.png    // Capture at 00:01:00
...
c:\images\image_01-25-15.png    // Last capture
3
  • As far as I know this is not possible yet. This seems to be ticket #1452: image2 to support %t.
    – llogan
    Commented Aug 28, 2015 at 19:22
  • I thought not, though sifting through old google results, seemed the data was available, and hopefully someone had figured it out. Thank you.
    – GDP
    Commented Aug 28, 2015 at 19:23
  • 2
    If you trust that the outputs are exactly 1/15 apart, then you can script some renaming. Lame, but perhaps an option.
    – llogan
    Commented Aug 28, 2015 at 19:24

1 Answer 1

1

As some people have written, there is probably no option for ffmpeg command, that can do what you want. On linux machine I would suggest you to use the following script

#!/bin/bash
interval=15 # interval between images in seconds

for ((i=0; i<$1; ++i)); do
timestamp=$(date -d @$((-3600+${i}*${interval})) +%H-%M-%S)
mv image${i}.png image_${timestamp}.png
done

exit 0

you can call it in the directory with images as

$ script_name NNN

where NNN is the total number of images (I assume that you start numbering with 0 instead of 1, it is not difficult).

As you can see I rely on the linux command date, which is capable of converting seconds into hours.

Since you seem to be on Windows machine, there are a couple of options, how you can use this script.

  1. Rewrite it into Windows batch file. There is a topic here, which discusses how to use command similar to date on Windows.

  2. Install cygwin and run the script above from cygwin command line

  3. Use standalone bash coomand line for running the script above.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .