diff --git a/Package.swift b/Package.swift index ec29330..5a83f4a 100644 --- a/Package.swift +++ b/Package.swift @@ -1,10 +1,11 @@ -// swift-tools-version:5.2 +// swift-tools-version:5.3 // The swift-tools-version declares the minimum version of Swift required to build this package. import PackageDescription let package = Package( name: "SwiftFFmpeg", + platforms: [.iOS(.v9), .macOS(.v10_10), .tvOS(.v10)], products: [ .library( name: "SwiftFFmpeg", @@ -12,14 +13,75 @@ let package = Package( ) ], targets: [ - .systemLibrary( - name: "CFFmpeg", - pkgConfig: "libavformat" - ), .target( name: "SwiftFFmpeg", dependencies: ["CFFmpeg"] ), + .target( + name: "CFFmpeg", + dependencies: [ + "libavcodec", + "libavdevice", + "libavfilter", + "libavformat", + "libavutil", + "libswresample", + "libswscale", + ], + linkerSettings: [ + .linkedLibrary("z"), + .linkedLibrary("bz2"), + .linkedLibrary("iconv"), + .linkedLibrary("lzma"), + .linkedFramework("Security"), + .linkedFramework("CoreMedia"), + .linkedFramework("CoreVideo"), + .linkedFramework("AudioToolbox"), + .linkedFramework("VideoToolbox"), + .linkedFramework("OpenGL"), + .linkedFramework("CoreImage"), + .linkedFramework("AppKit"), + ] + ), + .binaryTarget( + name: "libavcodec", + url: "https://github.com/sunlubo/SwiftFFmpeg/blob/master/xcframework/libavcodec.zip?raw=true", + checksum: "97f406b33946c1ab941af7dd02991e5cc3703779bb018de8ff265eb7a6d236fa" + ), + .binaryTarget( + name: "libavdevice", + url: + "https://github.com/sunlubo/SwiftFFmpeg/blob/master/xcframework/libavdevice.zip?raw=true", + checksum: "87738dff91380bd23de288e8702f0aa5511d80895c0974daba13dc117bdd599c" + ), + .binaryTarget( + name: "libavfilter", + url: + "https://github.com/sunlubo/SwiftFFmpeg/blob/master/xcframework/libavfilter.zip?raw=true", + checksum: "cb9b72b3cd923c9b065041cf6a87e164264f16eb282ea338b15bdae6dd5a3d15" + ), + .binaryTarget( + name: "libavformat", + url: + "https://github.com/sunlubo/SwiftFFmpeg/blob/master/xcframework/libavformat.zip?raw=true", + checksum: "9def922d249207ed7be7aebdab7bbd2ff3bc41187dcb0bd77c8e216630407e00" + ), + .binaryTarget( + name: "libavutil", + url: "https://github.com/sunlubo/SwiftFFmpeg/blob/master/xcframework/libavutil.zip?raw=true", + checksum: "3ca05b51466e4fec332b5c1c607b228a67f4eb7a89e09944d19550474214f4e2" + ), + .binaryTarget( + name: "libswresample", + url: + "https://github.com/sunlubo/SwiftFFmpeg/blob/master/xcframework/libswresample.zip?raw=true", + checksum: "76aa9805c67a040a729eee4599162a982f4bbd2609e7c92b7a3c589159259a7a" + ), + .binaryTarget( + name: "libswscale", + url: "https://github.com/sunlubo/SwiftFFmpeg/blob/master/xcframework/libswscale.zip?raw=true", + checksum: "b5e47c27f44c6818cc11a41fe43535e7bdb25d171a0b5c4984b52b303c7e53b1" + ), .target( name: "SwiftFFmpegExamples", dependencies: ["SwiftFFmpeg"] diff --git a/Sources/CFFmpeg/avcodec_shim.h b/Sources/CFFmpeg/include/avcodec_shim.h similarity index 100% rename from Sources/CFFmpeg/avcodec_shim.h rename to Sources/CFFmpeg/include/avcodec_shim.h diff --git a/Sources/CFFmpeg/avdevice_shim.h b/Sources/CFFmpeg/include/avdevice_shim.h similarity index 100% rename from Sources/CFFmpeg/avdevice_shim.h rename to Sources/CFFmpeg/include/avdevice_shim.h diff --git a/Sources/CFFmpeg/avfilter_shim.h b/Sources/CFFmpeg/include/avfilter_shim.h similarity index 100% rename from Sources/CFFmpeg/avfilter_shim.h rename to Sources/CFFmpeg/include/avfilter_shim.h diff --git a/Sources/CFFmpeg/avformat_shim.h b/Sources/CFFmpeg/include/avformat_shim.h similarity index 100% rename from Sources/CFFmpeg/avformat_shim.h rename to Sources/CFFmpeg/include/avformat_shim.h diff --git a/Sources/CFFmpeg/avutil_shim.h b/Sources/CFFmpeg/include/avutil_shim.h similarity index 100% rename from Sources/CFFmpeg/avutil_shim.h rename to Sources/CFFmpeg/include/avutil_shim.h diff --git a/Sources/CFFmpeg/swresample_shim.h b/Sources/CFFmpeg/include/swresample_shim.h similarity index 100% rename from Sources/CFFmpeg/swresample_shim.h rename to Sources/CFFmpeg/include/swresample_shim.h diff --git a/Sources/CFFmpeg/swscale_shim.h b/Sources/CFFmpeg/include/swscale_shim.h similarity index 100% rename from Sources/CFFmpeg/swscale_shim.h rename to Sources/CFFmpeg/include/swscale_shim.h diff --git a/Sources/CFFmpeg/module.modulemap b/Sources/CFFmpeg/module.modulemap deleted file mode 100644 index debc676..0000000 --- a/Sources/CFFmpeg/module.modulemap +++ /dev/null @@ -1,37 +0,0 @@ -module CFFmpeg [system] { - module AVUtil { - header "avutil_shim.h" - link "avutil" - export * - } - module AVFormat { - header "avformat_shim.h" - link "avformat" - export * - } - module AVCodec { - header "avcodec_shim.h" - link "avcodec" - export * - } - module AVFilter { - header "avfilter_shim.h" - link "avfilter" - export * - } - module AVDevice { - header "avdevice_shim.h" - link "avdevice" - export * - } - module Swscale { - header "swscale_shim.h" - link "swscale" - export * - } - module Swresample { - header "swresample_shim.h" - link "swresample" - export * - } -} diff --git a/Sources/CFFmpeg/src/empty.c b/Sources/CFFmpeg/src/empty.c new file mode 100644 index 0000000..2d74ff4 --- /dev/null +++ b/Sources/CFFmpeg/src/empty.c @@ -0,0 +1,7 @@ +// +// empty.c +// CFFmpeg +// +// Created by sunlubo on 2020/8/6. +// Copyright © 2019-2020 sunlubo. All rights reserved. +// diff --git a/scripts/build.sh b/scripts/build.sh index 0c57a75..1fc9acb 100755 --- a/scripts/build.sh +++ b/scripts/build.sh @@ -2,7 +2,7 @@ FFMPEG_VERSION=4.3.1 FFMPEG_SOURCE_DIR=FFmpeg-n$FFMPEG_VERSION -FFMPEG_LIBS="libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswresample libswscale" +FFMPEG_LIBS="libavcodec libavdevice libavfilter libavformat libavutil libswresample libswscale" PREFIX=`pwd`/output ARCH="x86_64" @@ -20,12 +20,11 @@ cd $FFMPEG_SOURCE_DIR ./configure \ --prefix=$PREFIX \ - --enable-gpl \ --enable-version3 \ --disable-programs \ --disable-doc \ --arch=$ARCH \ - --extra-cflags="-arch $ARCH -march=native -fno-stack-check" \ + --extra-cflags="-fno-stack-check" \ --disable-debug || exit 1 make clean diff --git a/xcframework/libavcodec.zip b/xcframework/libavcodec.zip index a85f75a..a709187 100644 Binary files a/xcframework/libavcodec.zip and b/xcframework/libavcodec.zip differ diff --git a/xcframework/libavdevice.zip b/xcframework/libavdevice.zip index 854c0f4..ba72a02 100644 Binary files a/xcframework/libavdevice.zip and b/xcframework/libavdevice.zip differ diff --git a/xcframework/libavfilter.zip b/xcframework/libavfilter.zip index 07fe110..83fbe4a 100644 Binary files a/xcframework/libavfilter.zip and b/xcframework/libavfilter.zip differ diff --git a/xcframework/libavformat.zip b/xcframework/libavformat.zip index e4e3399..d0bb520 100644 Binary files a/xcframework/libavformat.zip and b/xcframework/libavformat.zip differ diff --git a/xcframework/libavutil.zip b/xcframework/libavutil.zip index 03a14a9..d9ea57e 100644 Binary files a/xcframework/libavutil.zip and b/xcframework/libavutil.zip differ diff --git a/xcframework/libpostproc.zip b/xcframework/libpostproc.zip deleted file mode 100644 index 83abb30..0000000 Binary files a/xcframework/libpostproc.zip and /dev/null differ diff --git a/xcframework/libswresample.zip b/xcframework/libswresample.zip index f5ca515..fe4a640 100644 Binary files a/xcframework/libswresample.zip and b/xcframework/libswresample.zip differ diff --git a/xcframework/libswscale.zip b/xcframework/libswscale.zip index 28abfa1..9b0e627 100644 Binary files a/xcframework/libswscale.zip and b/xcframework/libswscale.zip differ