whatwg / html

HTML Standard
https://html.spec.whatwg.org/multipage/
Other
8.03k stars 2.62k forks source link

Require `img` to be able to load the same video formats as `video` supports #7141

Open zcorpan opened 2 years ago

zcorpan commented 2 years ago

Related to https://github.com/whatwg/html/issues/6363

Regardless of what changes are made or not made to video, the question of which formats img should support remains. That's this issue.

WebKit supports video formats in img, while Gecko and Chromium do not.

In https://bugs.chromium.org/p/chromium/issues/detail?id=791658 it was requested that Chromium support MP4/h.264 in img. The issue was closed as WontFix:

Closing as WontFix per c#35, due to the following:

  • The widespread adoption of WebP (addresses CDN use case)
  • Forthcoming AV1 based image formats (ditto).
  • Memory inefficiency with allowing arbitrary video in image.
  • Most sites have already switched to <video muted> now that autoplay is allowed.

For the last point, video today doesn't have the same capabilities as img (e.g. srcset, media).

For AVIF, I asked on Twitter if there are reasons why it would still make sense to support other video formats assuming img can load AVIF: https://twitter.com/zcorpan/status/1428459457407864836

Is animated AVIF good enough for the "autoplaying muted looping short video" use case? That is, is making <img> support video formats playable by <video> unnecessary given AVIF?

zcorpan commented 2 years ago

cc @whatwg/media

kornelski commented 2 years ago

As someone who works for CDN with animation conversion feature: animated WebP is bad. We would prefer not to use it.

The animated WebP format has been designed to be conceptually similar to GIF, and work for the same use-cases that GIF does, but this made it inherit GIF's weaknesses. Content that makes GIF sizes balloon typically also compresses poorly in WebP. Both are especially inefficient for short video clips with camera motion — a use-case handled better even by ancient codecs like MPEG-1. WebP often fails to meaningfully reduce GIF file sizes, and can even end up making files larger than GIF.

kornelski commented 2 years ago

@eeeps on why GIF is still used:

https://twitter.com/etportis/status/1442838357432700932

Many, many contexts that aren't built to accept video files and loop/mute/autoplay them, without displaying controls. e.g.: most CMSes, messaging platforms, and the <img> tag.

https://twitter.com/etportis/status/1443218535774253060

One perf use case for GIF over <video> is (I think) speculative preloading. Last I checked (a while ago...) a tiny GIF could render/autoplay faster than a tiny <video>.

colinbendell commented 2 years ago

From an end-user perspective: the human doesn't really know the difference between a gif and an mp4 except perhaps the length of play. They are all 'gifs' to most humans.

colinbendell commented 2 years ago

A few considerations that should be defined:

Yay295 commented 2 years ago

should the UA support streaming formats

gif's can technically be streamed, so I think video streams should be allowed as well.

what are the equivalent dimX, dimY, resX, resY EXIF attributes

This would be hard to set, because I know it's possible with with at least VP8 to actually change the size of the video with each frame.

jonsneyers commented 2 years ago

A concern I have about the current Chrome approach of allowing AV1 wrapped in AVIF in an img tag, but not AV1 wrapped in any other container, is the following:

What about Nokia's patent claims on HEIF? AV1 is designed to be royalty-free, but the HEIF container that AVIF uses may not actually be royalty-free — at least Nokia does not give a patent grant, except for non-commercial purposes. See also: https://news.ycombinator.com/item?id=19874121

If we could use AV1 in any video container (in particular, in a non-patent-encumbered one), and not be forced to wrap it specifically in AVIF (which is based on HEIF), I would consider that a lot safer regarding potential patent trolling when adoption becomes larger and Nokia smells money. It would make perfect sense for them to lay low now and wait for more adoption before they start demanding royalties. These patents will only expire around 2035-2036, so they could be a problem.

Sheraff commented 2 years ago

For accessibility purposes, there are probably scenarios where you'll have to offer a way to pause the video. Will <img> tags now have a JS .pause() method?

From WCAG 2.1, potential friction point if an image can't be paused: 2.2.2 Pause, Stop, Hide.

kornelski commented 2 years ago

@Sheraff This problem already exists for GIF. The difference is not in user-visible behavior (which I agree should be improved!), but in allowing smaller file sizes.

Sheraff commented 2 years ago

@kornelski this solution is being debated as

jonsneyers commented 2 years ago
  • but also as a crutch for the removal of the media attribute in video <source> tags (which still exists in the picture <source> tags), in which case we would be losing accessibility features

Why would <img> being able to load the same video formats as <video> be an argument to not have the media attribute in video <source> tags? I think it's clear that the video tag is still needed for actual video (with audio, typically not looping, with controls, etc), and picture/img will not make it redundant.

So I think all of the following would be good, and they are imo orthogonal issues:

Sheraff commented 2 years ago

@jonsneyers the media attribute has already been removed from video <source> tags. So at this point, we have no clean way of doing responsive videos for above-the-fold content. If <picture> starts to support video content, developers are going to flock to this solution for the use-case of responsive above-the-fold videos.

So in my opinion, this change should either land with accessibility in mind, or land at the same time as some changes to the <video> tag that solve the responsive above-the-fold videos use-case.

zcorpan commented 2 years ago

This issue is not about the media attribute on video's source element. Continue that discussion in https://github.com/whatwg/html/issues/6363 please.

zcorpan commented 2 years ago

@Sheraff can you file a new issue about the ability to pause animated images in img?