Building ffmpeg locally

For help and support with Universal Media Server
Forum rules
Please make sure you follow the Problem Reporting Guidelines before posting if you want a reply
Post Reply
michaelt
Posts: 155
Joined: Tue Feb 03, 2015 11:18 am
Location: lost in the depths of my mind

Building ffmpeg locally

Post by michaelt »

I am starting this thread to track the process of building ffmpeg locally so as to avoid issues with errors due to the external build configurations and support. The goal is to build just what UMS needs and make it error free.

This is a continuation of the work done in viewtopic.php?f=11&t=3350 which is now complete and closed. The first reply here will be a repeat of the build information posted there.
MacPro5,1 - 2.8 GHz, 32 GB, 20TB, OS X 10.11.6,
. . . . and a few others.
Samsung UN55C8000
Home Theater (WIP): OS X based now, dedicated Linux later.
michaelt
Posts: 155
Joined: Tue Feb 03, 2015 11:18 am
Location: lost in the depths of my mind

Re: Building ffmpeg locally

Post by michaelt »

How to build:
This is a combination of notes and shell (ksh) commands. Cut & paste - do not directly execute this:

Code: Select all

#!/bin/ksh
#
# HowTo: build ffmpeg on OSX (Lion 10.7.5) Java 8, NetBeans 8.0.2
#   These scripts use korn shell, not bash!
#   Derived from: CompilationGuide/MacOSX – FFmpeg - https://trac.ffmpeg.org/wiki/CompilationGuide/MacOSX
#
#   NOTE: if you are familiar with brew - plese help me clean this up.
#
################################################################################
#
# Homebrew (aka: brew):
#
# 1 - This MUST be run by an admin account
# 2 - System software & tools MUST be up to date. Use 'brew doctor' below to check
#
# PATH is critical:
#   All of these components must be in it and MUST be in this order.
#   Others may be inserted anywhere. "~/bin" is optional if you override any standard commands.
#
PATH=~/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/X11/bin:/usr/local/git/bin
#
# Prerequisites:
#   Create a save path for each version in case the environment self destructs:
    mkdir -p /usr/local/ffmpeg_saved/
#   Editor: (I use Aquamacs, a Mac emacs)
#   Xcode 4.6.3 (Mountian Lion, Lion) version will vary by OS:
#     https://developer.apple.com/downloads  # search: "xcode 4.6.3"
#   homebrew
      ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
#       Fix a well known error:
      cd /usr/local
      git reset --hard FETCH_HEAD
#       ?? cleanup the library;
      cd ./Library
      git clean -fd
#
#
################################################################################
# check for updates first:
    brew doctor
#     A lot of warnings, look for "bad" stuff or continue & fix what breaks
#     Note: Xcode may report as 4.6 - ignore the warning
#
# unset DYLD_LIBRARY_PATH ??
#
################################################################################
#
# Install ffmpeg & all the dependencies
#
    brew install ffmpeg
    #--brew uninstall ffmpeg   # may not get all the libraries, so uninstall & do again
    brew link --overwrite pkg-config    # ???? forgot why required
    # 1 - Warning due to OSX "port" detection: (ignore for now)
    #       Warning: It appears you have MacPorts or Fink installed.
    #        Software installed with other package managers causes known problems for
    #        Homebrew. If a formula fails to build, uninstall MacPorts/Fink and try again.
    #     ./Library/Logs/Homebrew/libvorbis/config.log : missing ac_nonexistent.h
    #  2 - brew rm -f `brew list` # will force a new download 
#
####  Now build & fix until no errors:
#
    brew install ffmpeg --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis  --with-opus --with-x265
# output is in: /usr/local/Cellar/ffmpeg/2.6.2/bin/ffmpeg  # but will not work with UMS, don't try.
#
###################################
#
# Now the modifications:
#
# *** Mandatory change: ffmpeg.rb:74  --enable-shared => --enable-static
    ( cd /usr/local/Library/Formula \
        && sed -e 's/--enable-shared/--enable-static/' < ffmpeg.rb > xx.$$ \
          && mv -f xx.$$ ffmpeg.rb )
