Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

.Srt caption doesn't work?


Hey everybody,


I just discovred this incredible player (thanks to the author, really!).

I wanted to add subtitles to some of my videos. I created the code with the setup wizard, with the .srt file url.
But when I play the video, the "T" button appears but the subtitles don't. I also tried with the .srt file example (http://www.jeroenwijering.com/extras/subtitles_example.txt) but nothing...

Is that me (I looked for a solution, but maybe I did something wrong!) or the .srt format is not accepted by the player?


Thanks very much! :)

31 Community Answers

JeroenW

JW Player Support Agent  
0 rated :

It could very well be that the SRT files are on another webserver than your SWF file. Then security restrictions in the flash player will prevent the reading of the SRT file.

There are some fixes for this, I’ve explained then in the playlist section [url=http://www.jeroenwijering.com/extras/readme.html]of the readme[/url]. (loading playlists from another domain causes the same problem)

JW Player

User  
0 rated :

Thanks for your answer. :)

The problem wasn't this one, actually. The subtitles didn't play because the FLV file didn't have correct metadata inserted. I fixed that, and the subtitles are now playing. :)

But... but first, the special caracters don't show. It's french subtitles so there's a weird symbol instead of the "" or "" letters.
Secondly, the subtitles are not synchronised with the video, they show one second too late or so. When I play the same video with the same subtitles on my computer (with VLC), it fit completely though.

JeroenW

JW Player Support Agent  
0 rated :

Please make sure to save your SRT files in UTF8 format for the special characters to appear OK. Ultimately, you could also send a UTF8 header along with the SRT files.

As to the timing problem; I just found out the captioning works at a resolution of 1 second in the player. I’ll set it to 1/10 of a second so the captions might display more in SYNC.

JW Player

User  
0 rated :

Hi everybody,

Congratulations for your player. From my experience is the only one that creates outlined text with transparent background (I can believe adobe captioning component does not support tts outline!).
The only problem I am experiencing right now is that when I create a 3 lines caption in a srt file the player seems to create a space for 4 lines leaving a blank line between the second and third line. Is this a bug or may be srt files do not support more than 2 lines for caption?

JeroenW

JW Player Support Agent  
0 rated :

The captioning component indeed supports just 2 lines. But perhaps the third line is a bit too large so a single dot or space drops to the fourth line?

JW Player

User  
0 rated :

Thank you for your answer.
I have posted an example at:
http://flickr.com/photos/96864787@N00/1311530199/

JeroenW

JW Player Support Agent  
0 rated :

Thanks for the JPG! I’ll have a look at what might cause this …

JW Player

User  
0 rated :

Hi, I got a similar error with JW Player version 3.12

Here's a screenshot of the error.
http://www.flickr.com/photos/billhung/1494136816/

A copy of the srt and my HTML code are attached below.



0
00:00:11,000 --> 00:00:14,000
I think that people like me who have good taste.

1
00:00:14,000 --> 00:00:17,000
People who are "white collared"

2
00:00:17,000 --> 00:00:20,000
It's natural we should drive nice cars.

3
00:00:20,000 --> 00:00:23,000
That's why Honda is my favorite brand.

4
00:00:25,000 --> 00:00:30,000
When you drive a nice car, it's like you're flying.

5
00:00:32,000 --> 00:00:37,000
So when I drive my Honda, I feel like the whole world is flying.

6
00:00:41,000 --> 00:00:45,000
When I'm driving, people are envious of me.

7
00:00:46,000 --> 00:00:49,000
Only people who drive Hondas can have this feeling.

8
00:00:51,000 --> 00:00:55,000
One day, I was passed by a red QQ car.

9
00:00:55,000 --> 00:01:00,000
I thought "How dare this QQ driver try pass a Honda".

10
00:01:00,000 --> 00:01:02,000
This guy was looking for trouble.

11
00:01:03,000 --> 00:01:07,000
Not only should you not disrespect a Honda, you should never disrespect someone who's white collared.

12
00:01:09,000 --> 00:01:14,000
I easily just stepped on the gas and forced the QQ off the road.

