Bug 2053867 - chromium: Use system ffmpeg libraries
Summary: chromium: Use system ffmpeg libraries
Keywords:
Status: CLOSED CURRENTRELEASE
Alias: None
Product: Fedora
Classification: Fedora
Component: chromium
Version: rawhide
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: ---
Assignee: Tom "spot" Callaway
QA Contact: Fedora Extras Quality Assurance
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2022-02-12 19:32 UTC by Andreas Schneider
Modified: 2023-01-09 19:53 UTC (History)
8 users (show)

Fixed In Version:
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 2053868 (view as bug list)
Environment:
Last Closed: 2023-01-09 19:53:07 UTC
Type: Bug
Embargoed:


Attachments (Terms of Use)
ffmpeg-fix-first-dts-tracking.patch (4.43 KB, patch)
2022-02-26 12:55 UTC, Andreas Schneider
no flags Details | Diff

Description Andreas Schneider 2022-02-12 19:32:35 UTC
Starting with Fedora 36 we have a royality free version of FFMPEG in the repository.

Please link against the system ffmpeg!

https://src.fedoraproject.org/rpms/ffmpeg

Comment 1 Kevin Kofler 2022-02-12 23:43:45 UTC
Unfortunately, the way this is implemented does not help Chromium at all, see the discussion under bug #2053868.

Comment 2 Andreas Schneider 2022-02-13 07:36:27 UTC
openSUSE is linking chromium with system ffmpeg which can be replaced by Packman ffmpeg just fine.

Comment 3 Kevin Kofler 2022-02-13 10:53:32 UTC
Define "just fine"… The two issues I have pointed out are not going to make the browser fail to start up or something. They are going to stealthily degrade the user experience on some websites. Some websites will be unable to play audio/video because they trust the browser when it claims to support or not support a given codec and send it the wrong or no audio/video file. Some WebRTC websites will also not work because they require H.264 encoding (OpenH264) which is only available in qt5-qtwebengine-freeworld, not in qt5-qtwebengine (and it SHOULD be the same in Chromium, I have not checked though). (Note that FFmpeg does NOT support H.264 encoding, i.e., H.264 encoding requires libx264 (not supported by Chromium) or OpenH264.)

I also do not know how OpenSUSE handles OpenH264, but I would guess their handling of it is less strict than in Fedora, where it can only be shipped through Cisco, no package is allowed to bundle it, and it is also not allowed to hard-depend on it and not even possible to link to it at compile time, as Chromium and QtWebEngine require. That makes the whole exercise of swapping FFmpeg at runtime pretty pointless because you need a freeworld build of the whole package anyway.

Comment 4 Kevin Kofler 2022-02-13 11:05:41 UTC
(To be clear: Technically, FFmpeg indirectly supports H.264 encoding through libx264 if linked against it, so the RPM Fusion build of FFmpeg supports that, but Chromium does not even try to use FFmpeg for H.264 encoding, only for decoding, I guess because it was developed against a bundled copy of FFmpeg that is not linked against libx264 and because using OpenH264 ensures that the other end can decode it even if it uses OpenH264 also for decoding, unlike Chromium. OpenH264 supports only a subset of H.264.)

Comment 5 Andreas Schneider 2022-02-13 13:19:13 UTC
How exactly is the experience of chromium in Fedora better, if it links statically against an internally stripped down ffmpeg version?

Comment 6 Kevin Kofler 2022-02-13 16:16:39 UTC
At least it correctly reports that it does not support, e.g., H.264, so websites will (if correctly implemented) not attempt to send it videos in that format if they have an unencumbered format available. And installing chromium-freeworld gives you a version that supports the codecs and reports so.

That said, I would not object to moving Chromium to RPM Fusion altogether. I see little value in having the crippled version in Fedora to begin with. The situation is different for QtWebEngine where we need something to build core KDE applications against. That is quite similar to what you are trying to achieve with the Fedora ffmpeg-free, except that replacing FFmpeg is not sufficient for the reasons explained, we have to rebuild and replace the entire QtWebEngine.

