Bug 224689 - [GStreamer] Kaltura video playback is choppy (also affects cnn.com, reddit.com, various other websites)
Summary: [GStreamer] Kaltura video playback is choppy (also affects cnn.com, reddit.co...
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: Media (show other bugs)
Version: WebKit Nightly Build
Hardware: PC Linux
: P2 Normal
Assignee: Nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-04-16 13:28 PDT by Michael Catanzaro
Modified: 2023-01-06 09:10 PST (History)
4 users (show)

See Also:


Attachments
Debug log (756.67 KB, text/x-log)
2021-04-16 13:28 PDT, Michael Catanzaro
no flags Details
Screencast of choppy playback (3.17 MB, video/webm)
2021-04-16 13:29 PDT, Michael Catanzaro
no flags Details
Example on cnn.com (397.31 KB, video/webm)
2021-10-12 07:41 PDT, Michael Catanzaro
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Catanzaro 2021-04-16 13:28:46 PDT
Created attachment 426265 [details]
Debug log

Video playback of any Kaltura video, e.g. https://demo.kaltura.me/rapt-test.html, is slow and choppy. This happens with both Ephy Tech Preview and F34 system Epiphany, both using gstreamer-openh264.

Surprisingly, Firefox has the same issue. (Could be something up with OpenH264?)

P.S. It's open source: https://github.com/kaltura/kaltura-player-js
Comment 1 Michael Catanzaro 2021-04-16 13:29:20 PDT
Created attachment 426266 [details]
Screencast of choppy playback
Comment 2 Philippe Normand 2021-04-23 02:46:14 PDT
Might be an openh264dec bug indeed:

0:00:04.095260351 230244 0x7f6560003430 LOG        webkitmediaplayer MediaPlayerPrivateGStreamer.cpp:767:didLoadingProgress:<media-player-5> didLoadingProgress: false
0:00:04.104046315 230244 0x5604e2269060 ERROR            openh264dec :0::<openh264dec0> [OpenH264] this = 0x0x7f63780bf6d0, Error:DecodeCurrentAccessUnit()::::::PrefetchPic ERROR, pSps->iNumRefFrames:5.
Comment 3 Michael Catanzaro 2021-07-11 07:05:34 PDT
Do you think it's a GStreamer bug, or a bug with OpenH264?
Comment 4 Michael Catanzaro 2021-07-23 05:56:59 PDT
Still broken with the 21.08 runtime (including GStreamer 1.18)
Comment 5 Philippe Normand 2021-07-23 06:04:49 PDT
(In reply to Michael Catanzaro from comment #4)
> Still broken with the 21.08 runtime (including GStreamer 1.18)

I'm not very surprised, given how little maintenance the gst openh264 decoder receives.
Comment 6 Michael Catanzaro 2021-10-12 07:41:20 PDT
Created attachment 440927 [details]
Example on cnn.com

Here's another example: https://dynaimage.cdn.cnn.com/cnn/animations/w_447/211012075606-desktop-climate-central-london.mp4. I almost opened a new bug for this before I realized it's probably this same issue.
Comment 7 Philippe Normand 2021-10-12 09:39:53 PDT
(In reply to Michael Catanzaro from comment #6)
> Created attachment 440927 [details]
> Example on cnn.com
> 
> Here's another example:
> https://dynaimage.cdn.cnn.com/cnn/animations/w_447/211012075606-desktop-
> climate-central-london.mp4. I almost opened a new bug for this before I
> realized it's probably this same issue.

This one plays just fine with gst main openh264dec.
In the future please open GStreamer bugs for openh264 issues.
Comment 8 Michael Catanzaro 2021-10-12 10:48:30 PDT
(In reply to Philippe Normand from comment #7)
> This one plays just fine with gst main openh264dec.

I feel like we could avoid a lot of the "works for me" issues if we aligned the WebKit and GNOME runtimes on the same version of GStreamer.

Looks like we have gst 1.18.5 in freedesktop-sdk 21.08, so that is the version that we would need to investigate to ensure that Tech Preview works properly.

> In the future please open GStreamer bugs for openh264 issues.

Sorry, but I have no way to know what is an openh264 issue vs. what is a WebKit issue until you tell me. It seems that most of the multimedia bugs I report turn out to be WebKit issues, though, so I think this Bugzilla is at least the right place to start. ;)
Comment 9 Michael Catanzaro 2021-10-12 11:17:43 PDT
(In reply to Michael Catanzaro from comment #8)
> Looks like we have gst 1.18.5 in freedesktop-sdk 21.08, so that is the
> version that we would need to investigate to ensure that Tech Preview works
> properly.

That is actually the latest stable version. Do you think this may have been fixed in openh264dec between 1.18.5 and current main?
Comment 10 Michael Catanzaro 2021-11-18 14:30:58 PST
(In reply to Philippe Normand from comment #7)
> This one plays just fine with gst main openh264dec.
> In the future please open GStreamer bugs for openh264 issues.

Are you sure it's working fine? In current Tech Preview, it seems to work for the first few seconds, but then it degrades badly. Again, this is using the very latest GStreamer 1.18.5.
Comment 11 Philippe Normand 2021-11-20 02:25:58 PST
(In reply to Michael Catanzaro from comment #10)
> (In reply to Philippe Normand from comment #7)
> > This one plays just fine with gst main openh264dec.
> > In the future please open GStreamer bugs for openh264 issues.
> 
> Are you sure it's working fine? In current Tech Preview, it seems to work
> for the first few seconds, but then it degrades badly. Again, this is using
> the very latest GStreamer 1.18.5.

when I tested this it was with the latest development version back then. Of the git main branch. Which is much ahead of 1.18.5.
Comment 12 Philippe Normand 2022-08-16 12:01:13 PDT
Wasn't the openh264 flatpak extension bumped recently? Is this still happening with newer openh264? In any case I'm not sure we can do much about this in WebKit. Might be better to report the issue to the openh264 bug tracker maybe?
Comment 13 Michael Catanzaro 2022-08-16 12:35:24 PDT
(In reply to Philippe Normand from comment #12)
> Wasn't the openh264 flatpak extension bumped recently? Is this still
> happening with newer openh264? 

It's still happening with the latest Ephy Tech Preview, using OpenH264 2.1.0. But the latest version of OpenH264 is 2.3.0. I have no clue why the update has not been made available. I will ask.

> In any case I'm not sure we can do much about
> this in WebKit. Might be better to report the issue to the openh264 bug
> tracker maybe?

Maybe, but (a) this should be reported by a multimedia developer, not by me, and (b) it will sadly be ignored on that issue tracker regardless.
Comment 14 Philippe Normand 2022-12-24 08:52:31 PST
Here after enabling the new gst va plugin, playback in Ephy TP works much better.

export GST_PLUGIN_FEATURE_RANK=vah264dec:MAX,vah265dec:MAX,vavp8dec:MAX,vavp9dec:MAX

If the maintenance of the openh264 plugin is not good enough I see only 2 options:

a. Hire qualified engineers to help with maintenance

or

b. Disable h.264 support in Ephy

At this point I'm even tempted to down-rank openh264 directly in WebKit. It's such a bad user experience.
Comment 15 Michael Catanzaro 2022-12-25 06:54:13 PST
I'll continue to argue in support of option a. There is a chance that funding for this might actually materialize, perhaps.

(Of course we can't disable H.264.)

> At this point I'm even tempted to down-rank openh264 directly in WebKit. It's such a bad user experience.

This would prefer the va plugin if available, but would not disable openh264 entirely, correct? If so, that sounds fine.
Comment 16 Philippe Normand 2023-01-05 10:00:44 PST
(In reply to Michael Catanzaro from comment #15)
> I'll continue to argue in support of option a. There is a chance that
> funding for this might actually materialize, perhaps.
> 
> (Of course we can't disable H.264.)
> 
> > At this point I'm even tempted to down-rank openh264 directly in WebKit. It's such a bad user experience.
> 
> This would prefer the va plugin if available, but would not disable openh264
> entirely, correct? If so, that sounds fine.

If the VA decoder can't be created because the runtime host is missing hardware capabilities then decodebin should try the next decoder in line, yes.
Comment 17 Philippe Normand 2023-01-05 10:02:13 PST
Maybe we could first do this experiment in Ephy TP? Add this env var: `GST_PLUGIN_FEATURE_RANK=openh264dec:0`
Comment 18 Michael Catanzaro 2023-01-05 10:29:36 PST
I'm not sure Tech Preview would be a good place to experiment because it's not supposed to have any encumbered codecs available. Certainly there should not be any va decoders capable of handling H.264 there; if so, that would be a bug.
Comment 19 Michael Catanzaro 2023-01-05 10:30:19 PST
BTW if you're willing to create an OpenH264 bug report for the original issue here, then I can try to get it some attention.
Comment 20 Philippe Normand 2023-01-05 10:47:12 PST
(In reply to Michael Catanzaro from comment #18)
> I'm not sure Tech Preview would be a good place to experiment because it's
> not supposed to have any encumbered codecs available. Certainly there should
> not be any va decoders capable of handling H.264 there; if so, that would be
> a bug.

flatpak run --command=bash  --user org.gnome.Epiphany.Devel
[📦 org.gnome.Epiphany.Devel ~]$ gst-inspect-1.0 va
Plugin Details:
  Name                     va
  Description              VA-API codecs plugin
  Filename                 /usr/lib/x86_64-linux-gnu/gstreamer-1.0/libgstva.so
  Version                  1.20.4
  License                  LGPL
  Source module            gst-plugins-bad
  Source release date      2022-10-12
  Binary package           GStreamer Bad Plug-ins source release
  Origin URL               freedesktop-sdk

  vadeinterlace: VA-API Deinterlacer
  vah264dec: VA-API H.264 Decoder
  vah265dec: VA-API H.265 Decoder
  vampeg2dec: VA-API Mpeg2 Decoder
  vapostproc: VA-API Video Postprocessor

  5 features:
  +-- 5 elements
Comment 21 Philippe Normand 2023-01-05 10:51:21 PST
I see this more like a feature ;) Besides, enabling hw decoding is good for the environment and your laptop fans will thank you.
Comment 22 Philippe Normand 2023-01-05 11:16:51 PST
By default the va plugin is not used though, because the rank of the elements is too low...
Comment 23 Michael Catanzaro 2023-01-05 15:50:09 PST
Hm, does it actually work? It's OK for it to be installed as long as it doesn't work. I'm afraid it really needs to not work. :/
Comment 24 Philippe Normand 2023-01-06 01:43:47 PST
(In reply to Michael Catanzaro from comment #23)
> Hm, does it actually work? It's OK for it to be installed as long as it
> doesn't work. I'm afraid it really needs to not work. :/

From my personal experience on a laptop with intel GPU and a desktop with AMD GPU, the VA decoder works, and actually rendering looks correct too, which is not the case for the openh264 decoder.

It's opt-in though, using an env var...
Comment 25 Michael Catanzaro 2023-01-06 08:34:14 PST
Phil, I have no doubt that the va decoder is way better than OpenH264. But that really doesn't matter. The fact that va decoders for encumbered codecs are available in the main GNOME runtime currently is a serious oversight, which I've just reported so that GNOME can decide what to do about that. Most likely we will split those out to an extension.

Back to the original topic of this bug. Clearly you've concluded that this is an OpenH264 bug and not a WebKit bug, yes? But I don't have enough multimedia expertise to create a useful bug report to the OpenH264 developers. Is that something you can help with?
Comment 26 Michael Catanzaro 2023-01-06 09:10:06 PST
(In reply to Michael Catanzaro from comment #25)
> The fact that va decoders for encumbered codecs
> are available in the main GNOME runtime currently is a serious oversight,
> which I've just reported so that GNOME can decide what to do about that.

I'm wrong. :) The va decoders cannot be used without va drivers that are not shipped, so it's fine.