13
00:01:15,000 --> 00:01:20,000
QQ's are such terrible cars. Without even saying a word, I vandalized the QQ.

14
00:01:21,000 --> 00:01:24,000
The QQ driver was furious, but I calmly said:

15
00:01:26,000 --> 00:01:31,000
Driving a QQ wasn't your mistake. Your mistake was trying to challenge a Honda.

16
00:01:32,000 --> 00:01:36,000
You can't possible match up to a Honda.

17
00:01:40,000 --> 00:01:43,000
Take me for example. Someone with so much taste.

18
00:01:44,000 --> 00:01:46,000
An ideal white collared person.

19
00:01:46,000 --> 00:01:50,000
And then look at my car. So valuable. So luxurious.

20
00:01:50,000 --> 00:01:56,000
Because you dared pass me, you deserve to have your car vandalized.

21
00:01:57,000 --> 00:02:00,000
All the people who were watching began applauding.

22
00:02:00,000 --> 00:02:04,000
I left to a rousing ovation.



<html>
<head>
<script type="text/javascript" src="swfobject.js"></script>
</head>
<body>
<p id="player1"><a href="http://www.macromedia.com/go/getflashplayer">Get the Flash Player</a> to see this player.</p>
<script type="text/javascript">
var s1 = new SWFObject("flvplayer.swf","single","320","240","7");
s1.addParam("allowfullscreen","true");
s1.addVariable("file","honda_girl.flv");
s1.addVariable("image","honda_girl.jpg");
s1.addVariable("width","320");
s1.addVariable("height","240");
s1.addVariable("captions","honda_girl.srt");
s1.write("player1");
</script>
</body>
</html>

JW Player

User  
0 rated :

Bill,

try using the mediapler instead of the flash player. I tested your srt file with this code and works just fine. the size of the player is slightly different...

<html>
<head>
<script type="text/javascript" src="swfobject.js"></script>
<script type="text/javascript" src="swfobject.js" />
<div id="player">This text will be replaced</div>
<script type="text/javascript">
var so = new SWFObject('mediaplayer.swf','mpl','352','305','7');
so.addParam('allowfullscreen','true');
so.addParam('allowscriptaccess','true');
so.addVariable('displayheight','288');
so.addVariable('file','honda_girl.flv');
so.addVariable('height','305');
so.addVariable('width','352');
so.addVariable('callback','honda_girl.srt');
so.write('player');
</script>
</head>
<body>
<embed src="mediaplayer.swf" width="352" height="305" allowfullscreen="true" allowscriptaccess="always" flashvars="&displayheight=288&file=honda_girl.flv&height=305&width=352&captions=honda_girl.srt" />
</body>
</html>

JW Player

User  
0 rated :

SRT has never worked for me with the FLVPlayer, so I'm digging into your code

I'm assuming that in your code above, this is in error:

so.addVariable('callback','honda_girl.srt'); it should be so.addVariable('captions','honda_girl.srt'); correct?

Looking at your function parseSRT() in the class CaptionParser, I'm finding that it's not splitting the srt string properly.

after you do your unescaping, the arr array just seems to consume the entire SRT file and show it as the first caption

