• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit Search
0

Inserting a Youtube video into an EPub

Explorer ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

I have created an enhanced epub with five videos embedded in the iframe, and the book works fine for a few readers. However, when I run epubcheck, it gives me an error as epub standards are set not to accept iframe. Many suggest using 

<video></video>

However, since the Youtube video is not addressed as .MP4, the system inserts its controls, and the video does not display. 

I have tried and added these lines to the content.opf for each video;

<item id="content_001"  href="content_001.xhtml" media-type="application/xhtml+xml" properties="remote-resources"/>
<item id="content_iframe"  href="https://www.youtube.com/embed/qlMuzbjMASo" media-type="text/html"/>

However, I still get the following error:

ERROR (RSC-006) at "ABC.epub/OEBPS/ABC.xhtml" (line 14, col 215):
Remote resource reference is not allowed; resources must be placed in the OCF.

Does anyone have any ideas on how to get rid of this error?

TOPICS
EPUB , Feature request , How to , Performance

Views

401

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

LEGEND , Dec 19, 2022 Dec 19, 2022

Youtube isn't a video source - it's a full service video player, designed to allow embedding only in specific ways that maintain the profits. You may need to put your videos on a media server.

Votes

Translate

Translate
Guide , Dec 21, 2022 Dec 21, 2022

@James Gifford—NitroPressis correct in stating that the <iframe> tag should be avoided.

 

That said, YouTube videos can be embedded simply by copying the shared iframe code, although it is not part of the official epub standard, and there is no garantuee it will play in any given epub reader.

 

The <video> tag is an option. The following code will work in Thorium Reader:

 

<video id="video01" width="1280" height="720" preload="auto" controls="true">
<source src="https://mydomain.com/video/myvideo.mp4"

...

Votes

Translate

Translate
Community Expert ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

I am not sure EPUB, at the standards level, is built to manage embedded video.

 

While you can often hack in HTML features, as you've done with iframe, it won't pass validation and will work only erratically in viewers.

 

While EPUB is 'packaged web page,' it doesn't quite work like, well, a web page. Remote resources just aren't part of the package. (That is, it has to be a package.)

 


| Word & InDesign to Kindle & EPUB: a Pro Guide (Amazon)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

Depending on your budget, it might be worth having a look at in5, an InDesign plugin (at extra cost):
https://ajarproductions.com

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

Honestly, I'd say the right approach for the OP is a simple web page. While it doesn't "package" as a standalone document, an HTML/CSS page can be a highly sophisticated presentation with almost unlimited design and embedded content, which will present on almost any modern browser on any platform or device.

 

"Books" aren't always the right medium. 🙂

 


| Word & InDesign to Kindle & EPUB: a Pro Guide (Amazon)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

I have read through GitHub Epubcheck forums. There are many discussions to go through. However, they are not a support group. They have brought up the issue with iframe, Youtube, and Vimeo videos, among many other subjects. Still, they do not offer a solution besides changing the wrapping a video tag around the video source. 

Creating a website for a book is simple enough for me. However, by doing so, we develop more challenges like registration, paying for the book, abuse, and hacking. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

There are a lot of EPUB and e-book forums out there, yes.

 

'Nuf sed.

 

The EPUB 3.x standard simply doesn't support every feature that web browsers do, and iframes are an old, deprecated element anyway.

 

For the reasons I already noted, it's not likely EPUB, even a vastly revised standard (the EPUB 4 I hope to wake up to someday), will accommodate web-like features such as embedded media. When you think about it, very few non-web platforms do... at most they will open a browser that can handle that kind of content.

 

I have to say that I find "a book" whose content is based on "embedded YouTube videos" to be a curious thing. You want publishing control, revenue and document security... using someone else's content. Isn't that a bit like selling a book-encyclopedia that consists of nothing but Wikipedia links?

 

Anyway, I won't judge your project sight unseen except to say that you're looking for an implementation that's not very workable on a technical basis for a book concept that's not entirely sensible. In any case, neither EPUB nor Kindle are solutions; if a web page doesn't provide you with packaged sales and content protection, Derek's suggestion of In5, which is very much a hybrid solution for publications like this, might be what you need.

 


| Word & InDesign to Kindle & EPUB: a Pro Guide (Amazon)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

quote

There are a lot of EPUB and e-book forums out there, yes.

 

'Nuf sed.

 

The EPUB 3.x standard simply doesn't support every feature that web browsers do, and iframes are an old, deprecated element anyway.

 

For the reasons I already noted, it's not likely EPUB, even a vastly revised standard (the EPUB 4 I hope to wake up to someday), will accommodate web-like features such as embedded media. When you think about it, very few non-web platforms do... at most they will open a browser that can handle that kind of content.

 

I have to say that I find "a book" whose content is based on "embedded YouTube videos" to be a curious thing. You want publishing control, revenue and document security... using someone else's content. Isn't that a bit like selling a book-encyclopedia that consists of nothing but Wikipedia links?

 

Anyway, I won't judge your project sight unseen except to say that you're looking for an implementation that's not very workable on a technical basis for a book concept that's not entirely sensible. In any case, neither EPUB nor Kindle are solutions; if a web page doesn't provide you with packaged sales and content protection, Derek's suggestion of In5, which is very much a hybrid solution for publications like this, might be what you need.

 


By @James Gifford—NitroPress

Unfortunately, it seems you don't understand the dilemma. The videos and the material are all mine. However, to make an ePub not too heavy, I decided to embed the videos from YouTube. So much for not being judgmental!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

Well, you never said that, so I'll stand by what I said, in context.

 

I'm not sure publishing a video-heavy "book" for commercial sale, and then using YouTube to carry the file load you don't want to, is any much better.

 

Host your own videos and you will have, among other things, far greater control and content options for your 'book.' You'll still need to find a platform that allows all the aspects you want to involve. Good luck, though.

 


| Word & InDesign to Kindle & EPUB: a Pro Guide (Amazon)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

Youtube isn't a video source - it's a full service video player, designed to allow embedding only in specific ways that maintain the profits. You may need to put your videos on a media server.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

This is a great idea. However, the issue is the iframe in ePub, not where to host the videos.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

Asked and answered. Iframes don't work in EPUB, at least, not in the majority of readers. All ethical and business issues aside, what you want to achieve here won't work in the combination you suggest.

 

The only way you can get a hosted video to play from an EPUB (or Kindle) is to provide a link that will be played in the user's device's browser.

 


| Word & InDesign to Kindle & EPUB: a Pro Guide (Amazon)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

First of all, videos do not work on Kindle anyways. Second, this is not my first Rodeo. I have created a process to create ePubs for RTL languages for my books. Third, you insist that you have answered my question without a technical explanation. An expert would have done this a few times with different results and told me about his experiences. I am sure others would have different answers, and I await hearing from them.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

Look, I'm not sure why you're being so hostile here. I've given you a very specific answer. EPUB simply does not support the iframes keyword or notion of embedded web page content. I'm not sure what further technical explanation you need.

 

That a few of the random readers you've tried seem to work is not really a contradiction to that. Hardly any two readers are the same; many have whatever extensions or mods the developer felt like including. I suspect that if you try the highly standards-compliant ones like Thorium, it won't work at all.

 

However, even assuming you're willing to sell an EPUB for which readers will have to use a specific reader, or subset of readers, you have another problem you should already understand. You are going to need your EPUB issued by a sales platform that can implement DRM, so as to preserve your sales against piracy etc. (your stated goal). Not many seller platforms will accept an EPUB that won't validate. I'm neither here nor there with validation — I think it's largely overrated in the modern era — but if you can't get your EPUB with iframe content past validating, no one is going to sell it for you, and it's difficult to do DRM'ed e-books as an independent seller.

 

Please do ask if you have any further questions. But getting irritated because I tell you, from a position of some expertise, that what you want to do, overall, won't work, isn't helpful to either of us.

 


