summaryrefslogtreecommitdiff
path: root/recipes/ffmpeg.recipe
blob: 4366a800b4e16c090bca2c6d74771d8fb2471fee (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# -*- Mode: Python -*- vi:si:et:sw=4:sts=4:ts=4:syntax=python
from cerbero.tools.libtool import LibtoolLibrary

class Recipe(recipe.Recipe):
    name = 'ffmpeg'
    version = '6.0'
    licenses = [License.LGPLv2_1Plus]
    stype = SourceType.TARBALL
    url = 'https://ffmpeg.org/releases/%(name)s-%(version)s.tar.xz'
    tarball_checksum = '57be87c22d9b49c112b6d24bc67d42508660e6b718b3db89c44e47e289137082'
    patches = [
        name + '/0001-Add-Meson-build.patch',
    ]

    btype = BuildType.MESON
    meson_options = {
        'avdevice': 'disabled',
        'programs': 'disabled',
        'flac_encoder': 'disabled',
        'protocols': 'disabled',
        'devices': 'disabled',
        'network': 'disabled',
        'hwaccels': 'disabled',
        'dxva2': 'disabled',
        'vdpau': 'disabled',
        'filters': 'disabled',
        'yadif_filter': 'enabled',
        # Uncomment the following option once implemented in the port
        # 'doc': 'disabled',
        'd3d11va': 'disabled',
        'audiotoolbox': 'disabled',
        'videotoolbox': 'disabled',
        'vaapi': 'disabled',
        'crystalhd': 'disabled',
        'mediacodec': 'disabled',
        'mediafoundation' : 'disabled',
        'nvenc': 'disabled',
        'mmal': 'disabled',
        'omx': 'disabled',
        'omx_rpi': 'disabled',
        'cuda': 'disabled',
        'cuvid': 'disabled',
        'libmfx': 'disabled',
        'libnpp': 'disabled',
        'libnpp': 'disabled',
        'iconv': 'disabled',
        'jni': 'disabled',
        'v4l2_m2m': 'disabled',
        'vulkan': 'disabled',
        'tests': 'disabled', # To not waste time
        # These two are redundant with Meson
        # 'stripping': 'disabled',
        # 'optimizations': 'enabled,
        'nonfree': 'disabled',
        'version3': 'disabled',
    }

    deps = ['bzip2', 'zlib']

    files_libs = ['libavcodec', 'libavformat', 'libavutil', 'libswresample', 'libavfilter', 'libpostproc', 'libswscale']
    files_devel = []

    def prepare(self):
        # Arch-specific flags
        if self.config.target_arch == Architecture.X86:
            if self.config.target_platform == Platform.IOS:
                # Simulator doesn't like shared libs
                self.library_type = LibraryType.STATIC
            elif self.config.target_platform == Platform.ANDROID:
                # ld.lld: error: relocation R_386_32 cannot be used against local symbol; recompile with -fPIC
                # See https://github.com/FFmpeg/FFmpeg/blob/n6.0/libavutil/x86/x86inc.asm#L104-L108
                self.meson_options['asm'] = 'disabled'

        # Populate self.files_devel
        files_devel_tpl = ['%(libdir)s/{}.la', '%(libdir)s/pkgconfig/{}.pc', 'include/{}']
        if self.library_type != LibraryType.SHARED:
            files_devel_tpl += ['%(libdir)s/{}.a']
        for lib in self.files_libs:
            self.files_devel += [tpl.format(lib) for tpl in files_devel_tpl]

    def post_install(self):
    # Meson does not generate la files
        LibtoolLibrary('avcodec', None, None, None,
                       self.config.libdir, self.config.target_platform,
                       deps=['swresample', 'avutil', 'z'],
                       static_only=self.library_type == LibraryType.STATIC).save()
        LibtoolLibrary('avfilter', None, None, None,
                       self.config.libdir, self.config.target_platform,
                       deps=['avformat', 'avcodec', 'swresample', 'avutil'],
                       static_only=self.library_type == LibraryType.STATIC).save()
        LibtoolLibrary('avformat', None, None, None,
                       self.config.libdir, self.config.target_platform,
                       deps=['avcodec', 'swresample', 'avutil', 'bz2', 'z'],
                       static_only=self.library_type == LibraryType.STATIC).save()
        LibtoolLibrary('avutil', None, None, None,
                       self.config.libdir, self.config.target_platform,
                       static_only=self.library_type == LibraryType.STATIC).save()
        LibtoolLibrary('postproc', None, None, None,
                       self.config.libdir, self.config.target_platform,
                       static_only=self.library_type == LibraryType.STATIC).save()
        LibtoolLibrary('swresample', None, None, None,
                       self.config.libdir, self.config.target_platform,
                       deps=['avutil'],
                       static_only=self.library_type == LibraryType.STATIC).save()
        LibtoolLibrary('swscale', None, None, None,
                       self.config.libdir, self.config.target_platform,
                       deps=['avutil'],
                       static_only=self.library_type == LibraryType.STATIC).save()
        super().post_install()