Comment 7 Andreas Schneider 2022-02-15 08:11:28 UTC
(In reply to Kevin Kofler from comment #6)
> At least it correctly reports that it does not support, e.g., H.264, so
> websites will (if correctly implemented) not attempt to send it videos in
> that format if they have an unencumbered format available. And installing
> chromium-freeworld gives you a version that supports the codecs and reports
> so.

So if you get only h264 support if you install the version from rpmfusion, then I don't see a reason why not link against system ffmpeg for Fedora. Also it is strange that they hardcode h264 as they have all the functions in place to query if a codec is available on the system or not.

Most websites don't use h264 anymore. On YT you either get VP9 or AV1.

Comment 9 Kevin Kofler 2022-02-15 20:13:36 UTC
This is a cool feature, but I have two major concerns with it:
1. This is a downstream patch that you are going to have to adapt for each FFmpeg release. Knowing FFmpeg upstream's stance on workarounds for patent restrictions and on dynamic codec loading, I doubt that this is ever going to be accepted upstream, is it?
2. Does this actually work in Chromium? Does Chromium not want to encode with OpenH264 directly, bypassing FFmpeg?

Comment 10 Andreas Schneider 2022-02-16 13:18:18 UTC
The chromium code is quite strange. For webrtc it looks like it uses openh264 directly and ffmpeg doesn't work for RTC. Looking at webrtc standalone it seems to use ffmpeg. For videos on the web it hardcodes h264 without querying ffmpeg if it supports the codec.

Comment 11 Kevin Kofler 2022-02-16 13:33:51 UTC
That is basically what I pointed out all this time. (Now, if it reports H.264 as supported even if Chromium was built with "proprietary_codecs" disabled, that is even worse than I expected and a definite bug in Chromium.)

Comment 12 Kevin Kofler 2022-02-16 13:34:55 UTC
(but that "proprietary_codecs" flag is a compile-time option, so it will not help with a runtime-pluggable FFmpeg, even if Chromium handles it correctly)

Comment 13 Kevin Kofler 2022-02-16 14:18:35 UTC
About the hardcoded codec list(s), see, e.g.:
https://chromium.googlesource.com/chromium/src/+/2ce3e342ee589cacfae4a909852780815236a0c4/media/base/mime_util_internal.cc#292

See how everything depends on compile-time flags, runtime-plugging codecs is not supported.

Comment 14 Andreas Schneider 2022-02-16 19:17:50 UTC
Would be nice to make it an runtime option. The ffmpeg glue code provides functions for that.

Comment 15 Kevin Kofler 2022-02-26 09:52:51 UTC
FYI, RPM Fusion decided to drop the ffmpeg-support-chromium.patch:
https://pkgs.rpmfusion.org/cgit/free/ffmpeg.git/commit/?id=71696edc6a35c6a91c0b419368d2f4c6c79d1ac0

Comment 16 Andreas Schneider 2022-02-26 12:53:01 UTC
I've looked into chromium already. ffmpeg tools keep track of first_dts on their own so it should be possible to do the same in chromium.

https://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff/ab4f299e


However I'm a C developer and C++ is most of the time confusing for me. However I will upload the untested patch I have. Maybe someone can help ...

Comment 17 Andreas Schneider 2022-02-26 12:55:38 UTC
Created attachment 1863406 [details]
ffmpeg-fix-first-dts-tracking.patch

Help is much appreciated ...

Comment 18 Demi Marie Obenour 2022-03-10 08:20:42 UTC
(In reply to Kevin Kofler from comment #6)
> At least it correctly reports that it does not support, e.g., H.264, so
> websites will (if correctly implemented) not attempt to send it videos in
> that format if they have an unencumbered format available. And installing
> chromium-freeworld gives you a version that supports the codecs and reports
> so.
> 
> That said, I would not object to moving Chromium to RPM Fusion altogether. I
> see little value in having the crippled version in Fedora to begin with. The
> situation is different for QtWebEngine where we need something to build core
> KDE applications against. That is quite similar to what you are trying to
> achieve with the Fedora ffmpeg-free, except that replacing FFmpeg is not
> sufficient for the reasons explained, we have to rebuild and replace the
> entire QtWebEngine.

Hard disagree.  If we go this route we might as well not ship any browsers
at all.  Chromium is vastly more secure than Firefox if kept up to date and
should be what is recommended.

Comment 19 Andreas Schneider 2022-03-15 13:52:23 UTC
I've created a patch upstream to work with system ffmpeg:

https://chromium-review.googlesource.com/c/chromium/src/+/3525614

Comment 20 Neal Gompa 2022-12-28 19:06:17 UTC
Than, I see you're updating Chromium. Would you consider taking a look at fixing this bug for your update?

Comment 21 Than Ngo 2022-12-31 12:02:23 UTC
(In reply to Neal Gompa from comment #20)
> Than, I see you're updating Chromium. Would you consider taking a look at
> fixing this bug for your update?

it is pretty hard to fix this in a short time. Maybe we should consider putting the patch from comment 15 into ffmpeg-free.

Than

Comment 22 Neal Gompa 2022-12-31 13:07:52 UTC
I originally did have that patch, but I dropped it to remain ABI compatible with RPM Fusion's ffmpeg package.

Comment 23 Kevin Kofler 2022-12-31 14:29:53 UTC
Yes, the RPM Fusion ffmpeg maintainer refused to apply that patch, even though it was in Fedora, on the grounds that it was rejected upstream.

Comment 24 Than Ngo 2023-01-09 19:53:07 UTC
it is fixed in chromium-108


Note You need to log in before you can comment on or make changes to this bug.