Producing High-Quality Video for JavaFXTM Applications Frank Galligan On2 Technologies VP, Engineering
Why We are Here Who We Are General Encoding Best Practices VP6 JavaFX & Video Questions 2
On2 Video in JavaFX Makes high-quality rich media possible in any JavaFX application On2 decoder built into the JavaFX runtime itself Wide cross-platform distribution On2 video is the only format guaranteed to play in JavaFX No matter what kind of device Encode once, play anywhere 3
You Watch VP6 Every Day 4
Why We are Here Who We Are General Encoding Best Practices VP6 JavaFX & Video Questions 5
On2 Technologies, Inc. 3 Corporate Drive Suite 100 Clifton Park, NY 12065 6
On2 History 1993 The Duck Corporation: Compression technology (TrueMotion) for PC video games & consoles. Sega Saturn, others. 2000 Open-sourced our VP3 video codec (first VPx codec). Today known as Theora. 2002-05 VP5 & VP6 deployed in Nullsoft Winamp & SHOUTCast, AIM, others. 7
History (cont d.) 2005 Macromedia Flash Player 9 adopts VP6. Most of the Flash video on the web today is VP6-encoded. Released Flix 8 family of encoding applications & SDKs for VP6 Flash video. 2007 Skype adopts VP7 as the format for Skype video calls. Move Networks selects VP7 for its high-quality web video products. 8
History (cont d.) September 2008 VP8 announced. Significant quality & performance improvements over VP7. December 2008 Sun releases JavaFX 1.0, with VP6 playback support. 9
Unique Features & Benefits of On2 Formats Real-time encoding On2 Excels in videoconferencing, other low-latency environments Easy to understand & use No profiles, levels, B-frames other complicated settings Where possible, the encoders make the hard decisions for you Low decoding complexity Able to play in software on low-power devices 10
On2 Formats: Not Only for PCs Some On2 Chip / IP partners ~30 chip vendors have agreements for VPx codecs, for set-top boxes, cell phones, handheld games, security cameras, PC accelerators. 11
Why We are Here Who We Are General Encoding Best Practices VP6 JavaFX & Video Questions 12
Video Source garbage in = garbage out Poor Quality Source Material 13
De-interlacing Interlaced Source Material De-interlaced Compressed Material Interlaced Compressed Material 14
Aspect Ratio Original 16x9 Aspect Ratio Squeezed 4x3 Aspect Ratio Changing aspect ratio of the source can cause funny looking stretched or squished output Big Buck Bunny does not look so big anymore 15
One Pass vs Two Pass These two choices are about speed vs quality Two pass will analyze the movie first Two pass will always yield better quality 16
VBR vs CBR VBR = Variable Bitrate VBR will try allocate more bits for complex sections and less bits for easy sections VBR is used for local video or video over HTTP For offline encoding usually use two pass VBR CBR = Constant Bitrate CBR will try to keep a constant bitrate in all sections CBR is used for live streaming and streaming servers More about this later 17
Bandwidth Are you targeting mobile networks or playback from Internet? Disc? Your target bandwidth will dictate your resolution and frame rate. Example: Mobile over 2.5G Target: 40 Kbps Video resolution: 160x120 Video frame rate: 6 fps 18
Bandwidth (Cont.) Example PC broadband Target: 300 Kbps Video resolution: 320x240 Video frame rate: 15 fps Example Hi-Def device Target: 6 Mbps Video resolution: 1920x1080 Video frame rate: 30 fps 19
CPU Processing Power A newer PC will have more processing power to decode more material than a mobile phone Example Mobile Phone CPU: 512 MHz Arm 11 Video resolution: 640x480 Video frame rate: 30 fps Example PC CPU: 2.4 GHz Video resolution: 1920x1080 Video frame rate: 60 fps 20
Why We are Here Who We Are General Encoding Best Practices VP6 JavaFX & Video Questions 21
Advantages of On2 VP6 Low complexity decode 30% lighter than H.264 Enables a better playback experience on a wider range of devices VP6 is highly competitive with H.264 Main & High profiles, particularly HD Realtime Encoding Videoconferencing apps in Java, streaming live events 22
Sample Quality Comparison PSNR Quality @ 30 H.264 High 290 Kbps VP6-E 297 Kbps H.264 Base 360 Kbps 23
VP6 Low Decoder Complexity VP6 video decoder for Intel Moorestown (Atom) Measured VP6 decoder performance on 1.66GHz Intel N280 Atom 720p (1.5mb) @24fps, ~950 Mhz (VP6-E) 720p (1.5mb) @24fps, ~653 Mhz (VP6-S) Supported operating systems: Windows, Linux 24
More Chip numbers Simulated VP6 decoder performance for ARM1136J-S*: QVGA@30fps, 256kbps: 80 MHz (VP6-S) QVGA@30fps, 256kbps: 131 MHz (VP6-E) VGA@15fps, 512kbps: 189 MHz (VP6-S) VGA@15fps, 512kbps: 245 MHz (VP6-E) Measured VP6 decoder performance for Arm Cortex A8*: VGA@30fps, 1024kbps: 220 MHz (VP6-E) 25
How to get the Best Quality From VP6 The secret is Let the Compressor Handle It But there still some choices we can make (And we will go through all of the settings) 26
VP6-E vs VP6-S VP6-S and VP6-E are two profiles of VP6 Both work in JavaFX VP6-E is higher quality at the expense of decoding complexity VP6-S is a good choice for HD At HD VP6-S is usually 20-30% easier to decode than VP6-E At HD quality difference is usually only 5-10% VP6-S is also a good choice for low-power devices 27
Key Frame offsets JavaFX supports the Key Frame object in FXM files For a very small increase in file size, your users experience can be greatly improved The user does not have to wait until the whole FXM file is downloaded before seeking within the file 28
VP6 Quality Setting Good Attempts to strike a balance between quality and time to encode Best This will yield the highest quality On average 10-20% better quality over good but at 2x the time to encode For most offline encodes, choose Best Speed Encoder will turn on/off features striving to maintain the CPU percentage you choose 29
VP6 Sharpness A low sharpness setting results in fewer visible artifacts but may blur the source video somewhat A high sharpness results in a sharper video but may result in more visible artifacts 30
VP6 Datarate Control Happily, there are very few situations where you should need to change these values. Undershoot % target Lowers datarate in easy sections to make more bits available in a buffer to improve complex sections. Override Quantizers Determines the quality of the output. A lower Maximum produces higher quality at the expense of datarate. This value tells the encoder do not compress past this value. Minimum is the opposite. This value tells the encoder to always compress at least this value. 31
VP6 Datarate Control (Cont.) Temporal Resampling If the encoder can t achieve the requested datarate then this will allow the encoder to achieve the datarate by dropping frames Down Watermark determines the percentage of the datarate buffer below which the encoder is permitted to start dropping frames Resamplong is the last resort for the encoder to achieve the requested datarate 32
VP6 Streaming Parameters These values are only used with CBR Peak Bitrate The maximum bitrate allowed in the stream Prebuffer The number of seconds of data that the media player should preload before starting playback Optimal Buffer The ideal number of seconds in the buffer that the encoder strives to maintain Max Buffer The maximum size of the buffer in seconds. 33
VP6 Two Pass Section Datarate These values are only used with VBR Variability This value tells the encoder how much it is allowed to fluctuate the datarate. A higher value means the encoder is allowed to fluctuate more to increase quality while striving to maintain datarate Min Section This value is lowest datarate the encoder is allowed to go Max Section This value is highest datarate the encoder is allowed to go 34
VP6 is Actively Maintained On2 continues to improve VP6 quality and performance 35
Encoding On2 Video for JavaFX Demos of two encoding tools On2 Flix Pro desktop On2 Flix Cloud web service 36
Why We are Here Who We Are General Encoding Best Practices VP6 JavaFX & Video Questions 37
Playing Video in JavaFX Simple example to play VP6 in JavaFX: package simplestvideoplayer; import javafx.scene.media.media; import javafx.scene.media.mediaplayer; import javafx.scene.media.mediaview; import javafx.scene.scene; import javafx.stage.stage; varvideoview: MediaView = MediaView { mediaplayer: MediaPlayer { media: Media {source: "http://sun.edgeboss.net/download/sun/media/1460825906/1460825906_2956241001_big-buck-bunny640x360.flv"} autoplay: true } } Stage { width: 640 height: 360 scene: Scene {content: videoview} } 38
Playing Video in JavaFX (Cont d) A more useful example is here: http://www.javafx.com/samples/simplevideoplayer/inde The simple video player uses the media component developed by Sun to make a full-fledged player with not more much code than what we used above. For more examples of playing video please see http://www.javafx.com/ 39
Decoder Ubiquity is Key to Success Web video in 2005 Don t let this happen to you! VP6 is the only format guaranteed to play in JavaFX 40
VP6 in depth http://www.dspdesignline.com/211100053;jsessionid=t http://bit.ly/flgze 41
Questions? 42
Frank Galligan frank@on2.com 43