6

About how to get a transparent background with a webm video via alpha channel, here is one person that says you should encode with VP8 and not VP9.

WebM Alpha only displayed in Chrome?

And here is another person who says it's the opposite thing, like it should be VP9 and not VP8.

Transparent webm video displays solid background color on Chrome for Android 68 on android 9.0

Is there a way to make every device display webm files that contain alpha channel correctly?

EDIT1: HERE ARE SOME TEST RESULTS! I have produced two versions of the same webm file, one with VP8 encoding and another with VP9 encoding. I have run tests to view them on different devices. On a SONY phone (android/chrome 74) the one with VP8 encoding is displayed correctly with a transparent background while the one with VP9 encoding has its background filled with solid black instead of transparent. On a HUAWEI phone (android/chrome 74) it is the exact opposite! The one with VP9 is displayed correctly while the one with VP8 has its background filled with solid black instead of transparent. On an ASUS tablet both the VP8 and VP9 are displayed correctly. On a XIAOMI phone neither VP8 nor VP9 is displayed correctly.

EDIT2: Here is a page with some good explanation that I don't fully understand, https://sites.google.com/a/webmproject.org/wiki/alpha-channel I'm sure it's all about getting those parameters right to make it work on all android devices. Like the football/soccer player's video on

https://simpl.info/videoalpha/

...on my desktop (chorme/windows), on my tablet (chrome/android) and on my SONY phone (chrome/android) both the dancer and the soccer player videos are displayed correctly with a transparent background through alpha channel (which is expected). But on HUAWEI and XIAOMI phones only the football/soccer player video is working as expected while, strangely, the dancer's background is filled with solid gray. How can that soccer player's video work on all android devices; I want my webm files to do the same but don't know how to achieve that.

HolyResistance
  • 594
  • 1
  • 8
  • 26
  • I've been using Adobe Media Encoder to produce my webm files. That soccer player's video file must have been encoded with some GOOD settings and a GOOD method that I wish I knew. I will try ffmpeg and post the results. – HolyResistance Jun 11 '19 at 22:05
  • I tried using ffmpeg instead of Adobe Media Encoder. The results were exactly the same. Next I will try another software called MediaCoder found on mediacoderhq.com – HolyResistance Jun 22 '19 at 22:54
  • Result: I couldn´t get any satisfactory results with mediaCoder. – HolyResistance Aug 13 '19 at 19:40

2 Answers2

5

At long last I have a partial solution.

I was able to achieve consistent transparency on various devices by using animated 'webp' files instead of 'webm' files. Since my videos are very short and have no audio, using animated webp files were the best solution for me.

With this approach you want to save each frame of your video as a separate file (like uncompressed PNG with alpha) and then get the webp plug-in for Photoshop from https://github.com/webmproject/WebPShop. Finally put every frame on a layer in Photoshop and name every layer like (50 ms) or (100 ms) (including the parentheses). And "Save As" webp thanks to your new plugin. It worked on every device in my tests.


Some useful notes about webps,

  1. The webp file size and the compression rate are not always proportional. For instance saving with 90% quality instead of 80% quality MAY ACTUALLY DECREASE THE FILE SIZE in some cases! Strange but true.
  2. As of iOS 15 some frames in animated webp files can be horizontally cropped due to some bugginess in Safari.
HolyResistance
  • 594
  • 1
  • 8
  • 26
  • Note that switching to a WebP file means you're no longer working with video per se but rather an animated image sequence, similar to GIF, which would also be a solution for this. GIF would be less efficient but almost certainly more compatible with iOS 15 Safari, so that choice depends on your priorities. Also, the much, _much_ easier way to do that conversion is `ffmpeg -i myvideo.mp4 myvideo.webp` (with `-loop 0` if you want it to loop). – TigerhawkT3 Mar 27 '23 at 21:30
0

I found out (at least in my case) that the issue with displaying transparency is related to the webm video resolution.

A webm with resolution 640x360 as they show on the Google official guide works fine on low end devices, indeed both webm videos with alpha in the official example have an nHD resolution which has many drawbacks.

If you change the nHD resolution the alpha channel stops workin on low-end devices. Maybe this could depend on the processing power of the device (could be related to how webm works internally for alpha channel or on the GPU driver as pointed out in this issue?).

dnhyde
  • 1,265
  • 2
  • 14
  • 24
  • Well, even if this is true, my tests suggest that resolution may not be the only cause of the failure. Sometimes results seem to depend only on the brand of the mobile device (like same browser, different device). Also I remember testing on a SAMSUNG phone when Chrome-for-mobile didn't display the alpha while Samsung-internet-browser did. That was the same device, just different browser. – HolyResistance Sep 14 '19 at 13:13