1

I'm trying to build ffmpeg with NVENC support so I can then build obs-studio with NVENC support, using this as a guide. I've sorted out every dependency after a bit of headache, and am now to the point where I should be able to compile ffmpeg with the edits to its rules file just fine. However, my trusty terminal spits the following out at me:

http://pastebin.com/888pa3kW

Here is my ffmpeg/debian/rules file:

#!/usr/bin/make -f

export V=1

# sets DEBIAN_VERSION variable
include /usr/share/dpkg/pkg-info.mk

# Get the Debian version revision:
DEB_REVISION := $(word 2, $(subst -, ,$(DEB_VERSION)))

# sets DEB_HOST_* variables
include /usr/share/dpkg/architecture.mk

# Ubuntu ld adds -Bsymbolic-functions by default, but that prevents FFmpeg from building.
export DEB_LDFLAGS_MAINT_STRIP=-Wl,-Bsymbolic-functions

# Package name for the extra flavor.
EXTRA_PKGS := $(shell sed -nr 's/^Package:[[:space:]]*(.*extra[0-9]+)[[:space:]]*$$/\1/p' debian/control)
FLAVORS = standard extra static

# Enable as many features as possible, as long as the result is still GPLv2+ (a GPLv3+ variant is built as libavcodec-extra/libavfilter-extra flavor).
# The following flags (and build-dependencies) are not added, because they would require a libavformat-extra flavor:
#   --enable-libsmbclient           (libsmbclient-dev [!hurd-i386 !m68k !sparc64])
# The following flags are not added, because the necessary libraries are not in Debian:
#   --enable-decklink
#   --enable-libcelt                (see #676592: removed from Debian as abandoned upstream, replaced by opus)
#   --enable-libdcadec
#   --enable-libilbc                (see #675959 for the RFP bug)
#   --enable-libkvazaar
#   --enable-libmfx
#   --enable-libnut
#   --enable-libopenh264
#   --enable-libopenmpt
#   --enable-libschroedinger        (see #845037: removal due to security issues)
#   --enable-libutvideo
#   --enable-libvidstab             (see #709193 for the RFP bug)
#   --enable-libxavs
#   --enable-libzimg
# The following flags are not added for various reasons:
#   * --enable-librtmp:             ffmpeg has better built-in RTMP support with listen mode.
#   * --enable-libv4l2 [!hurd-any]: This is only needed for very old devices and may cause problems for others.
#                                   Should anyone need it, using LD_PRELOAD pointing on libv4l2 has the same effect.
#   * --enable-opencl [!hurd-any]:  This is considered an experimental API.
CONFIG := --prefix=/usr \
    --extra-version="$(DEB_REVISION)" \
    --toolchain=hardened \
    --libdir=/usr/lib/$(DEB_HOST_MULTIARCH) \
    --incdir=/usr/include/$(DEB_HOST_MULTIARCH) \
    --enable-gpl \
    --disable-stripping \
    --enable-avresample \
    --enable-avisynth \
    --enable-gnutls \
    --enable-ladspa \
    --enable-libass \
    --enable-libbluray \
    --enable-libbs2b \
    --enable-libcaca \
    --enable-libcdio \
    --enable-libebur128 \
    --enable-libflite \
    --enable-libfontconfig \
    --enable-libfreetype \
    --enable-libfribidi \
    --enable-libgme \
    --enable-libgsm \
    --enable-libmodplug \
    --enable-libmp3lame \
    --enable-libopenjpeg \
    --enable-libopus \
    --enable-libpulse \
    --enable-librubberband \
    --enable-libshine \
    --enable-libsnappy \
    --enable-libsoxr \
    --enable-libspeex \
    --enable-libssh \
    --enable-libtheora \
    --enable-libtwolame \
    --enable-libvorbis \
    --enable-libvpx \
    --enable-libwavpack \
    --enable-libwebp \
    --enable-libx265 \
    --enable-libxvid \
    --enable-libzmq \
    --enable-libzvbi \
    --enable-omx \
    --enable-openal \
    --enable-opengl \
    --enable-sdl2 \
    --enable-nonfree \
    --enable-nvenc

# The standard configuration only uses the shared CONFIG.
CONFIG_standard = --enable-shared

# With these enabled, resulting binaries are effectively licensed as GPLv3+.
CONFIG_extra = --enable-shared \
    --enable-version3 \
    --disable-doc \
    --disable-programs \
    --enable-libopencore_amrnb \
    --enable-libopencore_amrwb \
    --enable-libtesseract \
    --enable-libvo_amrwbenc

