Merge branch 'main' into development

pull/583/head
Taner Sener 3 years ago
commit 8148022090
  1. 37
      .github/workflows/android-build-scripts.yml
  2. 2
      .github/workflows/ios-build-scripts.yml
  3. 9
      .github/workflows/macos-build-scripts.yml
  4. 22
      .github/workflows/stale.yml
  5. 9
      .github/workflows/tvos-build-scripts.yml
  6. 19
      README.md
  7. 2
      android/README.md
  8. 4
      react-native/android/build.gradle
  9. 31
      react-native/android/src/main/java/com/arthenica/ffmpegkit/reactnative/FFmpegKitReactNativeModule.java
  10. 18
      react-native/ios/FFmpegKitReactNativeModule.m
  11. 2
      react-native/package.json
  12. 2
      react-native/src/index.d.ts
  13. 20
      react-native/src/index.js
  14. 2
      scripts/android/ffmpeg.sh

@ -14,7 +14,15 @@ on:
- 'android.sh' - 'android.sh'
pull_request: pull_request:
branches: branches:
- development
- main - main
paths:
- '.github/workflows/android-build-scripts.yml'
- 'android/**'
- '!android/README.md'
- 'scripts/**'
- 'tools/**'
- 'android.sh'
jobs: jobs:
build-main-on-linux: build-main-on-linux:
@ -133,3 +141,32 @@ jobs:
- name: print ffbuild logs - name: print ffbuild logs
if: ${{ failure() }} if: ${{ failure() }}
run: '[[ -f ./src/ffmpeg/ffbuild/config.log ]] && tail -50 ./src/ffmpeg/ffbuild/config.log' 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'

@ -15,10 +15,12 @@ on:
- 'ios.sh' - 'ios.sh'
pull_request: pull_request:
branches: branches:
- development
- main - main
paths: paths:
- '.github/workflows/ios-build-scripts.yml' - '.github/workflows/ios-build-scripts.yml'
- 'apple/**' - 'apple/**'
- '!apple/README.md'
- 'scripts/**' - 'scripts/**'
- 'tools/**' - 'tools/**'
- 'apple.sh' - 'apple.sh'

@ -15,7 +15,16 @@ on:
- 'macos.sh' - 'macos.sh'
pull_request: pull_request:
branches: branches:
- development
- main - main
paths:
- '.github/workflows/macos-build-scripts.yml'
- 'apple/**'
- '!apple/README.md'
- 'scripts/**'
- 'tools/**'
- 'apple.sh'
- 'macos.sh'
jobs: jobs:
build-main-on-macos-bigsur: build-main-on-macos-bigsur:

@ -2,23 +2,25 @@ name: mark stale issues and pull requests
on: on:
schedule: schedule:
- cron: "0 0 * * *" - cron: "30 1 * * *"
jobs: jobs:
stale: stale:
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps: steps:
- uses: actions/stale@v4 - uses: actions/stale@v5
with: with:
repo-token: ${{ secrets.GITHUB_TOKEN }} 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.' days-before-stale: 60
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.' 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-issue-label: 'no-issue-activity'
stale-pr-label: 'no-pr-activity' stale-pr-label: 'no-pr-activity'
exempt-issue-labels: 'enhancement' exempt-issue-labels: 'enhancement,unreleased'
exempt-pr-labels: 'enhancement' exempt-pr-labels: 'enhancement,unreleased'
exempt-all-assignees: 'true' exempt-all-assignees: 'true'
permissions:
issues: write
pull-requests: write

@ -15,7 +15,16 @@ on:
- 'tvos.sh' - 'tvos.sh'
pull_request: pull_request:
branches: branches:
- development
- main - main
paths:
- '.github/workflows/tvos-build-scripts.yml'
- 'apple/**'
- '!apple/README.md'
- 'scripts/**'
- 'tools/**'
- 'apple.sh'
- 'tvos.sh'
jobs: jobs:
build-main-on-macos-bigsur: build-main-on-macos-bigsur:

