{% set version = "4.2" %}

package:
  name: ffmpeg
  version: {{ version }}

source:
  - url: https://ffmpeg.org/releases/ffmpeg-{{ version }}.tar.gz  # [not win]
    sha256: 9353228c2a397d1c62df7ca16033ec8a0cd2b12296de83a1c74948fe7395bb87  # [not win]

  - url: file:///c:/Users/circleci/project/tmp/ffmpeg-{{ version }}-win64-shared-dev-lgpl.tar.gz  # [win]
    sha256: "{{ environ.get('FFMPEG_SHA') }}"  # [win]

build:
  number: 1
  run_exports:
  # seems to be minor version compatibility
  # https://abi-laboratory.pro/tracker/timeline/ffmpeg/
    - {{ pin_subpackage('ffmpeg', max_pin='x.x') }}

requirements:
  build:
    - {{ compiler("c") }}
    - {{ compiler("cxx") }}
    - pkg-config  # [not win]
    - libtool  # [not win]
    - nasm  # [not win]
    - lame  # [not win]
    - make  # [not win]
  host:
    - bzip2
    - libpng
    - freetype
    - gnutls  # [not win]
    - libiconv
    - zlib
    - openh264  # [not win]
    - lame  # [not win]
    - gmp  # [unix]
    - nettle # [not win]
  run:
    - bzip2
    - libpng
    - freetype
    - gnutls  # [not win]
    - libiconv
    - zlib
    - openh264  # [not win]
    - lame  # [not win]
    - gmp  # [unix]
    - nettle  # [not win]

test:
  commands:
    - ffmpeg --help
    - ffmpeg -loglevel panic -protocols | grep "https"  # [not win]
    - ffmpeg -loglevel panic -codecs | grep "libmp3lame"  # [not win]
    - ffmpeg -loglevel panic -codecs | grep "DEVI.S zlib"  # [unix]
    - ffmpeg -loglevel panic -codecs | grep "DEV.LS h264"  # [unix]
    - ffmpeg -loglevel panic -codecs | grep "libopenh264"  # [unix]
    # Verify dynamic libraries on all systems
    {% set ffmpeg_libs = [
        "avcodec",
        "avdevice",
        "swresample",
        "avfilter",
        "swresample",
        "avcodec",
        "avformat",
        "swscale",
        "avresample"
    ] %}
    {% for each_ffmpeg_lib in ffmpeg_libs %}
    - test -f $PREFIX/lib/lib{{ each_ffmpeg_lib }}.dylib  # [osx]
    - test -f $PREFIX/lib/lib{{ each_ffmpeg_lib }}.so     # [linux]
    {% endfor %}
    - conda inspect linkages -p $PREFIX $PKG_NAME  # [not win]
    - conda inspect objects -p $PREFIX $PKG_NAME  # [osx]

about:
  home: http://www.ffmpeg.org/
  license: LGPL
  license_file: COPYING.LGPLv2.1  # [unix]
  summary: Cross-platform solution to record, convert and stream audio and video.
