Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide example for packaging FFmpeg binaries #29

Open
gregcotten opened this issue Jan 7, 2020 · 14 comments
Open

Provide example for packaging FFmpeg binaries #29

gregcotten opened this issue Jan 7, 2020 · 14 comments

Comments

@gregcotten
Copy link
Collaborator

gregcotten commented Jan 7, 2020

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.

@sunlubo
Copy link
Owner

sunlubo commented Jan 8, 2020

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.

@gregcotten
Copy link
Collaborator Author

I'll keep an eye out for it!

@gregcotten
Copy link
Collaborator Author

WWDC20 talk tomorrow regarding this very topic!

@sunlubo
Copy link
Owner

sunlubo commented Aug 6, 2020

I have added support for SE-0272 in #41 (comment). Can you try and verify it?

@gregcotten
Copy link
Collaborator Author

Will test soon! Are the binaries dylib or static?

@sunlubo
Copy link
Owner

sunlubo commented Aug 7, 2020

static

@thieso2
Copy link

thieso2 commented Aug 7, 2020

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 yasm/yasm#141

@sunlubo
Copy link
Owner

sunlubo commented Aug 8, 2020

It works fine on Xcode11E708 with 5.3-DEVELOPMENT-SNAPSHOT-2020-08-05-a toolchain.
I will try Xcode12b4 in next few days.

@gregcotten
Copy link
Collaborator Author

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.

@sunlubo
Copy link
Owner

sunlubo commented Aug 25, 2020

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?

@gregcotten
Copy link
Collaborator Author

This build script enables GPL parts of FFmpeg, which make it impossible to use in a closed-source commercial project.

@sunlubo
Copy link
Owner

sunlubo commented Aug 25, 2020

You mean this part?

--enable-gpl
@gregcotten
Copy link
Collaborator Author

Yep

@sunlubo
Copy link
Owner

sunlubo commented Aug 28, 2020

The --enable-gpl option has been removed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants