Thursday, May 16, 2013

Video in Kindle books, thanks to EPUB3

Yesterday, I wrote about how you can call external audio/video files in an EPUB3 document. This works brilliantly in iBooks and Readium, but so far, nowhere else. What happens when it doesn't work is actually pretty interesting. According to the spec, you can add a fallback message, and indeed a fallback photo or link. In this case, I've used the poster image as a fallback image.

<p>Does everyone have their own cat videos? I sure do. Here are Nighty and a very small Momo playing the box game.</p>
    <video controls="controls" poster="image/poster.jpg" width="384" height="276">
    <source src="http://www.elizabethcastro.com/epub/examples/catbox2.mp4" />
    <source src="http://www.elizabethcastro.com/epub/examples/catbox2.wvm" />
    <p><a href="http://www.elizabethcastro.com/epub/examples/catbox.mp4"><img id="poster" width="384" height="276" src="image/poster.jpg" alt="poster" /> Click to play the video</a> and then return to read the rest of the book. </p>
    </video>


The only problem is that Adobe Digital Editions is the only EPUB ereader that properly displays the fallback message.

Adobe Digital Editions - video fallback

But it's nice. If you click the link, your default browser opens, and the video plays.

Unfortunately, if you open the EPUB file on the NOOK, or in Kobo (even the Kobo for iOS app), or even if you open it in iBooks without internet access—and thus the video cannot be displayed—you get varying things—sometimes the poster image, sometimes controls but no video—but no fallback content.

Kobo - no fallback

Fallback leads to video for Kindle books

But what about Kindle? Suppose you take that EPUB3 file, and pass it through KDP, or Kindle Previewer, or KindleGen, which all do the same thing—convert an EPUB file to KF8/mobi. And yes, they work on EPUB3 files as well as EPUB2 files. Next, open that converted mobi file in a Kindle Fire.

The fallback text, photo, and link appear, and better yet, when you click the link, Kindle Fire sends you to the browser, and plays the video. When you're done, the back arrows take you back to the book.



If that's not enough, stick it on Dropbox, and open your Dropbox app on an iPad. Once it's been copied, click the Open in another application arrow (upper right corner) and choose Kindle for iOS. Again, the fallback text, photo, and link appear, and when you click them, the video plays. It's true that you get an error message, but I'm guessing there's a way to get around that, but regardless, the video plays anyway. As if it were in a special window inside the Kindle iOS app. And when you've finished watching the video, click Done, and you go right back to the book.




So let's sum up:

1. So far, you can only play an embedded video right on a page in an ebook in iBooks and NOOK. But B&N won't let self- and indie publishers add such books to Pub It!.

2. You can play external video files right on a page in an ebook only in iBooks.

3. The fallback text doesn't appear in NOOK or Kobo.

4. The fallback text does appear in ADE and—if you convert the EPUB3 file to KF8/mobi—it also appears in Kindle Fire and Kindle for iOS (perhaps other Kindles too?), and all of these let you play the fallback video in an external browser.

5. An added caveat: I haven't uploaded a book to KDP with a link to external video. I can't guarantee that such a thing is permitted.

6. This opens up a lot of possibilities.

You can download the mobi file here. And if you liked this post, consider subscribing to my blog so I have time to write more!

