SwiftFFmpeg
SwiftFFmpeg copied to clipboard
Provide example for packaging FFmpeg binaries
I'd be happy to lend my advice as I am currently doing this in a shipping macOS app, but I'm wondering what the best way to do this would be. I currently use a build script to build the FFmpeg libraries from source + an xcodeproject to help generate .frameworks for CFFmpeg and SwiftFFmpeg. Not so sure if this is the best way but it gets the job done.
Currently, due to the lack of support for binary dependencies in SPM, I have adopted a similar approach to you. Recently, SPM team put forward a proposal for binary dependencies (SE-0272) and it was approved. Once the proposal is implemented, we can integrate FFmpeg library internally.
I'll keep an eye out for it!
WWDC20 talk tomorrow regarding this very topic!
I have added support for SE-0272 in https://github.com/sunlubo/SwiftFFmpeg/pull/41#issue-463928497. Can you try and verify it?
Will test soon! Are the binaries dylib or static?
static
Great Work! Thank you.
What I'm seeing building a tiny project that uses this branch via SPM in Xcode12b4 on 10.15.6 is
Ld /Users/thies/Library/Developer/Xcode/DerivedData/binaryffmpeg-cpzbcxscrwnfiyghxwaadmoptrun/Build/Products/Debug/binaryffmpeg.app/Contents/MacOS/binaryffmpeg normal (in target 'binaryffmpeg' from project 'binaryffmpeg')
cd /Users/thies/Temp/binaryffmpeg
/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -target x86_64-apple-macos10.15 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk -L/Users/thies/Library/Developer/Xcode/DerivedData/binaryffmpeg-cpzbcxscrwnfiyghxwaadmoptrun/Build/Products/Debug -F/Users/thies/Library/Developer/Xcode/DerivedData/binaryffmpeg-cpzbcxscrwnfiyghxwaadmoptrun/Build/Products/Debug -filelist /Users/thies/Library/Developer/Xcode/DerivedData/binaryffmpeg-cpzbcxscrwnfiyghxwaadmoptrun/Build/Intermediates.noindex/binaryffmpeg.build/Debug/binaryffmpeg.build/Objects-normal/x86_64/binaryffmpeg.LinkFileList -Xlinker -rpath -Xlinker @executable_path/../Frameworks -Xlinker -object_path_lto -Xlinker /Users/thies/Library/Developer/Xcode/DerivedData/binaryffmpeg-cpzbcxscrwnfiyghxwaadmoptrun/Build/Intermediates.noindex/binaryffmpeg.build/Debug/binaryffmpeg.build/Objects-normal/x86_64/binaryffmpeg_lto.o -Xlinker -export_dynamic -Xlinker -no_deduplicate -fobjc-link-runtime -L/Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/macosx -L/usr/lib/swift -Xlinker -add_ast_path -Xlinker /Users/thies/Library/Developer/Xcode/DerivedData/binaryffmpeg-cpzbcxscrwnfiyghxwaadmoptrun/Build/Intermediates.noindex/binaryffmpeg.build/Debug/binaryffmpeg.build/Objects-normal/x86_64/binaryffmpeg.swiftmodule -framework Security -framework CoreMedia -framework CoreVideo -framework AudioToolbox -framework VideoToolbox -framework OpenGL -framework CoreImage -framework AppKit -lz -lbz2 -liconv -llzma -framework libavcodec -framework libavdevice -framework libavfilter -framework libavformat -framework libavutil -framework libpostproc -framework libswresample -framework libswscale -Xlinker -dependency_info -Xlinker /Users/thies/Library/Developer/Xcode/DerivedData/binaryffmpeg-cpzbcxscrwnfiyghxwaadmoptrun/Build/Intermediates.noindex/binaryffmpeg.build/Debug/binaryffmpeg.build/Objects-normal/x86_64/binaryffmpeg_dependency_info.dat -o /Users/thies/Library/Developer/Xcode/DerivedData/binaryffmpeg-cpzbcxscrwnfiyghxwaadmoptrun/Build/Products/Debug/binaryffmpeg.app/Contents/MacOS/binaryffmpeg -Xlinker -add_ast_path -Xlinker /Users/thies/Library/Developer/Xcode/DerivedData/binaryffmpeg-cpzbcxscrwnfiyghxwaadmoptrun/Build/Intermediates.noindex/SwiftFFmpeg.build/Debug/SwiftFFmpeg.build/Objects-normal/x86_64/SwiftFFmpeg.swiftmodule
ld: in /Users/thies/Library/Developer/Xcode/DerivedData/binaryffmpeg-cpzbcxscrwnfiyghxwaadmoptrun/Build/Products/Debug/libswscale.framework/libswscale(input.o), building for macOS, but linking in object file built for free standing, for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I saw this message before, but it did not cause the linker to fail. There is some write up about this problem here https://github.com/yasm/yasm/issues/141
It works fine on Xcode11E708 with 5.3-DEVELOPMENT-SNAPSHOT-2020-08-05-a toolchain. I will try Xcode12b4 in next few days.
I think we need to have a LGPL-compliant version for the build script, and to do that I believe we'll need to use dynamic libraries.
I think we need to have a LGPL-compliant version for the build script, and to do that I believe we'll need to use dynamic libraries.
which build script?
This build script enables GPL parts of FFmpeg, which make it impossible to use in a closed-source commercial project.
You mean this part?
--enable-gpl
Yep
The --enable-gpl
option has been removed.