Saturday, May 1, 2010

Midterm "Assignment 5"

MIDTERM
For this assignment we were assigned to take a movie and dump the frames into a folder and edit them to be something different. For this I changed my frames from color to black and white using gimp. I then used my terminal to execute all my scripting and coding.




Converting and Putting Frames in Tmpframe
This code here is my first code that converted the video from mts to mpg and then dumped the frames into tmpframe:

183 ffmpeg
184 cd ~/Documents/
185 ls
186 ls -l | grep INTRO*
187 cd INTRO\ TO\ MODELING/
188 ls
189 ffmpeg -i 00012.MTS -s 640x480 car.mpg
190 ls
191 mkdir tmpframe
192 ffmpeg -i car.mpg -f image2 tmpframe/frame-%04d.ppm
193 ppminvert frame-0001.ppm > inverted.ppm

Rename
This first script was ran to rename all the frames from having the 0001 to just being a number from 1 to 630:

#!/bin/bash

# Script to remove excess zeros from file names

clear


i=100

while [ $i -ge 100 ]
do
mv frame-0$i.ppm frame-$i.ppm
i=$[ $i+1 ]
done


Convert
This script used ffmpeg to convert all the frames from ppm to jpg:

#!/bin/bash

# Script to convert ppm files to jpeg

clear

i=1

while [ $i -le 630 ]
do
ffmpeg -i frame-$i.ppm frame-$i.jpg
i=$[ $i+1 ]
done


MAking Frames Back Into a Movie
This is the script that put all the frames back together into an mpg movie:

#!/bin/bash
# Natasha Keller
# Script to Make MPG Movie using FFMPEG

clear

echo "Executing script to convert PPM files to AVI format"

## Initially tried using a while loop
# then found single line in man page that would
# accomplish what i needed.

# This program when ran after the conversion to JPG
# program will conver the JPG images into an MPEG movie

# Note: The default framerate, bit rate, and size were used


#i=1

#while [ $i -le 630 ]
#do


ffmpeg -f image2 -i frame-%d.jpg out.mpg

#i=$[ $i+1 ]
#done

echo "Movie complete. Please view out.avi in Quicktime."

No comments:

Post a Comment