12 comments:

  1. This is great, Liz. Can you clarify if your testing was with reflowable or FXL titles? Do you know if this works with fixed-layout content?

    ReplyDelete
    Replies
    1. My test was on a flowing book since they're much easier to convert to KF8/mobi. I haven't tried with FXL yet, though I suspect it would also work.

      Delete
    2. Audio/Video does not work in KF8 FXL, as per the specs in Section 6 of the newest Guidelines. Testing has confirmed.

      Delete
  2. Hi Liz,

    Love your site. You are so helpful! It's so great with all the different formats out there.

    I wanted to let you know this is directly from the Amazon Kindle Publishing Guidelines:

    6.2 Streaming Video
    Streaming video is not supported at this time. Use embedded video instead.

    This is the same for streaming audio. Sadly, it looks like they aren't supporting streaming. Lame!

    I have a question regarding Kindle multi-media eBooks. We typically publish our products via Apple because most of our products are image, video and audio heavy. With the new release of Kindle allowing Audio and Video embedded material, we were super excited that we could finally start getting our products on Amazon, but we haven't had success. After doing some research I believe the problem is that our titles are in FXL. I've read a blog that fixed-layout audio/video titles aren't supported on the Kindle and I wanted to see if you had experienced this as well? (Here's the blog I read: http://authoradventures.blogspot.com/2013/04/audiovideo-in-kindle-ebooks.html)

    Any insight would be greatly appreciated! Thanks!
    -Travis

    ReplyDelete
  3. This page <www.htmlgoodies.com/primers/html/article.php/3884796/HTML-5-Tutorial-for-Web-Developers-The-Video-Element.htm looks like it may have an answer. Use JavaScript to determine if the video loaded, and provide an alternative on failure:

    <script>
     function failed(e) {
       // video playback failed - show a message saying why
       switch (e.target.error.code) {
         case e.target.error.MEDIA_ERR_ABORTED:
           alert('You aborted the video playback.');
           break;
         case e.target.error.MEDIA_ERR_NETWORK:
           alert('A network error caused the video download to fail part-way.');
           break;
         case e.target.error.MEDIA_ERR_DECODE:
           alert('The video playback was aborted due to a corruption problem or because the video used features your browser did not support.');
           break;
         case e.target.error.MEDIA_ERR_SRC_NOT_SUPPORTED:
           alert('The video could not be loaded, either because the server or network failed or because the format is not supported.');
           break;
         default:
           alert('An unknown error occurred.');
           break;
       }
     }
    </script>

    I haven't tried it yet.

    ReplyDelete
  4. Thank you for this super helpful post! I am a big fan of your blog.

    ReplyDelete
  5. There is a flaw in the HTML5 spec for AV fall back mechanisms which is responsible for (some of) the inconsistent behaviour observed. In a nutshell, the fall back is there for when the audio/video element isn't supported, but in a lot of cases the element *is* supported but the format of the specific asset isn't (or streaming isn't supported). The result is a dead video play with some or none of the fall back rendered.

    ReplyDelete
  6. I've been looking into video in .mobi files (on kindle devices) for a long time. It's been doable without this fallback, although it still links to some SUB directory, and I've only ever seen it in enhanced kindle editions, surrounded by these funky defs in the video tag mediarecindex="00003" recindex="00004". I won't bother trying to figure out where these reference to, as I'm pretty sure it's amazons own creation, but it would be nice to have the option available for personal creation already ;). Your thoughts?

    ReplyDelete
    Replies
    1. Have you seen video work in Kindle on a sideloaded or self-published book?

      Delete
  7. I am embedding a video in a Kindle book, and on the iPad the poster displays fine with a "play" button shown, but when I press it I am told "Unable to play video. There was a problem downloading the video content of this title. Please remove the book form your device and re-download it." These books work fine in iOS. The videos are mp4/x264/baseline profile encoded. Any thoughts or experience with this?

    ReplyDelete
  8. Brilliant article. I have published detailed review here of my test results with EPUB3 and Kindle tag:

    http://wpencyclopedia.com/blog/2013/10/epub3-and-kindle-support-for-videos-and-the-html5-tag/

    Please comment if you have any additional helpful information.

    Summary: Kindle publishing guidelines mention support for the HTML5 tag, but in terms of implementation it still appears to be in the category of a "good idea" on their side (as of Oct/2013). The fallback text still works however

    ReplyDelete
    Replies
    1. Also with regards to your question " I haven't uploaded a book to KDP with a link to external video" -- it works fine, i just put video splash image with link to external youtube or vimeo. Obviously this won't work on early Kindles (before FIRE) and i don't see anyway of specifying this in Kindle marketplace (i will need to ask)

      Delete

More of my books