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

HTTP Streaming with TomCat Server


I have a Tomcat server and I want to do HTTP streaming for flv files.

Since there does not seem to be any streaming module available for Tomcat (I do not want to go through apache and mod_jk route), I developed a filter servlet for streaming .flv files

The idea is that JW player sends test.flv?start=XXXX when it wants to play from XXXX byte. Tomcat is a byte streaming server that accepts request with range headers. So my filter converts from one format to another.

Here is what I have done.

1)Intercept request for flv files.
2)See whether there is a 'start' parameter in the URL
3)Modify the request by adding a 'Range' header and pass it on to default servlet.

The problem I face is this:
When I play the test.flv file, it plays.
When I seek to a position in the test.flv(that has not been downloaded), then the player gives a "FILE NOT FOUND" error.

But when I see the response from server, I see that the server gives a SUCCESS : HTTP 206 partial response.

So What could be the problem? Is it
1) JW player does not work with HTTP 206 response?
2) The file offset (for the keyframe) in the media file is wrong? Though I have used flvtool2 as well as flvmdi to create flv files with keyframes. Both files have same problem.

But why is JW player saying "FILE NOT FOUND" when server is returning a HTTP 206 partial response?


6 Community Answers

JW Player

User  
0 rated :

I wanted to give the Request and response headers (masking out URL as it is confidential).
These request/response headers are not when JW player requested. These are when I typed the request in browser a URL similar to JW player request

request/response when 0 is the offset (file is played from beginning successfully)
------------------------------
Request

URL:http:XXXXXXXX/test.flv?start=0
Request Method:GET
Status Code:206 Partial Content

Request Headers

Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Authorization:Basic ZWNoby1zZW5zZTplY2hvLXNlbnNl
Connection:keep-alive
Cookie:JSESSIONID=7023CF057104EE4AC473460205A6A279
Host:XXXXX
Referer:XXXXXX
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64)

AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56

Safari/537.17

Query String Parameters
start:0

Response Headers

Accept-Ranges:bytes
Cache-Control:no-cache
Content-Length:4014431
Content-Range:bytes 0-4014430/4014431
Date:Fri, 01 Feb 2013 07:41:34 GMT
ETag:W/"4014431-1359698202000"
Expires:Thu, 01 Jan 1970 00:00:00 UTC
Last-Modified:Fri, 01 Feb 2013 05:56:42 GMT
Pragma:No-cache
Server:Apache-Coyote/1.1


request/response when video is seeked to middle (JW player says "FILE NOT FOUND")
-------------------------------------------------
Request

URL:XXXXXXXX/test.flv?start=2973538
Request Method:GET
Status Code:206 Partial Content

Request Headers

Accept:*/*
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8
Authorization:Basic ZWNoby1zZW5zZTplY2hvLXNlbnNl
Connection:keep-alive
Cookie:JSESSIONID=7023CF057104EE4AC473460205A6A279
Host:XXXXX
Referer:XXXXXXXX
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64)

AppleWebKit/537.17 (KHTML, like Gecko) Chrome/24.0.1312.56

Safari/537.17

Query String Parameters
start:2973538

Response Headers

Accept-Ranges:bytes
Cache-Control:no-cache
Content-Length:1040893
Content-Range:bytes 2973538-4014430/4014431
Date:Fri, 01 Feb 2013 07:42:34 GMT
ETag:W/"4014431-1359698202000"
Expires:Thu, 01 Jan 1970 00:00:00 UTC
Last-Modified:Fri, 01 Feb 2013 05:56:42 GMT
Pragma:No-cache
Server:Apache-Coyote/1.1

Ethan Feldman

JW Player Support Agent  
0 rated :

Is there a link you can provide?

JW Player

User  
0 rated :

Thanks, ethan.

Sure. here is the link.

http://107.21.98.209:8080/jwplayer

It has a jwplayer plugin.
But the video does not autostart. You have to click on the play button to play the video.


Ethan Feldman

JW Player Support Agent  
0 rated :

This works fine, and under:

provider: ‘http’,

Add:

autostart: ‘true’,

JW Player

User  
0 rated :

Ethan,
Thanks. I will add the autostart so that video can autostart.

As I said earlier, it works fine when you hit the play button. But when you seek to a video that is not downloaded yet, the jwplayer gives an error.

For instance, Try this.
1)Click on the link.
2)Let the clip play.
3)Click on the time bar at 2.30 minutes (a part not downloaded)
4)JW player will show an error that "test.flv is not found."

Seeking to a part of video not downloaded is the problem.

Ethan Feldman

JW Player Support Agent  
0 rated :

It could have to do with the module being used. I haven’t used that FLV pseudo streaming module before. I have used the Apache one for MP4, though, which doesn’t have this issue – http://www.longtailvideo.com/support/jw-player/28855/pseudo-streaming-in-flash

This question has received the maximum number of answers.