How to avoid firefox playing YouTube videos with stutter

Firefox works fine with the default codecs in fedora workstation 40.
I need to use SimpleScreenRecorder (SRR), and had installed x264 from rpm-fusion to create mp4 videos there.
After that Firefox is playing YouTube videos with stuttering
video example

These packages aren’t installed

❯ dnf list libswscale-free libavcodec-free
Last metadata expiration check: 0:08:27 ago on Sat 21 Sep 2024 11:36:57 AM -05.
Available Packages
libavcodec-free.i686                                                                    6.1.2-1.fc40                                                                   updates
libavcodec-free.x86_64                                                                  6.1.2-1.fc40                                                                   updates
libswscale-free.i686                                                                    6.1.2-1.fc40                                                                   updates
libswscale-free.x86_64                                                                  6.1.2-1.fc40                                                                   updates
~                                                                                                                                                                            
❯     

I have following the recommendations of rpm-fusion web

sudo dnf swap ffmpeg-free ffmpeg --allowerasing
sudo dnf update @multimedia --setopt="install_weak_deps=False" --exclude=PackageKit-gstreamer-plugin
sudo dnf update @sound-and-video

How to setup Firefox with rpm-fusion codecs x264, ffmpeg and avoid stutter in YouTube videos

Thanks in advance.

❯ neofetch
             .',;::::;,'.                chris@fedora 
         .';:cccccccccccc:;,.            ------------ 
      .;cccccccccccccccccccccc;.         OS: Fedora Linux 40 (Workstation Edition) x86_64 
    .:cccccccccccccccccccccccccc:.       Kernel: 6.10.10-200.fc40.x86_64 
  .;ccccccccccccc;.:dddl:.;ccccccc;.     Uptime: 34 mins 
 .:ccccccccccccc;OWMKOOXMWd;ccccccc:.    Packages: 2159 (rpm), 11 (flatpak) 
.:ccccccccccccc;KMMc;cc;xMMc:ccccccc:.   Shell: zsh 5.9 
,cccccccccccccc;MMM.;cc;;WW::cccccccc,   Resolution: 1920x1080 
:cccccccccccccc;MMM.;cccccccccccccccc:   DE: GNOME 46.5 
:ccccccc;oxOOOo;MMM0OOk.;cccccccccccc:   WM: Mutter 
cccccc:0MMKxdd:;MMMkddc.;cccccccccccc;   WM Theme: Adwaita 
ccccc:XM0';cccc;MMM.;cccccccccccccccc'   Theme: Adwaita [GTK2/3] 
ccccc;MMo;ccccc;MMW.;ccccccccccccccc;    Icons: Adwaita [GTK2/3] 
ccccc;0MNc.ccc.xMMd:ccccccccccccccc;     Terminal: kitty 
cccccc;dNMWXXXWM0::cccccccccccccc:,      CPU: Intel i5-4430 (4) @ 3.200GHz 
cccccccc;.:odl:.;cccccccccccccc:,.       GPU: NVIDIA GeForce GT 610 
:cccccccccccccccccccccccccccc:'.         Memory: 3703MiB / 15777MiB 
.:cccccccccccccccccccccc:;,..
  '::cccccccccccccc::;,.                                         
                                                                 

Is the package libavcodec-freeworld installed? sudo dnf install libavcodec-freeworld --allowerasing would manage that if necessary.

The multimedia group contains optional packages so

sudo dnf group install --with-optional -x PackageKit-gstreamer-plugin multimedia

may install the missing codecs, especially

 Conditional Packages:
   gstreamer-plugins-espeak
   libavcodec-freeworld
   libavcodec-freeworld
   libavcodec-freeworld
   libheif-freeworld
   pipewire-codec-aptx
   qt5-qtwebengine-freeworld
   vlc-plugins-freeworld

The dnf install @multimedia is equivalent to dnf group install multimedia.

@computersavvy @vekruse None of the solutions worked.

❯ dnf list libavcodec-freeworld
Last metadata expiration check: 0:19:40 ago on Sat 21 Sep 2024 03:45:08 PM -05.
Installed Packages
libavcodec-freeworld.x86_64                                 6.1.2-2.fc40                                  @rpmfusion-free-updates
Available Packages
libavcodec-freeworld.i686                                   6.1.2-2.fc40                                  rpmfusion-free-updates 
~                                                                                                                               
❯ 
❯ sudo dnf group install --with-optional -x PackageKit-gstreamer-plugin multimedia
Last metadata expiration check: 4:06:28 ago on Sat 21 Sep 2024 11:59:24 AM -05.
No match for group package "PackageKit-gstreamer-plugin"
Dependencies resolved.
==============================================================================================================================================================================
 Package                                   Architecture                             Version                                   Repository                                 Size
==============================================================================================================================================================================
Installing Groups:
 Multimedia                                                                                                                                                                  

Transaction Summary
==============================================================================================================================================================================

Is this ok [y/N]: y
Complete!
~                                                                                                                                                                          4s
❯ 

After install I restarted the computer, but doesn’t work.

As it seems you have all the codecs, the problem could be elsewhere, for example the Nvidia drivers or perhaps the SimpleScreenRecorder has something to do with it. Neither of which I am familiar with.

sudo dnf install x265.x86_64 libde265.x86_64 x265-libs

H.265 is not supported on Firefox, regardless of the packages you install; there is simply no way to enable it. YouTube primarily uses VP9 and AV1 codecs, so you don’t need H.265 anyway. You can go to about:support in Firefox. The page will show you the media codec support status:

Firefox in fedora repo has many issue like some codes does not work.

I recommend you to just remove firefox
sudo dnf remove firefox
And install firefox from software store as flatpak from flathub
Else
flatpak install flathub org.mozilla.firefox
It will give you a good out of the box experience no issues at all.
And it is more secure to use a browser as a flatpak.

@yuntaz It was a mistake writing there x265, I meant to say x264

1 Like

Can you check ‘Media’ section on about:support page?

Can you walk back through what was installed using:
sudo dnf history
sudo dnf history info transaction

Maybe look at what you’ve installed initially trying to fix this and remove packages one at a time until the symptom changes.

It is the info of about:profile in firefox.

Added h264, rpmfusion and removed audio, flatpak, gnome, intel

It seems that no hardware acceleration is configured, which may be causing video stutter. Do you know what GPU you’re using? If it’s a typical, recent NVIDIA GPU, you can try the following:

dnf install libva-nvidia-driver akmod-nvidia xorg-x11-drv-nvidia xorg-x11-drv-nvidia-cuda

After running the command, wait about 10 minutes for the NVIDIA driver to compile.

Then, you’ll need to configure Firefox and set the following environment variables:

  • In Firefox about:config page, enable these settings:
    • Set media.ffmpeg.vaapi.enabled to true
    • Set media.rdd-ffmpeg.enabled to true
    • Set gfx.x11-egl.force-enabled to true
  • Set these environment variables:
    • MOZ_DISABLE_RDD_SANDBOX=1
    • LIBVA_DRIVER_NAME=nvidia

Is HEVC supported at all with Firefox on Linux? I was under the impression it was only supported under Windows with media.wmf.hevc.enabled

I have Intel UHD 630 and on F40 I have Unsupported under HEVC both Software/HW.

Edit: I see x264 is what was meant, but I’m still curious about HEVC :stuck_out_tongue:

HEVC (h265) is not supported: Web video codec guide - Web media technologies | MDN

Mozilla will not support HEVC while it is encumbered by patents.

1 Like

With that quote, why does that flag exist and seemingly work on Windows? Or is it a matter of semantics? (I guess Firefox is passing it to wmf but why can’t it do that with ffmpeg?)

There are 3 models with VDAPU Feature Set “C”. They use the “legacy” 390xx driver.

1 Like

WMF is a DRM-enabled environment for media plugins, so the key here is probably the proprietary nature of the integration. There is no open source alternative for this that could be used on linux, ffmpeg doesn’t have anything like that.

2 Likes

In that case, the method I mentioned above does not work. I’m not personally familiar with this card, but I think you would need the Nouveau driver instead to enable video acceleration. If it becomes too complex, lowering video bitrate is another alternative.

I feel that H.265 licensing is a huge mess. My understanding is that each application requires a license to use H.265. However, MPV can play H.265 videos with hardware acceleration using FFmpeg and VAAPI, but Firefox cannot.