Skip to content

Instantly share code, notes, and snippets.

@mcarletti
Last active March 11, 2024 08:23
Show Gist options
  • Star 17 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mcarletti/7989d1c04199dba60a01adf8ac54fe31 to your computer and use it in GitHub Desktop.
Save mcarletti/7989d1c04199dba60a01adf8ac54fe31 to your computer and use it in GitHub Desktop.
Enable H.264 codec support for Opera browser
#!/bin/bash
# Author: Marco Carletti
# Date: May 2022
# Version: 0.2.0
# Last update: July 17, 2023
# Changed comments, tested versions and added other distros info, such as Debian and Fedora.
# Thanks to everyone for comments, suggestions, fixes and testings!
# Tested on
# ---------
#
# Ubuntu 18.04
#
# v0.1.0
# 62.0.3331.116
# 63.0.3368.66
#
# Ubuntu 20.04
#
# v0.1.0
# 70.0.3728.95
# 73.0.3856.284
# 74.0.3911.107
# 74.0.3911.232
#
# v0.2.0
# 87.0.4390.25
#
# Ubuntu 22.04
#
# v0.2.0
# 99.0.4788.13
# Other distros
# THIS SCRIPT WILL NOT WORK AS IS IS. EACH OS REQUIRES SPECIFIC FIXES.
# Search in the comments for further details :)
# -------------
#
# Debian 11.4
# Requires `-c` option in `sudo` commands (credits: `gidici`)
#
# v0.2.0
# 90.0.4480.80
#
# Fedora 37
# Requires to copy the lib file to opera lib folder and chown to root (credits: `JPDucky`)
#
# v0.2.0
# 100.0.4815.54 (Opera One)
# Release notes
# -------------
#
# v0.2.0 Smarter use of curl options to fix failing permalink. Special thanks to `dotarr` for the fix!
# Last update: May 18, 2022
#
# v0.1.0 It is basically a cleaned version of what you can find in this post from Opera forum:
# https://forums.opera.com/topic/34659/opera-linux-browser-h-264-support-through-x264-open-source-codec
# Last update: Aug 18, 2020
# Retrieve latest FFMPEG release version.
# We get the complete url pointing to the latest zip package via the curl command.
#
# -L If the server reports that the requested page has moved to a different location
# this option will make curl redo the request on the new place.
#
# -o <file> Write output to <file> instead of stdout.
#
# -s Silent or quiet mode. Don't show progress meter or error messages.
#
# -w <format> Make curl display information on stdout after a completed transfer. The format is
# a string that may contain plain text mixed with any number of variables.
URL=`curl -L -o /dev/null -s -w %{url_effective} https://github.com/iteufel/nwjs-ffmpeg-prebuilt/releases/latest`
FFMPEGVER=${URL%\"*}
FFMPEGVER=${FFMPEGVER##*/}
FFMPEGZIP=${FFMPEGVER}-linux-x64.zip
# Download library from complete url and save it locally.
# Archive is extracted in the working directory and immediately deleted.
#
# -L (see above)
# -O Write output to a local file named like the remote file we get.
# Only the file part of the remote file is used, the path is cut off.
curl -L -O https://github.com/iteufel/nwjs-ffmpeg-prebuilt/releases/download/${FFMPEGVER}/${FFMPEGZIP}
unzip ${FFMPEGZIP}
rm ${FFMPEGZIP}
# Overwrite Opera libffmpeg (requires root privileges).
# Install (ie. copy) the latest version of the library in the system library folder.
# Before overwriting the Opera library file, make a copy... So we can manually rollback if we messed up things :)
sudo mv libffmpeg.so /usr/lib/x86_64-linux-gnu/libffmpeg_h264.so
sudo mv /usr/lib/x86_64-linux-gnu/opera/libffmpeg.so /usr/lib/x86_64-linux-gnu/opera/libffmpeg.so.orig
sudo ln -s /usr/lib/x86_64-linux-gnu/libffmpeg_h264.so /usr/lib/x86_64-linux-gnu/opera/libffmpeg.so
@lpaoliespin
Copy link

Thanks!! It worked perfectly for me on Ubuntu 20.04.2 LTS (Focal Fossa) 64-bit + Opera 74.0.3911.107.

@ondrejkopicka
Copy link

Thanks :) Still works on Ubuntu 20.04.3 LTS, Opera 74.0.3911.232

@dotarr
Copy link

dotarr commented May 17, 2022

I found that the extraction of variables from URL into FFMPEGVER and FFMPEGZIP had started failing pointing to the redirection between /latest and the permalink to the numbered version no longer being output by curl, adding some switches appeared to fix:

URL=$(curl -Ls -o /dev/null -w %{url_effective} https://github.com/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt/releases/latest)
FFMPEGVER=${URL%\"*}
FFMPEGVER=${FFMPEGVER##*/}
FFMPEGZIP=${FFMPEGVER}-linux-x64.zip
curl -L -O https://github.com/iteufel/nwjs-ffmpeg-prebuilt/releases/download/${FFMPEGVER}/${FFMPEGZIP}
unzip ${FFMPEGZIP}

sudo mv libffmpeg.so /usr/lib/x86_64-linux-gnu/opera/lib_extra

@mcarletti
Copy link
Author

Thanks everyone! I've updated the script with your notes and fixes. I've also tested the script with the latest Opera version (currently, it is 87.0.4390.25).

@gidici
Copy link

gidici commented Sep 11, 2022

Works with Opera 90.0.4480.80 on Debian 11.4. Thanks. I only changed sudo with su -c "...."

@thibault-duhem
Copy link

Works with Opera version :99.0.4788.13 and System:Ubuntu 22.04.2 LTS (x86_64; ubuntu:GNOME)
Chromium version:113.0.5672.127
Thank you !!

@JPDucky
Copy link

JPDucky commented Jul 14, 2023

Opera One(version: 100.0.4815.54)
fedora 37: had to change the bottom 3 lines to make it work, opera would not launch with the symlink

sudo mv libffmpeg.so /usr/lib64/opera/libffmpeg_h264.so
sudo mv /usr/lib64/opera/libffmpeg.so /usr/lib64/opera/libffmpeg.so.orig
sudo cp /usr/lib64/libffmpeg_h264.so /usr/lib64/opera/libffmpeg.so

also had to change ownership of libffmpeg.so to root

@iRedds
Copy link

iRedds commented Sep 5, 2023

Система:Ubuntu 22.04.3 LTS (x86_64; ubuntu:GNOME)
Версия Chromium:116.0.5845.141
Thank you

@butter-fly04
Copy link

Will this work with flatpak package?
I'm using Opera's flatpack package form flathub on Fedora.

@mcarletti
Copy link
Author

@butter-fly04 I don't know how Fedora+flatpak+flathub works since I use Ubuntu+apt, however OperaOne was tested under Fedora by @JPDucky. Check it here!

@jameskentTX
Copy link

jameskentTX commented Feb 17, 2024

It is working on Debian 11, Opera One(version: 107.0.5045.21).
I downloaded codec from https://github.com/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt/releases
Thank you. Great advice.

Unfortunately after Opera upgrade support for H.264 disappeared again :(

I created file opera_libffmpeg.sh and run this file after each opera upgrade. It takes several seconds only and I have support for H264 again.
Change folders name.

#!/bin/bash

# download compressed libffmpeg.so from below, copy to /home/adam/software and unzip it
# https://github.com/nwjs-ffmpeg-prebuilt/nwjs-ffmpeg-prebuilt/releases
sudo cp /home/adam/software/0.85.0-linux-x64/libffmpeg.so /usr/lib/x86_64-linux-gnu/opera/libffmpeg_h264.so
sudo mv /usr/lib/x86_64-linux-gnu/opera/libffmpeg.so /usr/lib/x86_64-linux-gnu/opera/libffmpeg.so.orig
sudo cp /usr/lib/x86_64-linux-gnu/opera/libffmpeg_h264.so /usr/lib/x86_64-linux-gnu/opera/libffmpeg.so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment