Using mencoder to add captions to videoI have been using mencoder to add captions to timelapse video that I create from a series of photos. I perform these 2 functions in a single step using mencoder.
Following are some samples.
Basic Title for VideoThis puts a title on the screen for the first few seconds of the video.
mencoder "mf://*.jpg"
-o _movie02.avi
-ovc lavc
-lavcopts vcodec=mjpeg
-font c:\windows\fonts\verdana.ttf
-sub title.srt
-subalign 2
-subfont-autoscale 0
-subfont-text-scale 16
Argument Explanations-font c:\windows\fonts\verdana.ttfThe -font argument needs to be provided with the path to a font file. In this example, I used the Verdana font located in my Windows\fonts folder.
-sub title.srtThe -sub argument specifies an "srt" file that exists in the current directory. This file is called a "SubRip Title" file and normally has the extension "srt". The text for the title(s) is located in this file.
The "srt" file has the following format:
1
00:00:00,000 --> 00:00:15,000
This is the text of the first title.
2
00:00:30,000 --> 00:01:00,000
This is the text of the second title.
The "1" and "2 are simply serial numbers indicating the title "number".
The second line represents the time the title starts and ends in hours:minutes:seconds. The "seconds" field contains 3 decimal places after the comma. Note that the comma is a decimal delimiter used in France (the origin of the "srt" file format). Americans should think of this as a decimal point (because that's what it represents).
The third line is the actual text that you want to have displayed. This text is limited to a maximum of 2 lines in length.
So, if you wanted to have a single title displayed throughout the length of your video, your "srt" file may look like this:
1
00:00:00,000 --> 99:00:00,000
This is my subtitle.
Note that the start time is the very beginning of the video and the end time is much longer than the video. This ensures the title is displayed all the way through the video.
-subalign 2This tells mencoder to align the title with the bottom of the video.
-subfont-autoscale 0This tells mencoder to interpret the value of the -subfont-text-scale argument as "points".
-subfont-text-scale 16This tells mencoder to make the font size of the title 16 points. In order for this argument to be interpreted as a "point" size, the argument -subfont-autoscale must be set to 0 (zero).