Menu Sign In Contact FAQ
Banner
Welcome to our forums

A video with dynamic subtitles or a GPS moving map insert

I found a free portable way to put text into an individual jpg file, using Perl.

Here is the example image. It was the kind of size you might get from a modern camera, but I scaled it down for this website. In any event it illustrates the need to use true-type fonts with a very large font-size.

If you install Perl (I used Strawberry Perl) you can run the following script: (OK, no prizes for style...)

use GD;

# in real life: the filename, text positions and maybe the font-size
# and colours would be command line arguments to this perl script.

# load image from the jpg file
open (JPG,"mov1.jpg") || die;
$im = newFromJpeg GD::Image(JPG) || die;
close JPG;

# allocate some colors that we might want to use
$white = $im->colorClosest(255,255,255);
$black = $im->colorClosest(  0,  0,  0);       
$red   = $im->colorClosest(255,  0,  0);      
$blue  = $im->colorClosest(  0,  0,255);

# use the four built-in fonts to write some text which
# is much too small to be useful
$im->string(gdTinyFont,      2, 10,"Some text",$white);
$im->string(gdSmallFont,     2, 60,"Some text",$black);
$im->string(gdMediumBoldFont,2,110,"Some text",$red  );
$im->string(gdLargeFont,     2,160,"Some text",$blue );

# so now try a properly scalable true-type font, e.g. Verdana bold
# $font is the full path to the true-type font file
# (note double back-slashes are required)
$font = "C:\\Windows\\winsxs\\amd64_microsoft-windows-font-truetype-verdana_LOADS_OF_HEX\\verdanab.ttf";

# write text in a color, font, size, angle, x-position, y-position
$im->stringFT($red,  $font, 48,0,  2,260, "Some Larger text");
$im->stringFT($blue, $font,160,0,  2,500, "Some Larger text");


# make sure we are writing to a binary stream
binmode STDOUT;

# Convert the image to JPG and print it on standard output
print $im->jpeg;
White Waltham EGLM, United Kingdom

That's an amazingly powerful language.

This is the sort of end result I have in mind

The video would be 1024P 25 FPS or whatever. The data would come in a CSV file, with date/time in the first column. The space set aside for the text could be fixed at say 20% of the frame width. The titles could be in the CSV file as well; it is easy to generate a CSV with anything whatever in it.

I am sure that, somewhere out there in the wild, there is just the perfect way to do this, because it must be awfully common in say the racing world where they do an awful lot of data acquisition.

Administrator
Shoreham EGKA, United Kingdom

Peter,

Would it help you to get in touch with this guy?



Good luck

Patrick

Hungriger Wolf (EDHF), Germany

Originally I had thought of one perl call per jpg, with a huge batch file controlling the calls.

But, you have a csv file with timestamps which have to be matched to the jpg number, so you are better off parsing the csv in perl (perl is brilliant at that), and handle looping over the jpg files within a single perl script.

If you want a border on the right then you can do this (your cropped file was 637x397):

  # make a new image to work on, then write out
my $im2=new GD::Image(637+125,397);

# we have a new image, so allocate colours
$white = $im2->colorAllocate(255,255,255); # white is background
$black = $im2->colorAllocate(  0,  0,  0);       

# copy over the original jpg image
$im2->copy($im, 0,0, 0,0,637,397);

then write text on the new image $im2 and then write out the image as a jpg.

That's probably much too much Perl already, EuroGA is starting to look like Stack Overflow... :-)

White Waltham EGLM, United Kingdom

I've done some digging into the past when I asked some people about this, and tools mentioned were an open source video processor called Ogre, and "substation alpha".

In essence the method suggested was to make a movie containing just the subtitles and then merge the two.

Administrator
Shoreham EGKA, United Kingdom

Following on from this old thread, I have realised that I merely need a means of generating a video with a black (or transparent – is it possible?) background, containing the supplied text in some specified font and at a specified position, and then any half decent video editor (I use Vegas 11) can merge together multiple video tracks.

So one doesn’t need any special software to do the merging. Vegas could merge any number of video tracks.

Administrator
Shoreham EGKA, United Kingdom

I’m not sure if this is relevant here, but this is what one of my short movies looks like in Final Cut Pro.

Spending too long online
EGTF Fairoaks, EGLL Heathrow, United Kingdom

I can see you are merging multiple sound tracks Chris, but how come the video is just one linear track? Did you cut the unwanted parts (the vast majority of any flying video ) out of it in a separate operation beforehand? What I mean is that you did have multiple cameras so must have had multiple concurrent vieo tracks.

I have never tried merging video. I know how one merges stills in a studio setting, using a chroma key (yeah, lots of examples on youtube ) and one could do the same with a video but maybe there is a way to generate a video track with the text which has a genuine transparent background.

Administrator
Shoreham EGKA, United Kingdom

Hi

I would create a subtitle file in one of the common formats, then use DirectVobSub to do the gruntwork of embedding them in the video.

Look here:-

http://en.wikipedia.org/wiki/DirectVobSub

and here for the most simple subtitle encoding format:-

http://en.wikipedia.org/wiki/SubRip

Or, for more flexibility (you could resize the video and do your blacked out area simultaneously), look at AviSynth with the TextSub filter.

Steve

Last Edited by stevelup at 20 May 10:06

how come the video is just one linear track?

It is a single video track but almost all the clips are multicam clips. Once the clips are imported, you group the related clips together as a “multicam” clip. Essentially, these are different views or “angles” of the same scene.

These clips are synchronised by timecode, audio or manual markers. Since I don’t record the audio with the camera, I use timecode then tweak it if necessary.

So my three cameras, “glareshield”, “overhead” and “cabin” are each recording at the same time. The three clips of, say, take-off, get grouped into a multicam clip called “take-off”, and then that clip is dropped into the timeline.

As you play the clip you simply click on the angle that you want to use.

As far as dynamic subtitles go, can you not simply use a moving title of some sort? Something like this?



Spending too long online
EGTF Fairoaks, EGLL Heathrow, United Kingdom
Sign in to add your message

Back to Top