if(scs) {
var str = "";
var j = -2;
while(j < unescape(this).length) {
var oj = j;
j = unescape(this).indexOf('=&',j+2);
j == -1 ? j = unescape(this).length: null;
str = "&"+unescape(this).substring(oj+2,j) + str;
}

var arr = str.split("\r\n\r\n");


So there must be something up with the split ? Here is my srt file

1
00:00:01,440 --> 00:00:03,375
Senator, we're making
our final approach into Coruscant.

2
00:00:03,476 --> 00:00:04,501
Very good, Lieutenant.

JW Player

User  
0 rated :

to use captions for a single file:bc.. so.addVariable("captions","true");
so.addVariable("captions","captions.srt");


to use captions for a playlist:bc.. so.addVariable("captions","true");

playlist:bc.. <meta rel='captions'>captions.srt</meta>

while screwing around with this, I discovered that yu can use simple HTML formatting in the SRT test:<code>1
00:00:01,440 --> 00:00:03,375
<font size="6" face="Verdana">6-Senator, we're making
our final approach into Coruscant.</font>

2
00:00:03,476 --> 00:00:04,501
<font size="8" face="Verdana">8-Very good, *Lieutenant*.</font>

3
00:00:05,600 --> 00:00:07,500
<font size="10" face="Verdana">10-Senator, _something seems to be wrong,_
I can't see the landing strip on my radar.</font>

4
00:00:09,000 --> 00:00:12,250
<font size="12" face="Verdana">12-Lieutenant, your radar must be faulty.
There is the landing strip, right below us.</font>

5
00:00:14,500 --> 00:00:17,250
<font size="14" face="Verdana">14-It might look like a landing strip,
but it is just an illusion.</font>

6
00:00:20,500 --> 00:00:25,750
<font size="16" face="Verdana">16-That's the landing strip,
but the facilities are destroyed.</font>

7
00:00:27,500 --> 00:00:32,750
<font size="18" face="Verdana">18-Short because it's huge.</font>

8
00:00:36,000 --> 00:00:41,750
<font size="20" face="Verdana">20-Shorter!</font>

9
00:00:44,250 --> 00:00:48,000
<font size="22" face="Verdana">22-Huge</font>


note that the jw player works with a resolution of 0.01 second
setting to 0.001 seconds is a waste of time

one final note in SRT caption files, *EVERY* line must end with a carriage return and a line feed
not all text editors save the files this way
check with a hex editor
every line *MUST* end with 0A0D

JW Player

User  
0 rated :

If every line "MUST end with 0A0D" there is no way to generate it from a database (CMS) it has to be static files?

I tried to makes it through a CMS but all the captions show up in one go.

JW Player

User  
0 rated :

Your code that outputs the actual line must end with something like"\r\n" or whatever means carriage return line feed in the programming language that you are using.

So maybe:bc.. print $line . "\r\n";

JW Player

User  
0 rated :

The "\r\n" shouldn't be showing, they are invisible control characters.

Common programming language notation is to use "\r\n" to print those invisible control characters at the end of a line. Most Windows text editors put CRLF at the end of the line, whereas Apple and *nix usually only use one character new line, same as LF.

JW Player

User  
0 rated :

I'm using a CMS ExpressionEngine http://expressionengine.com

And using a custom field to out all the captions. Here is the page. It all shows within the first 5 seconds.

http://kadampafestivals.org/videos/
http://kadampafestivals.org/videos/captions/07-05-25-vg/en/captions.srt

Although the srt file has the extension it is still and dynamic page being pulled from the database. I've removed the \r\n again

JW Player

User  
0 rated :

In your custom field, try making the last character a line feed.

You can probably do this by holding the ALT key and typing 0010 (line feed) *on the number pad*.

If that doesn't work, try ALT and 0013 (carraige return).

JW Player

User  
0 rated :

Didn't work either :-P

I'm kind of glad though as that would have been a very labour intensive fix.

JW Player

User  
0 rated :

bc.. And using a custom field to out all the captions.
I don't understand. If you are using a custom field, and you put the correct line-ending characters at the end of the custom field, wouldn't that have automatically ouptut each line in the correct format? Or, can you change the line ending format of whatever program is using the custom field?

JW Player

User  
0 rated :

All the captions and time codes go into one custom field (a textarea) not individual custom fields for each line, sorry I didn't make that clear. I tried what you suggested by typing it in after the first few lines but they still showed up all as one block.

I'm using ExpressionEngine - http://expressionengine.com/

JW Player

User  
0 rated :

I searched through the Expression Engine site and could not find any reference to changing the line-ending characters, so I guess it's not possible.

You will have to output the srt files with Expression Engine, then open them with a text editor that does save files with CRLF and save them. Common Windows text editors such as Notepad and Wordpad do save text files with CRLF. Common *nix and Mac editors don't. If that's a BIG problem, then...

Can you upload and execute PHP scripts on your server? If the answer is YES, I could write a small PHP script that would load every srt file it can find and save them with the proper CRLF line-ending.

JW Player

User  
0 rated :

Hi, the "\r\n" way worked. Great. (I hate TimedText, and http://www.subtitle-horse.org/translator.php didn't work for me)
Anyway, I was able to display SRT subtitle files correctly now. Here's the perl script I used:

bc.. #!/usr/bin/perl -w
#Author: Bill Hung, Date: 2 Mar 2008

#1. open the file handler
open (INFILE, "honda_girl.origin.srt") || die "can't open file";

#2. read and print every line
while ($line = <INFILE>){
chomp($line);
print $line . "\r\n";
}

#3. close the file handler
close (INFILE);



Then I typed bc.. ~/script/add_newline.pl > honda_girl.srt
in the terminal

honda_girl.origin,srt is the input of the script and honda_girl.srt is the output of the script. honda_girl.srt is the input to the flv player, using the same code and player as my last post

JW Player

User  
0 rated :

First of all .. Thanx for the splendid player. Now let`s get to the bussines.
I have read most of the tutorials arownd here but i didn`t fownd someone with my problem .. wich is:
I use a redirectional decripting code to take the movies from another website like megavideo to play on my website separeu.org it works just fine but .. when i wana add subtitles (captions) to the player it bothers me that wen i click full screen the progress bar is almost al the midle of the screen and and its big.. also the subtitles are shown the same at the middle of the screen almost.If i press full screen before the movie loads it`s ok ... the bar is down and small and the subtitles are upon it. But if i exit full screen mode and enter again i face the same problem as i explained first. What seems to be the problem? It can be fixed? here is an example: http://www.separeu.org/example/Game_Plan.php (sorry for my bad english)
ps. i tried the stretch modes and they doesen`t work on full screen

JeroenW

JW Player Support Agent  
0 rated :

Did you use the 3.16 player? Have you tried moving to 4.0? It fixes a lot…

JW Player

User  
0 rated :

thanks a lot jeroen .. i guess i`ll try it .... please keep up the good work ... peace

JW Player

User  
0 rated :

How do you or where do you get the file .srt?

JW Player

User  
0 rated :

When will 4.5 player be available for licencing and release?

I am working with 4.5 latest from tunk and the sub in .txt format are working great in a playlist.. but aware that this verison is beta etc... don't wan to put it live until all is well here!

Loving the new layout of the captions and links by the way!

JW Player

User  
0 rated :

I am finding that the srt files did not work on IIS servers as the MIME type does not seem to be configured by default.. after changing the fiels to .txt files all is well on appache and IIS servers..

Small snag will subs though.. if you play a file then paus and click to play another file... the previous subs appear before the first bit of timecode with text attached to it kicks in!

JW Player

User  
0 rated :

Andrew Minton, you are a life saver! :)
Ive been searching like a maniac for days, when I saw your post about the MIME-types on IIS and Apache servers.

Fellas, try changing ".srt" to ".txt".
Thanks, Andrew

JW Player

User  
0 rated :

Same here, I've been googling all day why it won't work. IIS handling the MIME type different would've been the last thing I expected. Many thanks! :)

JW Player

User  
0 rated :

bc.. 1\r\n
00:00:01,440 --> 00:00:03,375\r\n
6-Senator, we're making\r\n
our final approach into Coruscant.\r\n
\r\n
2\r\n
00:00:03,476 --> 00:00:04,501\r\n
8-Very good,Lieutenant.\r\n




Don't seem to work no matter what I try. It still takes them all in one go.

JW Player

User  
0 rated :

Bye the way you don't necessarily need to change the .srt extension to .txt, By default IIS only serves those files whose mime type is configured. So just go to Default Web Siet -> Properties. Click the Http Headers tab, click the mime type button. you will see a new dialog in that click New. In the dialog box in the extension type .srt in the in the Mime Type text box type text/plain. click ok, again click ok to close the website dialog properties. Now IIS will be able to serve the .srt files

This question has received the maximum number of answers.