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

mandag den 17. oktober 2011

Create scrolling move text from a pdf file

If you look around on this blog you can see that much of it is about being able to produce video effect without a fancy graphic video editing program. I find it fuzzy to work with these heavy video editing programs when I often sit and just have a small computer at my disposal. My scripts can produce a good result without me having to sit and pull elements in place with the mouse drag-and-drop in a graphics program. I can instead give a precise command from a commando line and then just wait to see the job gets done. This script can be slow to get through the process. The example of “rolling credits” shown here took about half an hour to process on my little ASUS eee pc. But in that time I am free to work on something else. That works fine for me.

This script creates scrolling text video clip like the rolling credits of a movie. It makes it out of a PDF or PS (PostScript) document. That is when you want to produce your rolling credits, you simply typing them into a word processing program like OpenOffice Writer or AbiWord, etc. and then save (save a copy or export) as a pdf (almost any modern word processor will do this). You should set the page size to A4 paper size. Top and bottom margin should be an inch with is equal to 2.54 cm. The spread of your document equals to the screen stretched so the distance you have between the text and the edges of the document corresponds to what you're going to see on the screen.  I have usede a Font Size of 20 points which I think is a good starting point but it is up to you. You can format text just like you would in your word processing system. Use black for the text and white for the background. Although the text is spread out over several pages in the word processing program try to imagine that it's just one long continuous text when you set it up. The resulting video clip is white text on black background. This concept can obviously be expanded so that the text will run over the "living pictures" in your video, but it leads too far now. The script is also currently limited to producing a video output in VGA format 640 x 480 pixels.

For this script to work you must have the following programs on your computer:

1. The scripted is a bash shell script so you must have a bash shell environment that you have on most Unix platforms. OS X, Linux (Ubuntu, Red Hat, puppy etc), Solaris, etc.

2. The basic program package Netpbm command-line based and script-based image processing.

3. Ghostscript (GS), the classic Gnu / open-source tool for PDF and PostScript handeling.

4. Ffmpeg a really nice strong basic commando line based film/video editing and conversion tool.

To run the script you must have opened a terminal window. Xterm Aterm.. whatever. Then, in your working directory you should have your PostScript file and the script. You give PDF or PostScript file as an argument to the script like this:

./rolling yourfile.pdf

and now it will take a while to produces a video clicp script with "rolling credits" out of your document.

The script is here. If you want to download it you can right-click and then choose save target as, or similar. Now make sure the script is executable. You can probably also do the right-click action or from a commando line with

chmod +x rolling

http://www.mimoart.ooz.dk/rolling

If for some reason would want to see the pdf file I've used as the basis for this video eksepel so it is here.

http://www.mimoart.ooz.dk/youare.pdf