react-native-ffmpeg
Advanced tools
Comparing version
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
## 0.3.1 - 2019-01-31 | ||
- Includes fixes and enhancements for issues #41, #42 and #43. | ||
## 0.3.0 - 2018-12-29 | ||
@@ -5,0 +8,0 @@ - Using mobile-ffmpeg-v4.2.LTS |
@@ -234,5 +234,6 @@ import { NativeEventEmitter, NativeModules } from 'react-native'; | ||
* @param path which contains fonts (.ttf, .otf files) | ||
* @param mapping font name mapping like {"my_easy_font_name":"my complex font name"} | ||
*/ | ||
setFontDirectory(path) { | ||
RNFFmpegModule.setFontDirectory(path); | ||
setFontDirectory(path, mapping) { | ||
RNFFmpegModule.setFontDirectory(path, mapping); | ||
} | ||
@@ -239,0 +240,0 @@ |
{ | ||
"name": "react-native-ffmpeg", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "FFmpeg for React Native", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
174
README.md
@@ -1,2 +0,2 @@ | ||
# React Native FFmpeg [](https://gitter.im/react-native-ffmpeg/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)  [](react-native-ffmpeg) | ||
# React Native FFmpeg [](https://gitter.im/react-native-ffmpeg/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)  [](react-native-ffmpeg) | ||
@@ -8,3 +8,3 @@ FFmpeg for React Native | ||
### 1. Features | ||
- Based on Mobile FFmpeg | ||
- Based on MobileFFmpeg | ||
- Supports | ||
@@ -83,2 +83,4 @@ - Both Android and IOS | ||
``` | ||
- **DO NOT USE** `react-native link` **on IOS.** `react-native link` breaks Cocoapods dependencies. | ||
@@ -88,6 +90,6 @@ ##### 2.2.2 Advanced | ||
#### 2.3 Using Packages | ||
#### 2.3 Packages | ||
Default installation of `ReactNativeFFmpeg` using instructions in `2.1` and `2.2` enables the default package, which is based | ||
on `https` package. It is possible to enable other installed packages using following steps. | ||
Installation of `react-native-ffmpeg` using instructions in `2.1` and `2.2` enables the default package, which is based | ||
on `https` package. It is possible to enable other installed packages using the following steps. | ||
@@ -110,21 +112,24 @@ ##### 2.3.1 Android | ||
##### 2.3.3 Android Camera Support | ||
`mobile-ffmpeg v4.2` adds supports for `android_camera` device in main releases (non-LTS). If you want to access `Android` camera, enable support by selecting a non-LTS version for `mobile-ffmpeg` inside `build.gradle` file imported, under `../node_modules/react-native-ffmpeg/android` path. | ||
Please note that `devices with deprecated camera HAL 1.0 implementations (camera devices that have the LEGACY hardware level) are not supported` as described in [Android NDK Native API](https://developer.android.com/ndk/guides/stable_apis#camera) documentation. | ||
### 3. Using | ||
##### 2.3.4 IOS arm64e Support | ||
`mobile-ffmpeg` supports `arm64e` architecture in main releases (non-LTS) since `v4.2`. You can enable support for `arm64e` architecture by specifying a non-LTS version for `mobile-ffmpeg` inside imported `./node_modules/react-native-ffmpeg/ios/react-native-ffmpeg.podspec` file. | ||
1. Execute commands. | ||
### 3. Using | ||
- Use execute() method with a single command line and an argument delimiter | ||
1. Execute commands. | ||
``` | ||
import { LogLevel, RNFFmpeg } from 'react-native-ffmpeg'; | ||
RNFFmpeg.execute('-i file1.mp4 -c:v mpeg4 file2.mp4'); | ||
RNFFmpeg.execute('-i file1.mp4 -c:v mpeg4 file2.mp4', ' ').then(result => console.log("FFmpeg process exited with rc " + result.rc)); | ||
``` | ||
2. Check execution output. | ||
- Use executeWithArguments() method with an array of arguments | ||
``` | ||
import { LogLevel, RNFFmpeg } from 'react-native-ffmpeg'; | ||
RNFFmpeg.executeWithArguments(["-i", "file1.mp4", "-c:v", "mpeg4", "file2.mp4"]).then(result => console.log("FFmpeg process exited with rc " + result.rc)); | ||
``` | ||
2. Check execution output. Zero represents successful execution, non-zero values represent failure. | ||
``` | ||
RNFFmpeg.getLastReturnCode().then(result => { | ||
@@ -139,3 +144,3 @@ console.log("Last return code: " + result.lastRc); | ||
3. Stop an ongoing operation. | ||
3. Stop an ongoing operation. Note that this function does not wait for termination to complete and returns immediately. | ||
``` | ||
@@ -146,2 +151,3 @@ RNFFmpeg.cancel(); | ||
4. Get media information for a file. | ||
- Print all fields | ||
``` | ||
@@ -152,11 +158,38 @@ RNFFmpeg.getMediaInformation('<file path or uri>').then(info => { | ||
``` | ||
5. List enabled external libraries. | ||
- Print selected fields | ||
``` | ||
RNFFmpeg.getExternalLibraries().then(externalLibraries => { | ||
console.log(externalLibraries); | ||
RNFFmpeg.getMediaInformation('<file path or uri>').then(info => { | ||
console.log('Result: ' + JSON.stringify(info)); | ||
console.log('Media Information'); | ||
console.log('Path: ' + info.path); | ||
console.log('Format: ' + info.format); | ||
console.log('Duration: ' + info.duration); | ||
console.log('Start time: ' + info.startTime); | ||
console.log('Bitrate: ' + info.bitrate); | ||
if (info.streams) { | ||
for (var i = 0; i < info.streams.length; i++) { | ||
console.log('Stream id: ' + info.streams[i].index); | ||
console.log('Stream type: ' + info.streams[i].type); | ||
console.log('Stream codec: ' + info.streams[i].codec); | ||
console.log('Stream full codec: ' + info.streams[i].fullCodec); | ||
console.log('Stream format: ' + info.streams[i].format); | ||
console.log('Stream full format: ' + info.streams[i].fullFormat); | ||
console.log('Stream width: ' + info.streams[i].width); | ||
console.log('Stream height: ' + info.streams[i].height); | ||
console.log('Stream bitrate: ' + info.streams[i].bitrate); | ||
console.log('Stream sample rate: ' + info.streams[i].sampleRate); | ||
console.log('Stream sample format: ' + info.streams[i].sampleFormat); | ||
console.log('Stream channel layout: ' + info.streams[i].channelLayout); | ||
console.log('Stream sar: ' + info.streams[i].sampleAspectRatio); | ||
console.log('Stream dar: ' + info.streams[i].displayAspectRatio); | ||
console.log('Stream average frame rate: ' + info.streams[i].averageFrameRate); | ||
console.log('Stream real frame rate: ' + info.streams[i].realFrameRate); | ||
console.log('Stream time base: ' + info.streams[i].timeBase); | ||
console.log('Stream codec time base: ' + info.streams[i].codecTimeBase); | ||
} | ||
} | ||
}); | ||
``` | ||
6. Enable log callback. | ||
5. Enable log callback and redirect all `FFmpeg` logs to a console/file/widget. | ||
``` | ||
@@ -170,3 +203,3 @@ logCallback = (logData) => { | ||
7. Enable statistics callback. | ||
6. Enable statistics callback and follow the progress of an ongoing operation. | ||
``` | ||
@@ -180,12 +213,49 @@ statisticsCallback = (statisticsData) => { | ||
``` | ||
8. Set log level. | ||
7. Poll statistics without implementing statistics callback. | ||
``` | ||
RNFFmpeg.getLastReceivedStatistics().then(stats => console.log('Stats: ' + JSON.stringify(stats))); | ||
``` | ||
8. Reset statistics before starting a new operation. | ||
``` | ||
RNFFmpeg.resetStatistics(); | ||
``` | ||
9. Set log level. | ||
``` | ||
RNFFmpeg.setLogLevel(LogLevel.AV_LOG_WARNING); | ||
``` | ||
9. Register custom fonts directory. | ||
10. Register your own fonts by specifying a custom fonts directory, so they are available to use in `FFmpeg` filters. Please note that this function can not work on relative paths, you need to provide full file system path. | ||
- Without any font name mappings | ||
``` | ||
RNFFmpeg.setFontDirectory('<folder with fonts>'); | ||
RNFFmpeg.setFontDirectory('<folder with fonts>', null); | ||
``` | ||
- Apply custom font name mappings. This functionality is very useful if your font name includes ' ' (space) characters in it. | ||
``` | ||
RNFFmpeg.setFontDirectory('<folder with fonts>', { my_easy_font_name: "my complex font name" }); | ||
``` | ||
11. Use your own `fontconfig` configuration. | ||
``` | ||
RNFFmpeg.setFontconfigConfigurationPath('<fontconfig configuration directory>'); | ||
``` | ||
12. Disable log functionality of the library. Logs will not be printed to console and log callback will be disabled. | ||
``` | ||
RNFFmpeg.disableLogs(); | ||
``` | ||
13. Disable statistics functionality of the library. Statistics callback will be disabled but the last received statistics data will be still available. | ||
``` | ||
RNFFmpeg.disableStatistics(); | ||
``` | ||
14. List enabled external libraries. | ||
``` | ||
RNFFmpeg.getExternalLibraries().then(externalLibraries => { | ||
console.log(externalLibraries); | ||
}); | ||
``` | ||
@@ -198,13 +268,36 @@ ### 4. Versions | ||
- `0.2.x` releases are based on `FFmpeg v4.1-dev` and `MobileFFmpeg v3.x` | ||
- `0.3.0` release is based on `FFmpeg v4.2-dev` and `MobileFFmpeg v4.2` | ||
- `0.3.0` and `0.3.1` releases are based on `FFmpeg v4.2-dev` and `MobileFFmpeg v4.2` | ||
#### 4.1 Source Code | ||
#### 4.2 Source Code | ||
- `master` includes latest released version `v0.3.0` | ||
- `master` includes the latest released version `v0.3.1` | ||
- `development` branch includes new features and unreleased fixes | ||
### 5. Updates | ||
### 5. MobileFFmpeg | ||
Refer to [Changelog](CHANGELOG.md) for updates. | ||
`react-native-ffmpeg` uses [MobileFFmpeg](https://github.com/tanersener/mobile-ffmpeg) in its core. | ||
Starting from `v4.2`, `MobileFFmpeg` binaries are published in two different variants: `Main Release` and `LTS Release`. | ||
- Main releases include complete functionality of the library and support the latest SDK/API features | ||
- LTS releases are customized to support a wide range of devices. They are built using older API/SDK versions, so some features are not available for them | ||
By default, `react-native-ffmpeg` releases depend on `LTS` releases, to be backward compatible with its earlier versions. But you can change `MobileFFmpeg` variant and/or version used to support a specific feature/architecture. | ||
- To do that on Android, set a different value to `mobileFFmpegVersion` variable inside `build.gradle` file imported, under `../node_modules/react-native-ffmpeg/android` path. | ||
- On IOS, specify a different version for `mobile-ffmpeg` dependency inside imported `.podspec` file under `../node_modules/react-native-ffmpeg/ios` path. | ||
#### 5.1 Main Release vs LTS Release | ||
| | Main Release | LTS Release | | ||
| :----: | :----: | :----: | | ||
| Android API Level | 24 | 21 | | ||
| Android Camera Access | x | - | | ||
| Android Architectures | arm-v7a-neon<br/>arm64-v8a<br/>x86<br/>x86-64</br> | arm-v7a<br/>arm-v7a-neon<br/>arm64-v8a<br/>x86<br/>x86-64</br> | | ||
| IOS SDK | 12.1 | 9.3 | | ||
| Xcode Support | 10.1 | 7.3.1 | | ||
| IOS Architectures | arm64<br/>arm64e<br/>x86-64</br> | armv7<br/>arm64<br/>i386<br/>x86-64</br> | | ||
### 6. Tips | ||
@@ -214,4 +307,11 @@ | ||
- Sometimes `react-native run-ios` fails with weird build errors. Execute commands below and try again. | ||
- You should not use double quotes (") to define your complex filters or map definitions. | ||
``` | ||
-filter_complex [0:v]scale=1280:-1[v] -map [v] | ||
``` | ||
- If your commands include unnecessary quotes or space characters your command will fail with `No such filter: ' '` errors. Please check your command and remove them. | ||
- Sometimes `react-native run-ios` fails with weird build errors. Execute the following commands and try again. | ||
``` | ||
@@ -268,4 +368,8 @@ rm -rf ios/Pods ios/build ios/Podfile.lock | ||
### 8. License | ||
### 8. Updates | ||
Refer to [Changelog](CHANGELOG.md) for updates. | ||
### 9. License | ||
This project is licensed under the LGPL v3.0. However, if installation is customized to use a package with `-gpl` postfix (min-gpl, https-gpl, full-gpl) then `React Native FFmpeg` is subject to the GPL v3.0 license. | ||
@@ -275,7 +379,7 @@ | ||
### 9. Contributing | ||
### 10. Contributing | ||
Feel free to submit issues or pull requests. | ||
### 10. See Also | ||
### 11. See Also | ||
@@ -282,0 +386,0 @@ - [FFmpeg](https://www.ffmpeg.org) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1922458
0.27%376
38.24%876
-1.57%