#
# libvps will not build. Add "--with-libvpx" later when we figure out how to fix it!!
# avisynth, gpl are problematic, add "--with-avisynth --with-gpl" when fixed
#
# --enable-static does not work on brew command (yet??), it ignores it or I don't know how:
# ?? what other libs need to be added ??
###################################
#   x1 "Standard Build" from: https://trac.ffmpeg.org/wiki/CompilationGuide/MacOSX
#
    brew install ffmpeg --enable-static --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis ---with-opus -with-x265
###################################
# output: /usr/local/Cellar/ffmpeg/2.6.2/bin/ffmpeg
###################################
#
###################################
    brew reinstall ...  # for every build thereafter
###################################
#   x3* "Standard Build" + all From: https://evermeet.cx/ffmpeg/    <<<< STABLE NO ERRORS >>>>
#       without:  --with-libvpx --with-avisynth --with-gpl
#
    brew install ffmpeg  --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis --with-opus --with-x265 --with-fontconfig --with-libass --with-libbluray --with-libfreetype --with-libgsm --with-libmodplug --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopus --with-libschroedinger --with-libsoxr --with-libspeex --with-libtheora --with-libvidstab --with-libvo-aacenc --with-libvo-amrwbenc --with-libvorbis --with-libwavpack --with-libx264 --with-libx265 --with-libxavs --with-libxvid --with-libzmq --with-version3 --without-ffplay --without-indev=qtkit --without-indev=x11grab_xcb
    brew reinstall ...  # for every build thereafter
# Save:
    cp -f /usr/local/Cellar/ffmpeg/2.6.2/bin/ffmpeg /usr/local/ffmpeg_saved/ffmpeg-x3a
###################################
#   x? "Standard Build" + 
#
# Save:
#    cp -f /usr/local/Cellar/ffmpeg/2.6.2/bin/ffmpeg /usr/local/ffmpeg_saved/ffmpeg-x?
###################################
#
# copy to the UMS build area and make it writable (why??) or NetBeans fails.
# NOTE: Copy it from a user account (NOT admin) into your NB project:
#
# Save off each version in case the environment self destructs:
#    cp -f /usr/local/Cellar/ffmpeg/2.6.2/bin/ffmpeg /usr/local/ffmpeg_saved/ffmpeg-*
#
# Copy last stable version to UMS samdbox:
    # UMS project path <<<< Set this to your path >>>>
    PRPATH="/Users/umsmkv/UMS_J8/ums_osx-512J8x2/" 
    # UMS project ffmpeg file <<<< Set "-x3a" your saved file suffix >>>>
    cp -f /usr/local/ffmpeg_saved/ffmpeg-x3a  $PRPATH/target/bin/osx/ffmpeg
    chmod u+w $PRPATH/target/bin/osx/ffmpeg
Current Stable Build:
Working with the long option list from https://evermeet.cx/ffmpeg/ , had to convert to "with"…
It built but without three options: --with-libvpx --with-avisynth --with-gpl
Build size: 15.8 MB.
build command:

Code: Select all

 brew install ffmpeg  --with-fdk-aac --with-ffplay --with-freetype --with-libass --with-libquvi --with-libvorbis --with-opus --with-x265 --with-fontconfig --with-libass --with-libbluray --with-libfreetype --with-libgsm --with-libmodplug --with-libmp3lame --with-libopencore-amrnb --with-libopencore-amrwb --with-libopus --with-libschroedinger --with-libsoxr --with-libspeex --with-libtheora --with-libvidstab --with-libvo-aacenc --with-libvo-amrwbenc --with-libvorbis --with-libwavpack --with-libx264 --with-libx265 --with-libxavs --with-libxvid --with-libzmq --with-version3 --without-ffplay --without-indev=qtkit --without-indev=x11grab_xcb
A snippet from debug.log:

Code: Select all

DEBUG 00:32:13.607 [ffmpeg-1] Starting /Users/umsmkv/UMS_J8/ums_OSX-Java8_x2/target/ums-5.1.2_x2-distribution/UMS-x4.app/Contents/Resources/osx/ffmpeg -y -f lavfi -i nullsrc=s=720x480:d=1:r=1 -vf ass=DummyInput.ass -target ntsc-dvd -
TRACE 00:32:13.608 [ffmpeg-1] Setting FONTCONFIG_PATH to "/Users/umsmkv/UMS_J8/ums_OSX-Java8_x2/target/ums-5.1.2_x2-distribution/UMS-x4.app/Contents/Resources/fonts"
TRACE 00:32:13.608 [mplayer-0] Setting FONTCONFIG_PATH to "/Users/umsmkv/UMS_J8/ums_OSX-Java8_x2/target/ums-5.1.2_x2-distribution/UMS-x4.app/Contents/Resources/fonts"
INFO  00:32:13.617 [main] Searching for plugins in /Users/umsmkv/UMS_J8/ums_OSX-Java8_x2/target/ums-5.1.2_x2-distribution/UMS-x4.app/Contents/Resources/plugins
INFO  00:32:13.619 [main] No plugins found
TRACE 00:32:13.708 [ffmpeg-1] Successfully initialized buffer to 52,428,800 bytes.
TRACE 00:32:13.721 [mplayer-0] Successfully initialized buffer to 52,428,800 bytes.
DEBUG 00:32:13.722 [ffmpeg-1] Attaching thread: ffmpeg-1
DEBUG 00:32:13.722 [mplayer-0] Attaching thread: mplayer-0
DEBUG 00:32:13.723 [mplayer-0] Unix process ID (/Users/umsmkv/UMS_J8/ums_OSX-Java8_x2/target/ums-5.1.2_x2-distribution/UMS-x4.app/Contents/Resources/osx/mplayer): 82870
DEBUG 00:32:13.723 [ffmpeg-1] Unix process ID (/Users/umsmkv/UMS_J8/ums_OSX-Java8_x2/target/ums-5.1.2_x2-distribution/UMS-x4.app/Contents/Resources/osx/ffmpeg): 82869
INFO  00:32:13.735 [main] Registering transcoding engine: FFmpeg Audio
DEBUG 00:32:13.743 [mplayer-0-2] Can't init Apple Remote.
INFO  00:32:13.745 [main] Registering transcoding engine: MEncoder
INFO  00:32:13.745 [main] Registering transcoding engine: FFmpeg
INFO  00:32:13.747 [main] Registering transcoding engine: VLC
DEBUG 00:32:13.750 [main] Error reading ffmpeg web filters: File '/Users/umsmkv/Library/Application Support/UMS/ffmpeg.webfilters' does not exist
DEBUG 00:32:13.896 [ffmpeg-1-2] ffmpeg version 2.6.2 Copyright (c) 2000-2015 the FFmpeg developers
DEBUG 00:32:13.896 [ffmpeg-1-2]   built with Apple LLVM version 4.2 (clang-425.0.28) (based on LLVM 3.2svn)
DEBUG 00:32:13.897 [ffmpeg-1-2]   configuration: --prefix=/usr/local/Cellar/ffmpeg/2.6.2 --enable-static --enable-pthreads --enable-gpl --enable-version3 --enable-hardcoded-tables --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-libmp3lame --enable-libvo-aacenc --enable-libx264 --enable-libxvid --enable-libfdk-aac --enable-ffplay --enable-libfontconfig --enable-libfreetype --enable-libass --enable-libquvi --enable-libsoxr --enable-libvidstab --enable-libvorbis --enable-libopus --enable-libx265 --disable-indev=x11grab_xcb --enable-nonfree --enable-vda
DEBUG 00:32:13.897 [ffmpeg-1-2]   libavutil      54. 20.100 / 54. 20.100
DEBUG 00:32:13.897 [ffmpeg-1-2]   libavcodec     56. 26.100 / 56. 26.100
DEBUG 00:32:13.897 [ffmpeg-1-2]   libavformat    56. 25.101 / 56. 25.101
DEBUG 00:32:13.897 [ffmpeg-1-2]   libavdevice    56.  4.100 / 56.  4.100
DEBUG 00:32:13.897 [ffmpeg-1-2]   libavfilter     5. 11.102 /  5. 11.102
DEBUG 00:32:13.897 [ffmpeg-1-2]   libavresample   2.  1.  0 /  2.  1.  0
DEBUG 00:32:13.897 [ffmpeg-1-2]   libswscale      3.  1.101 /  3.  1.101
DEBUG 00:32:13.897 [ffmpeg-1-2]   libswresample   1.  1.100 /  1.  1.100
DEBUG 00:32:13.897 [ffmpeg-1-2]   libpostproc    53.  3.100 / 53.  3.100
DEBUG 00:32:13.898 [main] FFmpeg supported protocols: [cache, concat, crypto, data, ffrtmphttp, file, ftp, gopher, hls, http, httpproxy, mmsh, mmst, pipe, rtmp, rtmpt, rtp, srtp, subfile, tcp, udp, udplite, unix, mms]
INFO  00:32:13.898 [main] Registering transcoding engine: FFmpeg Web Video
DEBUG 00:32:13.899 [ffmpeg-1-2] Input #0, lavfi, from 'nullsrc=s=720x480:d=1:r=1':
DEBUG 00:32:13.899 [ffmpeg-1-2]   Duration: N/A, start: 0.000000, bitrate: N/A
DEBUG 00:32:13.899 [ffmpeg-1-2]     Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 720x480 [SAR 1:1 DAR 3:2], 1 tbr, 1 tbn, 1 tbc
INFO  00:32:13.899 [main] Registering transcoding engine: MEncoder Web
INFO  00:32:13.899 [main] Registering transcoding engine: VLC Web Video
INFO  00:32:13.902 [main] Registering transcoding engine: tsMuxeR
INFO  00:32:13.902 [main] Registering transcoding engine: Audio High Fidelity
INFO  00:32:13.903 [main] Registering transcoding engine: VLC Web Audio (Legacy)
INFO  00:32:13.903 [main] Registering transcoding engine: VLC Web Video (Legacy)
INFO  00:32:13.904 [main] Registering transcoding engine: dcraw Thumbnailer
INFO  00:32:13.959 [main] Using address /10.0.1.50 found on network interface: name:en0 (en0)
INFO  00:32:13.960 [main] Created socket: /10.0.1.50:5001
DEBUG 00:32:13.988 [mplayer-0-2] File not found: 'dummy'
DEBUG 00:32:13.988 [mplayer-0-2] Failed to open dummy.
TRACE 00:32:13.990 [mplayer-0] EOF
TRACE 00:32:13.991 [mplayer-0] Ready to Stop: true
ERROR 00:32:14.023 [main] Another program is using port 5001, which UMS needs.
ERROR 00:32:14.023 [main] You can change the port UMS uses on the General Configuration tab.
TRACE 00:32:14.024 [main] The error was: org.jboss.netty.channel.ChannelException: Failed to bind to: /10.0.1.50:5001
DEBUG 00:32:14.068 [main] Sending ALIVE...
DEBUG 00:32:14.069 [ffmpeg-1-2] [Parsed_ass_0 @ 0x7fad18417ec0] Added subtitle file: 'DummyInput.ass' (6 styles, 1 events)
TRACE 00:32:14.069 [main] Sending message from multicast socket on network interface: name:0.0.0.0
TRACE 00:32:14.069 [main] Multicast socket is on interface: /0.0.0.0
TRACE 00:32:14.069 [main] Socket Timeout: 0
TRACE 00:32:14.070 [main] Socket TTL: 32
DEBUG 00:32:14.071 [main] Reading uuid: "3d7edd4a-31e0-4758-9169-eb3f39a36933" (default: null)
INFO  00:32:14.071 [main] Using the following UUID configured in UMS.conf: 3d7edd4a-31e0-4758-9169-eb3f39a36933
DEBUG 00:32:14.072 [ffmpeg-1-2] Output #0, dvd, to 'pipe:':
DEBUG 00:32:14.072 [ffmpeg-1-2]   Metadata:
DEBUG 00:32:14.072 [ffmpeg-1-2]     encoder         : Lavf56.25.101
DEBUG 00:32:14.072 [ffmpeg-1-2]     Stream #0:0: Video: mpeg2video, yuv420p, 720x480 [SAR 1:1 DAR 3:2], q=2-31, 6000 kb/s, 29.97 fps, 90k tbn, 29.97 tbc
DEBUG 00:32:14.072 [ffmpeg-1-2]     Metadata:
DEBUG 00:32:14.072 [ffmpeg-1-2]       encoder         : Lavc56.26.100 mpeg2video
DEBUG 00:32:14.072 [ffmpeg-1-2] Stream mapping:
DEBUG 00:32:14.072 [ffmpeg-1-2]   Stream #0:0 -> #0:0 (rawvideo (native) -> mpeg2video (native))
DEBUG 00:32:14.073 [ffmpeg-1-2] Press [q] to stop, [?] for help
TRACE 00:32:14.074 [main] Waiting 250 milliseconds...
DEBUG 00:32:14.080 [ffmpeg-1-2] frame=    1 fps=0.0 q=1.6 Lsize=       8kB time=00:00:00.03 bitrate=1964.1kbits/s    
DEBUG 00:32:14.081 [ffmpeg-1-2] video:5kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 51.227615%
TRACE 00:32:14.087 [ffmpeg-1] EOF
TRACE 00:32:14.087 [ffmpeg-1] Ready to Stop: true
TRACE 00:32:14.327 [UPNPHelper] Setting multicast network interface: name:en0 (en0)
INFO  00:32:14.327 [main] The server is now available for renderers to find
DEBUG 00:32:16.493 [mplayer-0-Cleanup] Stopping Unix process 82870: mplayer-0
TRACE 00:32:16.493 [mplayer-0-Cleanup] Killing the Unix process: 82870
TRACE 00:32:16.495 [mplayer-0-Cleanup] Destroying buffer
DEBUG 00:32:16.589 [ffmpeg-1-Cleanup] Stopping Unix process 82869: ffmpeg-1
TRACE 00:32:16.589 [ffmpeg-1-Cleanup] Killing the Unix process: 82869
TRACE 00:32:16.589 [ffmpeg-1-Cleanup] Destroying buffer
I don't know enough to tell if all the libs really are in there but I like the chatter - more info is never bad.

One error: File '/Users/umsmkv/Library/Application Support/UMS/ffmpeg.webfilters' does not exist
MacPro5,1 - 2.8 GHz, 32 GB, 20TB, OS X 10.11.6,
. . . . and a few others.
Samsung UN55C8000
Home Theater (WIP): OS X based now, dedicated Linux later.
User avatar
Optimus_prime
Posts: 678
Joined: Fri Jun 01, 2012 6:39 pm
Location: Sydney, Australia

Re: Building ffmpeg locally

Post by Optimus_prime »

Nice work mate, just got back from work so i'll have a look
How Ask For Support
Remember, Debug Log's Can/Will Help and Explain your issues, we're not mind reader's but here to help
OS's I Use And Can Assist With: Windows 7/8, Mac OS-X 10.8 & 10.9
Mac OS-X Java 7 Builds Mac OS-X Java 7 Forum
Post Reply