Safest way to install latest stable ffmpeg (>= 4.3) on Ubuntu 20.04 (ppa not working)?

6,309

Solution 1

There are other PPAs with newer ffmpeg. The most recent is FFmpeg 4 - media tool (Xenial & newer) from Rob Savoury. To add this PPA to your system use commands below:

sudo add-apt-repository ppa:savoury1/ffmpeg4
sudo apt-get update
sudo apt-get install ffmpeg

As the result you will get the version with --enable-libzimg compile flag and ffmkv will not complain about "HDR to SDR conversion or resolution changes".

Note: you can search PPAs by yourself using special local application named Y PPA Manager, .

Solution 2

Simple solution

  1. Download an already compiled ffmpeg from johnvansickle.com. zscale support is included.
  2. Place the downloaded ffmpeg into your PATH by moving the downloaded ffmpeg into /usr/local/bin or ~/bin (re-login or run source ~/.profile if you move it into ~/bin).

This will not interfere with any system files or other packages. To uninstall simply delete the ffmpeg file.

I'm not a big fan of PPAs. They can be messy, are often overkill, and can cause problems by interfering with the package management system.

Solution 3

Perhaps the best way to get a copy of FFmpeg and the zscale filter is to use, but slightly modify, the excellent FFmpeg trac compilation guide. This guide will not interfere with system libraries.

This can be accomplished in only two easy steps:

1. Install zimg:

When installing the long list of dependencies in the guide add the following to also install zimage:

   mkdir -p ~/ffmpeg_sources && \
   cd ~/ffmpeg_sources && \
   wget https://github.com/sekrit-twc/zimg/archive/refs/tags/release-3.0.2.tar.gz && \
   tar xvf release-3.0.2.tar.gz && \
   cd zimg-release-3.0.2 && \
   ./autogen.sh && \
   ./configure --prefix="$HOME/ffmpeg_build" --disable-shared && \
   make && \
   make install

This installs a local copy of zimg that FFmpeg will pick up when it is compiled.

2. Compile FFmpeg:

Follow the full FFmpeg trac guide and when you reach the section where FFmpeg is compiled simply add the following to the ./configure string:

   --enable-libzimg

And this will be enough to enable the zscale filter.

3. Testing, testing...

FFmpeg itself can be tested for presence of the zscale filter:

andrew@ithaca:~$ ffmpeg -filters 2> /dev/null |grep zscale
 ..C zscale            V->V       Apply resizing, colorspace and bit depth conversion.
andrew@ithaca:~$ 

I tested ffmkv itself with a big upscale in size:

andrew@ithaca:~$ ffmkv --preset 'Up to 4K, original audio, 4GB per hour VBR, HDR' input.mkv output.mkv
Audio is Stream Copy VBR, filesize will be greater than estimated.
Processing pass 1 of VBR video, remaining time is remaining time for pass 1 only.
Process will sit on 100% while ffmpeg closes out functions.
ffmpeg conversion of input.mkv started on 08/30/21 7:53:05 PM
input.mkv has 1248 frames, now converting
ffmpeg: 1253 of 1248 frames at 24 fps, progress: 100% and ETA: 0h 0m 0s     
ffmpeg stopped on 08/30/21 7:54:06 PM

Processing pass 2 of VBR video, remaining time is total remaining time.
Process will sit on 100% while ffmpeg closes out functions.
ffmpeg conversion of input.mkv started on 08/30/21 7:54:06 PM
input.mkv has 1248 frames, now converting
ffmpeg: 1253 of 1248 frames at 23 fps, progress: 100% and ETA: 0h 0m 0s     
ffmpeg stopped on 08/30/21 7:55:06 PM
andrew@ithaca:~$ 

And all is well :)

Solution 4

There is a snap package for ffmpeg. The current version in the "stable" channel is 4.3.1 but does not list --enable-zimg in its build configuration as printed with -version, so it might not work. However, the "edge" channel of that snap package contains a version based on ffmpeg 4.4 with --enable-zimg. So installing would be as easy as

snap install ffmpeg --channel edge
Share:
6,309

Related videos on Youtube

user2671688
Author by

user2671688

Updated on September 18, 2022

Comments

  • user2671688
    user2671688 almost 2 years

    I'm trying to use ffmkv, which requires a version of ffmpeg that supports zscale.

    Their README says this is the default under 18.04, but my version under 20.04 is 4.2.4-1ubuntu0.1, which doesn't seem to include zscale support.

    If I run apt-get install ffmpeg, it says ffmpeg is already the newest version (7:4.2.4-1ubuntu0.1). but it's clear from ffmpeg.org that the current stable release is 4.3.2-0.

    I tried adding ppa:jonathonf/ffmpeg-4 to pick up the latest, but that fails to update ("doesn't have a Release file").

    What's the safest way to update it? Ideally, there's a PPA that will work, that my googling hasn't surfaced. Or, should I be downloading that ffmpeg_4.3.2-0+deb11u2ubuntu1_amd64.deb file and installing it with dpkg?

    I'm always paranoid about side-channel installing anything, especially when it involves anything to do with Video. What's the best "won't break future system APT updates" way to install the current stable ffmpeg?

    • marcelm
      marcelm almost 3 years
      "Their README says this is the default under 18.04, but ..." - Actually, that readme says zscale support is not supported in 18.04 by default (which makes sense, as zscale support is a new feature of ffmpeg 4.3.1).
    • user2671688
      user2671688 almost 3 years
      @marcelm oh WOW, that's so nebulously-worded! That can just as easily be interpreted the other way. :)
    • Gyan
      Gyan almost 3 years
      That only applies to that ppa. FFmpeg added zscale in 3.0
  • user2671688
    user2671688 almost 3 years
    Thanks, this seems to work great!
  • user2671688
    user2671688 almost 3 years
    uh-oh - after upgrading ffmpeg, I am just noticing that it broke KDEnlive - now it can't render to mp4 ("Unsupported video codec: libx264"). Do I need to install any other libraries?
  • N0rbert
    N0rbert almost 3 years
    It depends on how KDEnlive was installed.
  • user2671688
    user2671688 almost 3 years
    It's figured out; it looks like MLT needed to be updated. I just added the kdenlive PPA and upgraded its version, and now it all seems to work
  • stratis
    stratis over 2 years
    It's not easily maintenable but it's certainly a quick & nice fix. Thanks!
  • Avatar
    Avatar over 2 years
    I have downloaded the ffmpeg-release-amd64-static.tar.xz, extracted the build into a new folder ffmpeg and uploaded the folder to /usr/local/bin/ffmpeg. Now when trying to start ffmpeg with /usr/local/bin/ffmpeg/ffmpeg I get Permission denied. If I try sudo /usr/local/bin/ffmpeg/ffmpeg I get command not found. How to run ffmpeg?
  • Avatar
    Avatar over 2 years
    Got it running 👍 Just needed to change the permission of the executable file ffmpeg to 744.
  • Avatar
    Avatar over 2 years
    If you use ffmpeg with PHP and shell_exec(ffmpeg ...) then you need to use file permissions 777.
  • ohnoplus
    ohnoplus over 2 years
    This version seems to corrupt all of the output files for me. For instance ffmpeg -ss 03:57 -to 07:26 -i TestSeminarFull.mp4 -codec copy TestFirstBit.mp4 creates an output file that doesn't play in vlc or otherwise.
  • Bax
    Bax about 2 years
    Of course this is not a flexible and true way of installing packages but for now it solved my problem! I've spent a couple of hours, trying to install in in Docker, and it was like the further I go, the harder it becomes. Thank you!