From: MM on
For ages I have been planning to write a simple VB6 app that takes a
..srt file (subtitle file) and presents the subtitles on a second
screen at the right time during playback of the associated movie.

For those who don't know what a .srt file looks like, here's a short
sample:

1
00:00:05,238 --> 00:00:07,672
Hi, Fred, did you get the money?

2
00:00:08,008 --> 00:00:09,532
Nah, he refused!

3
00:00:10,677 --> 00:00:12,167
We cannot accept that...

4
00:00:12,345 --> 00:00:14,472
No, we can't, for sure.

The important parts are the start time and the message. So, for
example, we want to see "We cannot accept that..." to appear at 10.667
seconds from the start and disappear at 12.167.

An important requirement: Re-sync. Subtitles are notorious for getting
out of sync with the movie, so one should be able to re-sync at any
time by moving the subtitles forward or back a tad.

BTW, this has nothing to do with preparing a subtitle file in, say,
Subtitle Workshop for blending with a movie in, say, VLC Player. This
is all about displaying the subtitles separately, on a separate
monitor next to the television or screen on which the movie is
showing. Why? Well, I have several movies in a foreign language that I
don't understand but with *hardcoded* subtitles in ANOTHER language! I
do have the English .srt file, but I can't dub that over the top of
the hardcoded ones. I've tried and it looks terrible.

Another way would be to *hear* the subtitles spoken. Imagine the new
ListenToMySubs app is currently running and you're watching the movie.
At the precise time, e.g. 10.667, you hear, e.g. through headphones,
""We cannot accept that..." being played to you from a text-to-speech
app.

So how do I achieve this? I could start a timer running, then keep
comparing each millisecond with the next timestamp in the .srt file
(okay, the .srt file would first be converted to some more meaningful
data format, e.g. a UDT array), but this would mean a heck of a lot of
CPU time wasted.

I kinda think that events are somehow the way to go; that is, the .srt
file somehow "drives" the timer. (But don't overlook the re-sync
requirement.)

Alternatively, instead of a stopwatch timer I could perhaps use a
one-shot timer, and set it to trigger at the first time, then reset it
and it triggers at the next time and so on.

Any ideas? Has anyone already done it?

MM
From: Jim Mack on
MM wrote:
> For ages I have been planning to write a simple VB6 app that takes a
> .srt file (subtitle file) and presents the subtitles on a second
> screen at the right time during playback of the associated movie.
>
> For those who don't know what a .srt file looks like, here's a short
> sample:

...snip...

> The important parts are the start time and the message. So, for
> example, we want to see "We cannot accept that..." to appear at
> 10.667 seconds from the start and disappear at 12.167.
>
> An important requirement: Re-sync. Subtitles are notorious for
> getting out of sync with the movie, so one should be able to
> re-sync at any time by moving the subtitles forward or back a tad.
>
...snip...
>
> So how do I achieve this? I could start a timer running, then keep
> comparing each millisecond with the next timestamp in the .srt file
> (okay, the .srt file would first be converted to some more
> meaningful data format, e.g. a UDT array), but this would mean a
> heck of a lot of CPU time wasted.
>
> I kinda think that events are somehow the way to go; that is, the
> .srt file somehow "drives" the timer. (But don't overlook the
> re-sync requirement.)
>
> Alternatively, instead of a stopwatch timer I could perhaps use a
> one-shot timer, and set it to trigger at the first time, then reset
> it and it triggers at the next time and so on.
>
> Any ideas? Has anyone already done it?


The ideal situation is to get position information from the player. I
don't know if you can automate the VLC player, but in the case of WMP,
one of the object's properties is the CurrentPosition. And you don't
need to query it every millisecond, because at 25 fps new images only
occur every 40ms.

I've written (and sold) closed-captioning software and systems, and
the general approach is to have a UDT array that contains the caption
start times, in a form compatible with the data you'll trigger from,
and a pointer into a second array of structures containing the data,
position and color info, etc that's pointed to by the first array.

In your case you could do it with one UDT holding the start time and a
string. Rather than have an 'out' time, which is not often needed,
just have occasional blank string entries to clear the text.

For captioning this is driven by timecode, and frankly without some
position data coming from the player, I can't imagine how you could
possibly resync. With it, it becomes a quick binary chop of the
entries on startup, to find the one nearest to 'now' that hasn't yet
appeared.

--
Jim Mack
Twisted tees at http://www.cafepress.com/2050inc
"We sew confusion"

From: MM on
On Tue, 11 May 2010 14:43:25 +0100, MM <kylix_is(a)yahoo.co.uk> wrote:

