# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup       muniversal 1.0

name        transcode
version     1.1.7
revision    31
epoch       1
license     GPL-2+
categories  multimedia
maintainers {cogweb.net:lionteeth @Liontooth} {devans @dbevans}
description Video and audio processing tools
long_description    transcode is a suite of tools, all of which are \
            command line utilities, for transcoding various \
            video, audio, and container formats, running on a \
            platform that supports shared libraries and threads.\
            \
            Decoding and encoding is done by modules that are \
            responsible for feeding transcode with raw video/ \
            audio streams (import modules) and encoding the frames \
            (export modules). \
            \
            It includes a variety of video and audio filters, \
            including (but not limited to) video de-interlacing, \
            audio resampling, framerate conversion, different \
            resizing algorithms, smoothing, sharpening, denoisifying, \
            and cutting.

homepage        https://packages.gentoo.org/packages/media-video/transcode

master_sites    macports_distfiles

use_bzip2       yes

checksums       ${distfiles} \
                    rmd160  faa854acbbfd52faaa216505176f94d756d77841 \
                    sha256  1e4e72d8e0dd62a80b8dd90699f5ca64c9b0cb37a5c9325c184166a9654f0a92 \
                    size    2183627 \
                transcode-ffmpeg3.patch \
                    rmd160  bac993cb3bbe6ce69c995b596bb76e75fb185fa2 \
                    sha256  728ec3101039d98116275e36ea5cf0434a23a0bb82aca830ea9612fb9d16b062 \
                    size    50234 \
                transcode-ffmpeg4.patch \
                    rmd160  df5df5fb91b7051a580d697a52c3a6bd4d44e91a \
                    sha256  2cc680666f705685a9fdc54b5a377e7728765bde6ed83c43b835634e27767721 \
                    size    26970 \
                transcode-imagemagick7.patch \
                    rmd160  af4e4214203f4879c359b772afa73ef928710347 \
                    sha256  4ede15540ea6932954ac332c12dde130bf48e7e4773d1e04d3c3f23038c6ac51 \
                    size    34353

depends_build   port:pkgconfig

depends_lib     path:lib/libavcodec.dylib:ffmpeg \
                port:libmpeg2 \
                port:libdvdread \
                path:include/turbojpeg.h:libjpeg-turbo \
                port:lame

patch.pre_args-replace  -p0 -p1
patch.args      -b -V numbered
patchfiles      \
                patch-avilib-avidump.c.diff \
                patch-configure.in.diff \
                patch-filter-subtitler-load_font.c.diff

# https://www.archlinux.org/packages/community/x86_64/transcode/
patch_sites     https://git.archlinux.org/svntogit/community.git/plain/trunk/transcode-ffmpeg3.patch?h=packages/transcode&dummy=:ffmpeg3 \
                https://git.archlinux.org/svntogit/community.git/plain/trunk/transcode-ffmpeg4.patch?h=packages/transcode&dummy=:ffmpeg4
patchfiles-append \
                transcode-ffmpeg3.patch:ffmpeg3 \
                transcode-ffmpeg4.patch:ffmpeg4

use_autoreconf  yes
autoreconf.args -fiv

configure.args  --disable-mmx \
                --enable-libmpeg2 \
                --enable-libmpeg2convert \
                --without-x

# With muniversal configure needs help.  This configure's tests do not handle cross-compling, so we must set build and not just host alone.
platform darwin {
	lappend merger_configure_args(i386)  --build=i686-apple-${os.platform}${os.version}
}

default_variants +full +x11

# Optional components

variant mmx description {enable mmx optimizations} {
     configure.args-delete --disable-mmx
}

variant full requires a52dec faac freetype imagemagick libdv libogg libpostproc libquicktime libsdl libtheora libvorbis libxml2 lzo mjpegtools x264 xvid description {enable all optional components except deprecated} {
}

variant a52dec description {enable support for decoding ATSC A/52 streams} {
    depends_lib-append port:a52dec
    configure.args-append --enable-a52 --with-a52-prefix=${prefix}
}

variant faac requires experimental description {enable AAC encoding support via libfaac (experimental)} {
    depends_lib-append port:faac
    configure.args-append --enable-faac --with-faac-prefix=${prefix}
}

variant freetype description {enable support for the FreeType font engine} {
    depends_lib-append port:freetype
    configure.args-append --enable-freetype2
}

variant imagemagick description {enable support for the manipulation of still images} {
    depends_lib-append port:ImageMagick
    configure.args-append --enable-imagemagick --with-imagemagick-prefix=${prefix}
    if {![catch {set vers [lindex [registry_active ImageMagick] 0]}] && [vercmp [lindex $vers 1] 7.0] >= 0 } {
        patchfiles-append transcode-imagemagick7.patch
    }
}

variant libdv description {enable support for the Digital Video format via libdv} {
    depends_lib-append port:libdv
    configure.args-append --enable-libdv
}

variant libogg description {enable support for encoding and decoding ogg audio} {
    depends_lib-append port:libogg
    configure.args-append --enable-ogg
}

variant libpostproc description {enable libpostproc support from ffmpeg} {
    configure.args-append --enable-libpostproc
}

variant libquicktime description {enable support for QuickTime video} {
# use only libquicktime-devel until libquicktime is upgraded to build
# with ffmpeg-2.0
#    depends_lib-append path:lib/libquicktime.dylib:libquicktime-devel
    depends_lib-append port:libquicktime-devel
    configure.args-append --enable-libquicktime
}

variant libtheora description {enable support for the open video codec theora} {
    depends_lib-append port:libtheora
    configure.args-append --enable-theora
}

variant libvorbis description {enable support for a fully open compressed audio format} {
    depends_lib-append port:libvorbis
    configure.args-append --enable-vorbis
}

variant libxml2 description {enable support for the XML metalanguage} {
    depends_lib-append port:libxml2
    configure.args-append --enable-libxml2
}

variant lzo requires experimental description {enable lossless data compression via lzo2 (experimental)} {
    depends_lib-append port:lzo2
    configure.args-append --enable-lzo --with-lzo-prefix=${prefix}
}

variant mjpegtools description {enable mjpegtools support} {
    depends_lib-append port:mjpegtools
    configure.args-append --enable-mjpegtools
}

variant x264 requires experimental description {enable support for encoding H264/AVC video (experimental)} {
    depends_lib-append port:x264
    configure.args-append --enable-x264
}

variant xvid requires experimental description {enable support for the open Xvid video codec (experimental)} {
    depends_lib-append port:XviD
    configure.args-append --enable-xvid --with-xvid-prefix=${prefix}
}

variant experimental description {enable new, experimental or even incomplete components} {
    configure.args-append --enable-experimental
}

variant deprecated description {enable deprecated or even broken components} {
    configure.args-append --enable-deprecated
}

#
# Display options
#

variant libsdl description {enable Simple DirectMedia Layer display support} {
    depends_lib-append port:libsdl
    configure.args-append --enable-sdl
}

variant x11 {
    depends_lib-append port:xorg-libXv
    depends_lib-append port:xorg-libXaw
    depends_lib-append port:xpm
    configure.args-append --x-includes=${prefix}/include
    configure.args-append --x-libraries=${prefix}/lib
    configure.args-delete --without-x
}

livecheck.type  none
