Pages

Subscribe:

Thursday, 1 September 2011

Editing subtitles file using awk

Q)I wanted to add 9 seconds to each of the subtitle in my file to have it in sync with video. 
I wrote an awk org for it, and it did what i was trying to do. the video is in sync with subtitles now.
now when i play the video with this new subtitles file, movie player quits when it reaches a particular subtitle. every time it quits when it reaches the same place. this does not happen with the original subtitle file.
original file

43
00:09:20,820 --> 00:09:23,618
...in which I have grown
from childhood to a man!

44
00:09:24,757 --> 00:09:26,554
I had sworn by those
alps and peaks...



edited file

43
00:09:29,820 --> 00:09:32,618
...in which I have grown
from childhood to a man!

44
00:09:33,757 --> 00:09:35,554
I had sworn by those
alps and peaks...


movie player after showing the underlined text.

Any idea why this happens??

i am running mint 10- julia, Totem Movie Player 2.32.0 
--------------------------
A)#!/usr/bin/awk -f 
BEGIN {
FIELDWIDTHS="3 2 1 2 12 2 1 2 4"
OFS=""
}

/-->/ {
if ($4>21)
{
$4=$4-21;
if ($4<10)
{
$4=0$4
}
}
else
{
$4=60-(21-$4);
$2=$2-1;
if ($2<10)
{
$2=0$2;
}
};
if ($8>21)
{
$8=$8-21;
if ($8<10)
{
$8=0$8

}
}
else
{

$8=60-(21-$8);
$6=$6-1;
if ($6<10)
{
$6=0$6;
}
};

print $1,$2,$3,$4,$5,$6,$7,$8,$9}
$0 !~ /-->/ {print $0} 

No comments:

Post a Comment