@ -119,15 +119,16 @@ The exact version number of `FFmpeg` is obtained using `git describe --tags`. `d
indicates that `FFmpeg` source code is cloned from the `FFmpeg` `master` branch. indicates that `FFmpeg` source code is cloned from the `FFmpeg` `master` branch.
| Platforms | FFmpegKit Version | FFmpeg Version | Release Date | | 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.2](https://github.com/tanersener/ffmpeg-kit/releases/tag/react.native.v4.5.2) | 4.5-dev-3393 | May 25, 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 | | Flutter | [4.5.1](https://github.com/tanersener/ffmpeg-kit/releases/tag/flutter.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 | | 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 |
| Apple | [4.5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/v4.5.1) | 4.5-dev-3393 | Jan 14, 2022 | | Android | [4.5.1](https://github.com/tanersener/ffmpeg-kit/releases/tag/v4.5.1) | 4.5-dev-3393 | Jan 01, 2022 |
| Flutter | [4.5.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/flutter.v4.5.0) | 4.5-dev-2008 | Oct 05, 2021 | | Apple | [4.5.1](https://github.com/tanersener/ffmpeg-kit/releases/tag/v4.5.1) | 4.5-dev-3393 | Dec 30, 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 | | Flutter | [4.5.0](https://github.com/tanersener/ffmpeg-kit/releases/tag/flutter.v4.5.0) | 4.5-dev-2008 | Oct 05, 2021 |
| Android<br>Apple | [4.5](https://github.com/arthenica/ffmpeg-kit/releases/tag/v4.5) | 4.5-dev-2008 | Sep 18, 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<br>Apple | [4.4](https://github.com/arthenica/ffmpeg-kit/releases/tag/v4.4) | 4.4-dev-3015 | Mar 03, 2021 | | Android<br>Apple | [4.5](https://github.com/tanersener/ffmpeg-kit/releases/tag/v4.5) | 4.5-dev-2008 | Sep 18, 2021 |
| Android<br>Apple | [4.4](https://github.com/tanersener/ffmpeg-kit/releases/tag/v4.4) | 4.4-dev-3015 | Mar 03, 2021 |
### 10. LTS Releases ### 10. LTS Releases

@ -77,7 +77,7 @@ All libraries created by `android.sh` can be found under the `prebuilt` director
} }
dependencies { dependencies {
implementation 'com.arthenica:ffmpeg-kit-full:4.5.1' implementation 'com.arthenica:ffmpeg-kit-full:4.5.1-1'
} }
``` ```

@ -31,8 +31,8 @@ android {
defaultConfig { defaultConfig {
minSdkVersion safeExtGet('ffmpegKitPackage', 'https').contains("-lts") ? 16 : 24 minSdkVersion safeExtGet('ffmpegKitPackage', 'https').contains("-lts") ? 16 : 24
targetSdkVersion 30 targetSdkVersion 30
versionCode 451 versionCode 452
versionName "4.5.1" versionName "4.5.2"
} }
buildTypes { buildTypes {

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021 Taner Sener * Copyright (c) 2021-2022 Taner Sener
* *
* This file is part of FFmpegKit. * This file is part of FFmpegKit.
* *
@ -47,7 +47,6 @@ import com.arthenica.ffmpegkit.Signal;
import com.arthenica.ffmpegkit.Statistics; import com.arthenica.ffmpegkit.Statistics;
import com.facebook.react.bridge.Arguments; import com.facebook.react.bridge.Arguments;
import com.facebook.react.bridge.BaseActivityEventListener; import com.facebook.react.bridge.BaseActivityEventListener;
import com.facebook.react.bridge.LifecycleEventListener;
import com.facebook.react.bridge.Promise; import com.facebook.react.bridge.Promise;
import com.facebook.react.bridge.ReactApplicationContext; import com.facebook.react.bridge.ReactApplicationContext;
import com.facebook.react.bridge.ReactContextBaseJavaModule; import com.facebook.react.bridge.ReactContextBaseJavaModule;
@ -75,7 +74,7 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors; import java.util.concurrent.Executors;
import java.util.concurrent.atomic.AtomicBoolean; 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 LIBRARY_NAME = "ffmpeg-kit-react-native";
public static final String PLATFORM_NAME = "android"; public static final String PLATFORM_NAME = "android";
@ -131,7 +130,6 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule imple
this.asyncExecutorService = Executors.newFixedThreadPool(asyncWriteToPipeConcurrencyLimit); this.asyncExecutorService = Executors.newFixedThreadPool(asyncWriteToPipeConcurrencyLimit);
if (reactContext != null) { if (reactContext != null) {
reactContext.addLifecycleEventListener(this);
registerGlobalCallbacks(reactContext); registerGlobalCallbacks(reactContext);
} }
} }
@ -151,19 +149,6 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule imple
return "FFmpegKitReactNativeModule"; return "FFmpegKitReactNativeModule";
} }
@Override
public void onHostResume() {
}
@Override
public void onHostPause() {
}
@Override
public void onHostDestroy() {
this.asyncExecutorService.shutdown();
}
protected void registerGlobalCallbacks(final ReactApplicationContext reactContext) { protected void registerGlobalCallbacks(final ReactApplicationContext reactContext) {
FFmpegKitConfig.enableFFmpegSessionCompleteCallback(session -> { FFmpegKitConfig.enableFFmpegSessionCompleteCallback(session -> {
final DeviceEventManagerModule.RCTDeviceEventEmitter jsModule = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class); final DeviceEventManagerModule.RCTDeviceEventEmitter jsModule = reactContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter.class);
@ -984,6 +969,12 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule imple
promise.resolve(toStringArray(Packages.getExternalLibraries())); promise.resolve(toStringArray(Packages.getExternalLibraries()));
} }
@ReactMethod
public void uninit(final Promise promise) {
this.asyncExecutorService.shutdown();
promise.resolve(null);
}
protected void enableLogs() { protected void enableLogs() {
logsEnabled.compareAndSet(false, true); logsEnabled.compareAndSet(false, true);
} }
@ -1144,16 +1135,18 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule imple
} }
protected static WritableMap toMap(final MediaInformation mediaInformation) { protected static WritableMap toMap(final MediaInformation mediaInformation) {
if (mediaInformation != null) {
WritableMap map = Arguments.createMap(); WritableMap map = Arguments.createMap();
if (mediaInformation != null) {
JSONObject allProperties = mediaInformation.getAllProperties(); JSONObject allProperties = mediaInformation.getAllProperties();
if (allProperties != null) { if (allProperties != null) {
map = toMap(allProperties); map = toMap(allProperties);
} }
}
return map; return map;
} else {
return null;
}
} }
protected static WritableMap toMap(final JSONObject jsonObject) { protected static WritableMap toMap(final JSONObject jsonObject) {

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2021 Taner Sener * Copyright (c) 2021-2022 Taner Sener
* *
* This file is part of FFmpegKit. * This file is part of FFmpegKit.
* *
@ -695,6 +695,10 @@ RCT_EXPORT_METHOD(getExternalLibraries:(RCTPromiseResolveBlock)resolve rejecter:
resolve([Packages getExternalLibraries]); resolve([Packages getExternalLibraries]);
} }
RCT_EXPORT_METHOD(uninit:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
resolve(nil);
}
- (void)enableLogs { - (void)enableLogs {
logsEnabled = true; 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_START_TIME] = [NSNumber numberWithDouble:[[session getStartTime] timeIntervalSince1970]*1000];
dictionary[KEY_SESSION_COMMAND] = [session getCommand]; dictionary[KEY_SESSION_COMMAND] = [session getCommand];
if ([session isFFprobe]) { if ([session isFFmpeg]) {
if ([session isMediaInformation]) { 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; MediaInformationSession *mediaInformationSession = (MediaInformationSession*)session;
dictionary[KEY_SESSION_MEDIA_INFORMATION] = [FFmpegKitReactNativeModule toMediaInformationDictionary:[mediaInformationSession getMediaInformation]]; dictionary[KEY_SESSION_MEDIA_INFORMATION] = [FFmpegKitReactNativeModule toMediaInformationDictionary:[mediaInformationSession getMediaInformation]];
dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_MEDIA_INFORMATION]; dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_MEDIA_INFORMATION];
} else {
dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_FFPROBE];
}
} else {
dictionary[KEY_SESSION_TYPE] = [NSNumber numberWithInt:SESSION_TYPE_FFMPEG];
} }
return dictionary; return dictionary;

@ -1,6 +1,6 @@
{ {
"name": "ffmpeg-kit-react-native", "name": "ffmpeg-kit-react-native",
"version": "4.5.1", "version": "4.5.2",
"description": "FFmpeg Kit for React Native", "description": "FFmpeg Kit for React Native",
"main": "src/index", "main": "src/index",
"types": "src/index.d.ts", "types": "src/index.d.ts",

@ -92,6 +92,8 @@ declare module 'ffmpeg-kit-react-native' {
static init(): Promise<void>; static init(): Promise<void>;
static uninit(): Promise<void>;
static enableRedirection(): Promise<void>; static enableRedirection(): Promise<void>;
static disableRedirection(): Promise<void>; static disableRedirection(): Promise<void>;

@ -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) { if (sessionId === undefined) {
return FFmpegKitReactNativeModule.cancel(); return Promise.reject(new Error('sessionId is not defined'));
} else { } else {
return FFmpegKitReactNativeModule.cancelSession(sessionId); return FFmpegKitReactNativeModule.cancelSession(sessionId);
} }
@ -811,6 +812,15 @@ export class FFmpegKitConfig {
await FFmpegKitInitializer.initialize(); await FFmpegKitInitializer.initialize();
} }
/**
* Uninitializes the library.
*
* Calling this method before application termination is recommended but not required.
*/
static async uninit() {
return FFmpegKitReactNativeModule.uninit();
}
/** /**
* <p>Enables log and statistics redirection. * <p>Enables log and statistics redirection.
* *
@ -1608,7 +1618,7 @@ class FFmpegKitFactory {
} }
static getVersion() { static getVersion() {
return "4.5.1"; return "4.5.2";
} }
static getLogRedirectionStrategy(sessionId) { static getLogRedirectionStrategy(sessionId) {
@ -2474,7 +2484,7 @@ export class MediaInformation {
/** /**
* Returns duration. * Returns duration.
* *
* @return media duration in milliseconds * @return media duration in "seconds.microseconds" format
*/ */
getDuration() { getDuration() {
return this.getStringProperty(MediaInformation.KEY_DURATION); return this.getStringProperty(MediaInformation.KEY_DURATION);

@ -401,7 +401,7 @@ ${SED_INLINE} 's/static int av_log_level/__thread int av_log_level/g' "${BASEDIR
# 2. Enable ffmpeg-kit protocols # 2. Enable ffmpeg-kit protocols
if [[ ${NO_FFMPEG_KIT_PROTOCOLS} == "1" ]]; then 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 echo -e "\nINFO: Disabled custom ffmpeg-kit protocols\n" 1>>"${BASEDIR}"/build.log 2>&1
else else
cat ../../tools/protocols/libavformat_file.c >> libavformat/file.c cat ../../tools/protocols/libavformat_file.c >> libavformat/file.c

Loading…
Cancel
Save