Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Servlet streaming mp4 for html5 video in chrome

i'm trying to stream a movie (mp4 or ogv based upon browser) from a Java servlet to be used in a HTML5 webpage. After doing some research here, i found out that i need to support ranges. In most of the examples there is a reference to http://balusc.blogspot.be/2009/02/fileservlet-supporting-resume-and.html. This seems to work as it should for IE and Firefox except for some socket write errors that get thrown, but the movie plays in these 2 browsers.

In Chrome however, the movie starts off fine, but most of the times it simply goes blank when it's mp4 or just freezes when it's ogv after playing for a while. I'm not getting any errors tho.

I'm using the source code from Balusc for my servlet. The only thing I added was logic to determine a subfolder based upon the file requested, but this was allready happening before i added my own stuff.

Help will be greatly appreciated, cause it is driving me crazy that it sometimes works and sometimes doesn't without any clear reason.

Thanks, Andy

like image 786
Andy Avatar asked Jan 23 '13 14:01

Andy


1 Answers

For Chrome try to low byte-range to read from stream for response (ex.: you set 10240 bytes, as it seems from the source Balusc, set this value to 1024*8/7/6), some people told that it helps to play video exactly in Chrome.

like image 176
Arthur Kushman Avatar answered Nov 02 '22 16:11

Arthur Kushman