Wednesday, December 24, 2014

Video Bloat in Pages ePub Exports and How to Fix It

Pages 5.5.1 for MacOS X has an excellent ePub export option. That export option includes elements of ePub 3 such as embedded audio and video so Pages, being free with MacOS X, is a very attractive application for teachers at all levels who want to create eTextbooks containing rich media. However, there is a problem with Pages ePub video that this blog post will identify, document and provide solutions for. First, the problem statement.
Starting with Apple’s ePub template, we create a test project. To follow along, download the “ePub best practices” document from Apple’s “
Creating ePub files with Pages” support document, open it in Pages and do File > Save as template … which makes this template available to us now and in the future.
After we have the template saved, we add a 75 MB 1280 X 720 video with a duration of 5 minutes and 36 seconds (
download) to the still open Pages document. It now looks like this:

Video Quality Blog Post.001

The next step is to export this document as an ePub (File > Export To > ePub …). As we look at the output of this process in the Finder, we see that the ePub is about 280 MB despite the fact that the parent file, the Pages project, is only 80 MB in size. Here’s what that looks like:

Video Quality Blog Post.002

As far as I know, there is no application that can add useful data to source video. So, what is going on? Could this be an instance of unnecessary …

Video Quality Blog Post.003


… video bloat? The following delves into how to investigate that possibility. The first step in that investigation is to download ePub Zip Unzip so that we may peer inside the ePub file structure, find the video file and compare it with the original that was initially fed to Pages. This app has a very simple user interface that looks like this:

Video Quality Blog Post.004

The reality of an ePub file is that it is actually what is called a package file, a folder containing a variety of files that has been archived into a single file using the Zip compression algorithm. What ePub Zip Unzip does in this first step is simply to unzip the file into the folder it started out as. Once we have unzipped the ePub file, we can open this folder and examine its contents. Specifically, we’re interested in the video media because this is the only thing that we added to the Pages project beyond the template itself. Here is what we see:

Video Quality Blog Post.005


Clearly, we are looking at an instance of file bloat. The video file has grown more than 200 MB beyond its original size. This is not likely to be an improvement. To determine why this is so, we turn to another free, open source app called MediaInfo. Note that QuickTime X Player will also provide the most essential of this data but MediaInfo can provide additional data that is very useful to advanced users. Here’s what MediaInfo says about the original file:

Video Quality Blog Post.006

… and the video file exported by Pages:

Video Quality Blog Post.007


Here’s a table summarizing this analysis:


Video Quality Blog Post.008

The change in suffix from .mp4 to .m4v is inconsequential but the change in bit rate is key. The bit rate is 3.5 times greater than the source file! This is precisely what has inflated the file size. The formula for file size is bit rate times duration. So, will our readers benefit from this larger, longer to download file? Let’s see.


Link to full size version of this video: click here (opens in a new window)


Quite frankly, I see no improvement. Certainly not an improvement justifying an additional 200 MB in file size.

So that’s the problem. Now, how do we fix it? We already have some terrific clues. We have the ePub on the operating table and opened up so we can see and operate upon all of the internals. Why not try to replace the bloated video with the more efficient one that we started with. Here’s how:

First, we move the better file into the same location as the bloated version. Note that they have different names. This complicates things just a little bit. So copy the good video into the same folder as the bad video, like this:

Video Quality Blog Post.010


This is a simple drag and drop operation in the Finder. Next, we copy the full name of the bad video like so:


Video Quality Blog Post.011

Move the bad (bloated) file to the trash like so:


Video Quality Blog Post.012


Select and paste the name of the bad (bloated) file renaming the good file like so:

Video Quality Blog Post.013

Accept the change in the file suffix like so:

Video Quality Blog Post.014

Zip the folder back into an .ePub file like so:

Video Quality Blog Post.015

Enjoy the success of having reduced the file size of your ePub.

Video Quality Blog Post.016

Test the results in the iBooks.app to confirm that success.