| Word & InDesign to Kindle & EPUB: a Pro Guide (Amazon)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

Sir,

I am not hostile. However, I feel you are being negative about the whole idea. I am consulting with the community and not just you. And apparently, you have not heard of "enhanced ePubs" or "enhanced eBooks." This is what it is. There are many out there in the market, and they are selling. Your assumption is again wrong when you assume I am trying to sell something that, from your point of view, does not have value since it runs in a few viewers. I am creating this for a non-profit organization for their fundraiser. So, I do not accept your answer as a solution, and I would like to hear other opinions. I hope you won't consider wanting to hear from others as hostility.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

You are misreading my entire viewpoint. You asked a technical question; I gave you an experienced and fairly authoritative answer.

 

If you want to explore the extended technology that is rife — legion — in the ebook world, without any real standards or compatibility, I'm in no way arguing against it. But you've come up with this fairly odd mash-up of info technologies and are insistent on making it work, so I can tell you that a very nonstandard, niche solution is the only one you will find.

 

There are several regulars here who are very skilled and experienced with EPUB. That none of them has jumped in to correct my comments or add alternative views says much. You're completely welcome to wait for someone else to give you an answer on this. You may have more success asking in any of the many EPUB forums and blogs that are not tied to specific, standardized approaches such as InDesign and epubcheck.

 

And good luck to you with it all.

 


| Word & InDesign to Kindle & EPUB: a Pro Guide (Amazon)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

Thank you for your knowledgeable input. However, I believe not everything has a standard until a standard is created for it. So, "necessity is the mother of invention." 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 20, 2022 Dec 20, 2022

Copy link to clipboard

Copied

I think you're completely misunderstanding my input, here.

 

You are of course free to completely reinvent EPUB, from your document to any EPUB reader you choose, and make your iframe/YT embed work. It's all HTML./CSS, so it's far from impossible.

 

I'm not saying you can't/shouldn't do that because of some vague allegiance to "standards"; much of the e-book/EPUB world just sort of nods at standards and does whatever it wants to. You're welcome to take that route.

 

However... unless you are going to provide all of your buyers with a specific EPUB reader that can handle this non-standard feature, you are likely to run into a lot of unhappy buyers/users who either don't want to install that reader, can't for some reason, or — most importantly — assumed your "EPUB" conformed to the standard for EPUBs and is readable on a standards-based reader. Because EPUB is a standard, and there very much are expectations when you label a doc or a reader "EPUB."

 

You have a simple, binary choice here:

 

1)  Make your doc compliant with EPUB standards, so that all buyers have a reasonable chance to read it on one or two more or less standard readers (as well as some decreasing number of older, less standardized and proprietary ones). This is what I have been recommending, not as some commandment, but as the reasonable, professional approach to EPUBlishing.

 

2) Use any workaround, extension or hack that allows you to use iframe to embed your YT videos... and then accept that only some subset of EPUB readers, and not the most common/standards-based ones, will let readers read your book (either at all, or with the videos working as you expect).

 

You are completely free to take either route, but if you choose to go a proprietary one, you're likely to have reduced sales and a number of unhappy buyers (who expected "EPUB" to mean, you know, EPUB), or will have to specify at the outset that only _______ Reader will display the book completely. (And, ETA, you are going to have trouble finding a DRM-capable seller for your nonstandard file; going rogue means going it on your own.)

 

Other than that, I'm not telling you to do one thing or the other, or saying you can't do it... just that it's one or the other, no middle road. You insisting it somehow can be done doesn't change that what you want is not according to the EPUB standard and won't change the e-book or EPUB world to make it a universal approach for the majority of the field that does follow standards.

 

