# IT4Innovations 2022
# JK

easyblock = 'ConfigureMake'

name = 'FFmpeg'
version = '5.1.2'
versionsuffix = '-CUDA-%(cudaver)s'

homepage = 'https://www.ffmpeg.org/'
description = "A complete, cross-platform solution to record, convert and stream audio and video."

toolchain = {'name': 'GCCcore', 'version': '11.3.0'}

source_urls = [
    'https://%(namelower)s.org/releases/',
]
sources = [SOURCELOWER_TAR_BZ2]
checksums = ['39a0bcc8d98549f16c570624678246a6ac736c066cebdb409f9502e915b22f2b']

builddependencies = [
    ('binutils', '2.38'),
    ('pkgconf', '1.8.0'),
]
dependencies = [
    ('CUDA', '11.7.0', '', True),
    ('nvcodec', '11.1.5.1', '', True),
    ('NASM', '2.15.05'),
    ('zlib', '1.2.12'),
    ('bzip2', '1.0.8'),
    ('x264', '20220620'),
    ('LAME', '3.100'),
    ('x265', '3.5'),
    ('X11', '20220504'),
    ('freetype', '2.12.1'),
    ('fontconfig', '2.14.0'),
    ('FriBidi', '1.0.12'),
]

configopts = '--enable-pic --enable-shared --enable-gpl --enable-version3 --enable-nonfree --cc="$CC" --cxx="$CXX" '
configopts += '--enable-libx264 --enable-libx265 --enable-libmp3lame --enable-libfreetype --enable-fontconfig '
configopts += '--enable-libfribidi '
configopts += '--enable-cuda-nvcc --enable-cuvid --enable-nvenc --enable-nvdec --enable-libnpp '
configopts += '--extra-cflags=-I${EBROOTCUDA}/include  --extra-ldflags=-L${EBROOTCUDA}/lib64 '

sanity_check_paths = {
    'files': ['bin/ff%s' % x for x in ['mpeg', 'probe']] +
             ['lib/lib%s.%s' % (x, y) for x in ['avdevice', 'avfilter', 'avformat', 'avcodec', 'postproc',
                                                'swresample', 'swscale', 'avutil'] for y in [SHLIB_EXT, 'a']],
    'dirs': ['include']
}

sanity_check_commands = ['ffmpeg --help']

moduleclass = 'vis'
