diff --git a/.github/workflows/android-build-scripts.yml b/.github/workflows/android-build-scripts.yml index 8caf15c..e91cd46 100644 --- a/.github/workflows/android-build-scripts.yml +++ b/.github/workflows/android-build-scripts.yml @@ -14,7 +14,15 @@ on: - 'android.sh' pull_request: branches: + - development - main + paths: + - '.github/workflows/android-build-scripts.yml' + - 'android/**' + - '!android/README.md' + - 'scripts/**' + - 'tools/**' + - 'android.sh' jobs: build-main-on-linux: @@ -133,3 +141,32 @@ jobs: - name: print ffbuild logs if: ${{ failure() }} run: '[[ -f ./src/ffmpeg/ffbuild/config.log ]] && tail -50 ./src/ffmpeg/ffbuild/config.log' + build-main-without-ffmpeg-kit-protocols-on-linux: + name: build without ffmpeg-kit protocols + runs-on: ubuntu-20.04 + strategy: + matrix: + ndk-version: [ 'r22b-linux-x86_64' ] + defaults: + run: + shell: bash + steps: + - uses: actions/checkout@v2 + - name: set up adopt jdk 11 + uses: actions/setup-java@v3 + with: + distribution: 'adopt' + java-version: '11' + - name: set up android ndk + run: | + curl -s "https://dl.google.com/android/repository/android-ndk-${{ matrix.ndk-version }}.zip" -o ndk.zip + unzip -q -o ndk.zip -d .ndk + echo "ANDROID_NDK_ROOT=$PWD/.ndk/$(ls .ndk)" >> $GITHUB_ENV + - name: run the build script + run: ./android.sh --no-ffmpeg-kit-protocols --disable-x86 --disable-x86-64 --disable-arm-v7a --disable-arm-v7a-neon + - name: print build logs + if: ${{ always() }} + run: cat build.log + - name: print ffbuild logs + if: ${{ failure() }} + run: '[[ -f ./src/ffmpeg/ffbuild/config.log ]] && tail -50 ./src/ffmpeg/ffbuild/config.log' diff --git a/.github/workflows/ios-build-scripts.yml b/.github/workflows/ios-build-scripts.yml index 8990d8c..7d2ad13 100644 --- a/.github/workflows/ios-build-scripts.yml +++ b/.github/workflows/ios-build-scripts.yml @@ -15,10 +15,12 @@ on: - 'ios.sh' pull_request: branches: + - development - main paths: - '.github/workflows/ios-build-scripts.yml' - 'apple/**' + - '!apple/README.md' - 'scripts/**' - 'tools/**' - 'apple.sh' diff --git a/.github/workflows/macos-build-scripts.yml b/.github/workflows/macos-build-scripts.yml index b5dbea3..c06282c 100644 --- a/.github/workflows/macos-build-scripts.yml +++ b/.github/workflows/macos-build-scripts.yml @@ -15,7 +15,16 @@ on: - 'macos.sh' pull_request: branches: + - development - main + paths: + - '.github/workflows/macos-build-scripts.yml' + - 'apple/**' + - '!apple/README.md' + - 'scripts/**' + - 'tools/**' + - 'apple.sh' + - 'macos.sh' jobs: build-main-on-macos-bigsur: diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml index 0ca8c1a..171bb10 100644 --- a/.github/workflows/stale.yml +++ b/.github/workflows/stale.yml @@ -2,23 +2,25 @@ name: mark stale issues and pull requests on: schedule: - - cron: "0 0 * * *" + - cron: "30 1 * * *" jobs: stale: runs-on: ubuntu-latest + permissions: + issues: write + pull-requests: write steps: - - uses: actions/stale@v4 + - uses: actions/stale@v5 with: repo-token: ${{ secrets.GITHUB_TOKEN }} - stale-issue-message: 'This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.' - stale-pr-message: 'This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.' + days-before-stale: 60 + stale-issue-message: 'This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.' + stale-pr-message: 'This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.' + close-issue-message: 'This issue was closed because it has been stalled for 7 days with no activity.' + close-pr-message: 'This PR was closed because it has been stalled for 7 days with no activity.' stale-issue-label: 'no-issue-activity' stale-pr-label: 'no-pr-activity' - exempt-issue-labels: 'enhancement' - exempt-pr-labels: 'enhancement' + exempt-issue-labels: 'enhancement,unreleased' + exempt-pr-labels: 'enhancement,unreleased' exempt-all-assignees: 'true' - -permissions: - issues: write - pull-requests: write \ No newline at end of file diff --git a/.github/workflows/tvos-build-scripts.yml b/.github/workflows/tvos-build-scripts.yml index 9567643..d31d5be 100644 --- a/.github/workflows/tvos-build-scripts.yml +++ b/.github/workflows/tvos-build-scripts.yml @@ -15,7 +15,16 @@ on: - 'tvos.sh' pull_request: branches: + - development - main + paths: + - '.github/workflows/tvos-build-scripts.yml' + - 'apple/**' + - '!apple/README.md' + - 'scripts/**' + - 'tools/**' + - 'apple.sh' + - 'tvos.sh' jobs: build-main-on-macos-bigsur: diff --git a/README.md b/README.md index 725daae..bfffa70 100644 --- a/README.md +++ b/README.md @@ -118,16 +118,17 @@ include them. The exact version number of `FFmpeg` is obtained using `git describe --tags`. `dev` part in the version string indicates that `FFmpeg` source code is cloned from the `FFmpeg` `master` branch. -| Platforms | FFmpegKit Version | FFmpeg Version | Release Date | -|:----------------:|:--------------------------------------------------------------------------------------------:| :------------: |:------------:| -| Flutter | [4.5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/flutter.v4.5.1) | 4.5-dev-3393 | Jan 02, 2022 | -| React Native | [4.5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/react.native.v4.5.1) | 4.5-dev-3393 | Jan 02, 2022 | -| Android | [4.5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/v4.5.1) | 4.5-dev-3393 | Jan 01, 2022 | -| Apple | [4.5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/v4.5.1) | 4.5-dev-3393 | Jan 14, 2022 | -| Flutter | [4.5.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/flutter.v4.5.0) | 4.5-dev-2008 | Oct 05, 2021 | -| React Native | [4.5.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/react.native.v4.5.0) | 4.5-dev-2008 | Oct 01, 2021 | -| Android
Apple | [4.5](https://github.com/arthenica/ffmpeg-kit/releases/tag/v4.5) | 4.5-dev-2008 | Sep 18, 2021 | -| Android
Apple | [4.4](https://github.com/arthenica/ffmpeg-kit/releases/tag/v4.4) | 4.4-dev-3015 | Mar 03, 2021 | +| Platforms | FFmpegKit Version | FFmpeg Version | Release Date | +|:----------------:|:----------------------------------------------------------------------------------:| :------------: |:------------:| +| React Native | [4.5.2](https://github.com/tanersener/ffmpeg-kit/releases/tag/react.native.v4.5.2) | 4.5-dev-3393 | May 25, 2022 | +| Flutter | [4.5.1](https://github.com/tanersener/ffmpeg-kit/releases/tag/flutter.v4.5.1) | 4.5-dev-3393 | Jan 02, 2022 | +| React Native | [4.5.1](https://github.com/tanersener/ffmpeg-kit/releases/tag/react.native.v4.5.1) | 4.5-dev-3393 | Jan 02, 2022 | +| Android | [4.5.1](https://github.com/tanersener/ffmpeg-kit/releases/tag/v4.5.1) | 4.5-dev-3393 | Jan 01, 2022 | +| Apple | [4.5.1](https://github.com/tanersener/ffmpeg-kit/releases/tag/v4.5.1) | 4.5-dev-3393 | Dec 30, 2021 | +| Flutter | [4.5.0](https://github.com/tanersener/ffmpeg-kit/releases/tag/flutter.v4.5.0) | 4.5-dev-2008 | Oct 05, 2021 | +| React Native | [4.5.0](https://github.com/tanersener/ffmpeg-kit/releases/tag/react.native.v4.5.0) | 4.5-dev-2008 | Oct 01, 2021 | +| Android
Apple | [4.5](https://github.com/tanersener/ffmpeg-kit/releases/tag/v4.5) | 4.5-dev-2008 | Sep 18, 2021 | +| Android
Apple | [4.4](https://github.com/tanersener/ffmpeg-kit/releases/tag/v4.4) | 4.4-dev-3015 | Mar 03, 2021 | ### 10. LTS Releases diff --git a/android/README.md b/android/README.md index 3702df8..78e664a 100644 --- a/android/README.md +++ b/android/README.md @@ -77,7 +77,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director } dependencies { - implementation 'com.arthenica:ffmpeg-kit-full:4.5.1' + implementation 'com.arthenica:ffmpeg-kit-full:4.5.1-1' } ``` diff --git a/react-native/android/build.gradle b/react-native/android/build.gradle index e509ee4..e00921b 100644 --- a/react-native/android/build.gradle +++ b/react-native/android/build.gradle @@ -31,8 +31,8 @@ android { defaultConfig { minSdkVersion safeExtGet('ffmpegKitPackage', 'https').contains("-lts") ? 16 : 24 targetSdkVersion 30 - versionCode 451 - versionName "4.5.1" + versionCode 452 + versionName "4.5.2" } buildTypes { diff --git a/react-native/android/src/main/java/com/arthenica/ffmpegkit/reactnative/FFmpegKitReactNativeModule.java b/react-native/android/src/main/java/com/arthenica/ffmpegkit/reactnative/FFmpegKitReactNativeModule.java index 7f9ce9d..bccdcee 100644 --- a/react-native/android/src/main/java/com/arthenica/ffmpegkit/reactnative/FFmpegKitReactNativeModule.java +++ b/react-native/android/src/main/java/com/arthenica/ffmpegkit/reactnative/FFmpegKitReactNativeModule.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Taner Sener + * Copyright (c) 2021-2022 Taner Sener * * This file is part of FFmpegKit. * @@ -47,7 +47,6 @@ import com.arthenica.ffmpegkit.Signal; import com.arthenica.ffmpegkit.Statistics; import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.BaseActivityEventListener; -import com.facebook.react.bridge.LifecycleEventListener; import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactContextBaseJavaModule; @@ -75,7 +74,7 @@ import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.atomic.AtomicBoolean; -public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule implements LifecycleEventListener { +public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule { public static final String LIBRARY_NAME = "ffmpeg-kit-react-native"; public static final String PLATFORM_NAME = "android"; @@ -131,7 +130,6 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule imple this.asyncExecutorService = Executors.newFixedThreadPool(asyncWriteToPipeConcurrencyLimit); if (reactContext != null) { - reactContext.addLifecycleEventListener(this); registerGlobalCallbacks(reactContext); } } @@ -151,19 +149,6 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule imple return "FFmpegKitReactNativeModule"; } - @Override - public void onHostResume() { - } - - @Override - public void onHostPause() { - } - - @Override - public void onHostDestroy() { - this.asyncExecutorService.shutdown(); - } - protected void registerGlobalCallbacks(final ReactApplicationContext reactContext) { FFmpegKitConfig.enableFFmpegSessionCompleteCallback(session -> { final DeviceEventManagerModule.RCTDeviceEventEmitter jsModule = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class); @@ -984,6 +969,12 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule imple promise.resolve(toStringArray(Packages.getExternalLibraries())); } + @ReactMethod + public void uninit(final Promise promise) { + this.asyncExecutorService.shutdown(); + promise.resolve(null); + } + protected void enableLogs() { logsEnabled.compareAndSet(false, true); } @@ -1144,16 +1135,18 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule imple } protected static WritableMap toMap(final MediaInformation mediaInformation) { - WritableMap map = Arguments.createMap(); - if (mediaInformation != null) { + WritableMap map = Arguments.createMap(); + JSONObject allProperties = mediaInformation.getAllProperties(); if (allProperties != null) { map = toMap(allProperties); } - } - return map; + return map; + } else { + return null; + } } protected static WritableMap toMap(final JSONObject jsonObject) { diff --git a/react-native/ios/FFmpegKitReactNativeModule.m b/react-native/ios/FFmpegKitReactNativeModule.m index 9babaa4..7465cda 100644 --- a/react-native/ios/FFmpegKitReactNativeModule.m +++ b/react-native/ios/FFmpegKitReactNativeModule.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Taner Sener + * Copyright (c) 2021-2022 Taner Sener * * This file is part of FFmpegKit. * @@ -695,6 +695,10 @@ RCT_EXPORT_METHOD(getExternalLibraries:(RCTPromiseResolveBlock)resolve rejecter: resolve([Packages getExternalLibraries]); } +RCT_EXPORT_METHOD(uninit:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { + resolve(nil); +} + - (void)enableLogs { logsEnabled = true; } @@ -724,16 +728,14 @@ RCT_EXPORT_METHOD(getExternalLibraries:(RCTPromiseResolveBlock)resolve rejecter: dictionary[KEY_SESSION_START_TIME] = [NSNumber numberWithDouble:[[session getStartTime] timeIntervalSince1970]*1000]; dictionary[KEY_SESSION_COMMAND] = [session getCommand]; - if ([session isFFprobe]) { - if ([session isMediaInformation]) { - MediaInformationSession *mediaInformationSession = (MediaInformationSession*)session; - dictionary[KEY_SESSION_MEDIA_INFORMATION] = [FFmpegKitReactNativeModule toMediaInformationDictionary:[mediaInformationSession getMediaInformation]]; - dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_MEDIA_INFORMATION]; - } else { - dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_FFPROBE]; - } - } else { + if ([session isFFmpeg]) { dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_FFMPEG]; + } else if ([session isFFprobe]) { + dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_FFPROBE]; + } else if ([session isMediaInformation]) { + MediaInformationSession *mediaInformationSession = (MediaInformationSession*)session; + dictionary[KEY_SESSION_MEDIA_INFORMATION] = [FFmpegKitReactNativeModule toMediaInformationDictionary:[mediaInformationSession getMediaInformation]]; + dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_MEDIA_INFORMATION]; } return dictionary; diff --git a/react-native/package.json b/react-native/package.json index b1027c1..858566b 100644 --- a/react-native/package.json +++ b/react-native/package.json @@ -1,6 +1,6 @@ { "name": "ffmpeg-kit-react-native", - "version": "4.5.1", + "version": "4.5.2", "description": "FFmpeg Kit for React Native", "main": "src/index", "types": "src/index.d.ts", diff --git a/react-native/src/index.d.ts b/react-native/src/index.d.ts index 5836754..8de2b56 100644 --- a/react-native/src/index.d.ts +++ b/react-native/src/index.d.ts @@ -92,6 +92,8 @@ declare module 'ffmpeg-kit-react-native' { static init(): Promise; + static uninit(): Promise; + static enableRedirection(): Promise; static disableRedirection(): Promise; diff --git a/react-native/src/index.js b/react-native/src/index.js index 4b28ff5..03241f1 100644 --- a/react-native/src/index.js +++ b/react-native/src/index.js @@ -669,11 +669,12 @@ export class AbstractSession extends Session { } /** - * Cancels running the session. + * Cancels running the session. Only starts cancellation. Does not guarantee that session is cancelled when promise resolves. */ - cancel() { + async cancel() { + const sessionId = this.getSessionId(); if (sessionId === undefined) { - return FFmpegKitReactNativeModule.cancel(); + return Promise.reject(new Error('sessionId is not defined')); } else { return FFmpegKitReactNativeModule.cancelSession(sessionId); } @@ -811,6 +812,15 @@ export class FFmpegKitConfig { await FFmpegKitInitializer.initialize(); } + /** + * Uninitializes the library. + * + * Calling this method before application termination is recommended but not required. + */ + static async uninit() { + return FFmpegKitReactNativeModule.uninit(); + } + /** *

Enables log and statistics redirection. * @@ -1608,7 +1618,7 @@ class FFmpegKitFactory { } static getVersion() { - return "4.5.1"; + return "4.5.2"; } static getLogRedirectionStrategy(sessionId) { @@ -2474,7 +2484,7 @@ export class MediaInformation { /** * Returns duration. * - * @return media duration in milliseconds + * @return media duration in "seconds.microseconds" format */ getDuration() { return this.getStringProperty(MediaInformation.KEY_DURATION); diff --git a/scripts/android/ffmpeg.sh b/scripts/android/ffmpeg.sh index 08b4384..e2af2ac 100755 --- a/scripts/android/ffmpeg.sh +++ b/scripts/android/ffmpeg.sh @@ -401,7 +401,7 @@ ${SED_INLINE} 's/static int av_log_level/__thread int av_log_level/g' "${BASEDIR # 2. Enable ffmpeg-kit protocols if [[ ${NO_FFMPEG_KIT_PROTOCOLS} == "1" ]]; then - ${SED_INLINE} "s/ av_set_fd_close/\/\/av_set_fd_close/g" "${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/cpp/ffmpegkit.c 1>>"${BASEDIR}"/build.log 2>&1 + ${SED_INLINE} "s| av_set_saf|//av_set_saf|g" "${BASEDIR}"/android/ffmpeg-kit-android-lib/src/main/cpp/ffmpegkit.c 1>>"${BASEDIR}"/build.log 2>&1 echo -e "\nINFO: Disabled custom ffmpeg-kit protocols\n" 1>>"${BASEDIR}"/build.log 2>&1 else cat ../../tools/protocols/libavformat_file.c >> libavformat/file.c