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

Trying to get ffmpeg n6.1.2 working with our app #959

Open
brentpicasso opened this issue Jan 31, 2025 · 0 comments
Open

Trying to get ffmpeg n6.1.2 working with our app #959

brentpicasso opened this issue Jan 31, 2025 · 0 comments

Comments

@brentpicasso
Copy link
Contributor

brentpicasso commented Jan 31, 2025

Describe the bug
Getting duplicate symbol issue when running our app with ffmpeg n6.1.2

Hi, I'm working on contributing an updated recipe for ffmpeg. FFmpeg is building, but I'm seeing this error when the app is linked:

duplicate symbol '_ff_init_half2float_tables' in:
    /Users/macmini/Library/Developer/Xcode/DerivedData/racecaptureapp-gvoxmqndeqrfaxcpilbfwwppcdqu/Build/Products/Debug-iphoneos/libswscale.a[arm64][11](half2float.o)
    /Users/macmini/Library/Developer/Xcode/DerivedData/racecaptureapp-gvoxmqndeqrfaxcpilbfwwppcdqu/Build/Products/Debug-iphoneos/libavcodec.a[arm64][357](half2float.o)
ld: 1 duplicate symbols
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Here's my recipe.

  • Note it is referencing libX264 and libshine (those will be separate contributions)

I also have cleaned the old version of ffmpeg as much as possible from the build and app directories.

from kivy_ios.toolchain import Recipe, shprint
from os.path import join
import sh


class FFMpegRecipe(Recipe):
    version = "n6.1.2"
    url = "https://github.com/FFmpeg/FFmpeg/archive/{version}.zip"
    include_per_platform = True
    include_dir = "dist/include"
    optional_depends = ["openssl"]
    depends = ["libx264"]
    libraries = [
        "libavcodec/libavcodec.a",
        "libavdevice/libavdevice.a",
        "libavfilter/libavfilter.a",
        "libavformat/libavformat.a",
        "libavutil/libavutil.a",
        "libswresample/libswresample.a",
        "libswscale/libswscale.a",
    ]
    pbx_frameworks = ["VideoToolbox"]

    def prebuild_platform(self, plat):
        marker_name = f"patched_{plat.arch}"
        if self.has_marker(marker_name):
            return
        self.apply_patch("patches/configure.patch")
        self.set_marker(marker_name)

    def build_platform(self, plat):
        extra_cflags = []
        extra_ldflags = []
        options = [
            "--disable-everything",
            "--enable-swscale",
            "--enable-avcodec",
            "--enable-parsers",
            "--enable-decoders",
            "--enable-demuxers",
            "--enable-filter=aresample,resample,crop,scale",
            "--enable-protocol=file,http,rtmp",
            "--enable-pic",
            "--enable-small",
            "--enable-hwaccels",
            "--enable-static",
            "--disable-shared",
            # libpostproc is GPL: https://ffmpeg.org/pipermail/ffmpeg-user/2012-February/005162.html
            "--enable-gpl",
            "--enable-libx264",
            "--enable-libshine",
            # disable some unused algo
            # note: "golomb" are the one used in our video test, so don't use --disable-golomb
            # note: and for aac decoding: "rdft", "mdct", and "fft" are needed
            "--disable-dxva2",
            "--disable-vdpau",
            "--disable-vaapi",
            # disable binaries / doc
            "--enable-cross-compile",
            "--disable-debug",
            "--disable-programs",
            "--disable-doc",
            "--enable-pic"]
	
        extra_cflags += ["-I{}".format(join(self.ctx.dist_dir, "include", "common", "libx264"))]
        extra_cflags += ["-I{}".format(join(self.ctx.dist_dir, "include", "common", "libshine", "include"))]

        plat_basename = plat.name.split("-")[0]
        extra_ldflags += ["{}".format(join(self.ctx.dist_dir, "lib", plat_basename, "libx264.a"))]
        extra_ldflags += ["{}".format(join(self.ctx.dist_dir, "lib", plat_basename, "libshine.a"))]

        if "openssl.build_all" in self.ctx.state:
            options += [
                "--enable-openssl",
                "--enable-nonfree",
                "--enable-protocol=https,tls_openssl"]

        build_env = plat.get_env()

        build_env["CFLAGS"] += " " + " ".join(extra_cflags)
        build_env["LDFLAGS"] += " " + " ".join(extra_ldflags)

        build_env["VERBOSE"] = "1"
        configure = sh.Command(join(self.build_dir, "configure"))
        shprint(configure,
                "--target-os=darwin",
                "--arch={}".format(plat.arch),
                "--cc={}".format(build_env["CC"]),
                "--prefix={}/dist".format(self.build_dir),
                "--extra-cflags={}".format(build_env["CFLAGS"]),
                "--extra-cxxflags={}".format(build_env["CFLAGS"]),
                "--extra-ldflags={}".format(build_env["LDFLAGS"]),
                "--disable-x86asm",
                *options,
                _env=build_env)
        """
        shprint(sh.sed,
                "-i.bak",
                "s/HAVE_CLOSESOCKET=yes//g",
                "config.mak")
        shprint(sh.sed,
                "-i.bak",
                "s/#define HAVE_CLOSESOCKET 1//g",
                "config.h")
        if exists("config.asm"):
            shprint(sh.sed,
                    "-i.bak",
                    "s/%define HAVE_CLOSESOCKET 1//g",
                    "config.asm")
        """
        shprint(sh.make, "clean", _env=build_env)
        shprint(sh.make, self.ctx.concurrent_make, _env=build_env)
        shprint(sh.make, "install")


recipe = FFMpegRecipe()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant