Belle Nuit Montage - Editing etc. - Lausanne - Suisse - e-mail: matti@belle-nuit.com

Homepage : Textfilter : Examples [ Index - EDL - HTML - Registration - Subtitle] - Search - Sitemap


Creating a subtitle list for the laboratory

The following is an example how to use Textfilter in a real-world context. It uses many features of Textfilter and uses also scripts. If you did not read the Userguide yet, you may want to do that before, so that you can follow each step below.

You can build the project following the explications, but you can also open the project (which is a textfile) from this link Subtitleproject. If you are reading this from internet, click on the link, save it as a textfile and then open it with Textfilter.

The problem

You may have used Belle Nuit Subtitler to create subtitles for your long documentary. Now you can show your documentary to several festivals, so you are going to do a tape to film transfer. You will not use the video subtitles, but make laser subtitles in the lab. Of course, you want to reuse the subtitles you already have prepared for the video version. The laboratory tells you, that they accept text files of the following form:

Now, you think you have to retype the whole titlelist? This is not necessary, you just need a few steps with Textfilters nonlinear textprocessing.

Solution

We will reformat the subtitler document as a textfile with properly wrapped titles.

Then we will extract from the edit list the record in and record out times needed for the timing of the titles.

Finally we will merge the two files to create the textfile for the lab.

Preparing the input files

You need two files:

It is important that the number of titles matches the number of events in the EDL.

Processing the title list

Open a new textfilter project. An Input filter is already specified. Click select file and locate the subtitle.text file.You will see a textfile with the beginning lines

/Zvonimir Stille
Da ist diese Stille vor dem Angriff,
eine absolute Stille, vor dem Angriff.

Manchmal hatte ich das Gefühl,

sogar die Tiere merken, dass etwas geschieht.

Some titles have one line, some titles have two lines. Some titles were wrapped manually, some titles were made in Subtitler with smart wrap, but this wrap is not visible. We will not use the wrapping of the file, but reformat the titles according to the titlelength of the lab (max 38 characters). Also, there are some comment lines starting with "/".

We first remove the comments. Add a filter Skip comments and type "/" in the exclusion list. The comments are gone.

Now, we remove all manual wraps. We want to replace the single newlines with spaces. If we remove the single newlines, it will also remove the double newlines. To deal this, we do a circle replace. We will first replace the double newlines with a special sequence, say "###", then replace the single newlines and finally replace the special sequence with double newlines.

Add a filter Replace with the parameters find "\n\n" (double newline) and replace "###".

Add a filter Replace with the parameters find "\n" and replace " " (space).

Add a filter Replace with the parameters find "###" and replace "\n\n".

This works quite good, except for the first title, which now has a double space. In fact, the translator had put a space at the end of the first line, so it is now doubled. We filter this out:

Add a filter Replace with the parameters find "  " (double space) and replace " " (single space).

Now, we already have the textfile like this

Da ist diese Stille vor dem Angriff, eine absolute Stille, vor dem Angriff.

Manchmal hatte ich das Gefühl,

sogar die Tiere merken, dass etwas geschieht.

The titles are ready to be wrapped to the maximum length le laboratory specified. For this, we will write a little script. The script will pass through all titles. If the title is too long, then it will go through each word and make two parts, so that the length of both lines is as little as possible. This is the same wrapping Subtitler uses in smart wrap.

Add a filter Script with the following text:

function wraptitle(title as string, width as integer) as string
dim w,i,cw as integer
dim first,second,word as string

w = len(title)

if w < width then // title is only one line
return title
end if

if w > 2*width then // too long, we handle only two lines
return title
end if

cw = countfields(title," ")
first = nthfield(title," ",1)

for i = 2 to cw
word = nthfield(title," ",i)

if len(first) + len(word) > w/2 then
second = mid(title,len(first) + len(word) + 3)

if len(first) > len(second) then
return first + getnewline + word + " " + second
else
return first + " " + word + getnewline + second
end if
end if

first = first + " " + word
next
end function

// main function

dim text, title,result as string
dim i, cf as integer

text = gettext

cf = countfields(text,getnewline+getnewline)

for i = 1 to cf
title = nthfield(text,getnewline+getnewline,i)
title = wraptitle(title,38)
result = result + title + getnewline + getnewline
next

print result

The main function takes every title from the text with the separator double newline (getnewline) and applies the function wraptitle on it.

The wraptitle function first calculates the length of the title. If the length is shorter than the width, then the string is returned as is. If the length is longer than two times the width, it is also returned, because we will handle only two lines of text. You could add an error message here. Then it takes every word and adds the words to the string first. If the length of first and the next word is longer than half the width, then it compares the length of first with the string second (the part after the word) and appends word to the shorter of both.

