The online racing simulator
Video capture using python
(9 posts, started )
Video capture using python
I have created a program which takes a whole bunch of screenshots at a given frame rate. So far, it just captures images. But, I am going to install the pyMedia library, so that I can capture to an avi. It takes like NO cpu power whatsoever. It's a 15-line video capture program lol I will attatch my proggy later, as an .exe so that no-one has to download the two libraries that I am using. There is a limit on the amount of frames you can capture, 9 x 10^5 -1
-----------

http://4wheelerhummers.googlepages.com/screenie0.1.zip

I have created a windows version. Extract all files do a directory, go to a command prompt, navigate to the directory, all parameters are required:

screenie [Path and prefix] [format] [framerate]


for example:

screenie D:/capture_dir/LFS bmp 25

would output:
D:/capture_dir/LFS_100000.bmp
D:/capture_dir/LFS_100001.bmp
D:/capture_dir/LFS_100002.bmp
D:/capture_dir/LFS_100003.bmp
D:/capture_dir/LFS_10000.... and so on, at 25 FPS
Let me know what features should be added, and I will try. I am not that good though, I couldn't figure out how to create avi files yet, or resize on-the-fly with interpolation other then nearest. Just for fun I might try sending frames across my network using UDP.
Quote from wheel4hummer :Let me know what features should be added, and I will try. I am not that good though, I couldn't figure out how to create avi files yet, or resize on-the-fly with interpolation other then nearest. Just for fun I might try sending frames across my network using UDP.

You might want to take a look at PyMedia I believe it has an encoding module for AVI's (and supports various codecs, iirc).
#4 - DeKo
virtual dub should work with making the bmp's into an AVI. at least, it works with sourcerecorder, which does basically the same thing
So does bmp2avi.
-
(KiDCoDEa) DELETED by KiDCoDEa
That's insanely awesome!

I don't like python myself, mainly due to the fact that I really don't get it. The whole syntax of it just seems so wrong. But the fact you could make a 15 line program this powerful is just awesome. That said, python programmers are pretty much standing on the shoulders of giants.
Quote from Dygear :But the fact you could make a 15 line program this powerful is just awesome.

I just used libraries, they make it really easy. I used the "Python Image Library" (PIL) which has a function to take a screenshot, and save an image.

Here is the source if you are curious:

import Image # Import the Image library
import ImageGrab # Import ImageGrab, part of the Image library
import time # Import the built-in time library
import os,sys # Import the built-in system command library (proggy arguments)
num=100000
prefix = sys.argv[1] + "_" # Variable prefix is the first argument, with _ after it
ext = sys.argv[2] # Variable ext is the second argument
framerate = 1/int(sys.argv[3]) # Framerate is the 3rd argument, Hz is equal to Seconds^-1
while 1: # Loop until you close the window or terminate the program using Ctrl+C
num2 = str(num) # convert the number at the end to a string for the filename
f = prefix + num2 + "." + ext # More of creating the filename
im = ImageGrab.grab() # Grab the screen
im.save(f) # Save the screen as the filename
time.sleep(framerate) # Wait this amount of time (0.2s for 20fps)
num = num + 1 # Add 1 to the frame number

I tested my program more, and it turns out that the framerate varies by as much as like 50% depending on your processor load.
If your running dual core, ya should be fine tho.

Video capture using python
(9 posts, started )
FGED GREDG RDFGDR GSFDG