Sunday, May 8, 2011

IFDM 210 -Final Project-

For my final project I made a script that opens and runs my altered pygame, saves every 5th image, and then adds an effect, and compiles them into a movie.

Not only did I use ffmpeg and imagemagick to alter still frames, but I also worked to create a script that first called my pygame in bash an ran it quickly (which I had been trying to get to work since we began working with terminal). Before, to run it I had to enter the python module and go through multiple commands just to open the game window, which was very tedious while I was altering and improving on it. Now, my code not only opens the game in a split second, but runs it as well.

With the addition of the code I added to the original pygame code, run.sh now also takes every 5 frames from the game, and saves them out in the pyspaceinvaders folder (inside the Game folder) as .png images.

From here, am able to use imagemagick and ffmpeg to alter them further, and compile them into a movie.

I call them with imagemagick, to cycle through the still frames and apply a swirl effect with a for loop. After this is completed, I coded ffmpeg to take those images, and compile them into a movie, and after doing so, delete the excess still frames remaining in the folder.

Overall, I used 3 different programs. Through the terminal, I used Python, (which has a different syntax than bash and requires more specified spacing), and before this project, I had been unsuccessful in making it run through a bash script. I also used imagemagick to alter the saved still frames, and then ffmpeg to compile them into the movie.

This project was very difficult for me, but in the end I figured it out, and I'm glad I did, because now I have a new outlook on programming, and will be using it more in the future.


LINK TO .ZIP FOLDER:

http://dl.dropbox.com/u/18940217/Bmoody210_Final.zip


EXAMPLE RESULT:

Saturday, May 7, 2011

ffmpeg test example movie

Project History Links

http://dl.dropbox.com/u/18940217/FinalProject_TerminalHistory.txt


http://dl.dropbox.com/u/18940217/TerminalFinalHistory_2.txt


These are the links to the history files for both my final project, and the test. I tend to leave my terminal running as long as possible so I can continue my work, so that is why there are only wo, but they are quite long.

Wednesday, May 4, 2011

Trying to figure out how to save each frame of a played video game as an image

I have been researching and working on this for a while now, for my final project.

I originally was going to do something using imagemagick and combining pictures, but I really like compiling image frames together to make a movie like we've been doing with ffmpeg.
I found something that my seem to work...


NEVERMIND_ Half way through this I tried something new, and it's moved me a little farther than it did before,

a window pops up now, but then it disappears,

I started using i instead of self.framenum, because it kept throwing an error on that, the window then began to pop up but threw an error saying that i was referenced before it was defined, so i went through and fixed this, and now it is saying this for my variable name file, but no longer for i- so I am making progress...

FFmpeg Test/homework

This is my ffmpeg code from the test/homework


It takes the still frames out of a movie, adds the frame numbers and an effect to each image (I have edge written in here, but it can be any imagemagick effect,I used sketch and charcoal too, but this one takes the least amount of time)


After it applies the effect to each image it then compiles them back into a movie called edge.mov and then deletes all the image files, so none are left behind.


Then you can play the video and see the effects it has, and the frame numbers.


I had alot of trouble with this assignment at first, but once I had time to sit down and work through it, I began to figure it out, and I'm really glad we got to do it as a homework assignment as well, because now that I've gotten it, I feel so much better on this subject.




rm edge.mov


ffmpeg -i jumps.mov -s hd720 -f image2 %07d-fresh.png

for((i=1; i<50; i++))

do

fresh=`printf "%07d-fresh.png" $i`





STRING="Frame Number $i"

echo $STRING



mogrify $fresh -draw "text 25,25 '$STRING'" $fresh

convert $fresh -edge 2 $fresh.bmp


#convert $fresh -colorspace gray -sketch 0x20+120 $fresh

#convert $fresh -colorspace gray \

#\( +clone -blur 0x2 \) +swap -compose divide -composite \

#-linear-stretch 5%x0% $fresh

done


ffmpeg -f image2 -i %07d-fresh.png.bmp -r 25 -b 10000k -s 1200x720 edge.mov


rm *.png

rm *.png.bmp