We now have properly wrapped the titles for the string. We will save the intermediate result in a file.

Add an Output Folder filter and select a new folder called Temp. We will reuse this file, but first treat the edit list.

Processing the edit list

You can stay in the same project.

Add a Input File filter and select the file SUBTIT.EDL. You will have something like this:

TITLE: SUBTITLESPART1TITRATEST
001 AX V C 00:00:01:14 00:00:05:22 10:03:48:02 10:03:52:10
* FROM CLIP NAME: 0001.TIFF
002 AX V C 00:00:02:02 00:00:04:02 10:03:52:20 10:03:54:20
* FROM CLIP NAME: 0002.TIFF

Add a CMX3600 parser. You will have it as a list.

We will only use the Event, Record In and Record Out time and erase the rest. Also, we need to calculate frames instead of timecodes. So we need also a little script.

Add a filter Script with the following text. (Put it on bypass whilw writing.)

dim text as string

text = gettext

select case getcolumnname
case "Event"
case "Record In"
text = format(tctoframes(text,25),"00000")
case "Record Out"
text = format(tctoframes(text,25),"00000")
else
text = ""
end select

print text

This script is much simpler than the first one. If the project is in listmode, the script is being executed for each cell in the list. So we ask for the columnname to know in which cell we are. If we are in the event column, we take the text, and if we are in the record in and record out columns, we calculate the frame count for both timecodes. In all other cases, we set the text to empty.

Now, we do not want to parse back to CMX, so we change the parser to space and then the parser to text.

Add a Space parser filter.

Add a Text parser filter.

This looks nice, but still has too much spaces. We can remove them.

Add a Replace filter with the parameter find "    " (four spaces) and replace " " (space).

Merge the title list with the edit list

We will append both files and reorder them.

The titlelist has double return. To make the edit compatible, we also need double returns in the edit list

Add a Replace filter with the parameter find "\n" and replace "\n\n".

Now we will add the title list.

Add a Input file filter and locate the file in the temp folder. Check the Append option this time. It works - quite, in fact. We have a problem at the appending position:

012 00041 00100

013 00079 00146 Da ist diese Stille vor dem Angriff,
eine absolute Stille, vor dem Angriff.

Manchmal hatte ich das Gefühl,

There is no double return after the end of the edit list, so the last event and the first title are on the same line. We could edit the text by hand, but that ist not the aim of textfilter.The easiest way is to add the double return on the title list before saving.

Select the Script filter which is before the Output Folder filter. Insert an Insert Text filter. Type two newlines into the Text parameter. The title list is now starting with two newlines. Now click on the Input File filter at the bottom. The changes have been updated through the filters. This is the nonlinear part of Textfilter textprocesssing. 

012 00041 00100

013 00079 00146

Da ist diese Stille vor dem Angriff,
eine absolute Stille, vor dem Angriff.

Manchmal hatte ich das Gefühl,

We are quite finished. We now just need a little script to rearrange the lines.

Add a filter Script with the following text:

dim text, title, ev,result as string
dim i, cf as integer

text = gettext

cf = (countfields(text,getnewline+getnewline) -1)/ 2

for i = 1 to cf
ev = nthfield(text,getnewline+getnewline,i)
title = nthfield(text,getnewline+getnewline,i+cf)
result = result + ev + getnewline + title + getnewline + getnewline
next

print result

If we have n titles, then we will have 2*n+1 fields separated with double newlines. The script counts the number of titles, and then takes of the text every edl event and every titles and appends them to thre result. Presto!

001 00039 00147
Da ist diese Stille vor dem Angriff,
eine absolute Stille, vor dem Angriff.

002 00052 00102
Manchmal hatte ich das Gefühl,

Add an Output Folder filter and select a new folder called Lab. The textfile will be saved with the same name as the titlelist.

You now have done the list for one act. It takes some thinking, but it is already faster than retyping the list, and probably also faster than going into excel and making calculations. But the main thing is that you can reuse that now for act2 to 5. Just reassign the the two first input folder filters to the title lists of these acts and to the EDL of these acts, and it will make the appropriate output.

Save the project as Subtitleproject so you can reuse it.

To go further

You may modify the script and replace the Input File filters with Input Folder filters. Doing this, you just will have to fill the appropriate folders with the input files, run the project (eg going to the last filter in the list and press the Play In Out button) and take up the processed lists from the output folder. 

 

Textfilter was written with REALbasic http://www.realsoftware.com

 


Homepage : Textfilter : Examples [ Index - EDL - HTML - Registration - Subtitle] - Search - Sitemap

e-mail: matti@belle-nuit.com - www.belle-nuit.com - 5.5.02