Merge branch 'main' into development

This commit is contained in:
Taner Sener 2023-08-23 12:30:43 +01:00
commit aa9363dc53
31 changed files with 395 additions and 372 deletions

View File

@ -8,7 +8,7 @@ Please also include the context and motivation about the changes introduced.
- Documentation - Documentation
## Checks ## Checks
- [ ] Changes support all platforms (`Android`, `iOS`, `Linux`, macOS`, `tvOS`) - [ ] Changes support all platforms (`Android`, `iOS`, `Linux`, `macOS`, `tvOS`)
- [ ] Breaks existing functionality - [ ] Breaks existing functionality
- [ ] Implementation is completed, not half-done - [ ] Implementation is completed, not half-done
- [ ] Is there another PR already created for this feature/bug fix - [ ] Is there another PR already created for this feature/bug fix

View File

@ -15,7 +15,7 @@ It includes scripts to build `FFmpeg` native libraries, a wrapper library to run
- Supports hybrid platforms: Flutter, React Native - Supports hybrid platforms: Flutter, React Native
- Based on FFmpeg `v4.5-dev` or later with optional system and external libraries - Based on FFmpeg `v4.5-dev` or later with optional system and external libraries
- 8 prebuilt binary packages available at [Github](https://github.com/arthenica/ffmpeg-kit/releases), [Maven Central](https://search.maven.org), [CocoaPods](https://cocoapods.org), [pub](https://pub.dev) and [npm](https://www.npmjs.com) - 8 prebuilt binary packages available at [Github](https://github.com/arthenica/ffmpeg-kit/releases), [Maven Central](https://search.maven.org), [CocoaPods](https://cocoapods.org), [pub](https://pub.dev) and [npm](https://www.npmjs.com)
- Licensed under `LGPL 3.0`, or `GPL v3.0` if GPL licensed libraries are enabled - Licensed under `LGPL 3.0` by default, `GPL v3.0` if GPL licensed libraries are enabled
### 2. Android ### 2. Android
@ -124,23 +124,23 @@ the same `FFmpeg` release branch.
`dev` part in the version string indicates that `FFmpeg` source code is cloned from the `FFmpeg` `master` branch and `dev` part in the version string indicates that `FFmpeg` source code is cloned from the `FFmpeg` `master` branch and
the exact version number of `FFmpeg` is obtained using the `git describe --tags` command. the exact version number of `FFmpeg` is obtained using the `git describe --tags` command.
| Platforms | FFmpegKit Version | FFmpeg Version | Release Date | | Platforms | FFmpegKit Version | FFmpeg Version | Release Date |
|:----------------:|:----------------------------------------------------------------------------------:|:--------------:|:------------:| |:----------------:|:-----------------------------------------------------------------------------------:|:--------------:|:------------:|
| Android | [6.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/v6.0) | 6.0 | Aug 21, 2023 | | Android | [6.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/v6.0) | 6.0 | Aug 21, 2023 |
| Apple | [6.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/v6.0) | 6.0 | Aug 21, 2023 | | Apple | [6.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/v6.0) | 6.0 | Aug 21, 2023 |
| React Native | [5.1.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/react.native.v5.1.0) | 5.1.2 | Oct 03, 2022 | | React Native | [5.1.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/react.native.v5.1.0) | 5.1.2 | Oct 02, 2022 |
| Flutter | [5.1.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/flutter.v5.1.0) | 5.1.2 | Oct 02, 2022 | | Flutter | [5.1.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/flutter.v5.1.0) | 5.1.2 | Oct 02, 2022 |
| Android | [5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/v5.1) | 5.1.2 | Sep 29, 2022 | | Android | [5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/v5.1) | 5.1.2 | Sep 29, 2022 |
| Apple | [5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/v5.1) | 5.1.2 | Sep 29, 2022 | | Apple | [5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/v5.1) | 5.1.2 | Sep 29, 2022 |
| React Native | [4.5.2](https://github.com/arthenica/ffmpeg-kit/releases/tag/react.native.v4.5.2) | 4.5-dev-3393 | May 25, 2022 | | React Native | [4.5.2](https://github.com/arthenica/ffmpeg-kit/releases/tag/react.native.v4.5.2) | 4.5-dev-3393 | May 25, 2022 |
| Flutter | [4.5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/flutter.v4.5.1) | 4.5-dev-3393 | Jan 02, 2022 | | 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 | | 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 | | 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 | Dec 30, 2021 | | Apple | [4.5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/v4.5.1) | 4.5-dev-3393 | Dec 30, 2021 |
| Flutter | [4.5.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/flutter.v4.5.0) | 4.5-dev-2008 | Oct 05, 2021 | | 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 | | 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<br>Apple | [4.5](https://github.com/arthenica/ffmpeg-kit/releases/tag/v4.5) | 4.5-dev-2008 | Sep 18, 2021 | | Android<br>Apple | [4.5](https://github.com/arthenica/ffmpeg-kit/releases/tag/v4.5) | 4.5-dev-2008 | Sep 18, 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.4](https://github.com/arthenica/ffmpeg-kit/releases/tag/v4.4) | 4.4-dev-3015 | Mar 03, 2021 |
### 11. LTS Releases ### 11. LTS Releases

View File

@ -15,7 +15,7 @@ applications and 8 prebuilt binary packages available at [Github](https://github
- Supports hybrid platforms: Flutter, React Native - Supports hybrid platforms: Flutter, React Native
- Based on FFmpeg `v4.5-dev` or later with optional system and external libraries - Based on FFmpeg `v4.5-dev` or later with optional system and external libraries
- 8 prebuilt binary packages available at [Github](https://github.com/arthenica/ffmpeg-kit/releases), [Maven Central](https://search.maven.org), [CocoaPods](https://cocoapods.org), [pub](https://pub.dev) and [npm](https://www.npmjs.com) - 8 prebuilt binary packages available at [Github](https://github.com/arthenica/ffmpeg-kit/releases), [Maven Central](https://search.maven.org), [CocoaPods](https://cocoapods.org), [pub](https://pub.dev) and [npm](https://www.npmjs.com)
- Licensed under `LGPL 3.0`, or `GPL v3.0` if GPL licensed libraries are enabled - Licensed under `LGPL 3.0` by default, some packages licensed by `GPL v3.0` effectively
### 2. Android ### 2. Android
@ -116,7 +116,7 @@ the exact version number of `FFmpeg` is obtained using the `git describe --tags`
|:----------------:|:---------------------------------------------------------------------------------:|:--------------:|:------------:| |:----------------:|:---------------------------------------------------------------------------------:|:--------------:|:------------:|
| Android | [6.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/v6.0) | 6.0 | Aug 21, 2023 | | Android | [6.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/v6.0) | 6.0 | Aug 21, 2023 |
| Apple | [6.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/v6.0) | 6.0 | Aug 21, 2023 | | Apple | [6.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/v6.0) | 6.0 | Aug 21, 2023 |
| React Native | [5.1.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/react.native.v5.1.0) | 5.1.2 | Oct 03, 2022 | | React Native | [5.1.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/react.native.v5.1.0) | 5.1.2 | Oct 02, 2022 |
| Flutter | [5.1.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/flutter.v5.1.0) | 5.1.2 | Oct 02, 2022 | | Flutter | [5.1.0](https://github.com/arthenica/ffmpeg-kit/releases/tag/flutter.v5.1.0) | 5.1.2 | Oct 02, 2022 |
| Android | [5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/v5.1) | 5.1.2 | Sep 29, 2022 | | Android | [5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/v5.1) | 5.1.2 | Sep 29, 2022 |
| Apple | [5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/v5.1) | 5.1.2 | Sep 29, 2022 | | Apple | [5.1](https://github.com/arthenica/ffmpeg-kit/releases/tag/v5.1) | 5.1.2 | Sep 29, 2022 |

View File

@ -1,3 +1,13 @@
## 5.1.0
- Feature release based on native v5.1
- Implements AbstractSession.cancel() method
- Runs iOS and macOS callbacks on main queue
## 5.1.0-LTS
- Feature release based on native v5.1.LTS
- Implements AbstractSession.cancel() method
- Runs iOS and macOS callbacks on main queue
## 4.5.1 ## 4.5.1
- Feature release based on native v4.5.1 - Feature release based on native v4.5.1

View File

@ -5,14 +5,17 @@
- Includes both `FFmpeg` and `FFprobe` - Includes both `FFmpeg` and `FFprobe`
- Supports - Supports
- `Android`, `iOS` and `macOS` - `Android`, `iOS` and `macOS`
- FFmpeg `v4.5-dev` releases - FFmpeg `v5.1.2`
- `arm-v7a`, `arm-v7a-neon`, `arm64-v8a`, `x86` and `x86_64` architectures on Android - `arm-v7a`, `arm-v7a-neon`, `arm64-v8a`, `x86` and `x86_64` architectures on Android
- `Android API Level 16` or later - `Android API Level 24` or later
- `API Level 16` on LTS releases
- `armv7`, `armv7s`, `arm64`, `arm64-simulator`, `i386`, `x86_64`, `x86_64-mac-catalyst` and `arm64-mac-catalyst` - `armv7`, `armv7s`, `arm64`, `arm64-simulator`, `i386`, `x86_64`, `x86_64-mac-catalyst` and `arm64-mac-catalyst`
architectures on iOS architectures on iOS
- `iOS SDK 10` or later - `iOS SDK 12.1` or later
- `iOS SDK 10` on LTS releases
- `arm64` and `x86_64` architectures on macOS - `arm64` and `x86_64` architectures on macOS
- `macOS SDK 10.12+` or later - `macOS SDK 10.15` or later
- `macOS SDK 10.12` on LTS releases
- Can process Storage Access Framework (SAF) Uris on Android - Can process Storage Access Framework (SAF) Uris on Android
- 25 external libraries - 25 external libraries
@ -24,7 +27,7 @@
`vid.stab`, `x264`, `x265`, `xvidcore` `vid.stab`, `x264`, `x265`, `xvidcore`
- Licensed under LGPL 3.0, can be customized to support GPL v3.0 - Licensed under `LGPL 3.0` by default, some packages licensed by `GPL v3.0` effectively
### 2. Installation ### 2. Installation
@ -32,21 +35,21 @@ Add `ffmpeg_kit_flutter` as a dependency in your `pubspec.yaml file`.
```yaml ```yaml
dependencies: dependencies:
ffmpeg_kit_flutter: 4.5.1 ffmpeg_kit_flutter: 5.1.0
``` ```
#### 2.1 Packages #### 2.1 Packages
`ffmpeg` includes built-in encoders for some popular formats. However, there are certain external libraries that needs `FFmpeg` includes built-in encoders for some popular formats. However, there are certain external libraries that needs
to be enabled in order to encode specific formats/codecs. For example, to encode an `mp3` file you need `lame` or to be enabled in order to encode specific formats/codecs. For example, to encode an `mp3` file you need `lame` or
`shine` library enabled. You have to install a `ffmpeg_kit_flutter` package that has at least one of them inside. To `shine` library enabled. You have to install a `ffmpeg_kit_flutter` package that has at least one of them inside. To
encode an `h264` video, you need to install a package with `x264` inside. To encode `vp8` or `vp9` videos, you need encode an `h264` video, you need to install a package with `x264` inside. To encode `vp8` or `vp9` videos, you need
a `ffmpeg_kit_flutter` package with `libvpx` inside. a `ffmpeg_kit_flutter` package with `libvpx` inside.
`ffmpeg-kit` provides eight packages that include different sets of external libraries. These packages are named `ffmpeg-kit` provides eight packages that include different sets of external libraries. These packages are named
according to the external libraries included in them. Refer to according to the external libraries included. Refer to the
[Packages](https://github.com/arthenica/ffmpeg-kit#8-packages) section of the project README to see the names of those [Packages](https://github.com/arthenica/ffmpeg-kit/wiki/Packages) wiki page to see the names of those
packages and external libraries included in each of them. packages and external libraries included in each one of them.
#### 2.2 Installing Packages #### 2.2 Installing Packages
@ -55,7 +58,7 @@ using the following dependency format.
```yaml ```yaml
dependencies: dependencies:
ffmpeg_kit_flutter_<package name>: 4.5.1 ffmpeg_kit_flutter_<package name>: 5.1.0
``` ```
Note that hyphens in the package name must be replaced with underscores. Additionally, do not forget to use the package Note that hyphens in the package name must be replaced with underscores. Additionally, do not forget to use the package
@ -67,39 +70,44 @@ In order to install the `LTS` variant, append `-LTS` to the version you have for
```yaml ```yaml
dependencies: dependencies:
ffmpeg_kit_flutter: 4.5.1-LTS ffmpeg_kit_flutter: 5.1.0-LTS
``` ```
#### 2.4 LTS Releases #### 2.4 LTS Releases
`ffmpeg_kit_flutter` is published in two different variants: `Main Release` and `LTS Release`. Both releases share the `ffmpeg_kit_flutter` is published in two variants: `Main Release` and `LTS Release`. Both releases share the
same source code but is built with different settings (Architectures, API Level, iOS Min SDK, etc.). Refer to same source code but is built with different settings (Architectures, API Level, iOS Min SDK, etc.). Refer to the
[LTS Releases](https://github.com/arthenica/ffmpeg-kit#10-lts-releases) section of the project README to see how they [LTS Releases](https://github.com/arthenica/ffmpeg-kit/wiki/LTS-Releases) wiki page to see how they differ from each
compare to each other. other.
#### 2.5 Android and iOS Support #### 2.5 Platform Support
The following table shows the Android API level and iOS deployment target required in `ffmpeg_kit_flutter` releases. The following table shows Android API level, iOS deployment target and macOS deployment target requirements in
`ffmpeg_kit_flutter` releases.
<table> <table>
<thead> <thead>
<tr> <tr>
<th align="center" colspan="2">Main Release</th> <th align="center" colspan="3">Main Release</th>
<th align="center" colspan="2">LTS Release</th> <th align="center" colspan="3">LTS Release</th>
</tr> </tr>
<tr> <tr>
<th align="center">Android<br>API Level</th> <th align="center">Android<br>API Level</th>
<th align="center">iOS Minimum<br>Deployment Target</th> <th align="center">iOS Minimum<br>Deployment Target</th>
<th align="center">macOS Minimum<br>Deployment Target</th>
<th align="center">Android<br>API Level</th> <th align="center">Android<br>API Level</th>
<th align="center">iOS Minimum<br>Deployment Target</th> <th align="center">iOS Minimum<br>Deployment Target</th>
<th align="center">macOS Minimum<br>Deployment Target</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<tr> <tr>
<td align="center">24</td> <td align="center">24</td>
<td align="center">12.1</td> <td align="center">12.1</td>
<td align="center">10.15</td>
<td align="center">16</td> <td align="center">16</td>
<td align="center">10</td> <td align="center">10</td>
<td align="center">10.12</td>
</tr> </tr>
</tbody> </tbody>
</table> </table>

View File

@ -1,24 +1,31 @@
buildscript { buildscript {
repositories { repositories {
google() google()
jcenter() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.2.2' classpath 'com.android.tools.build:gradle:7.1.2'
}
}
rootProject.allprojects {
repositories {
google()
mavenCentral()
} }
} }
apply plugin: 'com.android.library' apply plugin: 'com.android.library'
android { android {
compileSdkVersion 30 compileSdkVersion 31
defaultConfig { defaultConfig {
minSdkVersion 24 minSdkVersion 24
targetSdkVersion 30 targetSdkVersion 31
versionCode 451 versionCode 510
versionName "4.5.1" versionName "5.1.0"
} }
buildTypes { buildTypes {
@ -35,14 +42,7 @@ android {
} }
} }
repositories {
mavenCentral()
jcenter()
google()
}
dependencies { dependencies {
implementation 'androidx.annotation:annotation:1.2.0' implementation 'androidx.annotation:annotation:1.2.0'
implementation 'com.arthenica:ffmpeg-kit-https:4.5.1-1' implementation 'com.arthenica:ffmpeg-kit-https:5.1'
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2021 Taner Sener * Copyright (c) 2018-2022 Taner Sener
* *
* This file is part of FFmpegKit. * This file is part of FFmpegKit.
* *
@ -831,7 +831,7 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
// FFmpegSession // FFmpegSession
protected void ffmpegSession(@NonNull final List<String> arguments, @NonNull final Result result) { protected void ffmpegSession(@NonNull final List<String> arguments, @NonNull final Result result) {
final FFmpegSession session = new FFmpegSession(arguments.toArray(new String[0]), null, null, null, LogRedirectionStrategy.NEVER_PRINT_LOGS); final FFmpegSession session = FFmpegSession.create(arguments.toArray(new String[0]), null, null, null, LogRedirectionStrategy.NEVER_PRINT_LOGS);
resultHandler.successAsync(result, toMap(session)); resultHandler.successAsync(result, toMap(session));
} }
@ -872,14 +872,14 @@ public class FFmpegKitFlutterPlugin implements FlutterPlugin, ActivityAware, Met
// FFprobeSession // FFprobeSession
protected void ffprobeSession(@NonNull final List<String> arguments, @NonNull final Result result) { protected void ffprobeSession(@NonNull final List<String> arguments, @NonNull final Result result) {
final FFprobeSession session = new FFprobeSession(arguments.toArray(new String[0]), null, null, LogRedirectionStrategy.NEVER_PRINT_LOGS); final FFprobeSession session = FFprobeSession.create(arguments.toArray(new String[0]), null, null, LogRedirectionStrategy.NEVER_PRINT_LOGS);
resultHandler.successAsync(result, toMap(session)); resultHandler.successAsync(result, toMap(session));
} }
// MediaInformationSession // MediaInformationSession
protected void mediaInformationSession(@NonNull final List<String> arguments, @NonNull final Result result) { protected void mediaInformationSession(@NonNull final List<String> arguments, @NonNull final Result result) {
final MediaInformationSession session = new MediaInformationSession(arguments.toArray(new String[0]), null, null); final MediaInformationSession session = MediaInformationSession.create(arguments.toArray(new String[0]), null, null);
resultHandler.successAsync(result, toMap(session)); resultHandler.successAsync(result, toMap(session));
} }

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2021 Taner Sener * Copyright (c) 2018-2022 Taner Sener
* *
* This file is part of FFmpegKit. * This file is part of FFmpegKit.
* *
@ -112,30 +112,40 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
- (void)registerGlobalCallbacks { - (void)registerGlobalCallbacks {
[FFmpegKitConfig enableFFmpegSessionCompleteCallback:^(FFmpegSession* session){ [FFmpegKitConfig enableFFmpegSessionCompleteCallback:^(FFmpegSession* session){
NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session]; NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session];
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]); dispatch_async(dispatch_get_main_queue(), ^() {
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]);
});
}]; }];
[FFmpegKitConfig enableFFprobeSessionCompleteCallback:^(FFprobeSession* session){ [FFmpegKitConfig enableFFprobeSessionCompleteCallback:^(FFprobeSession* session){
NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session]; NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session];
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]); dispatch_async(dispatch_get_main_queue(), ^() {
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]);
});
}]; }];
[FFmpegKitConfig enableMediaInformationSessionCompleteCallback:^(MediaInformationSession* session){ [FFmpegKitConfig enableMediaInformationSessionCompleteCallback:^(MediaInformationSession* session){
NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session]; NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session];
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]); dispatch_async(dispatch_get_main_queue(), ^() {
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]);
});
}]; }];
[FFmpegKitConfig enableLogCallback: ^(Log* log){ [FFmpegKitConfig enableLogCallback: ^(Log* log){
if (self->logsEnabled) { if (self->logsEnabled) {
NSDictionary *dictionary = [FFmpegKitFlutterPlugin toLogDictionary:log]; NSDictionary *dictionary = [FFmpegKitFlutterPlugin toLogDictionary:log];
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_LOG_CALLBACK_EVENT withDictionary:dictionary]); dispatch_async(dispatch_get_main_queue(), ^() {
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_LOG_CALLBACK_EVENT withDictionary:dictionary]);
});
} }
}]; }];
[FFmpegKitConfig enableStatisticsCallback:^(Statistics* statistics){ [FFmpegKitConfig enableStatisticsCallback:^(Statistics* statistics){
if (self->statisticsEnabled) { if (self->statisticsEnabled) {
NSDictionary *dictionary = [FFmpegKitFlutterPlugin toStatisticsDictionary:statistics]; NSDictionary *dictionary = [FFmpegKitFlutterPlugin toStatisticsDictionary:statistics];
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_STATISTICS_CALLBACK_EVENT withDictionary:dictionary]); dispatch_async(dispatch_get_main_queue(), ^() {
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_STATISTICS_CALLBACK_EVENT withDictionary:dictionary]);
});
} }
}]; }];
} }
@ -563,7 +573,7 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
// FFmpegSession // FFmpegSession
- (void)ffmpegSession:(NSArray*)arguments result:(FlutterResult)result { - (void)ffmpegSession:(NSArray*)arguments result:(FlutterResult)result {
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil withStatisticsCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:nil withLogCallback:nil withStatisticsCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs];
result([FFmpegKitFlutterPlugin toSessionDictionary:session]); result([FFmpegKitFlutterPlugin toSessionDictionary:session]);
} }
@ -604,14 +614,14 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
// FFprobeSession // FFprobeSession
- (void)ffprobeSession:(NSArray*)arguments result:(FlutterResult)result { - (void)ffprobeSession:(NSArray*)arguments result:(FlutterResult)result {
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; FFprobeSession* session = [FFprobeSession create:arguments withCompleteCallback:nil withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs];
result([FFmpegKitFlutterPlugin toSessionDictionary:session]); result([FFmpegKitFlutterPlugin toSessionDictionary:session]);
} }
// MediaInformationSession // MediaInformationSession
- (void)mediaInformationSession:(NSArray*)arguments result:(FlutterResult)result { - (void)mediaInformationSession:(NSArray*)arguments result:(FlutterResult)result {
MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil]; MediaInformationSession* session = [MediaInformationSession create:arguments withCompleteCallback:nil withLogCallback:nil];
result([FFmpegKitFlutterPlugin toSessionDictionary:session]); result([FFmpegKitFlutterPlugin toSessionDictionary:session]);
} }
@ -632,23 +642,21 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
// MediaInformationJsonParser // MediaInformationJsonParser
- (void)mediaInformationJsonParserFrom:(NSString*)ffprobeJsonOutput result:(FlutterResult)result { - (void)mediaInformationJsonParserFrom:(NSString*)ffprobeJsonOutput result:(FlutterResult)result {
NSError *error; @try {
MediaInformation* mediaInformation = [MediaInformationJsonParser from:ffprobeJsonOutput with:error]; MediaInformation* mediaInformation = [MediaInformationJsonParser fromWithError:ffprobeJsonOutput];
if (error == nil) {
result([FFmpegKitFlutterPlugin toMediaInformationDictionary:mediaInformation]); result([FFmpegKitFlutterPlugin toMediaInformationDictionary:mediaInformation]);
} else { } @catch (NSException *exception) {
NSLog(@"Parsing MediaInformation failed: %@.\n", error); NSLog(@"Parsing MediaInformation failed: %@.\n", [NSString stringWithFormat:@"%@\n%@", [exception userInfo], [exception callStackSymbols]]);
result(nil); result(nil);
} }
} }
- (void)mediaInformationJsonParserFromWithError:(NSString*)ffprobeJsonOutput result:(FlutterResult)result { - (void)mediaInformationJsonParserFromWithError:(NSString*)ffprobeJsonOutput result:(FlutterResult)result {
NSError *error; @try {
MediaInformation* mediaInformation = [MediaInformationJsonParser from:ffprobeJsonOutput with:error]; MediaInformation* mediaInformation = [MediaInformationJsonParser fromWithError:ffprobeJsonOutput];
if (error == nil) {
result([FFmpegKitFlutterPlugin toMediaInformationDictionary:mediaInformation]); result([FFmpegKitFlutterPlugin toMediaInformationDictionary:mediaInformation]);
} else { } @catch (NSException *exception) {
NSLog(@"Parsing MediaInformation failed: %@.\n", error); NSLog(@"Parsing MediaInformation failed: %@.\n", [NSString stringWithFormat:@"%@\n%@", [exception userInfo], [exception callStackSymbols]]);
result([FlutterError errorWithCode:@"PARSE_FAILED" message:@"Parsing MediaInformation failed with JSON error." details:nil]); result([FlutterError errorWithCode:@"PARSE_FAILED" message:@"Parsing MediaInformation failed with JSON error." details:nil]);
} }
} }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'ffmpeg_kit_flutter' s.name = 'ffmpeg_kit_flutter'
s.version = '4.5.1' s.version = '5.1.0'
s.summary = 'FFmpeg Kit for Flutter' s.summary = 'FFmpeg Kit for Flutter'
s.description = 'A Flutter plugin for running FFmpeg and FFprobe commands.' s.description = 'A Flutter plugin for running FFmpeg and FFprobe commands.'
s.homepage = 'https://github.com/arthenica/ffmpeg-kit' s.homepage = 'https://github.com/arthenica/ffmpeg-kit'
@ -23,112 +23,112 @@ Pod::Spec.new do |s|
s.subspec 'min' do |ss| s.subspec 'min' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-min', "4.5.1" ss.dependency 'ffmpeg-kit-ios-min', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'min-lts' do |ss| s.subspec 'min-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-min', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-min', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'min-gpl' do |ss| s.subspec 'min-gpl' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-min-gpl', "4.5.1" ss.dependency 'ffmpeg-kit-ios-min-gpl', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'min-gpl-lts' do |ss| s.subspec 'min-gpl-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-min-gpl', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-min-gpl', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'https' do |ss| s.subspec 'https' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-https', "4.5.1" ss.dependency 'ffmpeg-kit-ios-https', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'https-lts' do |ss| s.subspec 'https-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-https', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-https', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'https-gpl' do |ss| s.subspec 'https-gpl' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-https-gpl', "4.5.1" ss.dependency 'ffmpeg-kit-ios-https-gpl', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'https-gpl-lts' do |ss| s.subspec 'https-gpl-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-https-gpl', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-https-gpl', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'audio' do |ss| s.subspec 'audio' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-audio', "4.5.1" ss.dependency 'ffmpeg-kit-ios-audio', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'audio-lts' do |ss| s.subspec 'audio-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-audio', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-audio', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'video' do |ss| s.subspec 'video' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-video', "4.5.1" ss.dependency 'ffmpeg-kit-ios-video', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'video-lts' do |ss| s.subspec 'video-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-video', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-video', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'full' do |ss| s.subspec 'full' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-full', "4.5.1" ss.dependency 'ffmpeg-kit-ios-full', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'full-lts' do |ss| s.subspec 'full-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-full', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-full', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'full-gpl' do |ss| s.subspec 'full-gpl' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-full-gpl', "4.5.1" ss.dependency 'ffmpeg-kit-ios-full-gpl', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'full-gpl-lts' do |ss| s.subspec 'full-gpl-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-ios-full-gpl', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-full-gpl', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019-2021 Taner Sener * Copyright (c) 2019-2022 Taner Sener
* *
* This file is part of FFmpegKit. * This file is part of FFmpegKit.
* *
@ -35,7 +35,7 @@ import 'src/ffmpeg_kit_factory.dart';
/// Abstract session implementation which includes common features shared by /// Abstract session implementation which includes common features shared by
/// "FFmpeg", "FFprobe" and "MediaInformation" sessions. /// "FFmpeg", "FFprobe" and "MediaInformation" sessions.
class AbstractSession extends Session { abstract class AbstractSession extends Session {
static FFmpegKitPlatform _platform = FFmpegKitPlatform.instance; static FFmpegKitPlatform _platform = FFmpegKitPlatform.instance;
/// Defines how long default "getAll" methods wait, in milliseconds. /// Defines how long default "getAll" methods wait, in milliseconds.
@ -428,5 +428,18 @@ class AbstractSession extends Session {
bool isMediaInformation() => false; bool isMediaInformation() => false;
/// Cancels running the session. /// Cancels running the session.
void cancel() {} Future<void> cancel() async {
try {
final int? sessionId = getSessionId();
await FFmpegKitConfig.init();
if (sessionId == null) {
return _platform.ffmpegKitCancel();
} else {
return _platform.ffmpegKitCancelSession(sessionId);
}
} on PlatformException catch (e, stack) {
print("Plugin cancel error: ${e.message}");
return Future.error("cancel failed.", stack);
}
}
} }

View File

@ -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.
* *
@ -51,7 +51,7 @@ class Chapter {
String? getEndTime() => this.getStringProperty(Chapter.keyEndTime); String? getEndTime() => this.getStringProperty(Chapter.keyEndTime);
/// Returns all tags. /// Returns all tags.
Map<dynamic, dynamic>? getTags() => this.getProperties(Chapter.keyTags); Map<dynamic, dynamic>? getTags() => this.getProperty(Chapter.keyTags);
/// Returns the chapter property associated with the key. /// Returns the chapter property associated with the key.
String? getStringProperty(String key) => this._allProperties?[key]; String? getStringProperty(String key) => this._allProperties?[key];
@ -59,8 +59,8 @@ class Chapter {
/// Returns the chapter property associated with the key. /// Returns the chapter property associated with the key.
num? getNumberProperty(String key) => this._allProperties?[key]; num? getNumberProperty(String key) => this._allProperties?[key];
/// Returns the chapter properties associated with the key. /// Returns the chapter property associated with the key.
dynamic getProperties(String key) => this._allProperties?[key]; dynamic getProperty(String key) => this._allProperties?[key];
/// Returns all properties found. /// Returns all properties found.
Map<dynamic, dynamic>? getAllProperties() => this._allProperties; Map<dynamic, dynamic>? getAllProperties() => this._allProperties;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019-2021 Taner Sener * Copyright (c) 2019-2022 Taner Sener
* *
* This file is part of FFmpegKit. * This file is part of FFmpegKit.
* *
@ -49,11 +49,6 @@ class FFmpegSession extends AbstractSession {
return session; return session;
} }
/// Creates a new FFmpeg session from [sessionMap], which includes session
/// fields as map keys.
static FFmpegSession fromMap(Map<dynamic, dynamic> sessionMap) =>
AbstractSession.createFFmpegSessionFromMap(sessionMap);
/// Returns the session specific statistics callback. /// Returns the session specific statistics callback.
StatisticsCallback? getStatisticsCallback() => StatisticsCallback? getStatisticsCallback() =>
FFmpegKitFactory.getStatisticsCallback(this.getSessionId()); FFmpegKitFactory.getStatisticsCallback(this.getSessionId());

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019-2021 Taner Sener * Copyright (c) 2019-2022 Taner Sener
* *
* This file is part of FFmpegKit. * This file is part of FFmpegKit.
* *
@ -41,11 +41,6 @@ class FFprobeSession extends AbstractSession {
return session; return session;
} }
/// Creates a new FFprobe session from [sessionMap], which includes session
/// fields as map keys.
static FFprobeSession fromMap(Map<dynamic, dynamic> sessionMap) =>
AbstractSession.createFFprobeSessionFromMap(sessionMap);
/// Returns the session specific complete callback. /// Returns the session specific complete callback.
FFprobeSessionCompleteCallback? getCompleteCallback() => FFprobeSessionCompleteCallback? getCompleteCallback() =>
FFmpegKitFactory.getFFprobeSessionCompleteCallback(this.getSessionId()); FFmpegKitFactory.getFFprobeSessionCompleteCallback(this.getSessionId());

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019-2021 Taner Sener * Copyright (c) 2019-2022 Taner Sener
* *
* This file is part of FFmpegKit. * This file is part of FFmpegKit.
* *
@ -22,7 +22,7 @@ import 'stream_information.dart';
/// Media information class. /// Media information class.
class MediaInformation { class MediaInformation {
static const keyMediaProperties = "format"; static const keyFormatProperties = "format";
static const keyFilename = "filename"; static const keyFilename = "filename";
static const keyFormat = "format_name"; static const keyFormat = "format_name";
static const keyFormatLong = "format_long_name"; static const keyFormatLong = "format_long_name";
@ -38,40 +38,54 @@ class MediaInformation {
MediaInformation(this._allProperties); MediaInformation(this._allProperties);
/// Returns file name. /// Returns file name.
String? getFilename() => this.getStringProperty(MediaInformation.keyFilename); String? getFilename() =>
this.getStringFormatProperty(MediaInformation.keyFilename);
/// Returns format. /// Returns format.
String? getFormat() => this.getStringProperty(MediaInformation.keyFormat); String? getFormat() =>
this.getStringFormatProperty(MediaInformation.keyFormat);
/// Returns long format. /// Returns long format.
String? getLongFormat() => String? getLongFormat() =>
this.getStringProperty(MediaInformation.keyFormatLong); this.getStringFormatProperty(MediaInformation.keyFormatLong);
/// Returns duration. /// Returns duration.
String? getDuration() => this.getStringProperty(MediaInformation.keyDuration); String? getDuration() =>
this.getStringFormatProperty(MediaInformation.keyDuration);
/// Returns start time. /// Returns start time.
String? getStartTime() => String? getStartTime() =>
this.getStringProperty(MediaInformation.keyStartTime); this.getStringFormatProperty(MediaInformation.keyStartTime);
/// Returns size. /// Returns size.
String? getSize() => this.getStringProperty(MediaInformation.keySize); String? getSize() => this.getStringFormatProperty(MediaInformation.keySize);
/// Returns bitrate. /// Returns bitrate.
String? getBitrate() => this.getStringProperty(MediaInformation.keyBitRate); String? getBitrate() =>
this.getStringFormatProperty(MediaInformation.keyBitRate);
/// Returns all tags. /// Returns all tags.
Map<dynamic, dynamic>? getTags() => Map<dynamic, dynamic>? getTags() =>
this.getProperties(StreamInformation.keyTags); this.getFormatProperty(StreamInformation.keyTags);
/// Returns the media property associated with the key. /// Returns the property associated with the key.
String? getStringProperty(String key) => this.getMediaProperties()?[key]; String? getStringProperty(String key) => this.getAllProperties()?[key];
/// Returns the media property associated with the key. /// Returns the property associated with the key.
num? getNumberProperty(String key) => this.getMediaProperties()?[key]; num? getNumberProperty(String key) => this.getAllProperties()?[key];
/// Returns the media properties associated with the key. /// Returns the property associated with the key.
dynamic getProperties(String key) => this.getMediaProperties()?[key]; dynamic getProperty(String key) => this.getAllProperties()?[key];
/// Returns the format property associated with the key.
String? getStringFormatProperty(String key) =>
this.getFormatProperties()?[key];
/// Returns the format property associated with the key.
num? getNumberFormatProperty(String key) => this.getFormatProperties()?[key];
/// Returns the format property associated with the key.
dynamic getFormatProperty(String key) => this.getFormatProperties()?[key];
/// Returns all streams found as a list. /// Returns all streams found as a list.
List<StreamInformation> getStreams() { List<StreamInformation> getStreams() {
@ -102,9 +116,9 @@ class MediaInformation {
return list; return list;
} }
/// Returns all media properties. /// Returns all format properties found.
Map<dynamic, dynamic>? getMediaProperties() => Map<dynamic, dynamic>? getFormatProperties() =>
this._allProperties?[keyMediaProperties]; this._allProperties?[keyFormatProperties];
/// Returns all properties found, including stream properties. /// Returns all properties found, including stream properties.
Map<dynamic, dynamic>? getAllProperties() => this._allProperties; Map<dynamic, dynamic>? getAllProperties() => this._allProperties;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019-2021 Taner Sener * Copyright (c) 2019-2022 Taner Sener
* *
* This file is part of FFmpegKit. * This file is part of FFmpegKit.
* *
@ -43,11 +43,6 @@ class MediaInformationSession extends AbstractSession {
return session; return session;
} }
/// Creates a new MediaInformation session from [sessionMap], which includes
/// session fields as map keys.
static MediaInformationSession fromMap(Map<dynamic, dynamic> sessionMap) =>
AbstractSession.createMediaInformationSessionFromMap(sessionMap);
/// Returns the media information extracted in this session. /// Returns the media information extracted in this session.
MediaInformation? getMediaInformation() => this._mediaInformation; MediaInformation? getMediaInformation() => this._mediaInformation;

View File

@ -106,5 +106,5 @@ abstract class Session {
bool isMediaInformation(); bool isMediaInformation();
/// Cancels running the session. /// Cancels running the session.
void cancel(); Future<void> cancel();
} }

View File

@ -17,15 +17,13 @@
* along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>. * along with FFmpegKit. If not, see <http://www.gnu.org/licenses/>.
*/ */
import '../ffmpeg_session.dart'; import '../abstract_session.dart';
import '../ffmpeg_session_complete_callback.dart'; import '../ffmpeg_session_complete_callback.dart';
import '../ffprobe_session.dart';
import '../ffprobe_session_complete_callback.dart'; import '../ffprobe_session_complete_callback.dart';
import '../log.dart'; import '../log.dart';
import '../log_callback.dart'; import '../log_callback.dart';
import '../log_redirection_strategy.dart'; import '../log_redirection_strategy.dart';
import '../media_information.dart'; import '../media_information.dart';
import '../media_information_session.dart';
import '../media_information_session_complete_callback.dart'; import '../media_information_session_complete_callback.dart';
import '../session.dart'; import '../session.dart';
import '../statistics.dart'; import '../statistics.dart';
@ -66,12 +64,12 @@ class FFmpegKitFactory {
static Session mapToSession(Map<dynamic, dynamic> sessionMap) { static Session mapToSession(Map<dynamic, dynamic> sessionMap) {
switch (sessionMap["type"]) { switch (sessionMap["type"]) {
case 2: case 2:
return FFprobeSession.fromMap(sessionMap); return AbstractSession.createFFprobeSessionFromMap(sessionMap);
case 3: case 3:
return MediaInformationSession.fromMap(sessionMap); return AbstractSession.createMediaInformationSessionFromMap(sessionMap);
case 1: case 1:
default: default:
return FFmpegSession.fromMap(sessionMap); return AbstractSession.createFFmpegSessionFromMap(sessionMap);
} }
} }
@ -79,12 +77,13 @@ class FFmpegKitFactory {
if (sessionMap != null) { if (sessionMap != null) {
switch (sessionMap["type"]) { switch (sessionMap["type"]) {
case 2: case 2:
return FFprobeSession.fromMap(sessionMap); return AbstractSession.createFFprobeSessionFromMap(sessionMap);
case 3: case 3:
return MediaInformationSession.fromMap(sessionMap); return AbstractSession.createMediaInformationSessionFromMap(
sessionMap);
case 1: case 1:
default: default:
return FFmpegSession.fromMap(sessionMap); return AbstractSession.createFFmpegSessionFromMap(sessionMap);
} }
} else { } else {
return null; return null;
@ -100,7 +99,7 @@ class FFmpegKitFactory {
} }
} }
static String getVersion() => "4.5.1"; static String getVersion() => "5.1.0";
static LogRedirectionStrategy? getLogRedirectionStrategy(int? sessionId) => static LogRedirectionStrategy? getLogRedirectionStrategy(int? sessionId) =>
logRedirectionStrategyMap[sessionId]; logRedirectionStrategyMap[sessionId];

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2019-2021 Taner Sener * Copyright (c) 2019-2022 Taner Sener
* *
* This file is part of FFmpegKit. * This file is part of FFmpegKit.
* *
@ -108,7 +108,7 @@ class StreamInformation {
/// Returns all tags. /// Returns all tags.
Map<dynamic, dynamic>? getTags() => Map<dynamic, dynamic>? getTags() =>
this.getProperties(StreamInformation.keyTags); this.getProperty(StreamInformation.keyTags);
/// Returns the stream property associated with the key. /// Returns the stream property associated with the key.
String? getStringProperty(String key) => this._allProperties?[key]; String? getStringProperty(String key) => this._allProperties?[key];
@ -116,8 +116,8 @@ class StreamInformation {
/// Returns the stream property associated with the key. /// Returns the stream property associated with the key.
num? getNumberProperty(String key) => this._allProperties?[key]; num? getNumberProperty(String key) => this._allProperties?[key];
/// Returns the stream properties associated with the key. /// Returns the stream property associated with the key.
dynamic getProperties(String key) => this._allProperties?[key]; dynamic getProperty(String key) => this._allProperties?[key];
/// Returns all properties found. /// Returns all properties found.
Map<dynamic, dynamic>? getAllProperties() => this._allProperties; Map<dynamic, dynamic>? getAllProperties() => this._allProperties;

View File

@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2018-2021 Taner Sener * Copyright (c) 2018-2022 Taner Sener
* *
* This file is part of FFmpegKit. * This file is part of FFmpegKit.
* *
@ -112,30 +112,40 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
- (void)registerGlobalCallbacks { - (void)registerGlobalCallbacks {
[FFmpegKitConfig enableFFmpegSessionCompleteCallback:^(FFmpegSession* session){ [FFmpegKitConfig enableFFmpegSessionCompleteCallback:^(FFmpegSession* session){
NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session]; NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session];
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]); dispatch_async(dispatch_get_main_queue(), ^() {
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]);
});
}]; }];
[FFmpegKitConfig enableFFprobeSessionCompleteCallback:^(FFprobeSession* session){ [FFmpegKitConfig enableFFprobeSessionCompleteCallback:^(FFprobeSession* session){
NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session]; NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session];
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]); dispatch_async(dispatch_get_main_queue(), ^() {
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]);
});
}]; }];
[FFmpegKitConfig enableMediaInformationSessionCompleteCallback:^(MediaInformationSession* session){ [FFmpegKitConfig enableMediaInformationSessionCompleteCallback:^(MediaInformationSession* session){
NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session]; NSDictionary *dictionary = [FFmpegKitFlutterPlugin toSessionDictionary:session];
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]); dispatch_async(dispatch_get_main_queue(), ^() {
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_COMPLETE_CALLBACK_EVENT withDictionary:dictionary]);
});
}]; }];
[FFmpegKitConfig enableLogCallback: ^(Log* log){ [FFmpegKitConfig enableLogCallback: ^(Log* log){
if (self->logsEnabled) { if (self->logsEnabled) {
NSDictionary *dictionary = [FFmpegKitFlutterPlugin toLogDictionary:log]; NSDictionary *dictionary = [FFmpegKitFlutterPlugin toLogDictionary:log];
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_LOG_CALLBACK_EVENT withDictionary:dictionary]); dispatch_async(dispatch_get_main_queue(), ^() {
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_LOG_CALLBACK_EVENT withDictionary:dictionary]);
});
} }
}]; }];
[FFmpegKitConfig enableStatisticsCallback:^(Statistics* statistics){ [FFmpegKitConfig enableStatisticsCallback:^(Statistics* statistics){
if (self->statisticsEnabled) { if (self->statisticsEnabled) {
NSDictionary *dictionary = [FFmpegKitFlutterPlugin toStatisticsDictionary:statistics]; NSDictionary *dictionary = [FFmpegKitFlutterPlugin toStatisticsDictionary:statistics];
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_STATISTICS_CALLBACK_EVENT withDictionary:dictionary]); dispatch_async(dispatch_get_main_queue(), ^() {
self->_eventSink([FFmpegKitFlutterPlugin toStringDictionary:EVENT_STATISTICS_CALLBACK_EVENT withDictionary:dictionary]);
});
} }
}]; }];
} }
@ -563,7 +573,7 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
// FFmpegSession // FFmpegSession
- (void)ffmpegSession:(NSArray*)arguments result:(FlutterResult)result { - (void)ffmpegSession:(NSArray*)arguments result:(FlutterResult)result {
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil withStatisticsCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:nil withLogCallback:nil withStatisticsCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs];
result([FFmpegKitFlutterPlugin toSessionDictionary:session]); result([FFmpegKitFlutterPlugin toSessionDictionary:session]);
} }
@ -604,14 +614,14 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
// FFprobeSession // FFprobeSession
- (void)ffprobeSession:(NSArray*)arguments result:(FlutterResult)result { - (void)ffprobeSession:(NSArray*)arguments result:(FlutterResult)result {
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; FFprobeSession* session = [FFprobeSession create:arguments withCompleteCallback:nil withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs];
result([FFmpegKitFlutterPlugin toSessionDictionary:session]); result([FFmpegKitFlutterPlugin toSessionDictionary:session]);
} }
// MediaInformationSession // MediaInformationSession
- (void)mediaInformationSession:(NSArray*)arguments result:(FlutterResult)result { - (void)mediaInformationSession:(NSArray*)arguments result:(FlutterResult)result {
MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil]; MediaInformationSession* session = [MediaInformationSession create:arguments withCompleteCallback:nil withLogCallback:nil];
result([FFmpegKitFlutterPlugin toSessionDictionary:session]); result([FFmpegKitFlutterPlugin toSessionDictionary:session]);
} }
@ -632,23 +642,21 @@ extern int const AbstractSessionDefaultTimeoutForAsynchronousMessagesInTransmit;
// MediaInformationJsonParser // MediaInformationJsonParser
- (void)mediaInformationJsonParserFrom:(NSString*)ffprobeJsonOutput result:(FlutterResult)result { - (void)mediaInformationJsonParserFrom:(NSString*)ffprobeJsonOutput result:(FlutterResult)result {
NSError *error; @try {
MediaInformation* mediaInformation = [MediaInformationJsonParser from:ffprobeJsonOutput with:error]; MediaInformation* mediaInformation = [MediaInformationJsonParser fromWithError:ffprobeJsonOutput];
if (error == nil) {
result([FFmpegKitFlutterPlugin toMediaInformationDictionary:mediaInformation]); result([FFmpegKitFlutterPlugin toMediaInformationDictionary:mediaInformation]);
} else { } @catch (NSException *exception) {
NSLog(@"Parsing MediaInformation failed: %@.\n", error); NSLog(@"Parsing MediaInformation failed: %@.\n", [NSString stringWithFormat:@"%@\n%@", [exception userInfo], [exception callStackSymbols]]);
result(nil); result(nil);
} }
} }
- (void)mediaInformationJsonParserFromWithError:(NSString*)ffprobeJsonOutput result:(FlutterResult)result { - (void)mediaInformationJsonParserFromWithError:(NSString*)ffprobeJsonOutput result:(FlutterResult)result {
NSError *error; @try {
MediaInformation* mediaInformation = [MediaInformationJsonParser from:ffprobeJsonOutput with:error]; MediaInformation* mediaInformation = [MediaInformationJsonParser fromWithError:ffprobeJsonOutput];
if (error == nil) {
result([FFmpegKitFlutterPlugin toMediaInformationDictionary:mediaInformation]); result([FFmpegKitFlutterPlugin toMediaInformationDictionary:mediaInformation]);
} else { } @catch (NSException *exception) {
NSLog(@"Parsing MediaInformation failed: %@.\n", error); NSLog(@"Parsing MediaInformation failed: %@.\n", [NSString stringWithFormat:@"%@\n%@", [exception userInfo], [exception callStackSymbols]]);
result([FlutterError errorWithCode:@"PARSE_FAILED" message:@"Parsing MediaInformation failed with JSON error." details:nil]); result([FlutterError errorWithCode:@"PARSE_FAILED" message:@"Parsing MediaInformation failed with JSON error." details:nil]);
} }
} }

View File

@ -1,6 +1,6 @@
Pod::Spec.new do |s| Pod::Spec.new do |s|
s.name = 'ffmpeg_kit_flutter' s.name = 'ffmpeg_kit_flutter'
s.version = '4.5.1' s.version = '5.1.0'
s.summary = 'FFmpeg Kit for Flutter' s.summary = 'FFmpeg Kit for Flutter'
s.description = 'A Flutter plugin for running FFmpeg and FFprobe commands.' s.description = 'A Flutter plugin for running FFmpeg and FFprobe commands.'
s.homepage = 'https://github.com/arthenica/ffmpeg-kit' s.homepage = 'https://github.com/arthenica/ffmpeg-kit'
@ -23,112 +23,112 @@ Pod::Spec.new do |s|
s.subspec 'min' do |ss| s.subspec 'min' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-min', "4.5.1" ss.dependency 'ffmpeg-kit-macos-min', "5.1"
ss.osx.deployment_target = '10.15' ss.osx.deployment_target = '10.15'
end end
s.subspec 'min-lts' do |ss| s.subspec 'min-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-min', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-macos-min', "5.1.LTS"
ss.osx.deployment_target = '10.12' ss.osx.deployment_target = '10.12'
end end
s.subspec 'min-gpl' do |ss| s.subspec 'min-gpl' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-min-gpl', "4.5.1" ss.dependency 'ffmpeg-kit-macos-min-gpl', "5.1"
ss.osx.deployment_target = '10.15' ss.osx.deployment_target = '10.15'
end end
s.subspec 'min-gpl-lts' do |ss| s.subspec 'min-gpl-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-min-gpl', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-macos-min-gpl', "5.1.LTS"
ss.osx.deployment_target = '10.12' ss.osx.deployment_target = '10.12'
end end
s.subspec 'https' do |ss| s.subspec 'https' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-https', "4.5.1" ss.dependency 'ffmpeg-kit-macos-https', "5.1"
ss.osx.deployment_target = '10.15' ss.osx.deployment_target = '10.15'
end end
s.subspec 'https-lts' do |ss| s.subspec 'https-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-https', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-macos-https', "5.1.LTS"
ss.osx.deployment_target = '10.12' ss.osx.deployment_target = '10.12'
end end
s.subspec 'https-gpl' do |ss| s.subspec 'https-gpl' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-https-gpl', "4.5.1" ss.dependency 'ffmpeg-kit-macos-https-gpl', "5.1"
ss.osx.deployment_target = '10.15' ss.osx.deployment_target = '10.15'
end end
s.subspec 'https-gpl-lts' do |ss| s.subspec 'https-gpl-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-https-gpl', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-macos-https-gpl', "5.1.LTS"
ss.osx.deployment_target = '10.12' ss.osx.deployment_target = '10.12'
end end
s.subspec 'audio' do |ss| s.subspec 'audio' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-audio', "4.5.1" ss.dependency 'ffmpeg-kit-macos-audio', "5.1"
ss.osx.deployment_target = '10.15' ss.osx.deployment_target = '10.15'
end end
s.subspec 'audio-lts' do |ss| s.subspec 'audio-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-audio', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-macos-audio', "5.1.LTS"
ss.osx.deployment_target = '10.12' ss.osx.deployment_target = '10.12'
end end
s.subspec 'video' do |ss| s.subspec 'video' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-video', "4.5.1" ss.dependency 'ffmpeg-kit-macos-video', "5.1"
ss.osx.deployment_target = '10.15' ss.osx.deployment_target = '10.15'
end end
s.subspec 'video-lts' do |ss| s.subspec 'video-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-video', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-macos-video', "5.1.LTS"
ss.osx.deployment_target = '10.12' ss.osx.deployment_target = '10.12'
end end
s.subspec 'full' do |ss| s.subspec 'full' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-full', "4.5.1" ss.dependency 'ffmpeg-kit-macos-full', "5.1"
ss.osx.deployment_target = '10.15' ss.osx.deployment_target = '10.15'
end end
s.subspec 'full-lts' do |ss| s.subspec 'full-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-full', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-macos-full', "5.1.LTS"
ss.osx.deployment_target = '10.12' ss.osx.deployment_target = '10.12'
end end
s.subspec 'full-gpl' do |ss| s.subspec 'full-gpl' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-full-gpl', "4.5.1" ss.dependency 'ffmpeg-kit-macos-full-gpl', "5.1"
ss.osx.deployment_target = '10.15' ss.osx.deployment_target = '10.15'
end end
s.subspec 'full-gpl-lts' do |ss| s.subspec 'full-gpl-lts' do |ss|
ss.source_files = 'Classes/**/*' ss.source_files = 'Classes/**/*'
ss.public_header_files = 'Classes/**/*.h' ss.public_header_files = 'Classes/**/*.h'
ss.dependency 'ffmpeg-kit-macos-full-gpl', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-macos-full-gpl', "5.1.LTS"
ss.osx.deployment_target = '10.12' ss.osx.deployment_target = '10.12'
end end

View File

@ -3,7 +3,7 @@ description: FFmpeg Kit for Flutter. Supports Android, iOS and macOS platforms.
repository: https://github.com/arthenica/ffmpeg-kit repository: https://github.com/arthenica/ffmpeg-kit
issue_tracker: https://github.com/arthenica/ffmpeg-kit/issues issue_tracker: https://github.com/arthenica/ffmpeg-kit/issues
homepage: https://github.com/arthenica/ffmpeg-kit homepage: https://github.com/arthenica/ffmpeg-kit
version: 4.5.1 version: 5.1.0
environment: environment:
sdk: ">=2.12.0 <3.0.0" sdk: ">=2.12.0 <3.0.0"
@ -28,4 +28,4 @@ dependencies:
dev_dependencies: dev_dependencies:
flutter_test: flutter_test:
sdk: flutter sdk: flutter
plugin_platform_interface: ^2.0.2 plugin_platform_interface: ^2.1.3

View File

@ -4,11 +4,13 @@
- Includes both `FFmpeg` and `FFprobe` - Includes both `FFmpeg` and `FFprobe`
- Supports - Supports
- Both `Android` and `iOS` - Both `Android` and `iOS`
- FFmpeg `v4.5-dev` releases - FFmpeg `v5.1.2`
- `arm-v7a`, `arm-v7a-neon`, `arm64-v8a`, `x86` and `x86_64` architectures on Android - `arm-v7a`, `arm-v7a-neon`, `arm64-v8a`, `x86` and `x86_64` architectures on Android
- `Android API Level 16` or later - `Android API Level 24` or later
- `API Level 16` on LTS releases
- `armv7`, `armv7s`, `arm64`, `arm64-simulator`, `i386`, `x86_64`, `x86_64-mac-catalyst` and `arm64-mac-catalyst` architectures on iOS - `armv7`, `armv7s`, `arm64`, `arm64-simulator`, `i386`, `x86_64`, `x86_64-mac-catalyst` and `arm64-mac-catalyst` architectures on iOS
- `iOS SDK 10` or later - `iOS SDK 12.1` or later
- `iOS SDK 10` on LTS releases
- Can process Storage Access Framework (SAF) Uris on Android - Can process Storage Access Framework (SAF) Uris on Android
- 25 external libraries - 25 external libraries
@ -22,7 +24,7 @@
- `bzip2`, `iconv`, `libuuid`, `zlib` system libraries and `AudioToolbox`, `VideoToolbox`, `AVFoundation` system frameworks on iOS - `bzip2`, `iconv`, `libuuid`, `zlib` system libraries and `AudioToolbox`, `VideoToolbox`, `AVFoundation` system frameworks on iOS
- Includes Typescript definitions - Includes Typescript definitions
- Licensed under LGPL 3.0, can be customized to support GPL v3.0 - Licensed under `LGPL 3.0` by default, some packages licensed by `GPL v3.0` effectively
### 2. Installation ### 2. Installation
@ -32,16 +34,16 @@ yarn add ffmpeg-kit-react-native
#### 2.1 Packages #### 2.1 Packages
`ffmpeg` includes built-in encoders for some popular formats. However, there are certain external libraries that needs `FFmpeg` includes built-in encoders for some popular formats. However, there are certain external libraries that needs
to be enabled in order to encode specific formats/codecs. For example, to encode an `mp3` file you need `lame` or to be enabled in order to encode specific formats/codecs. For example, to encode an `mp3` file you need `lame` or
`shine` library enabled. You have to install a `ffmpeg-kit-react-native` package that has at least one of them inside. `shine` library enabled. You have to install a `ffmpeg-kit-react-native` package that has at least one of them inside.
To encode an `h264` video, you need to install a package with `x264` inside. To encode `vp8` or `vp9` videos, you need To encode an `h264` video, you need to install a package with `x264` inside. To encode `vp8` or `vp9` videos, you need
a `ffmpeg-kit-react-native` package with `libvpx` inside. a `ffmpeg-kit-react-native` package with `libvpx` inside.
`ffmpeg-kit` provides eight packages that include different sets of external libraries. These packages are `ffmpeg-kit` provides eight packages that include different sets of external libraries. These packages are named
named according to the external libraries included in them. Refer to according to the external libraries included. Refer to the
[Packages](https://github.com/arthenica/ffmpeg-kit#8-packages) section of the project README to see the names [Packages](https://github.com/arthenica/ffmpeg-kit/wiki/Packages) wiki page to see the names of those
of those packages and external libraries included in each of them. packages and external libraries included in each one of them.
##### 2.1.1 Package Names ##### 2.1.1 Package Names
@ -184,10 +186,10 @@ the package name you are using.
#### 2.4 LTS Releases #### 2.4 LTS Releases
`ffmpeg-kit-react-native` is published in two different variants: `Main Release` and `LTS Release`. Both releases `ffmpeg-kit-react-native` is published in two variants: `Main Release` and `LTS Release`. Both releases share the
share the same source code but is built with different settings (Architectures, API Level, iOS Min SDK, etc.). Refer to same source code but is built with different settings (Architectures, API Level, iOS Min SDK, etc.). Refer to the
[LTS Releases](https://github.com/arthenica/ffmpeg-kit#9-lts-releases) section of the project README to see how they [LTS Releases](https://github.com/arthenica/ffmpeg-kit/wiki/LTS-Releases) wiki page to see how they differ from each
compare to each other. other.
### 3. Using ### 3. Using

View File

@ -1,11 +1,11 @@
buildscript { buildscript {
repositories { repositories {
google() google()
jcenter() mavenCentral()
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:4.2.2' classpath 'com.android.tools.build:gradle:7.3.0'
} }
} }
@ -26,13 +26,13 @@ def safeExtGet(String prop, String fallback) {
} }
android { android {
compileSdkVersion 30 compileSdkVersion 31
defaultConfig { defaultConfig {
minSdkVersion safeExtGet('ffmpegKitPackage', 'https').contains("-lts") ? 16 : 24 minSdkVersion safeExtGet('ffmpegKitPackage', 'https').contains("-lts") ? 16 : 24
targetSdkVersion 30 targetSdkVersion 31
versionCode 452 versionCode 510
versionName "4.5.2" versionName "5.1.0"
} }
buildTypes { buildTypes {
@ -44,14 +44,13 @@ android {
disable 'GradleCompatible' disable 'GradleCompatible'
} }
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_11
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_11
} }
} }
repositories { repositories {
mavenCentral() mavenCentral()
jcenter()
google() google()
def found = false def found = false

View File

@ -1,3 +1,3 @@
android.useAndroidX=true android.useAndroidX=true
ffmpegKit.android.main.version=4.5.1-1 ffmpegKit.android.main.version=5.1
ffmpegKit.android.lts.version=4.5.1-1 ffmpegKit.android.lts.version=5.1

View File

@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.1-bin.zip distributionUrl=https\://services.gradle.org/distributions/gradle-7.5.1-bin.zip
zipStoreBase=GRADLE_USER_HOME zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists zipStorePath=wrapper/dists

View File

@ -344,7 +344,7 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule {
@ReactMethod @ReactMethod
public void ffmpegSession(final ReadableArray readableArray, final Promise promise) { public void ffmpegSession(final ReadableArray readableArray, final Promise promise) {
promise.resolve(toMap(new FFmpegSession(toArgumentsArray(readableArray), null, null, null, LogRedirectionStrategy.NEVER_PRINT_LOGS))); promise.resolve(toMap(FFmpegSession.create(toArgumentsArray(readableArray), null, null, null, LogRedirectionStrategy.NEVER_PRINT_LOGS)));
} }
@ReactMethod @ReactMethod
@ -395,14 +395,14 @@ public class FFmpegKitReactNativeModule extends ReactContextBaseJavaModule {
@ReactMethod @ReactMethod
public void ffprobeSession(final ReadableArray readableArray, final Promise promise) { public void ffprobeSession(final ReadableArray readableArray, final Promise promise) {
promise.resolve(toMap(new FFprobeSession(toArgumentsArray(readableArray), null, null, LogRedirectionStrategy.NEVER_PRINT_LOGS))); promise.resolve(toMap(FFprobeSession.create(toArgumentsArray(readableArray), null, null, LogRedirectionStrategy.NEVER_PRINT_LOGS)));
} }
// MediaInformationSession // MediaInformationSession
@ReactMethod @ReactMethod
public void mediaInformationSession(final ReadableArray readableArray, final Promise promise) { public void mediaInformationSession(final ReadableArray readableArray, final Promise promise) {
promise.resolve(toMap(new MediaInformationSession(toArgumentsArray(readableArray), null, null))); promise.resolve(toMap(MediaInformationSession.create(toArgumentsArray(readableArray), null, null)));
} }
// MediaInformationJsonParser // MediaInformationJsonParser

View File

@ -23,112 +23,112 @@ Pod::Spec.new do |s|
s.subspec 'min' do |ss| s.subspec 'min' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-min', "4.5.1" ss.dependency 'ffmpeg-kit-ios-min', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'min-lts' do |ss| s.subspec 'min-lts' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-min', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-min', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'min-gpl' do |ss| s.subspec 'min-gpl' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-min-gpl', "4.5.1" ss.dependency 'ffmpeg-kit-ios-min-gpl', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'min-gpl-lts' do |ss| s.subspec 'min-gpl-lts' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-min-gpl', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-min-gpl', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'https' do |ss| s.subspec 'https' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-https', "4.5.1" ss.dependency 'ffmpeg-kit-ios-https', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'https-lts' do |ss| s.subspec 'https-lts' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-https', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-https', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'https-gpl' do |ss| s.subspec 'https-gpl' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-https-gpl', "4.5.1" ss.dependency 'ffmpeg-kit-ios-https-gpl', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'https-gpl-lts' do |ss| s.subspec 'https-gpl-lts' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-https-gpl', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-https-gpl', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'audio' do |ss| s.subspec 'audio' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-audio', "4.5.1" ss.dependency 'ffmpeg-kit-ios-audio', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'audio-lts' do |ss| s.subspec 'audio-lts' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-audio', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-audio', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'video' do |ss| s.subspec 'video' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-video', "4.5.1" ss.dependency 'ffmpeg-kit-ios-video', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'video-lts' do |ss| s.subspec 'video-lts' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-video', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-video', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'full' do |ss| s.subspec 'full' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-full', "4.5.1" ss.dependency 'ffmpeg-kit-ios-full', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'full-lts' do |ss| s.subspec 'full-lts' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-full', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-full', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end
s.subspec 'full-gpl' do |ss| s.subspec 'full-gpl' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-full-gpl', "4.5.1" ss.dependency 'ffmpeg-kit-ios-full-gpl', "5.1"
ss.ios.deployment_target = '12.1' ss.ios.deployment_target = '12.1'
end end
s.subspec 'full-gpl-lts' do |ss| s.subspec 'full-gpl-lts' do |ss|
ss.source_files = '**/FFmpegKitReactNativeModule.m', ss.source_files = '**/FFmpegKitReactNativeModule.m',
'**/FFmpegKitReactNativeModule.h' '**/FFmpegKitReactNativeModule.h'
ss.dependency 'ffmpeg-kit-ios-full-gpl', "4.5.1.LTS" ss.dependency 'ffmpeg-kit-ios-full-gpl', "5.1.LTS"
ss.ios.deployment_target = '10' ss.ios.deployment_target = '10'
end end

View File

@ -244,7 +244,7 @@ RCT_EXPORT_METHOD(getArch:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRe
// FFmpegSession // FFmpegSession
RCT_EXPORT_METHOD(ffmpegSession:(NSArray*)arguments resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCT_EXPORT_METHOD(ffmpegSession:(NSArray*)arguments resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
FFmpegSession* session = [[FFmpegSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil withStatisticsCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; FFmpegSession* session = [FFmpegSession create:arguments withCompleteCallback:nil withLogCallback:nil withStatisticsCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs];
resolve([FFmpegKitReactNativeModule toSessionDictionary:session]); resolve([FFmpegKitReactNativeModule toSessionDictionary:session]);
} }
@ -285,37 +285,35 @@ RCT_EXPORT_METHOD(ffmpegSessionGetStatistics:(int)sessionId resolver:(RCTPromise
// FFprobeSession // FFprobeSession
RCT_EXPORT_METHOD(ffprobeSession:(NSArray*)arguments resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCT_EXPORT_METHOD(ffprobeSession:(NSArray*)arguments resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
FFprobeSession* session = [[FFprobeSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs]; FFprobeSession* session = [FFprobeSession create:arguments withCompleteCallback:nil withLogCallback:nil withLogRedirectionStrategy:LogRedirectionStrategyNeverPrintLogs];
resolve([FFmpegKitReactNativeModule toSessionDictionary:session]); resolve([FFmpegKitReactNativeModule toSessionDictionary:session]);
} }
// MediaInformationSession // MediaInformationSession
RCT_EXPORT_METHOD(mediaInformationSession:(NSArray*)arguments resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCT_EXPORT_METHOD(mediaInformationSession:(NSArray*)arguments resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
MediaInformationSession* session = [[MediaInformationSession alloc] init:arguments withCompleteCallback:nil withLogCallback:nil]; MediaInformationSession* session = [MediaInformationSession create:arguments withCompleteCallback:nil withLogCallback:nil];
resolve([FFmpegKitReactNativeModule toSessionDictionary:session]); resolve([FFmpegKitReactNativeModule toSessionDictionary:session]);
} }
// MediaInformationJsonParser // MediaInformationJsonParser
RCT_EXPORT_METHOD(mediaInformationJsonParserFrom:(NSString*)ffprobeJsonOutput resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCT_EXPORT_METHOD(mediaInformationJsonParserFrom:(NSString*)ffprobeJsonOutput resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
NSError *error; @try {
MediaInformation* mediaInformation = [MediaInformationJsonParser from:ffprobeJsonOutput with:error]; MediaInformation* mediaInformation = [MediaInformationJsonParser fromWithError:ffprobeJsonOutput];
if (error == nil) {
resolve([FFmpegKitReactNativeModule toMediaInformationDictionary:mediaInformation]); resolve([FFmpegKitReactNativeModule toMediaInformationDictionary:mediaInformation]);
} else { } @catch (NSException *exception) {
NSLog(@"MediaInformation parsing failed: %@.\n", error); NSLog(@"Parsing MediaInformation failed: %@.\n", [NSString stringWithFormat:@"%@\n%@", [exception userInfo], [exception callStackSymbols]]);
resolve(nil); resolve(nil);
} }
} }
RCT_EXPORT_METHOD(mediaInformationJsonParserFromWithError:(NSString*)ffprobeJsonOutput resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) { RCT_EXPORT_METHOD(mediaInformationJsonParserFromWithError:(NSString*)ffprobeJsonOutput resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject) {
NSError *error; @try {
MediaInformation* mediaInformation = [MediaInformationJsonParser from:ffprobeJsonOutput with:error]; MediaInformation* mediaInformation = [MediaInformationJsonParser fromWithError:ffprobeJsonOutput];
if (error == nil) {
resolve([FFmpegKitReactNativeModule toMediaInformationDictionary:mediaInformation]); resolve([FFmpegKitReactNativeModule toMediaInformationDictionary:mediaInformation]);
} else { } @catch (NSException *exception) {
NSLog(@"MediaInformation parsing failed: %@.\n", error); NSLog(@"Parsing MediaInformation failed: %@.\n", [NSString stringWithFormat:@"%@\n%@", [exception userInfo], [exception callStackSymbols]]);
reject(@"PARSE_FAILED", @"Parsing MediaInformation failed with JSON error.", nil); reject(@"PARSE_FAILED", @"Parsing MediaInformation failed with JSON error.", nil);
} }
} }

View File

@ -1,6 +1,6 @@
{ {
"name": "ffmpeg-kit-react-native", "name": "ffmpeg-kit-react-native",
"version": "4.5.2", "version": "5.1.0",
"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",
@ -19,7 +19,7 @@
"ios" "ios"
], ],
"repository": "https://github.com/arthenica/ffmpeg-kit", "repository": "https://github.com/arthenica/ffmpeg-kit",
"author": "ARTHENICA <open-source@arthenica.com> (https://github.com/arthenica)", "author": "ARTHENICA <open-source@arthenica.com> (https://www.arthenica.com)",
"license": "LGPL-3.0", "license": "LGPL-3.0",
"bugs": { "bugs": {
"url": "https://github.com/arthenica/ffmpeg-kit/issues" "url": "https://github.com/arthenica/ffmpeg-kit/issues"

View File

@ -2,8 +2,6 @@ declare module 'ffmpeg-kit-react-native' {
export abstract class AbstractSession implements Session { export abstract class AbstractSession implements Session {
protected constructor();
static createFFmpegSession(argumentsArray: Array<string>, logRedirectionStrategy?: LogRedirectionStrategy): Promise<FFmpegSession>; static createFFmpegSession(argumentsArray: Array<string>, logRedirectionStrategy?: LogRedirectionStrategy): Promise<FFmpegSession>;
static createFFmpegSessionFromMap(sessionMap: { [key: string]: any }): FFmpegSession; static createFFmpegSessionFromMap(sessionMap: { [key: string]: any }): FFmpegSession;
@ -212,12 +210,8 @@ declare module 'ffmpeg-kit-react-native' {
export class FFmpegSession extends AbstractSession implements Session { export class FFmpegSession extends AbstractSession implements Session {
constructor();
static create(argumentsArray: Array<string>, completeCallback?: FFmpegSessionCompleteCallback, logCallback?: LogCallback, statisticsCallback?: StatisticsCallback, logRedirectionStrategy?: LogRedirectionStrategy): Promise<FFmpegSession>; static create(argumentsArray: Array<string>, completeCallback?: FFmpegSessionCompleteCallback, logCallback?: LogCallback, statisticsCallback?: StatisticsCallback, logRedirectionStrategy?: LogRedirectionStrategy): Promise<FFmpegSession>;
static fromMap(sessionMap: { [key: string]: any }): FFmpegSession;
getStatisticsCallback(): StatisticsCallback; getStatisticsCallback(): StatisticsCallback;
getCompleteCallback(): FFmpegSessionCompleteCallback; getCompleteCallback(): FFmpegSessionCompleteCallback;
@ -266,12 +260,8 @@ declare module 'ffmpeg-kit-react-native' {
export class FFprobeSession extends AbstractSession implements Session { export class FFprobeSession extends AbstractSession implements Session {
constructor();
static create(argumentsArray: Array<string>, completeCallback?: FFprobeSessionCompleteCallback, logCallback?: LogCallback, logRedirectionStrategy?: LogRedirectionStrategy): Promise<FFprobeSession>; static create(argumentsArray: Array<string>, completeCallback?: FFprobeSessionCompleteCallback, logCallback?: LogCallback, logRedirectionStrategy?: LogRedirectionStrategy): Promise<FFprobeSession>;
static fromMap(sessionMap: { [key: string]: any }): FFprobeSession;
getCompleteCallback(): FFprobeSessionCompleteCallback; getCompleteCallback(): FFprobeSessionCompleteCallback;
isFFmpeg(): boolean; isFFmpeg(): boolean;
@ -321,7 +311,7 @@ declare module 'ffmpeg-kit-react-native' {
export class MediaInformation { export class MediaInformation {
static readonly KEY_MEDIA_PROPERTIES: string; static readonly KEY_FORMAT_PROPERTIES: string;
static readonly KEY_FILENAME: string; static readonly KEY_FILENAME: string;
static readonly KEY_FORMAT: string; static readonly KEY_FORMAT: string;
static readonly KEY_FORMAT_LONG: string; static readonly KEY_FORMAT_LONG: string;
@ -357,9 +347,15 @@ declare module 'ffmpeg-kit-react-native' {
getNumberProperty(key: string): number; getNumberProperty(key: string): number;
getProperties(key: string): Record<string, any>; getProperty(key: string): any;
getMediaProperties(): Record<string, any>; getStringFormatProperty(key: string): string;
getNumberFormatProperty(key: string): number;
getFormatProperty(key: string): any;
getFormatProperties(): Record<string, any>;
getAllProperties(): Record<string, any>; getAllProperties(): Record<string, any>;
@ -375,12 +371,8 @@ declare module 'ffmpeg-kit-react-native' {
export class MediaInformationSession extends AbstractSession implements Session { export class MediaInformationSession extends AbstractSession implements Session {
constructor();
static create(argumentsArray: Array<string>, completeCallback?: MediaInformationSessionCompleteCallback, logCallback?: LogCallback): Promise<MediaInformationSession>; static create(argumentsArray: Array<string>, completeCallback?: MediaInformationSessionCompleteCallback, logCallback?: LogCallback): Promise<MediaInformationSession>;
static fromMap(sessionMap: { [key: string]: any }): MediaInformationSession;
getMediaInformation(): MediaInformation; getMediaInformation(): MediaInformation;
setMediaInformation(mediaInformation: MediaInformation): void; setMediaInformation(mediaInformation: MediaInformation): void;
@ -591,7 +583,7 @@ declare module 'ffmpeg-kit-react-native' {
getNumberProperty(key): number; getNumberProperty(key): number;
getProperties(key): Record<string, any>; getProperty(key): any;
getAllProperties(): Record<string, any>; getAllProperties(): Record<string, any>;
@ -627,7 +619,7 @@ declare module 'ffmpeg-kit-react-native' {
getNumberProperty(key): number; getNumberProperty(key): number;
getProperties(key): Record<string, any>; getProperty(key): any;
getAllProperties(): Record<string, any>; getAllProperties(): Record<string, any>;

View File

@ -296,13 +296,6 @@ export class AbstractSession extends Session {
*/ */
#logRedirectionStrategy; #logRedirectionStrategy;
/**
* Creates a new abstract session.
*/
constructor() {
super();
}
/** /**
* Creates a new FFmpeg session. * Creates a new FFmpeg session.
* *
@ -1605,12 +1598,12 @@ class FFmpegKitFactory {
if (sessionMap !== undefined) { if (sessionMap !== undefined) {
switch (sessionMap.type) { switch (sessionMap.type) {
case 2: case 2:
return FFprobeSession.fromMap(sessionMap); return AbstractSession.createFFprobeSessionFromMap(sessionMap);
case 3: case 3:
return MediaInformationSession.fromMap(sessionMap); return AbstractSession.createMediaInformationSessionFromMap(sessionMap);
case 1: case 1:
default: default:
return FFmpegSession.fromMap(sessionMap); return AbstractSession.createFFmpegSessionFromMap(sessionMap);
} }
} else { } else {
return undefined; return undefined;
@ -1618,7 +1611,7 @@ class FFmpegKitFactory {
} }
static getVersion() { static getVersion() {
return "4.5.2"; return "5.1.0";
} }
static getLogRedirectionStrategy(sessionId) { static getLogRedirectionStrategy(sessionId) {
@ -1935,13 +1928,6 @@ class FFmpegKitInitializer {
*/ */
export class FFmpegSession extends AbstractSession { export class FFmpegSession extends AbstractSession {
/**
* Creates an empty FFmpeg session.
*/
constructor() {
super();
}
/** /**
* Creates a new FFmpeg session. * Creates a new FFmpeg session.
* *
@ -1963,16 +1949,6 @@ export class FFmpegSession extends AbstractSession {
return session; return session;
} }
/**
* Creates a new FFmpeg session from the given map.
*
* @param sessionMap map that includes session fields as map keys
* @returns FFmpeg session created
*/
static fromMap(sessionMap) {
return AbstractSession.createFFmpegSessionFromMap(sessionMap);
}
/** /**
* Returns the session specific statistics callback. * Returns the session specific statistics callback.
* *
@ -2252,13 +2228,6 @@ export class FFprobeKit {
*/ */
export class FFprobeSession extends AbstractSession { export class FFprobeSession extends AbstractSession {
/**
* Creates an empty FFprobe session.
*/
constructor() {
super();
}
/** /**
* Creates a new FFprobe session. * Creates a new FFprobe session.
* *
@ -2278,16 +2247,6 @@ export class FFprobeSession extends AbstractSession {
return session; return session;
} }
/**
* Creates a new FFprobe session from the given map.
*
* @param sessionMap map that includes session fields as map keys
* @returns FFprobe session created
*/
static fromMap(sessionMap) {
return AbstractSession.createFFprobeSessionFromMap(sessionMap);
}
/** /**
* Returns the session specific complete callback. * Returns the session specific complete callback.
* *
@ -2438,7 +2397,7 @@ export class Log {
*/ */
export class MediaInformation { export class MediaInformation {
static KEY_MEDIA_PROPERTIES = "format"; static KEY_FORMAT_PROPERTIES = "format";
static KEY_FILENAME = "filename"; static KEY_FILENAME = "filename";
static KEY_FORMAT = "format_name"; static KEY_FORMAT = "format_name";
static KEY_FORMAT_LONG = "format_long_name"; static KEY_FORMAT_LONG = "format_long_name";
@ -2460,7 +2419,7 @@ export class MediaInformation {
* @return media file name * @return media file name
*/ */
getFilename() { getFilename() {
return this.getStringProperty(MediaInformation.KEY_FILENAME); return this.getStringFormatProperty(MediaInformation.KEY_FILENAME);
} }
/** /**
@ -2469,7 +2428,7 @@ export class MediaInformation {
* @return media format * @return media format
*/ */
getFormat() { getFormat() {
return this.getStringProperty(MediaInformation.KEY_FORMAT); return this.getStringFormatProperty(MediaInformation.KEY_FORMAT);
} }
/** /**
@ -2478,7 +2437,7 @@ export class MediaInformation {
* @return media long format * @return media long format
*/ */
getLongFormat() { getLongFormat() {
return this.getStringProperty(MediaInformation.KEY_FORMAT_LONG); return this.getStringFormatProperty(MediaInformation.KEY_FORMAT_LONG);
} }
/** /**
@ -2487,7 +2446,7 @@ export class MediaInformation {
* @return media duration in "seconds.microseconds" format * @return media duration in "seconds.microseconds" format
*/ */
getDuration() { getDuration() {
return this.getStringProperty(MediaInformation.KEY_DURATION); return this.getStringFormatProperty(MediaInformation.KEY_DURATION);
} }
/** /**
@ -2496,7 +2455,7 @@ export class MediaInformation {
* @return media start time in milliseconds * @return media start time in milliseconds
*/ */
getStartTime() { getStartTime() {
return this.getStringProperty(MediaInformation.KEY_START_TIME); return this.getStringFormatProperty(MediaInformation.KEY_START_TIME);
} }
/** /**
@ -2505,7 +2464,7 @@ export class MediaInformation {
* @return media size in bytes * @return media size in bytes
*/ */
getSize() { getSize() {
return this.getStringProperty(MediaInformation.KEY_SIZE); return this.getStringFormatProperty(MediaInformation.KEY_SIZE);
} }
/** /**
@ -2514,7 +2473,7 @@ export class MediaInformation {
* @return media bitrate in kb/s * @return media bitrate in kb/s
*/ */
getBitrate() { getBitrate() {
return this.getStringProperty(MediaInformation.KEY_BIT_RATE); return this.getStringFormatProperty(MediaInformation.KEY_BIT_RATE);
} }
/** /**
@ -2523,7 +2482,7 @@ export class MediaInformation {
* @return tags dictionary * @return tags dictionary
*/ */
getTags() { getTags() {
return this.getProperties(MediaInformation.KEY_TAGS); return this.getFormatProperty(MediaInformation.KEY_TAGS);
} }
/** /**
@ -2571,58 +2530,103 @@ export class MediaInformation {
} }
/** /**
* Returns the media property associated with the key. * Returns the property associated with the key.
* *
* @param key property key * @param key property key
* @return media property as string or undefined if the key is not found * @return property as string or undefined if the key is not found
*/ */
getStringProperty(key) { getStringProperty(key) {
let mediaProperties = this.getMediaProperties(); let allProperties = this.getAllProperties();
if (mediaProperties !== undefined) { if (allProperties !== undefined) {
return mediaProperties[key]; return allProperties[key];
} else { } else {
return undefined; return undefined;
} }
} }
/** /**
* Returns the media property associated with the key. * Returns the property associated with the key.
* *
* @param key property key * @param key property key
* @return media property as number or undefined if the key is not found * @return property as number or undefined if the key is not found
*/ */
getNumberProperty(key) { getNumberProperty(key) {
let mediaProperties = this.getMediaProperties(); let allProperties = this.getAllProperties();
if (mediaProperties !== undefined) { if (allProperties !== undefined) {
return mediaProperties[key]; return allProperties[key];
} else { } else {
return undefined; return undefined;
} }
} }
/** /**
* Returns the media properties associated with the key. * Returns the property associated with the key.
* *
* @param key properties key * @param key property key
* @return media properties as an object or undefined if the key is not found * @return property as an object or undefined if the key is not found
*/ */
getProperties(key) { getProperty(key) {
let mediaProperties = this.getMediaProperties(); let allProperties = this.getAllProperties();
if (mediaProperties !== undefined) { if (allProperties !== undefined) {
return mediaProperties[key]; return allProperties[key];
} else { } else {
return undefined; return undefined;
} }
} }
/** /**
* Returns all media properties. * Returns the format property associated with the key.
* *
* @returns an object where media properties can be accessed by property names * @param key property key
* @return format property as string or undefined if the key is not found
*/ */
getMediaProperties() { getStringFormatProperty(key) {
let formatProperties = this.getFormatProperties();
if (formatProperties !== undefined) {
return formatProperties[key];
} else {
return undefined;
}
}
/**
* Returns the format property associated with the key.
*
* @param key property key
* @return format property as number or undefined if the key is not found
*/
getNumberFormatProperty(key) {
let formatProperties = this.getFormatProperties();
if (formatProperties !== undefined) {
return formatProperties[key];
} else {
return undefined;
}
}
/**
* Returns the format property associated with the key.
*
* @param key property key
* @return format property as an object or undefined if the key is not found
*/
getFormatProperty(key) {
let formatProperties = this.getFormatProperties();
if (formatProperties !== undefined) {
return formatProperties[key];
} else {
return undefined;
}
}
/**
* Returns all format properties defined.
*
* @returns an object where format properties can be accessed by property names
*/
getFormatProperties() {
if (this.#allProperties !== undefined) { if (this.#allProperties !== undefined) {
return this.#allProperties.format; return this.#allProperties[MediaInformation.KEY_FORMAT_PROPERTIES];
} else { } else {
return undefined; return undefined;
} }
@ -2677,13 +2681,6 @@ export class MediaInformationJsonParser {
export class MediaInformationSession extends AbstractSession { export class MediaInformationSession extends AbstractSession {
#mediaInformation; #mediaInformation;
/**
* Creates an empty MediaInformationSession.
*/
constructor() {
super();
}
/** /**
* Creates a new MediaInformationSession session. * Creates a new MediaInformationSession session.
* *
@ -2702,16 +2699,6 @@ export class MediaInformationSession extends AbstractSession {
return session; return session;
} }
/**
* Creates a new MediaInformationSession from the given map.
*
* @param sessionMap map that includes session fields as map keys
* @returns MediaInformationSession created
*/
static fromMap(sessionMap) {
return AbstractSession.createMediaInformationSessionFromMap(sessionMap);
}
/** /**
* Returns the media information extracted in this session. * Returns the media information extracted in this session.
* *
@ -3104,7 +3091,7 @@ export class StreamInformation {
* @return tags object * @return tags object
*/ */
getTags() { getTags() {
return this.getProperties(StreamInformation.KEY_TAGS); return this.getProperty(StreamInformation.KEY_TAGS);
} }
/** /**
@ -3136,12 +3123,12 @@ export class StreamInformation {
} }
/** /**
* Returns the stream properties associated with the key. * Returns the stream property associated with the key.
* *
* @param key properties key * @param key property key
* @return stream properties as an object or undefined if the key is not found * @return stream property as an object or undefined if the key is not found
*/ */
getProperties(key) { getProperty(key) {
if (this.#allProperties !== undefined) { if (this.#allProperties !== undefined) {
return this.#allProperties[key]; return this.#allProperties[key];
} else { } else {
@ -3238,7 +3225,7 @@ export class Chapter {
* @return tags object * @return tags object
*/ */
getTags() { getTags() {
return this.getProperties(StreamInformation.KEY_TAGS); return this.getProperty(StreamInformation.KEY_TAGS);
} }
/** /**
@ -3270,12 +3257,12 @@ export class Chapter {
} }
/** /**
* Returns the chapter properties associated with the key. * Returns the chapter property associated with the key.
* *
* @param key properties key * @param key property key
* @return chapter properties as an object or undefined if the key is not found * @return chapter property as an object or undefined if the key is not found
*/ */
getProperties(key) { getProperty(key) {
if (this.#allProperties !== undefined) { if (this.#allProperties !== undefined) {
return this.#allProperties[key]; return this.#allProperties[key];
} else { } else {