If you run ffmpeg with only the -i option, it will give you the length of the video on stderr (among many other things). You can write something around this by converting the duration and estimated number of frames to the correct -r option.
python, , . - , ffmpeg, 0, Preview-3 to Preview-n . , "1", Preview-3.png.
import sys,os,re
from subprocess import *
if len(sys.argv)<=1:
print("usage: python oneinn.py filename frames")
sys.exit(0)
try:
fvideo = sys.argv[1]
frames = float(sys.argv[2])
except:
sys.stderr.write("Failed to parse parameters.\n")
sys.exit(1)
output = Popen(["ffmpeg", "-i", fvideo], stderr=PIPE).communicate()
re_duration = re.compile("Duration: (.*?)\.")
duration = re_duration.search(output[1]).groups()[0]
seconds = reduce(lambda x,y:x*60+y,map(int,duration.split(":")))
rate = frames/seconds
print("Duration = %s (%i seconds)" % (duration, seconds))
print("Capturing one frame every %.1f seconds" % (1/rate))
output = Popen(["ffmpeg", "-i", fvideo, "-r", str(rate), "-vcodec", "png", 'Preview-%d.png']).communicate()