>For ages I have been planning to write a simple VB6 app that takes a
>.srt file (subtitle file) and presents the subtitles on a second
>screen at the right time during playback of the associated movie.
>
>For those who don't know what a .srt file looks like, here's a short
>sample:
>
>1
>00:00:05,238 --> 00:00:07,672
>Hi, Fred, did you get the money?
>
>2
>00:00:08,008 --> 00:00:09,532
>Nah, he refused!
>
>3
>00:00:10,677 --> 00:00:12,167
>We cannot accept that...
>
>4
>00:00:12,345 --> 00:00:14,472
>No, we can't, for sure.
>
>The important parts are the start time and the message. So, for
>example, we want to see "We cannot accept that..." to appear at 10.667
>seconds from the start and disappear at 12.167.
>
>An important requirement: Re-sync. Subtitles are notorious for getting
>out of sync with the movie, so one should be able to re-sync at any
>time by moving the subtitles forward or back a tad.
>
>BTW, this has nothing to do with preparing a subtitle file in, say,
>Subtitle Workshop for blending with a movie in, say, VLC Player. This
>is all about displaying the subtitles separately, on a separate
>monitor next to the television or screen on which the movie is
>showing. Why? Well, I have several movies in a foreign language that I
>don't understand but with *hardcoded* subtitles in ANOTHER language! I
>do have the English .srt file, but I can't dub that over the top of
>the hardcoded ones. I've tried and it looks terrible.
>
>Another way would be to *hear* the subtitles spoken. Imagine the new
>ListenToMySubs app is currently running and you're watching the movie.
>At the precise time, e.g. 10.667, you hear, e.g. through headphones,
>""We cannot accept that..." being played to you from a text-to-speech
>app.
>
>So how do I achieve this? I could start a timer running, then keep
>comparing each millisecond with the next timestamp in the .srt file
>(okay, the .srt file would first be converted to some more meaningful
>data format, e.g. a UDT array), but this would mean a heck of a lot of
>CPU time wasted.
>
>I kinda think that events are somehow the way to go; that is, the .srt
>file somehow "drives" the timer. (But don't overlook the re-sync
>requirement.)
>
>Alternatively, instead of a stopwatch timer I could perhaps use a
>one-shot timer, and set it to trigger at the first time, then reset it
>and it triggers at the next time and so on.
>
>Any ideas? Has anyone already done it?
>
>MM

I think I've answered my own question! Karl Peterson's
ICcrpCountdownNotify seems ideal for this purpose. I can even re-sync
on the fly by adding to or subtracting from cntNotify.Duration while
the timer is running.

MM
From: MM on
On Tue, 11 May 2010 10:30:50 -0400, "Jim Mack" <jmack(a)mdxi.nospam.com>
wrote:

>MM wrote:
>> For ages I have been planning to write a simple VB6 app that takes a
>> .srt file (subtitle file) and presents the subtitles on a second
>> screen at the right time during playback of the associated movie.
>>
>> For those who don't know what a .srt file looks like, here's a short
>> sample:
>
> ...snip...
>
>> The important parts are the start time and the message. So, for
>> example, we want to see "We cannot accept that..." to appear at
>> 10.667 seconds from the start and disappear at 12.167.
>>
>> An important requirement: Re-sync. Subtitles are notorious for
>> getting out of sync with the movie, so one should be able to
>> re-sync at any time by moving the subtitles forward or back a tad.
>>
> ...snip...
>>
>> So how do I achieve this? I could start a timer running, then keep
>> comparing each millisecond with the next timestamp in the .srt file
>> (okay, the .srt file would first be converted to some more
>> meaningful data format, e.g. a UDT array), but this would mean a
>> heck of a lot of CPU time wasted.
>>
>> I kinda think that events are somehow the way to go; that is, the
>> .srt file somehow "drives" the timer. (But don't overlook the
>> re-sync requirement.)
>>
>> Alternatively, instead of a stopwatch timer I could perhaps use a
>> one-shot timer, and set it to trigger at the first time, then reset
>> it and it triggers at the next time and so on.
>>
>> Any ideas? Has anyone already done it?
>
>
>The ideal situation is to get position information from the player. I
>don't know if you can automate the VLC player, but in the case of WMP,
>one of the object's properties is the CurrentPosition. And you don't
>need to query it every millisecond, because at 25 fps new images only
>occur every 40ms.
>
>I've written (and sold) closed-captioning software and systems, and
>the general approach is to have a UDT array that contains the caption
>start times, in a form compatible with the data you'll trigger from,
>and a pointer into a second array of structures containing the data,
>position and color info, etc that's pointed to by the first array.
>
>In your case you could do it with one UDT holding the start time and a
>string. Rather than have an 'out' time, which is not often needed,
>just have occasional blank string entries to clear the text.

I've just written a VERY quick-n-dirty protoype based on Karl
Peterson's ICcrpCountdownNotify (part of his ccrpTimers project) and
it is easy to time the 1-on, then 1-off, then 2-on, then 2-off and so
on, right through the movie (1, 2 etc refer to the subtitles, numbered
from 1 through nnn). In the final app I can just display the title in,
say, a label (using a large font if required, so as to be able to read
it from a distance easily), then erase the label with a blank string.

>For captioning this is driven by timecode, and frankly without some
>position data coming from the player, I can't imagine how you could
>possibly resync. With it, it becomes a quick binary chop of the
>entries on startup, to find the one nearest to 'now' that hasn't yet
>appeared.

Re-syncing should also be very easy, as I can change the duration on
the fly, e.g. cntNotify.Duration = cntNotify.Duration + 1000. So I
could have a Shift Forward command button (which subtracts 1000) and a
Shift Back button (which adds 1000). So there I am, watching the movie
and glancing at the second monitor briefly to read the subtitles (I
can read short texts in an instant), and if I detect the subtitle
getting out of sync, I can, with my wireless mouse, click on the
relevant button, several times in a row if need be.

MM
From: Larry Serflaten on

"MM" <kylix_is(a)yahoo.co.uk> wrote


> I think I've answered my own question! Karl Peterson's
> ICcrpCountdownNotify seems ideal for this purpose. I can even re-sync
> on the fly by adding to or subtracting from cntNotify.Duration while
> the timer is running.


I'm just curious...

If you're watching a Chinese movie with english subtitles,
how do you know when it is out of sync?

<g>
LFS


 |  Next  |  Last
Pages: 1 2
Prev: VB6 to Web
Next: sending email