From 1039ed0650cc5cee10add08667b9531004b91af1 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Fri, 20 Feb 2015 16:12:42 +0100 Subject: [PATCH] ffmpeg/ffpyplayer: preliminary recipes for ffmpeg / ffpyplayer. untested on simulator/device yet, but it compiles. --- recipes/ffmpeg/__init__.py | 59 ++++++++++++++++++++++++ recipes/ffpyplayer/__init__.py | 83 ++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+) create mode 100644 recipes/ffmpeg/__init__.py create mode 100644 recipes/ffpyplayer/__init__.py diff --git a/recipes/ffmpeg/__init__.py b/recipes/ffmpeg/__init__.py new file mode 100644 index 0000000..ff5d3ec --- /dev/null +++ b/recipes/ffmpeg/__init__.py @@ -0,0 +1,59 @@ +from toolchain import Recipe, shprint +from os.path import join +import sh + + +class FFMpegRecipe(Recipe): + version = "2.5.4" + url = "http://www.ffmpeg.org/releases/ffmpeg-{version}.tar.bz2" + include_per_arch = True + include_dir = "dist/include" + libraries = [ + "libavcodec/libavcodec.a", + "libavdevice/libavdevice.a", + "libavfilter/libavfilter.a", + "libavresample/libavresample.a", + "libavutil/libavutil.a", + "libswresample/libswresample.a", + "libswscale/libswscale.a"] + + def build_arch(self, arch): + options = ( + "--enable-cross-compile", + "--disable-debug", + "--disable-programs", + "--disable-doc", + "--enable-pic", + "--enable-avresample") + build_env = arch.get_env() + build_env["VERBOSE"] = "1" + configure = sh.Command(join(self.build_dir, "configure")) + shprint(configure, + "--target-os=darwin", + "--arch={}".format(arch.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"]), + *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") + shprint(sh.sed, + "-i.bak", + "s/%define HAVE_CLOSESOCKET 1//g", + "config.asm") + shprint(sh.make, "clean", _env=build_env) + shprint(sh.make, "-j3", _env=build_env) + shprint(sh.make, "install") + + +recipe = FFMpegRecipe() + diff --git a/recipes/ffpyplayer/__init__.py b/recipes/ffpyplayer/__init__.py new file mode 100644 index 0000000..1bcac95 --- /dev/null +++ b/recipes/ffpyplayer/__init__.py @@ -0,0 +1,83 @@ +from toolchain import Recipe, shprint +from os.path import join +import sh +import os +import fnmatch +import shutil + + +class FFPyplayerRecipe(Recipe): + version = "master" + url = "https://github.com/tito/ffpyplayer/archive/{version}.zip" + library = "libffpyplayer.a" + depends = ["python", "ffmpeg"] + + def cythonize(self, filename): + if filename.startswith(self.build_dir): + filename = filename[len(self.build_dir) + 1:] + print("Cythonize {}".format(filename)) + cmd = sh.Command(join(self.ctx.root_dir, "tools", "cythonize.py")) + shprint(cmd, filename) + + def cythonize_build(self): + root_dir = self.build_dir + for root, dirnames, filenames in os.walk(root_dir): + for filename in fnmatch.filter(filenames, "*.pyx"): + self.cythonize(join(root, filename)) + + def get_kivy_env(self, arch): + build_env = arch.get_env() + build_env["KIVYIOSROOT"] = self.ctx.root_dir + build_env["IOSSDKROOT"] = arch.sysroot + build_env["LDSHARED"] = join(self.ctx.root_dir, "tools", "liblink") + build_env["CC"] = "{} -I{}".format( + build_env["CC"], + join(self.ctx.dist_dir, "include", arch.arch, "libffi")) + build_env["ARM_LD"] = build_env["LD"] + build_env["ARCH"] = arch.arch + build_env["SDL_INCLUDE_DIR"] = join(self.ctx.dist_dir, "include", + "common", "sdl2") + build_env["FFMPEG_INCLUDE_DIR"] = join(self.ctx.dist_dir, "include", + arch.arch, "ffmpeg") + build_env["CONFIG_POSTPROC"] = "0" + return build_env + + def build_arch(self, arch): + build_env = self.get_kivy_env(arch) + hostpython = sh.Command(self.ctx.hostpython) + try: + shprint(hostpython, "setup.py", "build_ext", "-g", + _env=build_env) + except: + pass + self.cythonize_build() + shprint(hostpython, "setup.py", "build_ext", "-g", + _env=build_env) + self.biglink() + + def biglink(self): + dirs = [] + for root, dirnames, filenames in os.walk(self.build_dir): + if fnmatch.filter(filenames, "*.so.libs"): + dirs.append(root) + cmd = sh.Command(join(self.ctx.root_dir, "tools", "biglink")) + shprint(cmd, join(self.build_dir, "libffpyplayer.a"), *dirs) + + def install(self): + arch = list(self.filtered_archs)[0] + build_dir = self.get_build_dir(arch.arch) + os.chdir(build_dir) + hostpython = sh.Command(self.ctx.hostpython) + build_env = self.get_kivy_env(arch) + shprint(hostpython, "setup.py", "install", "-O2", + "--prefix", join(build_dir, "iosbuild"), + _env=build_env) + dest_dir = join(self.ctx.dist_dir, "root", "python", "lib", "python2.7", + "site-packages", "ffpyplayer") + shutil.copytree( + join(build_dir, "iosbuild", "lib", + "python2.7", "site-packages", "ffpyplayer"), + dest_dir) + +recipe = FFPyplayerRecipe() +