From 80ca06224b6b416432261d7587829c5d86bd77d8 Mon Sep 17 00:00:00 2001 From: mjbudd77 Date: Wed, 6 Oct 2021 18:29:58 -0400 Subject: [PATCH] Fix for macOSX homebrew ffmpeg bundling error. --- pipelines/macOS_BundleFFmpegFix.pl | 42 ++++++++++++++++++++++++++++++ pipelines/macOS_build.sh | 3 +++ 2 files changed, 45 insertions(+) create mode 100755 pipelines/macOS_BundleFFmpegFix.pl diff --git a/pipelines/macOS_BundleFFmpegFix.pl b/pipelines/macOS_BundleFFmpegFix.pl new file mode 100755 index 00000000..77bcb494 --- /dev/null +++ b/pipelines/macOS_BundleFFmpegFix.pl @@ -0,0 +1,42 @@ +#!/usr/bin/perl + +use strict; + +# MacOSX homebrew version of ffmpeg comes with 5 libraries. These libraries depend on each other +# and it seems that macdeployqt doesn't fix all the library paths when bundling them. +# This script fixes those bundling issues. +my $i; my $j; my $k; +my $LIBPATH=`brew --prefix ffmpeg`; +my @libList = ( "libavutil", "libavcodec", "libavformat", "libswscale", "libswresample" ); +my $lib; my $otool; +my @lines; + +for ($i=0; $i<=$#libList; $i++) +{ + #print "LIB: $libList[$i]\n"; + + $lib="$LIBPATH/lib/$libList[$i].dylib"; + $lib=~s/\n//; + + print "Fixing lib: '$lib'\n"; + + $otool=`otool -L $lib`; + + #print "otool: '$otool'\n"; + + @lines = split /\n/, $otool; + + for ($j=0; $j<=$#lines; $j++) + { + for ($k=0; $k<=$#libList; $k++) + { + if ( $lines[$j] =~ m/\s+(\/.*\/($libList[$k].*\.dylib))/ ) + { + #print "$1 $2\n"; + + print("install_name_tool -change $1 \@executable_path/../Frameworks/$2 $lib\n"); + system("install_name_tool -change $1 \@executable_path/../Frameworks/$2 $lib"); + } + } + } +} diff --git a/pipelines/macOS_build.sh b/pipelines/macOS_build.sh index 1af19682..b2e1e974 100755 --- a/pipelines/macOS_build.sh +++ b/pipelines/macOS_build.sh @@ -77,6 +77,9 @@ echo 'Install Optional Dependency ffmpeg' echo '****************************************' brew install ffmpeg +# Fix homebrew ffmpeg libraries so that they work in the bundle. +sudo $SCRIPT_DIR/macOS_BundleFFmpegFix.pl + #brew install zlib # Already installed in appveyor macOS export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/lib/pkgconfig: