Transcode – an amazing little avi tool

Posted on Wednesday 10 June 2009

A friend of mine recently had a problem with a couple of avi files he had of a movie of his. The movie was actually in two parts and he wanted it combined. Plus, he also had two subtitle files to the movie and was wondering if I could embed them into the finished avi file ( it was a foreign film. ) So he called his local help desk…. me.

I thought that I would tackle the subtitling first and found that one of Ubuntu’s main utilities mencoder did that for me quite nicely. I put the command into a little script ( I find it easier to help remember this gems if they are written down in my local bin directory… ) to make my life simpler

mencoder -o output.avi -oac mp3lame -ovc lavc -sub $ -utf8 -subfont-autoscale 0 -subfont-text-scale 15 -subpos 98 $1.avi

It worked like a dream. If you find the subtitles too large ( or small ) adjust the subfont-text-scale appropriately. You can also change the position of the subtitle ( near the bottom right now ) by adjusting the subpos setting.

It was at this point however, that I discovered that the subtitle files didn’t quite match both halves of the movie, and since they were indexed starting at 0:00  ( the beginning of each cut ) I couldn’t just paste them together without causing chaos. I thought the best solution would be to cut off the ending of the first half of the movie ( where the subtitles ran out ) and past it onto the second half ( where the subtitles actually started – and which currently meant that they were WAY out of sync. ) So now I needed a tool to cut up AVI files and another one to past the cut piece onto the second piece and then eventually merge them all together….

Suffice to say Google came through again as I came across a wonderful posting by Barat Balegere which talked about a great little tool called transcode. When you install transcode within Ubuntu ( you need to do this in a terminal window )

sudo apt-get install transcode

You not only get a code that lets you merge two avi files together ( and it works quite quickly ) but you also get a whole suite of tools to manipulate avi files, including one to split the file up however you wish! Excellent!

Two of the tools were exactly what I needed: avimerge and avisplit ( kind of self explanatory that. ) avimerge is the “simpler” of the two programs you just call the command followed by the files you want merged followed by the output file name. In a script it would look like this…


avimerge -i $1.avi $2.avi -o combinedfile.avi

The second tool, avisplit, is a little more complicated, in that you have to know right down to the second ( and even tighter of you prefer ) where you would like to cut your video at.

For example to cut the end off  ( keeping the beginning until that point ),  you would simply issue the command

avisplit -t 00:57:28.0 -i output.avi

Which would give you everything on the video from 0:00:00 to 00:57:28.0 if you wanted to then just cut out the last part and keep it you would then issue the command

avisplit -t 00:57:38.0-01:10:00 -i alfa.avi

Ensuring that the end time ( the part after the dash – ) was beyond the actual end of the file. In this case i would end up with a new file with whatever video started at 00:57:38 and lasted till the end of the file.

There are a bunch of other tools included with the transcode package: aviindex, avifix, tccat, tcdecode, tcdemux, tcextract, tcprobe, tcscan and of course transcode itself. While these tools may not have the glitz and pizzaz of the modern day GUI aor fancy window based tools, they really don’t need anything more that what they have. They are extremely fast and extremely flexible – what more can I say. Except….

Thank you Thomas Östreich for developing such a quick flexible and extremely useful tool!

End Article

Please Add Your Comment. PLEASE NOTE: Your comments WILL be held until authorized by the webmaster.