420 CHAPTER 11: Digital Video: Streaming Video, MediaPlayer, and MediaController classes
widescreen device aspect ratio, as is a 16:8 (or 2:1) aspect ratio, with 2160x1080 screens out now.
There is even a 2560x1440 resolution screen on the Samsung Galaxy S5 smartphone. Why this
resolution, you may be wondering? Power of Two (even) upsampling of the most common 1280x720
digital video content will provide the best viewing results. Multiply 1280 by 2 and 720 by 2 and see
what resulting screen resolution you come up with!
There is also 16:10 Pseudo HD resolution, which features 1280 by 800 pixels. In fact, this is a
common laptop, netbook, and mid-size tablet resolution. I would not be surprised to see a 16:8 1280
by 640 screen offered at some point in time as well. Generally, most content developers try to match
their video content resolution to the resolution (and thus the aspect ratio as well) of each Android
device upon which the video asset will be viewed.
Regardless of the resolution you use for your digital video content, your application can access
video in a couple of different ways. The way I do it, because I’m a data optimization freak, is captive
to the application. This means the data is inside of the Android application APK file itself, inside the
/res/raw data resource folder.
The other way to access video inside your Android app is by using a remote video data server.
In this case, the video is streamed from this remote server, over the Internet, and into your user’s
Android device as the video is playing back in realtime. Let’s hope that this video server doesn’t
crash, which is one of the downsides of streaming.
Video streaming is inherently more complicated than simply playing back captive video data. This is
because an Android device is communicating in realtime with remote data servers, receiving video
data packets, decoding the data packets as the video plays, and writing the frames to the Android
hardware display. Video streaming is supported via WebM on Android 4 and later devices, using the
WebM format, or using MPEG4 on all of the Android OS versions.
The last concept that we need to cover in this section is the concept of bitrate. Bitrate is a key
setting used in the video compression process, as you will see when we utilize Sorenson Squeeze
Pro 9 later on in the chapter. Bitrates represent the target bandwidth, or data pipe size, which is
able to accommodate a certain number of data bits streaming through it every second. Bitrates must
also take into consideration CPU processing power within any given Android phone, making video
data optimization even more important to the video playback quality.
This is because once bits travel through a data pipe, they also need to be processed and displayed
on the device screen. In fact, captive video assets which are included in Android application APK
files only need optimization for processing power. This is because if you’re using captive video files,
there is no data pipe for the video asset to travel through, and no data transfer overhead. Therefore,
bitrates for digital video assets need to be optimized not only for bandwidth, but also in anticipation
of variances in CPU capability. We’ll look at optimization next.
In general, the smaller the video data file size you are able to achieve, the faster the data will travel
through the data pipe, the easier it will be to decode the data using the codec and the CPU, and
the smaller your APK file size will be, for obvious reasons. Single-core CPUs in devices such as
smartwatches may not be able to decode high-resolution, high bitrate digital video assets without
“dropping” frames, which is a playback quality issue, so make sure to thoroughly optimize low
bitrate video assets if you are going to target older (or cheap) devices.