# The static libraries should not be built with PIC.
CONFIG_static = --disable-pic \
    --disable-doc \
    --disable-programs

# Disable optimizations if requested.
ifneq (,$(filter $(DEB_BUILD_OPTIONS),noopt))
CONFIG += --disable-optimizations
endif

# Respect CC/CXX from the environment, if they differ from the default.
# Don't set them if they equal the default, because that disables autodetection needed for cross-building.
ifneq ($(CC),cc)
    CONFIG += --cc=$(CC)
endif
ifneq ($(CXX),g++)
    CONFIG += --cxx=$(CXX)
endif

# Some libraries are built only on linux.
ifeq ($(DEB_HOST_ARCH_OS),linux)
    CONFIG += --enable-libdc1394 \
    --enable-libiec61883
endif

# Some build-dependencies are not installable on some architectures.
ifeq (,$(filter $(DEB_HOST_ARCH),powerpcspe))
    CONFIG_extra += --enable-netcdf
endif

# ffmpeg is involed in build-dependency cycles with opencv, x264 and chromaprint, so disable them in stage one.
# Also disable frei0r, which build-depends on opencv.
ifneq ($(filter stage1,$(DEB_BUILD_PROFILES)),)
    CONFIG += --disable-frei0r \
    --disable-chromaprint \
    --disable-libopencv \
    --disable-libx264
else
    CONFIG += --enable-libopencv \
    --enable-frei0r
ifeq (,$(filter $(DEB_HOST_ARCH),powerpcspe))
    CONFIG += --enable-libx264
endif
ifeq (,$(filter $(DEB_HOST_ARCH),sh4))
    CONFIG += --enable-chromaprint
endif
endif

# Disable altivec optimizations on powerpc, because they are not always available on this architecture.
ifeq ($(DEB_HOST_ARCH),powerpc)
    CONFIG += --disable-altivec
    # Build an altivec flavor of the libraries on powerpc.
    # This works around the problem that runtime cpu detection on powerpc currently does not work,
    # because, if altivec is enabled, all files are build with '-maltivec' so that the compiler inserts altivec instructions, wherever it likes.
    CONFIG_altivec = --enable-shared \
    --enable-altivec \
    --disable-doc \
    --disable-programs
    CONFIG_altivec-extra = $(CONFIG_altivec) $(CONFIG_extra)
    FLAVORS += altivec altivec-extra
endif

# Disable assembly optimizations on x32, because they don't work (yet).
ifneq (,$(filter $(DEB_HOST_ARCH),x32))
    CONFIG += --disable-asm
endif

# Disable optimizations on mips(el) and some on mips64(el), because they are not always available on these architectures.
ifneq (,$(filter $(DEB_HOST_ARCH),mips mipsel mips64 mips64el))
    CONFIG += --disable-mipsdsp \
    --disable-mipsdspr2 \
    --disable-loongson3 \
    --disable-mips32r6 \
    --disable-mips64r6
endif
ifneq (,$(filter $(DEB_HOST_ARCH),mips mipsel))
    CONFIG += --disable-mipsfpu
endif

# Set cross-build prefix for compiler, pkg-config...
# Cross-building also requires to manually set architecture/OS.
ifneq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
    CONFIG += --cross-prefix=$(DEB_HOST_GNU_TYPE)- \
    --arch=$(DEB_HOST_ARCH) \
    --target-os=$(DEB_HOST_ARCH_OS)
endif

# Use the default debhelper scripts, where possible.
%:
dh $@

# Add configuration options:
override_dh_auto_configure:
    $(foreach flavor,$(FLAVORS),mkdir -p debian/$(flavor);)
    $(foreach flavor,$(FLAVORS),set -e; echo " *** $(flavor) ***"; cd debian/$(flavor); ../../configure $(CONFIG) $(CONFIG_$(flavor)) || (cat config.log && exit 1); cd ../.. ;)
    touch override_dh_auto_configure

# Remove the subdirectories generated for the flavors.
override_dh_auto_clean:
    $(foreach flavor,$(FLAVORS),[ ! -d debian/$(flavor) ] || rm -r debian/$(flavor);)

# Create doxygen documentation:
override_dh_auto_build-indep:
    dh_auto_build -i --sourcedirectory=debian/standard -- apidoc
    # Create the minified CSS files.
    lessc debian/missing-sources/ffmpeg-web/src/less/style.less | cleancss > debian/standard/doc/style.min.css
    rm override_dh_auto_configure

override_dh_auto_build-arch:
    # Copy built object files to avoid building them again for the extra flavor.
    # Build qt-faststart here, to make it possible to build with 'nocheck'.
    set -e && for flavor in $(FLAVORS); do \
        echo " *** $$flavor ***"; \
        if echo "$$flavor" | grep -q "extra"; then \
            subdir=`[ "$$flavor" = "extra" ] && echo "debian/standard/" || echo "debian/altivec/"`; \
        for dir in `cd ./$$subdir; find libavcodec libavdevice libavfilter libavformat libavresample libavutil libpostproc libswscale libswresample -type d`; do \
            mkdir -p debian/"$$flavor"/"$$dir"; \
            echo "$$subdir$$dir"/*.o | grep -q '*' || cp "$$subdir$$dir"/*.o debian/"$$flavor"/"$$dir"; \
        done; \
        rm debian/"$$flavor"/libavcodec/allcodecs.o; \
        rm debian/"$$flavor"/libavfilter/allfilters.o; \
    fi; \
    if [ "$$flavor" = "standard" ]; then \
        $(MAKE) -C debian/standard tools/qt-faststart; \
    fi; \
    dh_auto_build -a --sourcedirectory=debian/"$$flavor" || (cat debian/"$$flavor"/config.log && exit 1); \
done

# Set the library path for the dynamic linker, because the tests otherwise don't find the libraries.
override_dh_auto_test-arch:
    export LD_LIBRARY_PATH="libavcodec:libavdevice:libavfilter:libavformat:libavresample:libavutil:libpostproc:libswresample:libswscale"; \
        dh_auto_test -a --sourcedirectory=debian/standard -- -k

# No tests for indep build.
override_dh_auto_test-indep:

override_dh_auto_install-arch:
    dh_auto_install -a --sourcedirectory=debian/standard
ifeq ($(DEB_HOST_ARCH),powerpc)
    install -d debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/altivec
    install -m 644 debian/altivec/*/*.so.* debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)/altivec
endif
    dh_auto_install -a --sourcedirectory=debian/extra --destdir=debian/tmp/extra
ifeq ($(DEB_HOST_ARCH),powerpc)
    install -d debian/tmp/extra/usr/lib/$(DEB_HOST_MULTIARCH)/altivec
    install -m 644 debian/altivec-extra/*/*.so.* debian/tmp/extra/usr/lib/$(DEB_HOST_MULTIARCH)/altivec
endif
    # Use the static libraries from the --disable-pic build
    install -m 644 debian/static/*/lib*.a debian/tmp/usr/lib/$(DEB_HOST_MULTIARCH)

override_dh_auto_install-indep:
    dh_auto_install -i --sourcedirectory=debian/standard

override_dh_install:
    dh_install $(addprefix -p,$(EXTRA_PKGS)) --sourcedir=debian/tmp/extra
    dh_install --remaining-packages

override_dh_makeshlibs:
    set -e && for pkg in $(shell dh_listpackages -a) ; do \
        case $$pkg in \
            ffmpeg|*-dev) \
                continue \
                ;; \
            *avcodec*) \
                soversion=$$(echo $$pkg | sed -nr 's/^[^0-9]*([0-9]+)$$/\1/p'); \
                dh_makeshlibs -p $$pkg -V"libavcodec$$soversion (>= ${DEB_VERSION_EPOCH_UPSTREAM}) | libavcodec-extra$$soversion (>= ${DEB_VERSION_EPOCH_UPSTREAM})" \
                ;; \
            *avfilter*) \
                soversion=$$(echo $$pkg | sed -nr 's/^[^0-9]*([0-9]+)$$/\1/p'); \
                dh_makeshlibs -p $$pkg -V"libavfilter$$soversion (>= ${DEB_VERSION_EPOCH_UPSTREAM}) | libavfilter-extra$$soversion (>= ${DEB_VERSION_EPOCH_UPSTREAM})" \
                ;; \
            *) \
                dh_makeshlibs -p $$pkg -V \
                ;; \
        esac \
    done

# Don't compress the example source code files.
override_dh_compress:
    dh_compress -Xexamples

I am running Linux Lite 3.2 64bit, which is based on Ubuntu 16.04. I'm essentially completely new to this, so I'll need some hand holding.

