<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Thomas</title>
	<atom:link href="http://thomasbutter.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://thomasbutter.wordpress.com</link>
	<description>---</description>
	<lastBuildDate>Thu, 27 May 2010 21:08:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='thomasbutter.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Thomas</title>
		<link>http://thomasbutter.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://thomasbutter.wordpress.com/osd.xml" title="Thomas" />
	<atom:link rel='hub' href='http://thomasbutter.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Working around JavaFX 1.3 video issues</title>
		<link>http://thomasbutter.wordpress.com/2010/05/27/working-around-javafx-1-3-video-issues/</link>
		<comments>http://thomasbutter.wordpress.com/2010/05/27/working-around-javafx-1-3-video-issues/#comments</comments>
		<pubDate>Thu, 27 May 2010 16:46:47 +0000</pubDate>
		<dc:creator>thomasbutter</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://thomasbutter.wordpress.com/?p=4</guid>
		<description><![CDATA[JavaFX1.3 has a quite nice media API, but still faces some important issues. Quite visible are these: FXM in MediaPlayer crashes very often on Windows ( http://javafx-jira.kenai.com/browse/RT-6415 ) There is no possiblity to seek in large videos without fully downloading them You can only seek backwards or in specially crafted FXM files with KeyFrame positions [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thomasbutter.wordpress.com&amp;blog=13856289&amp;post=4&amp;subd=thomasbutter&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>JavaFX1.3 has a quite nice media API, but still faces some important issues.</p>
<p>Quite visible are these:</p>
<ul>
<li>FXM in MediaPlayer crashes very often on Windows ( <a href="http://javafx-jira.kenai.com/browse/RT-6415">http://javafx-jira.kenai.com/browse/RT-6415</a> )</li>
<li>There is no possiblity to seek in large videos without fully downloading them</li>
<li>You can only seek backwards or in specially crafted FXM files with KeyFrame positions in the header</li>
<li>Video does not restart after a stalled download / during buffering and onStalled/onBuffering does not work reliably (or at all?)</li>
<li>autostart in MediaPlayer does not work on Linux</li>
<li>some minor different behaviour in other methods and different OS</li>
<li>Video is flickering a lot (=not usable anymore) on Mac</li>
</ul>
<p>Since it is Java you have a lot of possibilities for workarounds. Here is some code &#8211; probably useful in your projects &#8211; that implements a embedded server which sends the frames fast enough to not trigger the crasher bug and does all the HTTP byte-range stuff for fast seeking. Furthermore it reduces bandwidth usage since it throttles the download to the playback bitrate. It handles all the issues above besides the last one &#8211; if you are on a Mac (like me) you are out of luck&#8230;</p>
<p>A FLV/FXM file is a header and a series of &#8220;tags&#8221; each with a audio frame, video keyframe or other video frame. You can display any series of video frames starting with a keyframe. The embedded server only needs to know the positions of the keyframes and is then able to rewrite the individual flash tags to appear as one continuous video, even after seeking. The Player then simply plays one long video without knowing about the seek.</p>
<p>A config file for a video looks like this:<br />
<code><br />
#http://www.butter.eu/filename.fxm</code></p>
<p><code>*640 480</code></p>
<p><code>0 430</code></p>
<p><code> </code></p>
<p><code>5000 230000<br />
</code><br />
The first line is a hash followed by the URL of the FXM file. It is followed by the dimensions of the video and then contains many lines with the timestamp of a keyframe followed by its byte position. This list can be easily created using <a href="http://static.ubivent.com/jfx/KeyFrameList.java">this</a> code. Next you will need to seek in a file over http which can be done with a HTTP GET Range request. Therefore we have an easy class implementing an InputStream with seek() <a href="http://static.ubivent.com/jfx/HTTPSeekStream.java">here</a>. Whenever you seek it will simply start a new request for the given range.</p>
<p>Furthermore we need the embedded server. It simply starts a pseudo http server. For each request it serves a header and then the current frame with the tag time changed to 0ms. Each following frame is the decreased by the same time. After a seek the incoming stream is repositioned and the frames at that position appended. The output stream is also throttled so that only some small number of seconds of additional frames after the current playing position is transferred. This allows fast seeking since it will play the frames already in the buffer anyway. The code for the embedded server is <a href="http://static.ubivent.com/jfx/FLVTag.java">here</a> and <a href="http://static.ubivent.com/jfx/FXMServer.java">here</a>. From JavaFX you set the Media URL to http://localhost:{fxmserver.getPort()}/dummy.fxm and get the file from there. Using this embedded server it is straightforward to add live streaming support from an rtmp server.</p>
<p>The last part is a quite large FX CustomNode which embeds the MediaView and does all the restarting, translation of real time and fake stream time, starting at a specific time, handling platform differences etc: <a href="http://static.ubivent.com/jfx/VideoView.fx">VideoView.fx</a></p>
<p>All Files:</p>
<p><a href="http://static.ubivent.com/jfx/KeyFrameList.java">KeyFrameList.java</a></p>
<p><a href="http://static.ubivent.com/jfx/HTTPSeekStream.java">HTTPSeekStream.java</a></p>
<p><a href="http://static.ubivent.com/jfx/FLVTag.java">FLVTag.java</a></p>
<p><a href="http://static.ubivent.com/jfx/FXMServer.java">FXMServer.java</a></p>
<p><a href="http://static.ubivent.com/jfx/VideoView.fx">VideoView.fx</a></p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/thomasbutter.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/thomasbutter.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/thomasbutter.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/thomasbutter.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/thomasbutter.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/thomasbutter.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/thomasbutter.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/thomasbutter.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/thomasbutter.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/thomasbutter.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/thomasbutter.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/thomasbutter.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/thomasbutter.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/thomasbutter.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=thomasbutter.wordpress.com&amp;blog=13856289&amp;post=4&amp;subd=thomasbutter&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://thomasbutter.wordpress.com/2010/05/27/working-around-javafx-1-3-video-issues/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/a8a097481ee0d9e705e2784e66ea02b9?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">thomasbutter</media:title>
		</media:content>
	</item>
	</channel>
</rss>
