-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #954 from germn/ffpyplayer_new_toolchain
Add ffpyplayer and dependencies recipes for new toolchain.
- Loading branch information
Showing
8 changed files
with
240 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,138 @@ | ||
from pythonforandroid.toolchain import Recipe, shprint, shutil, current_directory | ||
from os.path import join, exists | ||
from pythonforandroid.toolchain import Recipe, shprint, current_directory, ArchARM | ||
from os.path import exists, join, realpath | ||
from os import uname | ||
import glob | ||
import sh | ||
import os | ||
import shutil | ||
|
||
""" | ||
FFmpeg for Android compiled with x264, libass, fontconfig, freetype, fribidi and lame (Supports Android 4.1+) | ||
|
||
http://writingminds.github.io/ffmpeg-android/ | ||
""" | ||
class FFMpegRecipe(Recipe): | ||
|
||
version = 'master' | ||
url = 'git+https://github.com/WritingMinds/ffmpeg-android.git' | ||
patches = ['settings.patch'] | ||
|
||
version = '3.1.8' # 3.2+ works with bugs | ||
url = 'http://ffmpeg.org/releases/ffmpeg-{version}.tar.bz2' | ||
md5sum = 'f25a0cdd7f731cfbd8c0f7842b0d15b9' | ||
depends = ['sdl2'] # Need this to build correct recipe order | ||
opts_depends = ['openssl', 'ffpyplayer_codecs'] | ||
patches = ['patches/fix-libshine-configure.patch'] | ||
|
||
def should_build(self, arch): | ||
return not exists(self.get_build_bin(arch)) | ||
build_dir = self.get_build_dir(arch.arch) | ||
return not exists(join(build_dir, 'lib', 'libavcodec.so')) | ||
|
||
def prebuild_arch(self, arch): | ||
self.apply_patches(arch) | ||
|
||
def get_recipe_env(self,arch): | ||
env = super(FFMpegRecipe, self).get_recipe_env(arch) | ||
env['NDK'] = self.ctx.ndk_dir | ||
return env | ||
|
||
def build_arch(self, arch): | ||
super(FFMpegRecipe, self).build_arch(arch) | ||
env = self.get_recipe_env(arch) | ||
build_dir = self.get_build_dir(arch.arch) | ||
with current_directory(build_dir): | ||
bash = sh.Command('bash') | ||
shprint(bash, 'init_update_libs.sh') | ||
shprint(bash, 'android_build.sh', _env=env) | ||
with current_directory(self.get_build_dir(arch.arch)): | ||
env = arch.get_env() | ||
|
||
flags = ['--disable-everything'] | ||
cflags = [] | ||
ldflags = [] | ||
|
||
def get_build_bin(self, arch): | ||
build_dir = self.get_build_dir(arch.arch) | ||
return join(build_dir, 'build', arch.arch, 'bin', 'ffmpeg') | ||
if 'openssl' in self.ctx.recipe_build_order: | ||
flags += [ | ||
'--enable-openssl', | ||
'--enable-nonfree', | ||
'--enable-protocol=https,tls_openssl', | ||
] | ||
build_dir = Recipe.get_recipe('openssl', self.ctx).get_build_dir(arch.arch) | ||
cflags += ['-I' + build_dir + '/include/'] | ||
ldflags += ['-L' + build_dir] | ||
|
||
if 'ffpyplayer_codecs' in self.ctx.recipe_build_order: | ||
# libx264 | ||
flags += ['--enable-libx264'] | ||
build_dir = Recipe.get_recipe('libx264', self.ctx).get_build_dir(arch.arch) | ||
cflags += ['-I' + build_dir + '/include/'] | ||
ldflags += ['-lx264', '-L' + build_dir + '/lib/'] | ||
|
||
def get_recipe_env(self, arch): | ||
env = super(FFMpegRecipe, self).get_recipe_env(arch) | ||
env['ANDROID_NDK'] = self.ctx.ndk_dir | ||
env['ANDROID_API'] = str(self.ctx.android_api) | ||
return env | ||
# libshine | ||
flags += ['--enable-libshine'] | ||
build_dir = Recipe.get_recipe('libshine', self.ctx).get_build_dir(arch.arch) | ||
cflags += ['-I' + build_dir + '/include/'] | ||
ldflags += ['-lshine', '-L' + build_dir + '/lib/'] | ||
|
||
# Enable all codecs: | ||
flags += [ | ||
'--enable-parsers', | ||
'--enable-decoders', | ||
'--enable-encoders', | ||
'--enable-muxers', | ||
'--enable-demuxers', | ||
] | ||
else: | ||
# Enable codecs only for .mp4: | ||
flags += [ | ||
'--enable-parser=h264,aac', | ||
'--enable-decoder=h263,h264,aac', | ||
] | ||
|
||
# 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 | ||
flags += [ | ||
'--disable-dxva2 --disable-vdpau --disable-vaapi', | ||
'--disable-dct', | ||
] | ||
|
||
# needed to prevent _ffmpeg.so: version node not found for symbol av_init_packet@LIBAVFORMAT_52 | ||
# /usr/bin/ld: failed to set dynamic section sizes: Bad value | ||
flags += [ | ||
'--disable-symver', | ||
] | ||
|
||
# disable binaries / doc | ||
flags += [ | ||
'--disable-ffmpeg', | ||
'--disable-ffplay', | ||
'--disable-ffprobe', | ||
'--disable-ffserver', | ||
'--disable-doc', | ||
] | ||
|
||
# other flags: | ||
flags += [ | ||
'--enable-filter=aresample,resample,crop,adelay,volume', | ||
'--enable-protocol=file,http', | ||
'--enable-small', | ||
'--enable-hwaccels', | ||
'--enable-gpl', | ||
'--enable-pic', | ||
'--disable-static', | ||
'--enable-shared', | ||
] | ||
|
||
# android: | ||
flags += [ | ||
'--target-os=android', | ||
'--cross-prefix=arm-linux-androideabi-', | ||
'--arch=arm', | ||
'--sysroot=' + self.ctx.ndk_platform, | ||
'--enable-neon', | ||
'--prefix={}'.format(realpath('.')), | ||
] | ||
cflags = [ | ||
'-march=armv7-a', | ||
'-mfpu=vfpv3-d16', | ||
'-mfloat-abi=softfp', | ||
'-fPIC', | ||
'-DANDROID', | ||
] + cflags | ||
|
||
env['CFLAGS'] += ' ' + ' '.join(cflags) | ||
env['LDFLAGS'] += ' ' + ' '.join(ldflags) | ||
|
||
configure = sh.Command('./configure') | ||
shprint(configure, *flags, _env=env) | ||
shprint(sh.make, '-j4', _env=env) | ||
shprint(sh.make, 'install', _env=env) | ||
# copy libs: | ||
sh.cp('-a', sh.glob('./lib/lib*.so'), self.ctx.get_libs_dir(arch.arch)) | ||
|
||
recipe = FFMpegRecipe() | ||
recipe = FFMpegRecipe() |
11 changes: 11 additions & 0 deletions
11
pythonforandroid/recipes/ffmpeg/patches/fix-libshine-configure.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- ./configure.orig 2016-09-19 04:41:33.000000000 +0300 | ||
+++ ./configure 2016-12-06 19:12:05.046025000 +0300 | ||
@@ -5260,7 +5260,7 @@ | ||
enabled libquvi && require_pkg_config libquvi quvi/quvi.h quvi_init | ||
enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket | ||
enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init | ||
-enabled libshine && require_pkg_config shine shine/layer3.h shine_encode_buffer | ||
+enabled libshine && require "shine" shine/layer3.h shine_encode_buffer -lshine | ||
enabled libsmbclient && { use_pkg_config smbclient libsmbclient.h smbc_init || | ||
require smbclient libsmbclient.h smbc_init -lsmbclient; } | ||
enabled libsnappy && require snappy snappy-c.h snappy_compress -lsnappy |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from pythonforandroid.toolchain import Recipe, CythonRecipe, shprint, current_directory, ArchARM | ||
from os.path import exists, join, realpath | ||
from os import uname | ||
import glob | ||
import sh | ||
import os | ||
|
||
|
||
class FFPyPlayerRecipe(CythonRecipe): | ||
version = 'master' | ||
url = 'https://github.com/matham/ffpyplayer/archive/{version}.zip' | ||
depends = ['python2', 'sdl2', 'ffmpeg'] | ||
opt_depends = ['openssl', 'ffpyplayer_codecs'] | ||
|
||
def get_recipe_env(self, arch, with_flags_in_cc=True): | ||
env = super(FFPyPlayerRecipe, self).get_recipe_env(arch) | ||
|
||
env["SDL_INCLUDE_DIR"] = join(self.ctx.bootstrap.build_dir, 'jni', 'SDL', 'include') | ||
env["SDL_LIB_DIR"] = join(self.ctx.bootstrap.build_dir, 'libs', arch.arch) | ||
|
||
build_dir = Recipe.get_recipe('ffmpeg', self.ctx).get_build_dir(arch.arch) | ||
env["FFMPEG_INCLUDE_DIR"] = join(build_dir, "include") | ||
env["FFMPEG_LIB_DIR"] = join(build_dir, "lib") | ||
|
||
return env | ||
|
||
recipe = FFPyPlayerRecipe() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from pythonforandroid.toolchain import Recipe | ||
|
||
|
||
class FFPyPlayerCodecsRecipe(Recipe): | ||
depends = ['libshine', 'libx264'] | ||
|
||
def build_arch(self, arch): | ||
pass | ||
|
||
recipe = FFPyPlayerCodecsRecipe() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
from pythonforandroid.toolchain import Recipe, shprint, current_directory, ArchARM | ||
from os.path import exists, join, realpath | ||
from os import uname | ||
import glob | ||
import sh | ||
|
||
|
||
class LibShineRecipe(Recipe): | ||
version = '20aee967f67abefd065c196eec7ce21adbbe1549' | ||
url = 'https://github.com/toots/shine/archive/{version}.zip' | ||
md5sum = 'bbf1f657e6adccb5e79f59da9ecfac2d' | ||
|
||
def should_build(self, arch): | ||
build_dir = self.get_build_dir(arch.arch) | ||
return not exists(join(build_dir, 'lib', 'libshine.a')) | ||
|
||
def build_arch(self, arch): | ||
with current_directory(self.get_build_dir(arch.arch)): | ||
env = self.get_recipe_env(arch) | ||
shprint(sh.Command('./bootstrap')) | ||
configure = sh.Command('./configure') | ||
shprint(configure, | ||
'--host=arm-linux', | ||
'--enable-pic', | ||
'--disable-shared', | ||
'--enable-static', | ||
'--prefix={}'.format(realpath('.')), | ||
_env=env) | ||
shprint(sh.make, '-j4', _env=env) | ||
shprint(sh.make, 'install', _env=env) | ||
|
||
recipe = LibShineRecipe() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from pythonforandroid.toolchain import Recipe, shprint, current_directory, ArchARM | ||
from os.path import exists, join, realpath | ||
from os import uname | ||
import glob | ||
import sh | ||
|
||
|
||
class LibX264Recipe(Recipe): | ||
version = 'x264-snapshot-20170608-2245-stable' # using mirror url since can't use ftp | ||
url = 'http://mirror.yandex.ru/mirrors/ftp.videolan.org/x264/snapshots/{version}.tar.bz2' | ||
md5sum = 'adf3b87f759b5cc9f100f8cf99276f77' | ||
|
||
def should_build(self, arch): | ||
build_dir = self.get_build_dir(arch.arch) | ||
return not exists(join(build_dir, 'lib', 'libx264.a')) | ||
|
||
def build_arch(self, arch): | ||
with current_directory(self.get_build_dir(arch.arch)): | ||
env = self.get_recipe_env(arch) | ||
configure = sh.Command('./configure') | ||
shprint(configure, | ||
'--cross-prefix=arm-linux-androideabi-', | ||
'--host=arm-linux', | ||
'--disable-asm', | ||
'--disable-cli', | ||
'--enable-pic', | ||
'--disable-shared', | ||
'--enable-static', | ||
'--prefix={}'.format(realpath('.')), | ||
_env=env) | ||
shprint(sh.make, '-j4', _env=env) | ||
shprint(sh.make, 'install', _env=env) | ||
|
||
recipe = LibX264Recipe() |