14
  • One thing I could notice, a missing back slash \ after --enable-sdl2 . Could you fix it and try again? Seem we have a time shift between us :) .
    – user.dz
    Dec 22 '16 at 9:29
  • It got farther, but ended with the same error. Shall I add the output to the op?
    – Devon C
    Dec 22 '16 at 18:06
  • Also how can I make a code block without adding four spaces behind each line? It's quite extraneous.
    – Devon C
    Dec 22 '16 at 18:06
  • ERROR: opengl not found. you are missing libgl1-mesa-dev , for code you may use <code></code> tag if you would like.
    – user.dz
    Dec 22 '16 at 18:51
  • For easy build dependencies tracking, you may use sudo apt build-dep ffmpeg to install most of if not all of them.
    – user.dz
    Dec 22 '16 at 18:55
1

I could build it without any issue in an LXC Ubuntu 16.04 container.

  1. vi /etc/apt/sources.list added source & backports repositories:

    deb http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse
    deb http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse
    deb http://security.ubuntu.com/ubuntu xenial-security main restricted universe multiverse
    deb http://security.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu xenial main restricted universe multiverse
    deb-src http://archive.ubuntu.com/ubuntu xenial-updates main restricted universe multiverse
    deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted universe multiverse
    deb-src http://security.ubuntu.com/ubuntu xenial-backports main restricted universe multiverse
    
  2. Install dependencies and build tools including debhelper & dh-autoreconf from backports repo, use apt-cache policy ... to check their current version.

    apt update
    apt build-dep ffmpeg
    apt install git openssl ca-certificates devscripts dh-autoreconf=12~ubuntu16.04.1 debhelper=10.2.2ubuntu1~ubuntu16.04.1 libchromaprint-dev libebur128-dev libleptonica-dev libnetcdf-dev libomxil-bellagio-dev libopenjp2-7-dev librubberband-dev libsdl2-dev libtesseract-dev nasm
    
  3. Download source

    git clone https://anonscm.debian.org/git/pkg-multimedia/ffmpeg.git
    
  4. Modify rules file to add --enable-nonfree and --enable-nvenc

    cd ffmpeg/
    echo 'libva 1 libva1' > debian/shlibs.local
    

    vi debian/rules:

    CONFIG :=...
        --enable-sdl2 \
        --enable-nonfree \
        --enable-nvenc
    
  5. Build it

    debuild -us -uc -b
    

Here is the list for result debian packages.

Reply to OP, for new error messages

  • lintian is a QC tool for Debian packages, It just verify the result packages, but not effect on building process.

    Now running lintian...
    E: ffmpeg changes: bad-distribution-in-changes-file unstable
    W: libavdevice57: virtual-package-depends-without-real-package-depends depends: libgl1
    N: 9 tags overridden (8 warnings, 1 info)
    Finished running lintian.
    

    However, if you want to correct that error message. That error raised because we copy source prepared for the unstable Debian release. Where is our case it should be xenial Ubuntu release. Run inside ffmpeg/ folder:

    dch
    

    To add new entry to debian/changelog and set it to xenial example:

    ffmpeg (7:3.2.2-1ubuntu1) xenial; urgency=medium
    
      * backport to xenial
    
     -- root <root@ci2>  Wed, 28 Dec 2016 11:24:08 +0000
    
  • libavfilter-extra* is alternative to libavfilter* and they can't be installed together in same system. You have to choose depending your need (If you don't know, install extra)

    dpkg: regarding libavfilter-extra6_3.2.2-1_amd64.deb containing libavfilter-extra6:amd64:
     libavfilter-extra6 conflicts with libavfilter6
    
  • Other missing dependencies that are available in repo, like:

     ffmpeg-doc depends on libjs-bootstrap; however:
      Package libjs-bootstrap is not installed.
    

    could be downloaded using:

    sudo apt -f install
    
9
  • All right, I'll try again on the 26th. Away for festivities and such currently. I reinstalled Linux Lite the other day, so maybe we will see different results.
    – Devon C
    Dec 24 '16 at 0:12
  • Sorry hit enter too soon. You did not add a " \" after nonfree and nvenc?
    – Devon C
    Dec 24 '16 at 0:14
  • @DevonC, you can delete comments. Sure i had to add \ for to continue same command on next line. Update my answer the show it clearly. If you can't reproduce same issue then we can close this question for this reason.
    – user.dz
    Dec 24 '16 at 10:00
  • Took longer to get back than I thought; sorry. It is building even as I type. Will get back to you when it finishes & I compile obs.
    – Devon C
    Dec 28 '16 at 10:38
  • 1
    It all compiled, but I ran into some errors, and also some errors in installing the debs: pastebin.com/AQSqzCaG
    – Devon C
    Dec 28 '16 at 11:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.