My Departement Of Nerdcore Enthusiasm

Tutorials and the like. Things which I have committed myself to. Often linux/UNIX-related.

tirsdag den 6. december 2011

Zooming in a video clip

This script is a way to zoom into a video clip already recorded. In order for that to work one must be able to move the "focus" around through the progression of the video clip so that one can keep the focus around a certain object. The scripted in reality consist of two scripts "prunpre" a preperatons a script and "prunrun" a "run script" which treats 60 frames at a time.
The script vil run on a Unix environment: Unix, Linux, Mac OS X, Solaris, Free BSD, etc. You can even run it in Windows if you install cygwin. besides having a UNIX/Linux environment, there are also some basic software packages you must have installed on the system before this script can be used. That is:

FFmpeg (commandolinie Video conversion and editing)
Feh (Image viewer)
Netpbm (Toolkit for manipulation of graphic images)

Here is a video demo of the scripts in action.


Here are the scrips. You can right click and download or open and copy paste.

prunpre
prunrun

Once you have the script downloaded, you will probably also have to make them executable.
chmod +x prunpre
chmod +x prunrun

When you have the two scripts, create a directory where you put the two scripts and the video clip you want to zoom in on.
Then the video clip needs to be converted into a series of numbered ppm images (ppm is an image format) one image per frame in the video clip.
You do that with ffmpeg. Open an x-terminal of one kind or another and switch to the directory where you you have the video clip and the scripts. then give the command:

ffmpeg -sameq -i myvideo.avi myvideo%d.ppm

Where naturally myvideo.avi be replaced with the name of the video clips you want to work with.

Note this process can be pretty disk-space intensive.

You're then ready to run the first script. So in your X-terminal you type.
./prunpre basename (Followed by "enter")
where basename is the base name of the pictures you just printed out with ffmpeg. If the images are called.

img1.ppm, img2.ppm, img3.ppm, img4.ppm

then your base name is "img".

The script will guide you through the following steps. After prunpre the second script prunrun have to be executed, but prunpre will give a message about that when it has completed its process. The demo-video here above could also give a sense of how to use the scripts.

A more general note that is dealing not just with these two scripts but also the other scripts on this blog and my whole approach to this work:
The scripts here I make because I need them myself for a specific task, but somtimes I think they are really good and very configurable and so I try to adjust them so that others could use them too. It is also a kind of aesthetic pleasure to make things nice of comprehensible to others. But I think I apeal to a very limitation audience with these scripts and therefore there is no reason to come around every all aspects of adaptation and compatibility. I think of it this way: For instance this scripts would, easily be adapted to run on the terminal on a mac computer. Or the scripts could easily be change to work together with an other image viewer than "feh", but I do not know if anyone will ever need this so there is no reason to make all this ajustments. I’d rather you contact my if you have any special needs. I know the scripts and I could probably easy ajust them to your needs. My contact info is here ore you can do a comment on the blog post here.

Enjoy
Mikkel

Ingen kommentarer:

Send en kommentar