That is, your innovation is not going to suddenly cause the standard, and all existing EPUB readers, to change. (You have no idea how slowly 'codified' change happens, here — it's somewhere between frustrating and maddening, really. EPUB3 is over ten years old and is only up to v3.2 in revisions... most of which are fine-tuning, not feature additions.)

 

So choose either route — I have no horse in the race. I just think it's important to understand the entirety of what you're choosing, especially if you have a group or organization counting on the success of and revenue from the project.

 


| Word & InDesign to Kindle & EPUB: a Pro Guide (Amazon)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 21, 2022 Dec 21, 2022

Copy link to clipboard

Copied

Thank you. It seems like you have the correct answer. As soon as I moved the files as MP4 to my server, at least the errors disappeared. However, there is still something missing, as the videos do not play.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Dec 21, 2022 Dec 21, 2022

Copy link to clipboard

Copied

There are more layers to getting multimedia to work correctly in EPUB, not the least of which is the reader.

 

Try several before you spend too much time trying to fix a problem that's not actually in the file itself.

 


| Word & InDesign to Kindle & EPUB: a Pro Guide (Amazon)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Dec 21, 2022 Dec 21, 2022

Copy link to clipboard

Copied

@James Gifford—NitroPressis correct in stating that the <iframe> tag should be avoided.

 

That said, YouTube videos can be embedded simply by copying the shared iframe code, although it is not part of the official epub standard, and there is no garantuee it will play in any given epub reader.

 

The <video> tag is an option. The following code will work in Thorium Reader:

 

<video id="video01" width="1280" height="720" preload="auto" controls="true">
<source src="https://mydomain.com/video/myvideo.mp4" />
</video>

 

It loads locally in Thorium from the supplied web address.

However, it does not load in Calibre's ePub viewer, even though the video player and its controls are displayed.

 

Calibre's ebook viewer does not support the licensed MP4 format, which is why it cannot play those files.

Encoding the video to webm/VP8 resolves this, and it plays in both readers. To do this, use a tool like Handbrake to transcode an existing mp4 to webm. The code changes to:

 

<video id="video01" width="1280" height="720" preload="auto" controls="true">
<source src="https://mydomain.com/video/myvideo.webm" />
</video>

 

See for codec support in epub: https://idpf.org/epub/30/spec/epub30-publications.html#note-video-codecs

 

webm/VP8 is considered the safest choice. But there is no garantuee that any given epub reader will display your videos, of course:

  • some readers refuse to load external online content
  • some readers do not support videos at all
  • some readers may only support one of the two codecs (either mp4 or webm)

 

Another potential issue with this approach: not everyone reading your book may be online. From my own experience, I am almost never online when reading an epub while traveling. It means that video content cannot be loaded and displayed. My wife is the same: almost always offline while reading epubs.

 

Then there is the problem of link rot. If you rely on external links for your book content, it is a given that content will disappear at some point in a few years time.

 

An alternative solution is to provide the reader with a link in your epub to a webpage that plays the video. Advantages are:

  • you leave it up to the reader to decide whether to view the video at a time convenient to them when they are online
  • When the reader taps/clicks the link in the epub, their preferred browser opens the link. All browsers, including mobile ones, will play your video - it will just work because browser have great support for video. (Unlike epub readers which is still the Wild West in a sense).
  • easier to secure your content.

 

As for your videos not playing: check that you have lowercase letters, no spaces, and no special characters in your file names. Ensure the videos are encoded to webm/VP8.

 

Which ebook readers are you targeting? Which have you tested?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 22, 2022 Dec 22, 2022

Copy link to clipboard

Copied

LATEST

Thank you for the complete explanation. I have created a few catalogs, which was great as the client did not care to have them go through the checker. And, of course, it works for a couple of readers, not the rest. I am currently working on a storybook for teenagers about Native Americans. They wanted to distribute this book through an agency, and they were required to pass through the checker. So, I cleaned up the book, but it would not take the iframes. So, I posted the MP4s on one of my servers and ran a test. I got it to work with the video tags and passed through the checker without errors. Now, I need to make changes to the book and the videos, and it should be done. Thorium and Adobe Digital both respond well.

Thanks again for taking the time to write in detail.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Dec 19, 2022 Dec 19, 2022

Copy link to clipboard

Copied

OK. Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines