28.04.2019 Views

[JAVA][Beginning Java 8 Games Development]

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Chapter 5 ■ An Introduction to Game Design: Concepts, Multimedia, and Using Scene Builder<br />

Once the bits travel through a data pipe, they also need to be processed and displayed on the device screen.<br />

Thus, bit rates for digital video assets must be optimized not only for bandwidth, but also in anticipation of variances<br />

in CPU processing power. Some single-core CPUs may not be able to decode high-resolution, high–bit rate digital<br />

video assets without dropping frames, so do make sure to optimize low–bit rate video assets if you are going to target<br />

older or less expensive consumer electronics devices.<br />

Digital Video Data Footprint Optimization: Using Codecs and Their Settings<br />

As mentioned earlier, your digital video asset will be compressed, using software utilities called codecs. There are two<br />

“sides” to the video codec: one that encodes the video data stream and another that decodes it. The video decoder<br />

will be part of the OS, platform (<strong>Java</strong>FX), or browser that uses it. The decoder is primarily optimized for speed, as<br />

smoothness of playback is a key issue, whereas the encoder is optimized to reduce the data footprint for the digital<br />

video asset it is generating. For this reason, the encoding process can take a long time, depending on how many<br />

processing cores a workstation contains. Most digital video content production workstations should support eight<br />

processor cores, like my 64-bit AMD octacore workstation.<br />

Codecs (the encoder side) are like plug-ins, in that they can be installed into different digital video–editing<br />

software packages to enable them to encode different digital video asset file formats. Because <strong>Java</strong> and <strong>Java</strong>FX 8<br />

support the MPEG-4 H.264 AVC format, you need to make sure that you are using one of the digital video software<br />

packages that supports encoding digital video data using (or into) this digital video file format. More than one<br />

software manufacturer makes MPEG-4 encoding software, so there will be different MPEG-4 AVC codecs that will<br />

yield different (better or worse) results, in terms of encoding speed and file size. The professional solution, which I<br />

highly recommend that you secure if you want to produce digital video professionally, is called Sorenson Squeeze Pro.<br />

There is also an open-source solution called EditShare LightWorks 12, which is scheduled to support output<br />

to the MPEG4 codec natively by 2014. When optimizing (setting compression settings) for digital video data file<br />

size, there are many variables that directly affect the digital video data footprint. I will discuss these in their order of<br />

importance, in in terms of effect on video file size, from the most important to the least, so that you will know which<br />

parameters to tweak to obtain the result you are looking for.<br />

Like with digital image compression, the resolution, or number of pixels, in each frame of video is the optimal<br />

place to start the optimization process. If your user is using 800 × 480 or 1,280 × 720 smartphones, e-readers, or<br />

tablets, then you do not need to use true HD 1,920 × 1,080 resolution to get good visual results for your digital video<br />

assets. With superfine density (small dot pitch) displays out there, you can scale a 1,280 video up 33 percent, and it<br />

will look reasonably good. The exception to this may be HD or UHD (popularly termed 4K iTV) games targeted at<br />

iTVs; for these huge, 55- to 75-inch (screen) scenarios, you would want to use the industry standard, true HD<br />

1,920 × 1,080 resolution.<br />

The next level of optimization would come in the number of frames used for each second of video (or FPS),<br />

assuming the actual number of seconds in the digital video itself cannot be shortened. As mentioned earlier, this is<br />

known as the frame rate, and instead of setting the video standard 30FPS frame rate, consider using a film standard<br />

frame rate of 24FPS or even the multimedia standard of 20FPS. You may even be able to use a 15FPS frame rate, half<br />

the video standard, depending on the amount (and speed) of movement within the content. Note that 15FPS is half as<br />

much data as 30FPS (a 100 percent reduction in data encoded). For some video content this will play back (look) the<br />

same as 30FPS content. The only way to test this is to try frame rate settings during the encoding process.<br />

The next most optimal setting for obtaining a smaller data footprint would be the bit rate that you set for a codec<br />

to try to achieve. Bit rate equates to the amount of compression applied and thus sets a quality level for the digital<br />

video data. It is important to note that you could simply use 30FPS, 1,920 resolution HD video and specify a low bitrate<br />

ceiling. If you do this, the results will not be as good-looking as if you had experimented with using a lower frame<br />

rate and resolution, in conjunction with a higher (quality) bit-rate setting. There is no set rule for this, as every digital<br />

video asset contains completely unique data (from the codec’s point of view).<br />

The next most effective setting for obtaining a smaller data footprint is the number of key frames that the codec<br />

uses to sample your digital video. Video codecs apply compression by looking at each frame and then encoding only<br />

the changes, or offsets, over the next several frames so that the codec algorithm does not have to encode every single<br />

www.it-ebooks.info<br />

115

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!