Compare commits

..

10 Commits

Author SHA1 Message Date
Taner Sener c293dd421b Using released versions in test-apps. 2018-11-09 15:49:11 +03:00
Taner Sener d46a5e1e66 ios release scripts updated. also fixes #41 for android vorbis builds. 2018-11-09 13:38:10 +03:00
Taner Sener a32f0067d4 ffmpeg patched for https://trac.ffmpeg.org/ticket/7433 2018-11-09 00:53:43 +03:00
Taner Sener aead62b215 new minor release: v2.2 2018-11-08 23:32:23 +03:00
Taner Sener b20376a785 Build file versions updated 2018-11-08 23:16:48 +03:00
Taner Sener e0b4aacf92 new version: libaom v1.0.0-898-g716f2896c 2018-11-08 23:11:46 +03:00
Taner Sener c461ea76d3 new version: x264-snapshot-20181107 2018-11-08 23:08:28 +03:00
Taner Sener ff1b1c4935 new version: ffmpeg v4.0.3 2018-11-03 22:16:09 +03:00
Taner Sener 28e52ed774 new version: opus v1.3 2018-11-03 22:16:08 +03:00
Taner Sener b68ffc3053 updated: android release package information 2018-10-15 23:07:39 +03:00
8270 changed files with 254513 additions and 1656102 deletions
-33
View File
@@ -1,33 +0,0 @@
---
name: Issue Template
about: Create an issue to help us improve
---
**Description**
Description of what the issue is about.
**Expected behavior**
What you expected to happen.
**Current behavior**
What happened.
**Screenshots**
If applicable, add screenshots to help explain your problem.
**Logs**
Post logs here or paste them to [Ghostbin](https://ghostbin.com) and insert the link here.
**Environment**
- Platform: [e.g. Android/IOS]
- Architecture: [arm-v7a, arm-v7a-neon, arm64-v8a, x86, x86_64, armv7, armv7s, arm64, i386, x86_64]
- Version (if applicable) [e.g. v1.2]
- Source branch (if applicable) [e.g. master, dev-v2.x]
- Xcode version (if applicable) [e.g. 7.3.1, 9.0.1]
- Cocoapods version (if applicable) [e.g. 1.2.1]
- Android Studio version (if applicable) [e.g. 3.1]
- Android NDK version (if applicable) [e.g. 16b, 17c]
**Other**
Add any other context about the problem here.
+63 -173
View File
@@ -1,104 +1,61 @@
# MobileFFmpeg [![Join the chat at https://gitter.im/mobile-ffmpeg/Lobby](https://badges.gitter.im/mobile-ffmpeg/Lobby.svg)](https://gitter.im/mobile-ffmpeg/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ![GitHub release](https://img.shields.io/badge/release-v4.2.1-blue.svg) ![Bintray](https://img.shields.io/badge/bintray-v4.2.1-blue.svg) ![CocoaPods](https://img.shields.io/badge/pod-v4.2.1-blue.svg)
# MobileFFmpeg [![Join the chat at https://gitter.im/mobile-ffmpeg/Lobby](https://badges.gitter.im/mobile-ffmpeg/Lobby.svg)](https://gitter.im/mobile-ffmpeg/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ![GitHub release](https://img.shields.io/badge/release-v2.2-blue.svg) ![Bintray](https://img.shields.io/badge/bintray-v2.2-blue.svg) ![CocoaPods](https://img.shields.io/badge/pod-v2.2-blue.svg)
FFmpeg for Android and IOS
<img src="https://github.com/tanersener/mobile-ffmpeg/blob/master/docs/assets/mobile-ffmpeg-logo-v7.png" width="320">
<img src="https://github.com/tanersener/mobile-ffmpeg/blob/dev-v2.x/docs/assets/mobile-ffmpeg-logo-v4.png" width="240">
### 1. Features
- Use binaries available at `Github`/`JCenter`/`CocoaPods` or build your own version with external libraries you need
- Supports
- Both Android and IOS
- FFmpeg `v3.4.x`, `v4.0.x`, `v4.1` and `v4.2-dev` releases
- 27 external libraries
- FFmpeg `v3.4.x` and `v4.0.x` releases
- 24 external libraries
`chromaprint`, `fontconfig`, `freetype`, `fribidi`, `gmp`, `gnutls`, `kvazaar`, `lame`, `libaom`, `libass`, `libiconv`, `libilbc`, `libtheora`, `libvorbis`, `libvpx`, `libwebp`, `libxml2`, `opencore-amr`, `opus`, `sdl`, `shine`, `snappy`, `soxr`, `speex`, `tesseract`, `twolame`, `wavpack`
`chromaprint`, `fontconfig`, `freetype`, `fribidi`, `gmp`, `gnutls`, `kvazaar`, `lame`, `libaom`, `libass`, `libiconv`, `libilbc`, `libtheora`, `libvorbis`, `libvpx`, `libwebp`, `libxml2`, `opencore-amr`, `opus`, `shine`, `snappy`, `soxr`, `speex`, `wavpack`
- 4 external libraries with GPL license
`vid.stab`, `x264`, `x265`, `xvidcore`
- Exposes both FFmpeg library and MobileFFmpeg wrapper library capabilities
- Includes cross-compile instructions for 43 open-source libraries
- Exposes FFmpeg capabilities both from FFmpeg libraries and through MobileFFmpeg wrapper library
- Creates shared libraries (.so for Android, .dylib for IOS)
- Includes cross-compile instructions for 38 open-source libraries
`chromaprint`, `expat`, `ffmpeg`, `fontconfig`, `freetype`, `fribidi`, `giflib`, `gmp`, `gnutls`, `kvazaar`, `lame`, `leptonica`, `libaom`, `libass`, `libiconv`, `libilbc`, `libjpeg`, `libjpeg-turbo`, `libogg`, `libpng`, `libsndfile`, `libtheora`, `libuuid`, `libvorbis`, `libvpx`, `libwebp`, `libxml2`, `nettle`, `opencore-amr`, `opus`, `sdl`, `shine`, `snappy`, `soxr`, `speex`, `tesseract`, `tiff`, `twolame`, `vid.stab`, `wavpack`, `x264`, `x265`, `xvidcore`
`chromaprint`, `expat`, `ffmpeg`, `fontconfig`, `freetype`, `fribidi`, `giflib`, `gmp`, `gnutls`, `kvazaar`, `lame`, `libaom`, `libass`, `libiconv`, `libilbc`, `libjpeg`, `libjpeg-turbo`, `libogg`, `libpng`, `libtheora`, `libuuid`, `libvorbis`, `libvpx`, `libwebp`, `libxml2`, `nettle`, `opencore-amr`, `opus`, `shine`, `snappy`, `soxr`, `speex`, `tiff`, `vid.stab`, `wavpack`, `x264`, `x265`, `xvidcore`
- Licensed under LGPL 3.0, can be customized to support GPL v3.0
#### 1.1 Android
- Builds `arm-v7a`, `arm-v7a-neon`, `arm64-v8a`, `x86` and `x86_64` architectures
- Supports `zlib` and `MediaCodec` system libraries
- Camera access on [supported devices](https://developer.android.com/ndk/guides/stable_apis#camera)
- Builds shared native libraries (.so)
- Supports `arm-v7a`, `arm-v7a-neon`, `arm64-v8a`, `x86` and `x86_64` architectures
- Creates Android archive with .aar extension
#### 1.2 IOS
- Builds `armv7`, `armv7s`, `arm64`, `arm64e`, `i386` and `x86_64` architectures
- Supports `bzip2`, `zlib` system libraries and `AudioToolbox`, `CoreImage`, `VideoToolbox`, `AVFoundation` system frameworks
- Objective-C API
- Camera access
- Supports `armv7`, `armv7s`, `arm64`, `i386` and `x86_64` architectures
- `ARC` enabled library
- Built with `-fembed-bitcode` flag
- Creates static framework and static universal (fat) library (.a)
- Creates IOS shared/dynamic universal (fat) library
- Creates IOS static universal (fat) library
- Creates IOS dynamic framework for IOS 8 or later
- Supports Xcode 7.3.1 or later
### 2. Using
Binaries are available at [Github](https://github.com/tanersener/mobile-ffmpeg/releases), [JCenter](https://bintray.com/bintray/jcenter) and [CocoaPods](https://cocoapods.org).
Prebuilt libraries are available at [Github](https://github.com/tanersener/mobile-ffmpeg/releases), [JCenter](https://bintray.com/bintray/jcenter) and [CocoaPods](https://cocoapods.org). Refer to [Using IOS Universal Binaries](https://github.com/tanersener/mobile-ffmpeg/wiki/Using-IOS-Universal-Binaries) guide to import IOS universal binaries released at [Github](https://github.com/tanersener/mobile-ffmpeg/releases).
Refer to [Using IOS Universal Binaries](https://github.com/tanersener/mobile-ffmpeg/wiki/Using-IOS-Universal-Binaries) guide to import IOS universal binaries released at [Github](https://github.com/tanersener/mobile-ffmpeg/releases).
There are eight different prebuilt packages. Below you can see which external libraries are enabled in each of them.
There are eight different binary packages. Below you can see which system libraries and external libraries are enabled in each of them.
| min | min-gpl | https | https-gpl | audio | video | full | full-gpl |
| :----: | :----: | :----: | :----: | :----: | :----: | :----: | :----: |
| - | vid.stab<sup>3</sup> <br/> x264<sup>1</sup> <br/> x265<sup>3</sup> <br/> xvidcore<sup>1</sup> | gnutls | gnutls <br/> vid.stab<sup>3</sup> <br/> x264<sup>1</sup> <br/> x265<sup>3</sup> <br/> xvidcore<sup>1</sup> | chromaprint<sup>3</sup> <br/> lame <br/> libilbc<sup>1</sup> <br/> libvorbis <br/> opencore-amr <br/> opus<sup>1</sup> <br/> shine <br/> soxr<sup>2</sup> <br/> speex <br/> wavpack | fontconfig <br/> freetype <br/> fribidi <br/> kvazaar <br/> libaom<sup>2</sup> <br/> libass <br/> libiconv <br/> libtheora <br/> libvpx <br/> snappy<sup>1</sup> | chromaprint<sup>3</sup> <br/> fontconfig <br/> freetype <br/> fribidi <br/> gmp <br/> gnutls <br/> kvazaar <br/> lame <br/> libaom<sup>2</sup> <br/> libass <br/> libiconv <br/> libilbc<sup>1</sup> <br/> libtheora <br/> libvorbis <br/> libvpx <br/> libwebp <br/> libxml2 <br/> opencore-amr <br/> opus<sup>1</sup> <br/> shine <br/> snappy<sup>1</sup> <br/> soxr<sup>2</sup> <br/> speex <br/> wavpack | chromaprint<sup>3</sup> <br/> fontconfig <br/> freetype <br/> fribidi <br/> gmp <br/> gnutls <br/> kvazaar <br/> lame <br/> libaom<sup>2</sup> <br/> libass <br/> libiconv <br/> libilbc<sup>1</sup> <br/> libtheora <br/> libvorbis <br/> libvpx <br/> libwebp <br/> libxml2 <br/> opencore-amr <br/> opus<sup>1</sup> <br/> shine <br/> snappy<sup>1</sup> <br/> soxr<sup>2</sup> <br/> speex <br/> vid.stab<sup>3</sup> <br/> wavpack <br/> x264<sup>1</sup> <br/> x265<sup>3</sup> <br/> xvidcore<sup>1</sup> |
<table>
<thead>
<tr>
<th align="center"></th>
<th align="center">min</th>
<th align="center">min-gpl</th>
<th align="center">https</th>
<th align="center">https-gpl</th>
<th align="center">audio</th>
<th align="center">video</th>
<th align="center">full</th>
<th align="center">full-gpl</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center"><sup>external libraries</sup></td>
<td align="center">-</td>
<td align="center"><sup>vid.stab</sup><br><sup>x264</sup><br><sup>x265</sup><br><sup>xvidcore</sup></td>
<td align="center"><sup>gmp</sup><br><sup>gnutls</sup></td>
<td align="center"><sup>gmp</sup><br><sup>gnutls</sup><br><sup>vid.stab</sup><br><sup>x264</sup><br><sup>x265</sup><br><sup>xvidcore</sup></td>
<td align="center"><sup>lame</sup><br><sup>libilbc</sup><br><sup>libvorbis</sup><br><sup>opencore-amr</sup><br><sup>opus</sup><br><sup>shine</sup><br><sup>soxr</sup><br><sup>speex</sup><br><sup>twolame</sup><br><sup>wavpack</sup></td>
<td align="center"><sup>fontconfig</sup><br><sup>freetype</sup><br><sup>fribidi</sup><br><sup>kvazaar</sup><br><sup>libaom</sup><br><sup>libass</sup><br><sup>libiconv</sup><br><sup>libtheora</sup><br><sup>libvpx</sup><br><sup>libwebp</sup><br><sup>snappy</sup></td>
<td align="center"><sup>fontconfig</sup><br><sup>freetype</sup><br><sup>fribidi</sup><br><sup>gmp</sup><br><sup>gnutls</sup><br><sup>kvazaar</sup><br><sup>lame</sup><br><sup>libaom</sup><br><sup>libass</sup><br><sup>libiconv</sup><br><sup>libilbc</sup><br><sup>libtheora</sup><br><sup>libvorbis</sup><br><sup>libvpx</sup><br><sup>libwebp</sup><br><sup>libxml2</sup><br><sup>opencore-amr</sup><br><sup>opus</sup><br><sup>shine</sup><br><sup>snappy</sup><br><sup>soxr</sup><br><sup>speex</sup><br><sup>twolame</sup><br><sup>wavpack</sup></td>
<td align="center"><sup>fontconfig</sup><br><sup>freetype</sup><br><sup>fribidi</sup><br><sup>gmp</sup><br><sup>gnutls</sup><br><sup>kvazaar</sup><br><sup>lame</sup><br><sup>libaom</sup><br><sup>libass</sup><br><sup>libiconv</sup><br><sup>libilbc</sup><br><sup>libtheora</sup><br><sup>libvorbis</sup><br><sup>libvpx</sup><br><sup>libwebp</sup><br><sup>libxml2</sup><br><sup>opencore-amr</sup><br><sup>opus</sup><br><sup>shine</sup><br><sup>snappy</sup><br><sup>soxr</sup><br><sup>speex</sup><br><sup>twolame</sup><br><sup>vid.stab</sup><br><sup>wavpack</sup><br><sup>x264</sup><br><sup>x265</sup><br><sup>xvidcore</sup></td>
</tr>
<tr>
<td align="center"><sup>android system libraries</sup></td>
<td align="center" colspan=8><sup>zlib</sup><br><sup>MediaCodec</sup></td>
</tr>
<tr>
<td align="center"><sup>ios system libraries</sup></td>
<td align="center" colspan=8><sup>zlib</sup><br><sup>AudioToolbox</sup><br><sup>AVFoundation</sup><br><sup>CoreImage</sup><br><sup>VideoToolbox</sup><br><sup>bzip2</sup></td>
</tr>
</tbody>
</table>
<sup>1</sup> - Supported since `v1.1`
- `libilbc`, `opus`, `snappy`, `x264` and `xvidcore` are supported since `v1.1`
<sup>2</sup> - Supported since `v2.0`
- `libaom` and `soxr` are supported since `v2.0`
- `chromaprint`, `vid.stab` and `x265` are supported since `v2.1`
- `sdl`, `tesseract`, `twolame` external libraries; `zlib`, `MediaCodec` Android system libraries; `bzip2`, `zlib` IOS system libraries and `AudioToolbox`, `CoreImage`, `VideoToolbox`, `AVFoundation` IOS system frameworks are supported since `v3.0`
- Since `v4.2`, `chromaprint`, `sdl` and `tesseract` libraries are not included in binary releases. You can still build them and include in your releases
<sup>3</sup> - Supported since `v2.1`
#### 2.1 Android
1. Add MobileFFmpeg dependency from `jcenter()`
```
dependencies {
implementation 'com.arthenica:mobile-ffmpeg-full:4.2.1'
dependencies {`
implementation 'com.arthenica:mobile-ffmpeg-full:2.2'
}
```
@@ -106,44 +63,23 @@ There are eight different binary packages. Below you can see which system librar
```
import com.arthenica.mobileffmpeg.FFmpeg;
FFmpeg.execute("-i file1.mp4 -c:v mpeg4 file2.mp4");
```
int rc = FFmpeg.execute("-i file1.mp4 -c:v mpeg4 file2.mp4");
3. Check execution output.
```
int rc = FFmpeg.getLastReturnCode();
String output = FFmpeg.getLastCommandOutput();
if (rc == RETURN_CODE_SUCCESS) {
Log.i(Config.TAG, "Command execution completed successfully.");
} else if (rc == RETURN_CODE_CANCEL) {
Log.i(Config.TAG, "Command execution cancelled by user.");
} else {
Log.i(Config.TAG, String.format("Command execution failed with rc=%d and output=%s.", rc, output));
Log.i(Config.TAG, String.format("Command execution failed with rc=%d.", rc));
}
```
4. Stop an ongoing operation.
3. Stop an ongoing operation.
```
FFmpeg.cancel();
```
5. Get media information for a file.
```
MediaInformation info = FFmpeg.getMediaInformation("<file path or uri>");
```
6. Record video and audio using Android camera.
```
FFmpeg.execute("-f android_camera -i 0:0 -r 30 -pixel_format bgr0 -t 00:00:05 <record file path>");
```
7. List enabled external libraries.
```
List<String> externalLibraries = Config.getExternalLibraries();
```
8. Enable log callback.
4. Enable log callback.
```
Config.enableLogCallback(new LogCallback() {
public void apply(LogMessage message) {
@@ -152,7 +88,7 @@ There are eight different binary packages. Below you can see which system librar
});
```
9. Enable statistics callback.
5. Enable statistics callback.
```
Config.enableStatisticsCallback(new StatisticsCallback() {
public void apply(Statistics newStatistics) {
@@ -161,12 +97,12 @@ There are eight different binary packages. Below you can see which system librar
});
```
10. Set log level.
6. Set log level.
```
Config.setLogLevel(Level.AV_LOG_FATAL);
```
11. Register custom fonts directory.
7. Register custom fonts directory.
```
Config.setFontDirectory(this, "<folder with fonts>", Collections.EMPTY_MAP);
```
@@ -174,79 +110,57 @@ There are eight different binary packages. Below you can see which system librar
#### 2.2 IOS
1. Add MobileFFmpeg pod to your `Podfile`
```
pod 'mobile-ffmpeg-full', '~> 4.2.1'
pod 'mobile-ffmpeg-full', '~> 2.2'
```
2. Execute commands.
2. Create and execute commands.
```
#import <mobileffmpeg/MobileFFmpeg.h>
[MobileFFmpeg execute: @"-i file1.mp4 -c:v mpeg4 file2.mp4"];
```
3. Check execution output.
```
int rc = [MobileFFmpeg getLastReturnCode];
NSString *output = [MobileFFmpeg getLastCommandOutput];
int rc = [MobileFFmpeg execute: @"-i file1.mp4 -c:v mpeg4 file2.mp4"];
if (rc == RETURN_CODE_SUCCESS) {
NSLog(@"Command execution completed successfully.\n");
} else if (rc == RETURN_CODE_CANCEL) {
NSLog(@"Command execution cancelled by user.\n");
} else {
NSLog(@"Command execution failed with rc=%d and output=%@.\n", rc, output);
NSLog(@"Command execution failed with rc=%d.\n", rc);
}
```
4. Stop an ongoing operation.
3. Stop an ongoing operation.
```
[MobileFFmpeg cancel];
```
5. Get media information for a file.
4. Enable log callback.
```
MediaInformation *mediaInformation = [MobileFFmpeg getMediaInformation:@"<file path or uri>"];
```
6. Record video and audio using IOS camera
```
[MobileFFmpeg execute: @"-f avfoundation -r 30 -video_size 1280x720 -pixel_format bgr0 -i 0:0 -vcodec h264_videotoolbox -vsync 2 -f h264 -t 00:00:05 %@", recordFilePath];
```
7. List enabled external libraries.
```
NSArray *externalLibraries = [MobileFFmpegConfig getExternalLibraries];
```
8. Enable log callback.
```
[MobileFFmpegConfig setLogDelegate:self];
- (void)logCallback: (int)level :(NSString*)message {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"%@", message);
});
}
...
[MobileFFmpegConfig setLogDelegate:self];
```
9. Enable statistics callback.
5. Enable statistics callback.
```
[MobileFFmpegConfig setStatisticsDelegate:self];
- (void)statisticsCallback:(Statistics *)newStatistics {
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"frame: %d, time: %d\n", newStatistics.getVideoFrameNumber, newStatistics.getTime);
});
}
...
[MobileFFmpegConfig setStatisticsDelegate:self];
```
10. Set log level.
6. Set log level.
```
[MobileFFmpegConfig setLogLevel:AV_LOG_FATAL];
```
11. Register custom fonts directory.
7. Register custom fonts directory.
```
[MobileFFmpegConfig setFontDirectory:@"<folder with fonts>" with:nil];
```
@@ -261,38 +175,16 @@ execution, video encoding, accessing https, encoding audio, burning subtitles an
### 3. Versions
`MobileFFmpeg` version number is aligned with `FFmpeg` since `v4.2`. Before that `MobileFFmpeg` version of a release and `FFmpeg` version included in that release was different.
- `MobileFFmpeg v1.x` is the previous stable, includes `FFmpeg v3.4.4`
| | v2.0 | v2.1 | v2.2 | v3.0 | v3.1 | v4.2 |v4.2.1 |
| :----: | :----: | :----: | :----: | :----: | :----: | :----: |:----: |
| FFmpeg | 4.0.1 | 4.0.2 | 4.0.3 | 4.1-dev-1517 | v4.1-10 | v4.2-dev-480 | v4.2-dev-1156 |
| Includes LTS Variant | - | - | - | - | - | X | - |
- `MobileFFmpeg v2.x` is the current stable, includes `FFmpeg v4.0.3`
### 4. LTS Releases
Starting from `v4.2`, `MobileFFmpeg` binaries are published in two different variants: `Main Release` and `LTS Release`.
- Main releases are published every 3 months. They include complete functionality of the library and support the latest SDK/API features.
- LTS releases are published every 6 months. These 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.
This table shows the differences between two variants.
| | Main Release | LTS Release |
| :----: | :----: | :----: |
| Android API Level | 24 | 21 |
| Android Camera Access | Yes | - |
| 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> |
### 5. Building
#### 5.1 Prerequisites
### 4. Building
#### 4.1 Prerequisites
1. Use your package manager (apt, yum, dnf, brew, etc.) to install the following packages.
```
autoconf automake libtool pkg-config curl cmake gcc gperf texinfo yasm nasm bison autogen patch git
autoconf automake libtool pkg-config curl cmake gcc gperf texinfo yasm nasm bison
```
Some of these packages are not mandatory for the default build.
Please visit [Android Prerequisites](https://github.com/tanersener/mobile-ffmpeg/wiki/Android-Prerequisites) and
@@ -300,21 +192,22 @@ Please visit [Android Prerequisites](https://github.com/tanersener/mobile-ffmpeg
2. Android builds require these additional packages.
- **Android SDK 5.0 Lollipop (API Level 21)** or later
- **Android NDK r19** or later with LLDB and CMake
- **Android NDK r16b** or later with LLDB and CMake
- **gradle 4.4** or later
3. IOS builds need these extra packages and tools.
- **IOS SDK 8.0.x** or later
- **IOS SDK 7.0.x** or later
- **Xcode 7.3.1** or later
- **Command Line Tools**
#### 5.2 Build Scripts
#### 4.2 Build Scripts
Use `android.sh` and `ios.sh` to build MobileFFmpeg for each platform.
After a successful build, compiled FFmpeg and MobileFFmpeg libraries can be found under `prebuilt` directory.
Both `android.sh` and `ios.sh` can be customized to override default settings,
[android.sh](https://github.com/tanersener/mobile-ffmpeg/wiki/android.sh) and
[ios.sh](https://github.com/tanersener/mobile-ffmpeg/wiki/ios.sh) wiki pages include all available build options.
##### 5.2.1 Android
##### 4.2.1 Android
```
export ANDROID_NDK_ROOT=<Android NDK Path>
./android.sh
@@ -322,52 +215,49 @@ export ANDROID_NDK_ROOT=<Android NDK Path>
<img src="https://github.com/tanersener/mobile-ffmpeg/blob/master/docs/assets/android_custom.gif" width="600">
##### 5.2.2 IOS
##### 4.2.2 IOS
```
./ios.sh
```
<img src="https://github.com/tanersener/mobile-ffmpeg/blob/master/docs/assets/ios_custom.gif" width="600">
##### 5.2.3 Building LTS Binaries
Use `--lts` option to build lts binaries for each platform.
#### 5.3 GPL Support
#### 4.3 GPL Support
It is possible to enable GPL licensed libraries `x264`, `xvidcore` since `v1.1` and `vid.stab`, `x265` since `v2.1`
from the top level build scripts.
Their source code is not included in the repository and downloaded when enabled.
#### 5.4 External Libraries
#### 4.4 External Libraries
`build` directory includes build scripts for external libraries. There are two scripts for each library, one for Android
and one for IOS. They include all options/flags used to cross-compile the libraries. `ASM` is enabled by most of them,
exceptions are listed under the [ASM Support](https://github.com/tanersener/mobile-ffmpeg/wiki/ASM-Support) page.
### 6. Documentation
### 5. Documentation
A more detailed documentation is available at [Wiki](https://github.com/tanersener/mobile-ffmpeg/wiki).
### 7. License
### 6. License
This project is licensed under the LGPL v3.0. However, if source code is built using optional `--enable-gpl` flag or
prebuilt binaries with `-gpl` postfix are used then MobileFFmpeg is subject to the GPL v3.0 license.
Source code of FFmpeg and external libraries is included in compliance with their individual licenses.
`strip-frameworks.sh` script included and distributed (until v4.x) is published under the [Apache License version 2.0](https://www.apache.org/licenses/LICENSE-2.0).
`strip-frameworks.sh` script included and distributed is published under the [Apache License version 2.0](https://www.apache.org/licenses/LICENSE-2.0).
In test applications, fonts embedded are licensed under the [SIL Open Font License](https://opensource.org/licenses/OFL-1.1); other digital assets are published in the public domain.
Please visit [License](https://github.com/tanersener/mobile-ffmpeg/wiki/License) page for the details.
### 8. Contributing
### 7. Contributing
If you have any recommendations or ideas to improve it, please feel free to submit issues or pull requests. Any help is appreciated.
### 9. See Also
### 8. See Also
- [libav gas-preprocessor](https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl)
- [FFmpeg API Documentation](https://ffmpeg.org/doxygen/4.0/index.html)
- [FFmpeg Wiki](https://trac.ffmpeg.org/wiki/WikiStart)
- [FFmpeg License and Legal Considerations](https://ffmpeg.org/legal.html)
- [FFmpeg External Library Licenses](https://www.ffmpeg.org/doxygen/4.0/md_LICENSE.html)
+54 -126
View File
@@ -36,34 +36,29 @@ LIBRARY_SNAPPY=24
LIBRARY_SOXR=25
LIBRARY_LIBAOM=26
LIBRARY_CHROMAPRINT=27
LIBRARY_TWOLAME=28
LIBRARY_SDL=29
LIBRARY_TESSERACT=30
LIBRARY_GIFLIB=31
LIBRARY_JPEG=32
LIBRARY_LIBOGG=33
LIBRARY_LIBPNG=34
LIBRARY_LIBUUID=35
LIBRARY_NETTLE=36
LIBRARY_TIFF=37
LIBRARY_EXPAT=38
LIBRARY_SNDFILE=39
LIBRARY_LEPTONICA=40
LIBRARY_ZLIB=41
LIBRARY_MEDIA_CODEC=42
LIBRARY_GIFLIB=28
LIBRARY_JPEG=29
LIBRARY_LIBOGG=30
LIBRARY_LIBPNG=31
LIBRARY_LIBUUID=32
LIBRARY_NETTLE=33
LIBRARY_TIFF=34
LIBRARY_EXPAT=35
LIBRARY_ZLIB=36
LIBRARY_MEDIA_CODEC=37
# ENABLE ARCH
ENABLED_ARCHITECTURES=(1 1 1 1 1)
# ENABLE LIBRARIES
ENABLED_LIBRARIES=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
ENABLED_LIBRARIES=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
export BASEDIR=$(pwd)
export MOBILE_FFMPEG_TMPDIR="${BASEDIR}/.tmp"
# USING API LEVEL 24 / Android 7.0 (NOUGAT)
export API=24
# USING API LEVEL 21 / Android 5.0 (LOLLIPOP)
export API=21
get_mobile_ffmpeg_version() {
local MOBILE_FFMPEG_VERSION=$(grep '#define MOBILE_FFMPEG_VERSION' ${BASEDIR}/android/app/src/main/cpp/mobileffmpeg.h | grep -Eo '\".*\"' | sed -e 's/\"//g')
@@ -87,9 +82,7 @@ When compilation ends an Android Archive (AAR) file is created with enabled plat
echo -e " -h, --help\t\t\tdisplay this help and exit"
echo -e " -V, --version\t\t\tdisplay version information and exit"
echo -e " -d, --debug\t\t\tbuild with debug information"
echo -e " -s, --speed\t\t\toptimize for speed instead of size"
echo -e " -l, --lts\t\t\tbuild lts packages to support API 21+ devices\n"
echo -e " -d, --debug\t\t\tbuild with debug information\n"
echo -e "Licensing options:"
@@ -106,8 +99,8 @@ When compilation ends an Android Archive (AAR) file is created with enabled plat
echo -e "Libraries:"
echo -e " --full\t\t\tenables all external libraries"
echo -e " --enable-android-media-codec\tbuild with built-in Android MediaCodec support[no]"
echo -e " --enable-android-zlib\t\tbuild with built-in zlib support[no]"
echo -e " --enable-android-media-codec\tbuild with built-in Android MediaCodec [no]"
echo -e " --enable-android-zlib\t\tbuild with built-in zlib [no]"
echo -e " --enable-chromaprint\t\tbuild with chromaprint [no]"
echo -e " --enable-fontconfig\t\tbuild with fontconfig [no]"
echo -e " --enable-freetype\t\tbuild with freetype [no]"
@@ -127,13 +120,10 @@ When compilation ends an Android Archive (AAR) file is created with enabled plat
echo -e " --enable-libxml2\t\tbuild with libxml2 [no]"
echo -e " --enable-opencore-amr\t\tbuild with opencore-amr [no]"
echo -e " --enable-opus\t\t\tbuild with opus [no]"
echo -e " --enable-sdl\t\t\tbuild with sdl [no]"
echo -e " --enable-shine\t\tbuild with shine [no]"
echo -e " --enable-snappy\t\tbuild with snappy [no]"
echo -e " --enable-soxr\t\t\tbuild with soxr [no]"
echo -e " --enable-speex\t\tbuild with speex [no]"
echo -e " --enable-tesseract\t\tbuild with tesseract [no]"
echo -e " --enable-twolame\t\tbuild with twolame [no]"
echo -e " --enable-wavpack\t\tbuild with wavpack [no]\n"
echo -e "GPL libraries:"
@@ -153,7 +143,7 @@ display_version() {
COMMAND=`echo $0 | sed -e 's/\.\///g'`
echo -e "\
$COMMAND v$(get_mobile_ffmpeg_version)\n\
$COMMAND $(get_mobile_ffmpeg_version)\n\
Copyright (c) 2018 Taner Sener\n\
License LGPLv3.0: GNU LGPL version 3 or later\n\
<https://www.gnu.org/licenses/lgpl-3.0.en.html>\n\
@@ -169,20 +159,7 @@ skip_library() {
}
enable_debug() {
export MOBILE_FFMPEG_DEBUG="-g"
BUILD_TYPE_ID+="debug "
}
optimize_for_speed() {
export MOBILE_FFMPEG_OPTIMIZED_FOR_SPEED="1"
}
enable_lts_build() {
export MOBILE_FFMPEG_LTS_BUILD="1"
# USING API LEVEL 21 / Android 5.0 (LOLLIPOP)
export API=21
export MOBILE_FFMPEG_DEBUG="-d"
}
reconf_library() {
@@ -298,9 +275,6 @@ set_library() {
opus)
ENABLED_LIBRARIES[LIBRARY_OPUS]=$2
;;
sdl)
ENABLED_LIBRARIES[LIBRARY_SDL]=$2
;;
shine)
ENABLED_LIBRARIES[LIBRARY_SHINE]=$2
;;
@@ -314,20 +288,6 @@ set_library() {
speex)
ENABLED_LIBRARIES[LIBRARY_SPEEX]=$2
;;
tesseract)
ENABLED_LIBRARIES[LIBRARY_TESSERACT]=$2
ENABLED_LIBRARIES[LIBRARY_LEPTONICA]=$2
ENABLED_LIBRARIES[LIBRARY_LIBWEBP]=$2
ENABLED_LIBRARIES[LIBRARY_GIFLIB]=$2
ENABLED_LIBRARIES[LIBRARY_JPEG]=$2
ENABLED_LIBRARIES[LIBRARY_ZLIB]=$2
set_library "tiff" $2
set_library "libpng" $2
;;
twolame)
ENABLED_LIBRARIES[LIBRARY_TWOLAME]=$2
ENABLED_LIBRARIES[LIBRARY_SNDFILE]=$2
;;
wavpack)
ENABLED_LIBRARIES[LIBRARY_WAVPACK]=$2
;;
@@ -340,16 +300,16 @@ set_library() {
xvidcore)
ENABLED_LIBRARIES[LIBRARY_XVIDCORE]=$2
;;
expat | giflib | jpeg | leptonica | libogg | libpng | libsndfile | libuuid)
# THESE LIBRARIES ARE NOT ENABLED DIRECTLY
tiff)
ENABLED_LIBRARIES[LIBRARY_TIFF]=$2
ENABLED_LIBRARIES[LIBRARY_JPEG]=$2
;;
nettle)
ENABLED_LIBRARIES[LIBRARY_NETTLE]=$2
set_library "gmp" $2
;;
tiff)
ENABLED_LIBRARIES[LIBRARY_TIFF]=$2
ENABLED_LIBRARIES[LIBRARY_JPEG]=$2
giflib | jpeg | libogg | libpng | libuuid | expat)
# THESE LIBRARIES ARE NOT ENABLED DIRECTLY
;;
*)
print_unknown_library $1
@@ -427,7 +387,7 @@ print_enabled_libraries() {
let enabled=0;
# FIRST BUILT-IN LIBRARIES
for library in {41..42}
for library in {36..37}
do
if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then
if [[ ${enabled} -ge 1 ]]; then
@@ -439,7 +399,7 @@ print_enabled_libraries() {
done
# THEN EXTERNAL LIBRARIES
for library in {0..30}
for library in {0..27}
do
if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then
if [[ ${enabled} -ge 1 ]]; then
@@ -458,20 +418,6 @@ print_enabled_libraries() {
}
build_application_mk() {
if [[ ! -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then
local LTS_BUILD_FLAG="-DMOBILE_FFMPEG_LTS "
fi
if [[ ${ENABLED_LIBRARIES[$LIBRARY_X265]} -eq 1 ]] || [[ ${ENABLED_LIBRARIES[$LIBRARY_TESSERACT]} -eq 1 ]]; then
local APP_STL="c++_shared"
else
local APP_STL="none"
${SED_INLINE} 's/c++_shared //g' ${BASEDIR}/android/jni/Android.mk 1>>${BASEDIR}/build.log 2>&1
fi
local BUILD_DATE="-DMOBILE_FFMPEG_BUILD_DATE=$(date +%Y%m%d 2>>${BASEDIR}/build.log)"
rm -f ${BASEDIR}/android/jni/Application.mk
cat > "${BASEDIR}/android/jni/Application.mk" << EOF
@@ -479,38 +425,27 @@ APP_OPTIM := release
APP_ABI := ${ANDROID_ARCHITECTURES}
APP_STL := ${APP_STL}
APP_STL := c++_shared
APP_PLATFORM := android-${API}
APP_PLATFORM := android-21
APP_CFLAGS := -O3 -DANDROID ${LTS_BUILD_FLAG}${BUILD_DATE} -Wall -Wno-deprecated-declarations -Wno-pointer-sign -Wno-switch -Wno-unused-result -Wno-unused-variable
APP_CFLAGS := -O3 -DANDROID -Wall -Wno-deprecated-declarations -Wno-pointer-sign -Wno-switch -Wno-unused-result -Wno-unused-variable
EOF
}
# ENABLE COMMON FUNCTIONS
. ${BASEDIR}/build/android-common.sh
DETECTED_NDK_VERSION=$(grep -Eo Revision.* ${ANDROID_NDK_ROOT}/source.properties | sed 's/Revision//g;s/=//g;s/ //g')
echo -e "\nINFO: Using Android NDK v${DETECTED_NDK_VERSION} provided at ${ANDROID_NDK_ROOT}\n" 1>>${BASEDIR}/build.log 2>&1
echo -e "INFO: Build options: $@\n" 1>>${BASEDIR}/build.log 2>&1
# CLEAR OLD NATIVE LIBS
rm -rf ${BASEDIR}/android/libs 1>>${BASEDIR}/build.log 2>&1
rm -rf ${BASEDIR}/android/obj 1>>${BASEDIR}/build.log 2>&1
GPL_ENABLED="no"
DISPLAY_HELP=""
BUILD_LTS=""
BUILD_TYPE_ID=""
BUILD_VERSION=$(git describe --tags 2>>${BASEDIR}/build.log)
while [ ! $# -eq 0 ]
do
case $1 in
-h | --help)
DISPLAY_HELP="1"
display_help
exit 0
;;
-V | --version)
display_version
@@ -524,12 +459,6 @@ do
-d | --debug)
enable_debug
;;
-s | --speed)
optimize_for_speed
;;
-l | --lts)
BUILD_LTS="1"
;;
--reconf-*)
CONF_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'`
@@ -541,7 +470,7 @@ do
rebuild_library ${BUILD_LIBRARY}
;;
--full)
for library in {0..42}
for library in {0..37}
do
if [[ $library -ne 18 ]] && [[ $library -ne 19 ]] && [[ $library -ne 20 ]] && [[ $library -ne 21 ]]; then
enable_library $(get_library_name $library)
@@ -568,33 +497,16 @@ do
shift
done;
# DETECT BUILD TYPE
rm -f ${BASEDIR}/android/jni/Android.mk 1>>${BASEDIR}/build.log 2>&1
if [[ ! -z ${BUILD_LTS} ]]; then
enable_lts_build
BUILD_TYPE_ID+="LTS "
cp ${BASEDIR}/tools/ndk/Android.lts.mk ${BASEDIR}/android/jni/Android.mk 1>>${BASEDIR}/build.log 2>&1
else
cp ${BASEDIR}/tools/ndk/Android.mk ${BASEDIR}/android/jni/Android.mk 1>>${BASEDIR}/build.log 2>&1
fi
if [[ ! -z ${DISPLAY_HELP} ]]; then
display_help
exit 0
fi
if [[ -z ${ANDROID_NDK_ROOT} ]]; then
echo "ANDROID_NDK_ROOT not defined"
exit 1
fi
echo -e "Building mobile-ffmpeg ${BUILD_TYPE_ID}library for Android\n"
echo -e -n "INFO: Building mobile-ffmpeg ${BUILD_VERSION} ${BUILD_TYPE_ID}library for Android: " 1>>${BASEDIR}/build.log 2>&1
echo -e "Building mobile-ffmpeg for Android\n"
echo -e -n "INFO: Building mobile-ffmpeg for Android: " 1>>${BASEDIR}/build.log 2>&1
echo -e `date` 1>>${BASEDIR}/build.log 2>&1
# PERFORM THIS CHECK ONLY ON LTS
if [[ ! -z ${MOBILE_FFMPEG_LTS_BUILD} ]] && [[ ${ENABLED_ARCHITECTURES[0]} -eq 0 ]] && [[ ${ENABLED_ARCHITECTURES[1]} -eq 1 ]]; then
if [[ ${ENABLED_ARCHITECTURES[0]} -eq 0 ]] && [[ ${ENABLED_ARCHITECTURES[1]} -eq 1 ]]; then
ENABLED_ARCHITECTURES[0]=1
echo -e "(*) arm-v7a architecture enabled since arm-v7a-neon will be built\n"
@@ -625,6 +537,9 @@ do
fi
done
# CLEANING PREVIOUSLY COPIED c++_shared.so FILES
rm -rf ${BASEDIR}/prebuilt/android-cpp-shared 1>>${BASEDIR}/build.log 2>&1
for run_arch in {0..4}
do
if [[ ${ENABLED_ARCHITECTURES[$run_arch]} -eq 1 ]]; then
@@ -632,10 +547,23 @@ do
export TOOLCHAIN=$(get_toolchain)
export TOOLCHAIN_ARCH=$(get_toolchain_arch)
create_toolchain || exit 1
# COPY libc++_shared.so FROM EACH TOOLCHAIN
mkdir -p ${BASEDIR}/prebuilt/android-cpp-shared/${TOOLCHAIN_ARCH}
if [[ $run_arch -eq 0 ]] || [[ $run_arch -eq 1 ]]; then
cp ${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/$(get_target_host)/lib/armv7-a/libc++_shared.so ${BASEDIR}/prebuilt/android-cpp-shared/${TOOLCHAIN_ARCH} 1>>${BASEDIR}/build.log 2>&1
elif [[ $run_arch -eq 4 ]]; then
cp ${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/$(get_target_host)/lib64/libc++_shared.so ${BASEDIR}/prebuilt/android-cpp-shared/${TOOLCHAIN_ARCH} 1>>${BASEDIR}/build.log 2>&1
else
cp ${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/$(get_target_host)/lib/libc++_shared.so ${BASEDIR}/prebuilt/android-cpp-shared/${TOOLCHAIN_ARCH} 1>>${BASEDIR}/build.log 2>&1
fi
. ${BASEDIR}/build/main-android.sh "${ENABLED_LIBRARIES[@]}" || exit 1
# CLEAR FLAGS
for library in {1..43}
for library in {1..38}
do
library_name=$(get_library_name $((library - 1)))
unset $(echo "OK_${library_name}" | sed "s/\-/\_/g")
@@ -690,14 +618,14 @@ if [[ ! -z ${ANDROID_ARCHITECTURES} ]]; then
echo -e -n "\n\nCreating Android archive under prebuilt/android-aar: "
./gradlew clean build 1>>${BASEDIR}/build.log 2>&1
gradle clean build 1>>${BASEDIR}/build.log 2>&1
if [ $? -ne 0 ]; then
echo -e "failed\n"
exit 1
fi
cp ${BASEDIR}/android/app/build/outputs/aar/mobile-ffmpeg.aar ${MOBILE_FFMPEG_AAR}/mobile-ffmpeg.aar 1>>${BASEDIR}/build.log 2>&1
cp ${BASEDIR}/android/app/build/outputs/aar/mobile-ffmpeg-*.aar ${MOBILE_FFMPEG_AAR}/mobile-ffmpeg.aar 1>>${BASEDIR}/build.log 2>&1
if [ $? -ne 0 ]; then
echo -e "failed\n"
+1 -1
View File
@@ -38,7 +38,7 @@ PROJECT_NAME = "MobileFFmpeg Android API"
# could be handy for archiving the generated documentation or if some version
# control system is used.
PROJECT_NUMBER = 4.2.1
PROJECT_NUMBER = 2.2
# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
+6 -12
View File
@@ -1,17 +1,15 @@
apply plugin: 'com.android.library'
android {
compileSdkVersion 28
compileSdkVersion 27
defaultConfig {
minSdkVersion 24
targetSdkVersion 28
versionCode 240421
versionName "4.2.1"
minSdkVersion 21
targetSdkVersion 27
versionCode 22
versionName "2.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
project.archivesBaseName = "mobile-ffmpeg"
}
buildTypes {
release {
minifyEnabled false
@@ -25,10 +23,6 @@ android {
}
}
testOptions {
unitTests.returnDefaultValues = true
}
libraryVariants.all { variant ->
variant.outputs.all { output ->
if (outputFile != null && outputFileName.endsWith('.aar')) {
@@ -53,7 +47,7 @@ afterEvaluate {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
@@ -8,17 +8,17 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.1'
classpath 'com.github.dcendents:android-maven-gradle-plugin:2.1'
}
}
android {
compileSdkVersion Integer.parseInt(releaseTargetSdk)
compileSdkVersion 27
defaultConfig {
minSdkVersion Integer.parseInt(releaseMinSdk)
targetSdkVersion Integer.parseInt(releaseTargetSdk)
minSdkVersion 21
targetSdkVersion 27
versionCode Integer.parseInt(releaseVersionCode)
versionName releaseVersionName
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
@@ -127,7 +127,7 @@ bintray {
websiteUrl = siteUrl
vcsUrl = gitUrl
licenses = allLicenses
dryRun = true
dryRun = false
publish = false
override = false
publicDownloadNumbers = false
@@ -166,7 +166,7 @@ afterEvaluate {
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
+2
View File
@@ -3,7 +3,9 @@
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"/>
</manifest>
+115 -139
View File
@@ -191,7 +191,7 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,
continue;
if (first) {
av_log(NULL, AV_LOG_INFO, "%s\n", msg);
printf("%s\n", msg);
first = 0;
}
av_strlcpy(buf, po->name, sizeof(buf));
@@ -199,9 +199,9 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,
av_strlcat(buf, " ", sizeof(buf));
av_strlcat(buf, po->argname, sizeof(buf));
}
av_log(NULL, AV_LOG_INFO, "-%-17s %s\n", buf, po->help);
printf("-%-17s %s\n", buf, po->help);
}
av_log(NULL, AV_LOG_INFO, "\n");
printf("\n");
}
void show_help_children(const AVClass *class, int flags)
@@ -209,7 +209,7 @@ void show_help_children(const AVClass *class, int flags)
const AVClass *child = NULL;
if (class->option) {
av_opt_show2(&class, NULL, flags, 0);
av_log(NULL, AV_LOG_INFO, "\n");
printf("\n");
}
while ((child = av_opt_child_class_next(class, child)))
@@ -1026,7 +1026,7 @@ static int init_report(const char *env)
av_free(key);
}
av_bprint_init(&filename, 0, AV_BPRINT_SIZE_AUTOMATIC);
av_bprint_init(&filename, 0, 1);
expand_filename_template(&filename,
av_x_if_null(filename_template, "%p-%t.log"), tm);
av_free(filename_template);
@@ -1214,12 +1214,12 @@ int show_buildconf(void *optctx, const char *opt, const char *arg)
int show_license(void *optctx, const char *opt, const char *arg)
{
#if CONFIG_NONFREE
av_log(NULL, AV_LOG_INFO,
printf(
"This version of %s has nonfree parts compiled in.\n"
"Therefore it is not legally redistributable.\n",
program_name );
#elif CONFIG_GPLV3
av_log(NULL, AV_LOG_INFO,
printf(
"%s is free software; you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation; either version 3 of the License, or\n"
@@ -1234,7 +1234,7 @@ int show_license(void *optctx, const char *opt, const char *arg)
"along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
program_name, program_name, program_name );
#elif CONFIG_GPL
av_log(NULL, AV_LOG_INFO,
printf(
"%s is free software; you can redistribute it and/or modify\n"
"it under the terms of the GNU General Public License as published by\n"
"the Free Software Foundation; either version 2 of the License, or\n"
@@ -1250,7 +1250,7 @@ int show_license(void *optctx, const char *opt, const char *arg)
"Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n",
program_name, program_name, program_name );
#elif CONFIG_LGPLV3
av_log(NULL, AV_LOG_INFO,
printf(
"%s is free software; you can redistribute it and/or modify\n"
"it under the terms of the GNU Lesser General Public License as published by\n"
"the Free Software Foundation; either version 3 of the License, or\n"
@@ -1265,7 +1265,7 @@ int show_license(void *optctx, const char *opt, const char *arg)
"along with %s. If not, see <http://www.gnu.org/licenses/>.\n",
program_name, program_name, program_name );
#else
av_log(NULL, AV_LOG_INFO,
printf(
"%s is free software; you can redistribute it and/or\n"
"modify it under the terms of the GNU Lesser General Public\n"
"License as published by the Free Software Foundation; either\n"
@@ -1301,7 +1301,7 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
const char *last_name;
int is_dev;
av_log(NULL, AV_LOG_INFO, "%s\n"
printf("%s\n"
" D. = Demuxing supported\n"
" .E = Muxing supported\n"
" --\n", device_only ? "Devices:" : "File formats:");
@@ -1346,7 +1346,7 @@ static int show_formats_devices(void *optctx, const char *opt, const char *arg,
break;
last_name = name;
av_log(NULL, AV_LOG_INFO, " %s%s %-15s %s\n",
printf(" %s%s %-15s %s\n",
decode ? "D" : " ",
encode ? "E" : " ",
name,
@@ -1379,97 +1379,76 @@ int show_devices(void *optctx, const char *opt, const char *arg)
if (codec->field) { \
const type *p = codec->field; \
\
av_log(NULL, AV_LOG_INFO, " Supported " list_name ":"); \
printf(" Supported " list_name ":"); \
while (*p != term) { \
get_name(*p); \
av_log(NULL, AV_LOG_INFO, " %s", name); \
printf(" %s", name); \
p++; \
} \
av_log(NULL, AV_LOG_INFO, "\n"); \
printf("\n"); \
} \
static void print_codec(const AVCodec *c)
{
int encoder = av_codec_is_encoder(c);
av_log(NULL, AV_LOG_INFO, "%s %s [%s]:\n", encoder ? "Encoder" : "Decoder", c->name,
printf("%s %s [%s]:\n", encoder ? "Encoder" : "Decoder", c->name,
c->long_name ? c->long_name : "");
av_log(NULL, AV_LOG_INFO, " General capabilities: ");
printf(" General capabilities: ");
if (c->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)
av_log(NULL, AV_LOG_INFO, "horizband ");
printf("horizband ");
if (c->capabilities & AV_CODEC_CAP_DR1)
av_log(NULL, AV_LOG_INFO, "dr1 ");
printf("dr1 ");
if (c->capabilities & AV_CODEC_CAP_TRUNCATED)
av_log(NULL, AV_LOG_INFO, "trunc ");
printf("trunc ");
if (c->capabilities & AV_CODEC_CAP_DELAY)
av_log(NULL, AV_LOG_INFO, "delay ");
printf("delay ");
if (c->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME)
av_log(NULL, AV_LOG_INFO, "small ");
printf("small ");
if (c->capabilities & AV_CODEC_CAP_SUBFRAMES)
av_log(NULL, AV_LOG_INFO, "subframes ");
printf("subframes ");
if (c->capabilities & AV_CODEC_CAP_EXPERIMENTAL)
av_log(NULL, AV_LOG_INFO, "exp ");
printf("exp ");
if (c->capabilities & AV_CODEC_CAP_CHANNEL_CONF)
av_log(NULL, AV_LOG_INFO, "chconf ");
printf("chconf ");
if (c->capabilities & AV_CODEC_CAP_PARAM_CHANGE)
av_log(NULL, AV_LOG_INFO, "paramchange ");
printf("paramchange ");
if (c->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)
av_log(NULL, AV_LOG_INFO, "variable ");
printf("variable ");
if (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS |
AV_CODEC_CAP_SLICE_THREADS |
AV_CODEC_CAP_AUTO_THREADS))
av_log(NULL, AV_LOG_INFO, "threads ");
if (c->capabilities & AV_CODEC_CAP_AVOID_PROBING)
av_log(NULL, AV_LOG_INFO, "avoidprobe ");
if (c->capabilities & AV_CODEC_CAP_INTRA_ONLY)
av_log(NULL, AV_LOG_INFO, "intraonly ");
if (c->capabilities & AV_CODEC_CAP_LOSSLESS)
av_log(NULL, AV_LOG_INFO, "lossless ");
if (c->capabilities & AV_CODEC_CAP_HARDWARE)
av_log(NULL, AV_LOG_INFO, "hardware ");
if (c->capabilities & AV_CODEC_CAP_HYBRID)
av_log(NULL, AV_LOG_INFO, "hybrid ");
printf("threads ");
if (!c->capabilities)
av_log(NULL, AV_LOG_INFO, "none");
av_log(NULL, AV_LOG_INFO, "\n");
printf("none");
printf("\n");
if (c->type == AVMEDIA_TYPE_VIDEO ||
c->type == AVMEDIA_TYPE_AUDIO) {
av_log(NULL, AV_LOG_INFO, " Threading capabilities: ");
printf(" Threading capabilities: ");
switch (c->capabilities & (AV_CODEC_CAP_FRAME_THREADS |
AV_CODEC_CAP_SLICE_THREADS |
AV_CODEC_CAP_AUTO_THREADS)) {
case AV_CODEC_CAP_FRAME_THREADS |
AV_CODEC_CAP_SLICE_THREADS: av_log(NULL, AV_LOG_INFO, "frame and slice"); break;
case AV_CODEC_CAP_FRAME_THREADS: av_log(NULL, AV_LOG_INFO, "frame"); break;
case AV_CODEC_CAP_SLICE_THREADS: av_log(NULL, AV_LOG_INFO, "slice"); break;
case AV_CODEC_CAP_AUTO_THREADS : av_log(NULL, AV_LOG_INFO, "auto"); break;
default: av_log(NULL, AV_LOG_INFO, "none"); break;
AV_CODEC_CAP_SLICE_THREADS: printf("frame and slice"); break;
case AV_CODEC_CAP_FRAME_THREADS: printf("frame"); break;
case AV_CODEC_CAP_SLICE_THREADS: printf("slice"); break;
case AV_CODEC_CAP_AUTO_THREADS : printf("auto"); break;
default: printf("none"); break;
}
av_log(NULL, AV_LOG_INFO, "\n");
}
if (avcodec_get_hw_config(c, 0)) {
av_log(NULL, AV_LOG_INFO, " Supported hardware devices: ");
for (int i = 0;; i++) {
const AVCodecHWConfig *config = avcodec_get_hw_config(c, i);
if (!config)
break;
av_log(NULL, AV_LOG_INFO, "%s ", av_hwdevice_get_type_name(config->device_type));
}
av_log(NULL, AV_LOG_INFO, "\n");
printf("\n");
}
if (c->supported_framerates) {
const AVRational *fps = c->supported_framerates;
av_log(NULL, AV_LOG_INFO, " Supported framerates:");
printf(" Supported framerates:");
while (fps->num) {
av_log(NULL, AV_LOG_INFO, " %d/%d", fps->num, fps->den);
printf(" %d/%d", fps->num, fps->den);
fps++;
}
av_log(NULL, AV_LOG_INFO, "\n");
printf("\n");
}
PRINT_CODEC_SUPPORTED(c, pix_fmts, enum AVPixelFormat, "pixel formats",
AV_PIX_FMT_NONE, GET_PIX_FMT_NAME);
@@ -1544,12 +1523,12 @@ static void print_codecs_for_id(enum AVCodecID id, int encoder)
{
const AVCodec *codec = NULL;
av_log(NULL, AV_LOG_INFO, " (%s: ", encoder ? "encoders" : "decoders");
printf(" (%s: ", encoder ? "encoders" : "decoders");
while ((codec = next_codec_for_id(id, codec, encoder)))
av_log(NULL, AV_LOG_INFO, "%s ", codec->name);
printf("%s ", codec->name);
av_log(NULL, AV_LOG_INFO, ")");
printf(")");
}
int show_codecs(void *optctx, const char *opt, const char *arg)
@@ -1557,7 +1536,7 @@ int show_codecs(void *optctx, const char *opt, const char *arg)
const AVCodecDescriptor **codecs;
unsigned i, nb_codecs = get_codecs_sorted(&codecs);
av_log(NULL, AV_LOG_INFO, "Codecs:\n"
printf("Codecs:\n"
" D..... = Decoding supported\n"
" .E.... = Encoding supported\n"
" ..V... = Video codec\n"
@@ -1574,16 +1553,16 @@ int show_codecs(void *optctx, const char *opt, const char *arg)
if (strstr(desc->name, "_deprecated"))
continue;
av_log(NULL, AV_LOG_INFO, " ");
av_log(NULL, AV_LOG_INFO, avcodec_find_decoder(desc->id) ? "D" : ".");
av_log(NULL, AV_LOG_INFO, avcodec_find_encoder(desc->id) ? "E" : ".");
printf(" ");
printf(avcodec_find_decoder(desc->id) ? "D" : ".");
printf(avcodec_find_encoder(desc->id) ? "E" : ".");
av_log(NULL, AV_LOG_INFO, "%c", get_media_type_char(desc->type));
av_log(NULL, AV_LOG_INFO, (desc->props & AV_CODEC_PROP_INTRA_ONLY) ? "I" : ".");
av_log(NULL, AV_LOG_INFO, (desc->props & AV_CODEC_PROP_LOSSY) ? "L" : ".");
av_log(NULL, AV_LOG_INFO, (desc->props & AV_CODEC_PROP_LOSSLESS) ? "S" : ".");
printf("%c", get_media_type_char(desc->type));
printf((desc->props & AV_CODEC_PROP_INTRA_ONLY) ? "I" : ".");
printf((desc->props & AV_CODEC_PROP_LOSSY) ? "L" : ".");
printf((desc->props & AV_CODEC_PROP_LOSSLESS) ? "S" : ".");
av_log(NULL, AV_LOG_INFO, " %-20s %s", desc->name, desc->long_name ? desc->long_name : "");
printf(" %-20s %s", desc->name, desc->long_name ? desc->long_name : "");
/* print decoders/encoders when there's more than one or their
* names are different from codec name */
@@ -1601,7 +1580,7 @@ int show_codecs(void *optctx, const char *opt, const char *arg)
}
}
av_log(NULL, AV_LOG_INFO, "\n");
printf("\n");
}
av_free(codecs);
return 0;
@@ -1612,7 +1591,7 @@ static void print_codecs(int encoder)
const AVCodecDescriptor **codecs;
unsigned i, nb_codecs = get_codecs_sorted(&codecs);
av_log(NULL, AV_LOG_INFO, "%s:\n"
printf("%s:\n"
" V..... = Video\n"
" A..... = Audio\n"
" S..... = Subtitle\n"
@@ -1628,18 +1607,18 @@ static void print_codecs(int encoder)
const AVCodec *codec = NULL;
while ((codec = next_codec_for_id(desc->id, codec, encoder))) {
av_log(NULL, AV_LOG_INFO, " %c", get_media_type_char(desc->type));
av_log(NULL, AV_LOG_INFO, (codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ? "F" : ".");
av_log(NULL, AV_LOG_INFO, (codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ? "S" : ".");
av_log(NULL, AV_LOG_INFO, (codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) ? "X" : ".");
av_log(NULL, AV_LOG_INFO, (codec->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)?"B" : ".");
av_log(NULL, AV_LOG_INFO, (codec->capabilities & AV_CODEC_CAP_DR1) ? "D" : ".");
printf(" %c", get_media_type_char(desc->type));
printf((codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ? "F" : ".");
printf((codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ? "S" : ".");
printf((codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) ? "X" : ".");
printf((codec->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)?"B" : ".");
printf((codec->capabilities & AV_CODEC_CAP_DR1) ? "D" : ".");
av_log(NULL, AV_LOG_INFO, " %-20s %s", codec->name, codec->long_name ? codec->long_name : "");
printf(" %-20s %s", codec->name, codec->long_name ? codec->long_name : "");
if (strcmp(codec->name, desc->name))
av_log(NULL, AV_LOG_INFO, " (codec %s)", desc->name);
printf(" (codec %s)", desc->name);
av_log(NULL, AV_LOG_INFO, "\n");
printf("\n");
}
}
av_free(codecs);
@@ -1662,10 +1641,10 @@ int show_bsfs(void *optctx, const char *opt, const char *arg)
const AVBitStreamFilter *bsf = NULL;
void *opaque = NULL;
av_log(NULL, AV_LOG_INFO, "Bitstream filters:\n");
printf("Bitstream filters:\n");
while ((bsf = av_bsf_iterate(&opaque)))
av_log(NULL, AV_LOG_INFO, "%s\n", bsf->name);
av_log(NULL, AV_LOG_INFO, "\n");
printf("%s\n", bsf->name);
printf("\n");
return 0;
}
@@ -1674,13 +1653,13 @@ int show_protocols(void *optctx, const char *opt, const char *arg)
void *opaque = NULL;
const char *name;
av_log(NULL, AV_LOG_INFO, "Supported file protocols:\n"
printf("Supported file protocols:\n"
"Input:\n");
while ((name = avio_enum_protocols(&opaque, 0)))
av_log(NULL, AV_LOG_INFO, " %s\n", name);
av_log(NULL, AV_LOG_INFO, "Output:\n");
printf(" %s\n", name);
printf("Output:\n");
while ((name = avio_enum_protocols(&opaque, 1)))
av_log(NULL, AV_LOG_INFO, " %s\n", name);
printf(" %s\n", name);
return 0;
}
@@ -1693,7 +1672,7 @@ int show_filters(void *optctx, const char *opt, const char *arg)
int i, j;
const AVFilterPad *pad;
av_log(NULL, AV_LOG_INFO, "Filters:\n"
printf("Filters:\n"
" T.. = Timeline support\n"
" .S. = Slice threading\n"
" ..C = Command support\n"
@@ -1719,14 +1698,14 @@ int show_filters(void *optctx, const char *opt, const char *arg)
( i && (filter->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS))) ? 'N' : '|';
}
*descr_cur = 0;
av_log(NULL, AV_LOG_INFO, " %c%c%c %-17s %-10s %s\n",
printf(" %c%c%c %-17s %-10s %s\n",
filter->flags & AVFILTER_FLAG_SUPPORT_TIMELINE ? 'T' : '.',
filter->flags & AVFILTER_FLAG_SLICE_THREADS ? 'S' : '.',
filter->process_command ? 'C' : '.',
filter->name, descr, filter->description);
}
#else
av_log(NULL, AV_LOG_INFO, "No filters available: libavfilter disabled\n");
printf("No filters available: libavfilter disabled\n");
#endif
return 0;
}
@@ -1737,10 +1716,10 @@ int show_colors(void *optctx, const char *opt, const char *arg)
const uint8_t *rgb;
int i;
av_log(NULL, AV_LOG_INFO, "%-32s #RRGGBB\n", "name");
printf("%-32s #RRGGBB\n", "name");
for (i = 0; (name = av_get_known_color_name(i, &rgb)); i++)
av_log(NULL, AV_LOG_INFO, "%-32s #%02x%02x%02x\n", name, rgb[0], rgb[1], rgb[2]);
printf("%-32s #%02x%02x%02x\n", name, rgb[0], rgb[1], rgb[2]);
return 0;
}
@@ -1749,7 +1728,7 @@ int show_pix_fmts(void *optctx, const char *opt, const char *arg)
{
const AVPixFmtDescriptor *pix_desc = NULL;
av_log(NULL, AV_LOG_INFO, "Pixel formats:\n"
printf("Pixel formats:\n"
"I.... = Supported Input format for conversion\n"
".O... = Supported Output format for conversion\n"
"..H.. = Hardware accelerated format\n"
@@ -1765,7 +1744,7 @@ int show_pix_fmts(void *optctx, const char *opt, const char *arg)
while ((pix_desc = av_pix_fmt_desc_next(pix_desc))) {
enum AVPixelFormat av_unused pix_fmt = av_pix_fmt_desc_get_id(pix_desc);
av_log(NULL, AV_LOG_INFO, "%c%c%c%c%c %-16s %d %2d\n",
printf("%c%c%c%c%c %-16s %d %2d\n",
sws_isSupportedInput (pix_fmt) ? 'I' : '.',
sws_isSupportedOutput(pix_fmt) ? 'O' : '.',
pix_desc->flags & AV_PIX_FMT_FLAG_HWACCEL ? 'H' : '.',
@@ -1784,24 +1763,24 @@ int show_layouts(void *optctx, const char *opt, const char *arg)
uint64_t layout, j;
const char *name, *descr;
av_log(NULL, AV_LOG_INFO, "Individual channels:\n"
printf("Individual channels:\n"
"NAME DESCRIPTION\n");
for (i = 0; i < 63; i++) {
name = av_get_channel_name((uint64_t)1 << i);
if (!name)
continue;
descr = av_get_channel_description((uint64_t)1 << i);
av_log(NULL, AV_LOG_INFO, "%-14s %s\n", name, descr);
printf("%-14s %s\n", name, descr);
}
av_log(NULL, AV_LOG_INFO, "\nStandard channel layouts:\n"
printf("\nStandard channel layouts:\n"
"NAME DECOMPOSITION\n");
for (i = 0; !av_get_standard_channel_layout(i, &layout, &name); i++) {
if (name) {
av_log(NULL, AV_LOG_INFO, "%-14s ", name);
printf("%-14s ", name);
for (j = 1; j; j <<= 1)
if ((layout & j))
av_log(NULL, AV_LOG_INFO, "%s%s", (layout & (j - 1)) ? "+" : "", av_get_channel_name(j));
av_log(NULL, AV_LOG_INFO, "\n");
printf("%s%s", (layout & (j - 1)) ? "+" : "", av_get_channel_name(j));
printf("\n");
}
}
return 0;
@@ -1812,7 +1791,7 @@ int show_sample_fmts(void *optctx, const char *opt, const char *arg)
int i;
char fmt_str[128];
for (i = -1; i < AV_SAMPLE_FMT_NB; i++)
av_log(NULL, AV_LOG_INFO, "%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str), i));
printf("%s\n", av_get_sample_fmt_string(fmt_str, sizeof(fmt_str), i));
return 0;
}
@@ -1860,10 +1839,10 @@ static void show_help_demuxer(const char *name)
return;
}
av_log(NULL, AV_LOG_INFO, "Demuxer %s [%s]:\n", fmt->name, fmt->long_name);
printf("Demuxer %s [%s]:\n", fmt->name, fmt->long_name);
if (fmt->extensions)
av_log(NULL, AV_LOG_INFO, " Common extensions: %s.\n", fmt->extensions);
printf(" Common extensions: %s.\n", fmt->extensions);
if (fmt->priv_class)
show_help_children(fmt->priv_class, AV_OPT_FLAG_DECODING_PARAM);
@@ -1879,23 +1858,23 @@ static void show_help_muxer(const char *name)
return;
}
av_log(NULL, AV_LOG_INFO, "Muxer %s [%s]:\n", fmt->name, fmt->long_name);
printf("Muxer %s [%s]:\n", fmt->name, fmt->long_name);
if (fmt->extensions)
av_log(NULL, AV_LOG_INFO, " Common extensions: %s.\n", fmt->extensions);
printf(" Common extensions: %s.\n", fmt->extensions);
if (fmt->mime_type)
av_log(NULL, AV_LOG_INFO, " Mime type: %s.\n", fmt->mime_type);
printf(" Mime type: %s.\n", fmt->mime_type);
if (fmt->video_codec != AV_CODEC_ID_NONE &&
(desc = avcodec_descriptor_get(fmt->video_codec))) {
av_log(NULL, AV_LOG_INFO, " Default video codec: %s.\n", desc->name);
printf(" Default video codec: %s.\n", desc->name);
}
if (fmt->audio_codec != AV_CODEC_ID_NONE &&
(desc = avcodec_descriptor_get(fmt->audio_codec))) {
av_log(NULL, AV_LOG_INFO, " Default audio codec: %s.\n", desc->name);
printf(" Default audio codec: %s.\n", desc->name);
}
if (fmt->subtitle_codec != AV_CODEC_ID_NONE &&
(desc = avcodec_descriptor_get(fmt->subtitle_codec))) {
av_log(NULL, AV_LOG_INFO, " Default subtitle codec: %s.\n", desc->name);
printf(" Default subtitle codec: %s.\n", desc->name);
}
if (fmt->priv_class)
@@ -1917,40 +1896,40 @@ static void show_help_filter(const char *name)
return;
}
av_log(NULL, AV_LOG_INFO, "Filter %s\n", f->name);
printf("Filter %s\n", f->name);
if (f->description)
av_log(NULL, AV_LOG_INFO, " %s\n", f->description);
printf(" %s\n", f->description);
if (f->flags & AVFILTER_FLAG_SLICE_THREADS)
av_log(NULL, AV_LOG_INFO, " slice threading supported\n");
printf(" slice threading supported\n");
av_log(NULL, AV_LOG_INFO, " Inputs:\n");
printf(" Inputs:\n");
count = avfilter_pad_count(f->inputs);
for (i = 0; i < count; i++) {
av_log(NULL, AV_LOG_INFO, " #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i),
printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->inputs, i),
media_type_string(avfilter_pad_get_type(f->inputs, i)));
}
if (f->flags & AVFILTER_FLAG_DYNAMIC_INPUTS)
av_log(NULL, AV_LOG_INFO, " dynamic (depending on the options)\n");
printf(" dynamic (depending on the options)\n");
else if (!count)
av_log(NULL, AV_LOG_INFO, " none (source filter)\n");
printf(" none (source filter)\n");
av_log(NULL, AV_LOG_INFO, " Outputs:\n");
printf(" Outputs:\n");
count = avfilter_pad_count(f->outputs);
for (i = 0; i < count; i++) {
av_log(NULL, AV_LOG_INFO, " #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i),
printf(" #%d: %s (%s)\n", i, avfilter_pad_get_name(f->outputs, i),
media_type_string(avfilter_pad_get_type(f->outputs, i)));
}
if (f->flags & AVFILTER_FLAG_DYNAMIC_OUTPUTS)
av_log(NULL, AV_LOG_INFO, " dynamic (depending on the options)\n");
printf(" dynamic (depending on the options)\n");
else if (!count)
av_log(NULL, AV_LOG_INFO, " none (sink filter)\n");
printf(" none (sink filter)\n");
if (f->priv_class)
show_help_children(f->priv_class, AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM |
AV_OPT_FLAG_AUDIO_PARAM);
if (f->flags & AVFILTER_FLAG_SUPPORT_TIMELINE)
av_log(NULL, AV_LOG_INFO, "This filter has support for timeline through the 'enable' option.\n");
printf("This filter has support for timeline through the 'enable' option.\n");
#else
av_log(NULL, AV_LOG_ERROR, "Build without libavfilter; "
"can not to satisfy request\n");
@@ -1962,15 +1941,12 @@ static void show_help_bsf(const char *name)
{
const AVBitStreamFilter *bsf = av_bsf_get_by_name(name);
if (!name) {
av_log(NULL, AV_LOG_ERROR, "No bitstream filter name specified.\n");
return;
} else if (!bsf) {
if (!bsf) {
av_log(NULL, AV_LOG_ERROR, "Unknown bit stream filter '%s'.\n", name);
return;
}
av_log(NULL, AV_LOG_INFO, "Bit stream filter %s\n", bsf->name);
printf("Bit stream filter %s\n", bsf->name);
PRINT_CODEC_SUPPORTED(bsf, codec_ids, enum AVCodecID, "codecs",
AV_CODEC_ID_NONE, GET_CODEC_NAME);
if (bsf->priv_class)
@@ -2206,20 +2182,20 @@ static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
if (!fmt || !fmt->priv_class || !AV_IS_INPUT_DEVICE(fmt->priv_class->category))
return AVERROR(EINVAL);
av_log(NULL, AV_LOG_INFO, "Auto-detected sources for %s:\n", fmt->name);
printf("Auto-detected sources for %s:\n", fmt->name);
if (!fmt->get_device_list) {
ret = AVERROR(ENOSYS);
av_log(NULL, AV_LOG_INFO, "Cannot list sources. Not implemented.\n");
printf("Cannot list sources. Not implemented.\n");
goto fail;
}
if ((ret = avdevice_list_input_sources(fmt, NULL, opts, &device_list)) < 0) {
av_log(NULL, AV_LOG_INFO, "Cannot list sources.\n");
printf("Cannot list sources.\n");
goto fail;
}
for (i = 0; i < device_list->nb_devices; i++) {
av_log(NULL, AV_LOG_INFO, "%s %s [%s]\n", device_list->default_device == i ? "*" : " ",
printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ",
device_list->devices[i]->device_name, device_list->devices[i]->device_description);
}
@@ -2236,20 +2212,20 @@ static int print_device_sinks(AVOutputFormat *fmt, AVDictionary *opts)
if (!fmt || !fmt->priv_class || !AV_IS_OUTPUT_DEVICE(fmt->priv_class->category))
return AVERROR(EINVAL);
av_log(NULL, AV_LOG_INFO, "Auto-detected sinks for %s:\n", fmt->name);
printf("Auto-detected sinks for %s:\n", fmt->name);
if (!fmt->get_device_list) {
ret = AVERROR(ENOSYS);
av_log(NULL, AV_LOG_INFO, "Cannot list sinks. Not implemented.\n");
printf("Cannot list sinks. Not implemented.\n");
goto fail;
}
if ((ret = avdevice_list_output_sinks(fmt, NULL, opts, &device_list)) < 0) {
av_log(NULL, AV_LOG_INFO, "Cannot list sinks.\n");
printf("Cannot list sinks.\n");
goto fail;
}
for (i = 0; i < device_list->nb_devices; i++) {
av_log(NULL, AV_LOG_INFO, "%s %s [%s]\n", device_list->default_device == i ? "*" : " ",
printf("%s %s [%s]\n", device_list->default_device == i ? "*" : " ",
device_list->devices[i]->device_name, device_list->devices[i]->device_description);
}
@@ -2275,7 +2251,7 @@ static int show_sinks_sources_parse_arg(const char *arg, char **dev, AVDictionar
}
}
} else
av_log(NULL, AV_LOG_INFO, "\nDevice name is not provided.\n"
printf("\nDevice name is not provided.\n"
"You can pass devicename[,opt1=val1[,opt2=val2...]] as an argument.\n\n");
return 0;
}
+1 -5
View File
@@ -20,10 +20,6 @@
*/
/*
* CHANGES 03.2019
* --------------------------------------------------------
* - config.h include removed
*
* CHANGES 08.2018
* --------------------------------------------------------
* - fftools_ prefix added to file name and include guards
@@ -39,6 +35,7 @@
#include <stdint.h>
#include "config.h"
#include "libavcodec/avcodec.h"
#include "libavfilter/avfilter.h"
#include "libavformat/avformat.h"
@@ -361,7 +358,6 @@ typedef struct OptionParseContext {
* Parse an options group and write results into optctx.
*
* @param optctx an app-specific options context. NULL for global options group
* @param g option group
*/
int parse_optgroup(void *optctx, OptionGroup *g);
+51 -108
View File
@@ -140,14 +140,8 @@ const char *const forced_keyframes_const_names[] = {
NULL
};
typedef struct BenchmarkTimeStamps {
int64_t real_usec;
int64_t user_usec;
int64_t sys_usec;
} BenchmarkTimeStamps;
static void do_video_stats(OutputStream *ost, int frame_size);
static BenchmarkTimeStamps get_benchmark_time_stamps(void);
static int64_t getutime(void);
static int64_t getmaxrss(void);
static int ifilter_has_all_input_formats(FilterGraph *fg);
@@ -159,7 +153,7 @@ static int64_t decode_error_stat[2];
static int want_sdp = 1;
static BenchmarkTimeStamps current_time;
static int current_time;
AVIOContext *progress_avio = NULL;
static uint8_t *subtitle_out;
@@ -682,7 +676,7 @@ static void abort_codec_experimental(AVCodec *c, int encoder)
static void update_benchmark(const char *fmt, ...)
{
if (do_benchmark_all) {
BenchmarkTimeStamps t = get_benchmark_time_stamps();
int64_t t = getutime();
va_list va;
char buf[1024];
@@ -690,11 +684,7 @@ static void update_benchmark(const char *fmt, ...)
va_start(va, fmt);
vsnprintf(buf, sizeof(buf), fmt, va);
va_end(va);
av_log(NULL, AV_LOG_INFO,
"bench: %8" PRIu64 " user %8" PRIu64 " sys %8" PRIu64 " real %s \n",
t.user_usec - current_time.user_usec,
t.sys_usec - current_time.sys_usec,
t.real_usec - current_time.real_usec, buf);
av_log(NULL, AV_LOG_INFO, "bench: %8"PRIu64" %s \n", t - current_time, buf);
}
current_time = t;
}
@@ -747,11 +737,11 @@ static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int u
if (ret < 0)
exit_program(1);
}
ret = av_packet_make_refcounted(pkt);
ret = av_packet_ref(&tmp_pkt, pkt);
if (ret < 0)
exit_program(1);
av_packet_move_ref(&tmp_pkt, pkt);
av_fifo_generic_write(ost->muxing_queue, &tmp_pkt, sizeof(tmp_pkt), NULL);
av_packet_unref(pkt);
return;
}
@@ -795,7 +785,7 @@ static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int u
- FFMIN3(pkt->pts, pkt->dts, ost->last_mux_dts + 1)
- FFMAX3(pkt->pts, pkt->dts, ost->last_mux_dts + 1);
}
if ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) &&
if ((st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO || st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) &&
pkt->dts != AV_NOPTS_VALUE &&
!(st->codecpar->codec_id == AV_CODEC_ID_VP9 && ost->stream_copy) &&
ost->last_mux_dts != AV_NOPTS_VALUE) {
@@ -1102,7 +1092,6 @@ static void do_video_out(OutputFile *of,
if (!ost->filters_script &&
!ost->filters &&
(nb_filtergraphs == 0 || !filtergraphs[0]->graph_desc) &&
next_picture &&
ist &&
lrintf(next_picture->pkt_duration * av_q2d(ist->st->time_base) / av_q2d(enc->time_base)) > 0) {
@@ -1145,7 +1134,7 @@ static void do_video_out(OutputFile *of,
format_video_sync != VSYNC_PASSTHROUGH &&
format_video_sync != VSYNC_DROP) {
if (delta0 < -0.6) {
av_log(NULL, AV_LOG_VERBOSE, "Past duration %f too large\n", -delta0);
av_log(NULL, AV_LOG_WARNING, "Past duration %f too large\n", -delta0);
} else
av_log(NULL, AV_LOG_DEBUG, "Clipping frame in rate conversion by %f\n", -delta0);
sync_ipts = ost->sync_opts;
@@ -1220,8 +1209,6 @@ static void do_video_out(OutputFile *of,
/* duplicates frame if needed */
for (i = 0; i < nb_frames; i++) {
AVFrame *in_picture;
int forced_keyframe = 0;
double pts_time;
av_init_packet(&pkt);
pkt.data = NULL;
pkt.size = 0;
@@ -1236,9 +1223,17 @@ static void do_video_out(OutputFile *of,
in_picture->pts = ost->sync_opts;
#if 1
if (!check_recording_time(ost))
#else
if (ost->frame_number >= ost->max_frames)
#endif
return;
{
int forced_keyframe = 0;
double pts_time;
if (enc->flags & (AV_CODEC_FLAG_INTERLACED_DCT | AV_CODEC_FLAG_INTERLACED_ME) &&
ost->top_field_first >= 0)
in_picture->top_field_first = !!ost->top_field_first;
@@ -1254,12 +1249,8 @@ static void do_video_out(OutputFile *of,
in_picture->quality = enc->global_quality;
in_picture->pict_type = 0;
if (ost->forced_kf_ref_pts == AV_NOPTS_VALUE &&
in_picture->pts != AV_NOPTS_VALUE)
ost->forced_kf_ref_pts = in_picture->pts;
pts_time = in_picture->pts != AV_NOPTS_VALUE ?
(in_picture->pts - ost->forced_kf_ref_pts) * av_q2d(enc->time_base) : NAN;
in_picture->pts * av_q2d(enc->time_base) : NAN;
if (ost->forced_kf_index < ost->forced_kf_count &&
in_picture->pts >= ost->forced_kf_pts[ost->forced_kf_index]) {
ost->forced_kf_index++;
@@ -1310,8 +1301,6 @@ static void do_video_out(OutputFile *of,
ret = avcodec_send_frame(enc, in_picture);
if (ret < 0)
goto error;
// Make sure Closed Captions will not be duplicated
av_frame_remove_side_data(in_picture, AV_FRAME_DATA_A53_CC);
while (1) {
ret = avcodec_receive_packet(enc, &pkt);
@@ -1348,6 +1337,7 @@ static void do_video_out(OutputFile *of,
fprintf(ost->logfile, "%s", enc->stats_out);
}
}
}
ost->sync_opts++;
/*
* For video, number of frames in == number of packets out.
@@ -1511,6 +1501,8 @@ static int reap_filters(int flush)
av_rescale_q(filtered_frame->pts, filter_tb, enc->time_base) -
av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base);
}
//if (ost->source_index >= 0)
// *filtered_frame= *input_streams[ost->source_index]->decoded_frame; //for me_threshold
switch (av_buffersink_get_type(filter)) {
case AVMEDIA_TYPE_VIDEO:
@@ -1791,7 +1783,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
vid = 0;
av_bprint_init(&buf, 0, AV_BPRINT_SIZE_AUTOMATIC);
av_bprint_init(&buf_script, 0, AV_BPRINT_SIZE_AUTOMATIC);
av_bprint_init(&buf_script, 0, 1);
for (i = 0; i < nb_output_streams; i++) {
float q = -1;
ost = output_streams[i];
@@ -1812,7 +1804,7 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
av_bprintf(&buf, "frame=%5d fps=%3.*f q=%3.1f ",
frame_number, fps < 9.95, fps, q);
av_bprintf(&buf_script, "frame=%d\n", frame_number);
av_bprintf(&buf_script, "fps=%.2f\n", fps);
av_bprintf(&buf_script, "fps=%.1f\n", fps);
av_bprintf(&buf_script, "stream_%d_%d_q=%.1f\n",
ost->file_index, ost->index, q);
if (is_last_report)
@@ -1896,11 +1888,9 @@ static void print_report(int is_last_report, int64_t timer_start, int64_t cur_ti
if (total_size < 0) av_bprintf(&buf_script, "total_size=N/A\n");
else av_bprintf(&buf_script, "total_size=%"PRId64"\n", total_size);
if (pts == AV_NOPTS_VALUE) {
av_bprintf(&buf_script, "out_time_us=N/A\n");
av_bprintf(&buf_script, "out_time_ms=N/A\n");
av_bprintf(&buf_script, "out_time=N/A\n");
} else {
av_bprintf(&buf_script, "out_time_us=%"PRId64"\n", pts);
av_bprintf(&buf_script, "out_time_ms=%"PRId64"\n", pts);
av_bprintf(&buf_script, "out_time=%s%02d:%02d:%02d.%06d\n",
hours_sign, hours, mins, secs, us);
@@ -2212,12 +2202,10 @@ static void check_decode_result(InputStream *ist, int *got_output, int ret)
if (ret < 0 && exit_on_error)
exit_program(1);
if (*got_output && ist) {
if (exit_on_error && *got_output && ist) {
if (ist->decoded_frame->decode_error_flags || (ist->decoded_frame->flags & AV_FRAME_FLAG_CORRUPT)) {
av_log(NULL, exit_on_error ? AV_LOG_FATAL : AV_LOG_WARNING,
"%s: corrupt decoded frame in stream %d\n", input_files[ist->file_index]->ctx->url, ist->st->index);
if (exit_on_error)
exit_program(1);
av_log(NULL, AV_LOG_FATAL, "%s: corrupt decoded frame in stream %d\n", input_files[ist->file_index]->ctx->url, ist->st->index);
exit_program(1);
}
}
}
@@ -2241,6 +2229,9 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame)
/* determine if the parameters for this input changed */
need_reinit = ifilter->format != frame->format;
if (!!ifilter->hw_frames_ctx != !!frame->hw_frames_ctx ||
(ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data))
need_reinit = 1;
switch (ifilter->ist->st->codecpar->codec_type) {
case AVMEDIA_TYPE_AUDIO:
@@ -2254,13 +2245,6 @@ static int ifilter_send_frame(InputFilter *ifilter, AVFrame *frame)
break;
}
if (!ifilter->ist->reinit_filters && fg->graph)
need_reinit = 0;
if (!!ifilter->hw_frames_ctx != !!frame->hw_frames_ctx ||
(ifilter->hw_frames_ctx && ifilter->hw_frames_ctx->data != frame->hw_frames_ctx->data))
need_reinit = 1;
if (need_reinit) {
ret = ifilter_parameters_from_frame(ifilter, frame);
if (ret < 0)
@@ -2425,12 +2409,14 @@ static int decode_audio(InputStream *ist, AVPacket *pkt, int *got_output,
ist->samples_decoded += decoded_frame->nb_samples;
ist->frames_decoded++;
#if 1
/* increment next_dts to use for the case where the input stream does not
have timestamps or there are multiple frames in the packet */
ist->next_pts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) /
avctx->sample_rate;
ist->next_dts += ((int64_t)AV_TIME_BASE * decoded_frame->nb_samples) /
avctx->sample_rate;
#endif
if (decoded_frame->pts != AV_NOPTS_VALUE) {
decoded_frame_tb = ist->st->time_base;
@@ -2822,7 +2808,6 @@ static int process_input_packet(InputStream *ist, const AVPacket *pkt, int no_eo
ist->dts = ist->next_dts;
switch (ist->dec_ctx->codec_type) {
case AVMEDIA_TYPE_AUDIO:
av_assert1(pkt->duration >= 0);
if (ist->dec_ctx->sample_rate) {
ist->next_dts += ((int64_t)AV_TIME_BASE * ist->dec_ctx->frame_size) /
ist->dec_ctx->sample_rate;
@@ -2890,7 +2875,7 @@ static void print_sdp(void)
av_sdp_create(avc, j, sdp, sizeof(sdp));
if (!sdp_filename) {
av_log(NULL, AV_LOG_INFO, "SDP:\n%s\n", sdp);
printf("SDP:\n%s\n", sdp);
fflush(stdout);
} else {
if (avio_open2(&sdp_pb, sdp_filename, AVIO_FLAG_WRITE, &int_cb, NULL) < 0) {
@@ -3182,13 +3167,7 @@ static int init_output_stream_streamcopy(OutputStream *ost)
"Error setting up codec context options.\n");
return ret;
}
ret = avcodec_parameters_from_context(par_src, ost->enc_ctx);
if (ret < 0) {
av_log(NULL, AV_LOG_FATAL,
"Error getting reference codec parameters.\n");
return ret;
}
avcodec_parameters_from_context(par_src, ost->enc_ctx);
if (!codec_tag) {
unsigned int codec_tag_tmp;
@@ -3453,7 +3432,7 @@ static int init_output_stream_encode(OutputStream *ost)
"if you want a different framerate.\n",
ost->file_index, ost->index);
}
// ost->frame_rate = ist->st->avg_frame_rate.num ? ist->st->avg_frame_rate : (AVRational){25, 1};
if (ost->enc->supported_framerates && !ost->force_fps) {
int idx = av_find_nearest_q_idx(ost->frame_rate, ost->enc->supported_framerates);
ost->frame_rate = ost->enc->supported_framerates[idx];
@@ -3516,12 +3495,6 @@ static int init_output_stream_encode(OutputStream *ost)
enc_ctx->bits_per_raw_sample = frame_bits_per_raw_sample;
}
if (ost->top_field_first == 0) {
enc_ctx->field_order = AV_FIELD_BB;
} else if (ost->top_field_first == 1) {
enc_ctx->field_order = AV_FIELD_TT;
}
if (ost->forced_keyframes) {
if (!strncmp(ost->forced_keyframes, "expr:", 5)) {
ret = av_expr_parse(&ost->forced_keyframes_pexpr, ost->forced_keyframes+5,
@@ -3608,23 +3581,6 @@ static int init_output_stream(OutputStream *ost, char *error, int error_len)
return ret;
}
}
if (ist && ist->dec->type == AVMEDIA_TYPE_SUBTITLE && ost->enc->type == AVMEDIA_TYPE_SUBTITLE) {
int input_props = 0, output_props = 0;
AVCodecDescriptor const *input_descriptor =
avcodec_descriptor_get(dec->codec_id);
AVCodecDescriptor const *output_descriptor =
avcodec_descriptor_get(ost->enc_ctx->codec_id);
if (input_descriptor)
input_props = input_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);
if (output_descriptor)
output_props = output_descriptor->props & (AV_CODEC_PROP_TEXT_SUB | AV_CODEC_PROP_BITMAP_SUB);
if (input_props && output_props && input_props != output_props) {
snprintf(error, error_len,
"Subtitle encoding currently only possible from text to text "
"or bitmap to bitmap");
return AVERROR_INVALIDDATA;
}
}
if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) {
if (ret == AVERROR_EXPERIMENTAL)
@@ -4460,11 +4416,9 @@ static int process_input(int file_index)
if (ist->discard)
goto discard_packet;
if (pkt.flags & AV_PKT_FLAG_CORRUPT) {
av_log(NULL, exit_on_error ? AV_LOG_FATAL : AV_LOG_WARNING,
"%s: corrupt input packet in stream %d\n", is->url, pkt.stream_index);
if (exit_on_error)
exit_program(1);
if (exit_on_error && (pkt.flags & AV_PKT_FLAG_CORRUPT)) {
av_log(NULL, AV_LOG_FATAL, "%s: corrupt input packet in stream %d\n", is->url, pkt.stream_index);
exit_program(1);
}
if (debug_ts) {
@@ -4584,10 +4538,7 @@ static int process_input(int file_index)
pkt_dts + AV_TIME_BASE/10 < FFMAX(ist->pts, ist->dts)) {
ifile->ts_offset -= delta;
av_log(NULL, AV_LOG_DEBUG,
"timestamp discontinuity for stream #%d:%d "
"(id=%d, type=%s): %"PRId64", new offset= %"PRId64"\n",
ist->file_index, ist->st->index, ist->st->id,
av_get_media_type_string(ist->dec_ctx->codec_type),
"timestamp discontinuity %"PRId64", new offset= %"PRId64"\n",
delta, ifile->ts_offset);
pkt.dts -= av_rescale_q(delta, AV_TIME_BASE_Q, ist->st->time_base);
if (pkt.pts != AV_NOPTS_VALUE)
@@ -4902,30 +4853,23 @@ static int transcode(void)
return ret;
}
static BenchmarkTimeStamps get_benchmark_time_stamps(void)
static int64_t getutime(void)
{
BenchmarkTimeStamps time_stamps = { av_gettime_relative() };
#if HAVE_GETRUSAGE
struct rusage rusage;
getrusage(RUSAGE_SELF, &rusage);
time_stamps.user_usec =
(rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec;
time_stamps.sys_usec =
(rusage.ru_stime.tv_sec * 1000000LL) + rusage.ru_stime.tv_usec;
return (rusage.ru_utime.tv_sec * 1000000LL) + rusage.ru_utime.tv_usec;
#elif HAVE_GETPROCESSTIMES
HANDLE proc;
FILETIME c, e, k, u;
proc = GetCurrentProcess();
GetProcessTimes(proc, &c, &e, &k, &u);
time_stamps.user_usec =
((int64_t)u.dwHighDateTime << 32 | u.dwLowDateTime) / 10;
time_stamps.sys_usec =
((int64_t)k.dwHighDateTime << 32 | k.dwLowDateTime) / 10;
return ((int64_t) u.dwHighDateTime << 32 | u.dwLowDateTime) / 10;
#else
time_stamps.user_usec = time_stamps.sys_usec = 0;
return av_gettime_relative();
#endif
return time_stamps;
}
static int64_t getmaxrss(void)
@@ -4993,7 +4937,7 @@ void cancel_operation()
int execute(int argc, char **argv)
{
int i, ret;
BenchmarkTimeStamps ti;
int64_t ti;
int savedCode = setjmp(ex_buf__);
if (savedCode == 0) {
@@ -5040,23 +4984,22 @@ int execute(int argc, char **argv)
exit_program(1);
}
// if (nb_input_files == 0) {
// av_log(NULL, AV_LOG_FATAL, "At least one input file must be specified\n");
// exit_program(1);
// }
for (i = 0; i < nb_output_files; i++) {
if (strcmp(output_files[i]->ctx->oformat->name, "rtp"))
want_sdp = 0;
}
current_time = ti = get_benchmark_time_stamps();
current_time = ti = getutime();
if (transcode() < 0)
exit_program(1);
ti = getutime() - ti;
if (do_benchmark) {
int64_t utime, stime, rtime;
current_time = get_benchmark_time_stamps();
utime = current_time.user_usec - ti.user_usec;
stime = current_time.sys_usec - ti.sys_usec;
rtime = current_time.real_usec - ti.real_usec;
av_log(NULL, AV_LOG_INFO,
"bench: utime=%0.3fs stime=%0.3fs rtime=%0.3fs\n",
utime / 1000000.0, stime / 1000000.0, rtime / 1000000.0);
av_log(NULL, AV_LOG_INFO, "bench: utime=%0.3fs\n", ti / 1000000.0);
}
av_log(NULL, AV_LOG_DEBUG, "%"PRIu64" frames successfully decoded, %"PRIu64" decoding errors\n",
decode_error_stat[0], decode_error_stat[1]);
+2 -5
View File
@@ -17,10 +17,6 @@
*/
/*
* CHANGES 03.2019
* --------------------------------------------------------
* - config.h include removed
*
* CHANGES 08.2018
* --------------------------------------------------------
* - fftools_ prefix added to file name and include guards
@@ -35,6 +31,8 @@
#ifndef FFTOOLS_FFMPEG_H
#define FFTOOLS_FFMPEG_H
#include "config.h"
#include <stdint.h>
#include <stdio.h>
#include <signal.h>
@@ -498,7 +496,6 @@ typedef struct OutputStream {
AVRational frame_aspect_ratio;
/* forced key frames */
int64_t forced_kf_ref_pts;
int64_t *forced_kf_pts;
int forced_kf_count;
int forced_kf_index;
@@ -73,7 +73,6 @@ enum AVPixelFormat choose_pixel_fmt(AVStream *st, AVCodecContext *enc_ctx, AVCod
if (codec && codec->pix_fmts) {
const enum AVPixelFormat *p = codec->pix_fmts;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(target);
//FIXME: This should check for AV_PIX_FMT_FLAG_ALPHA after PAL8 pixel format without alpha is implemented
int has_alpha = desc ? desc->nb_components % 2 == 0 : 0;
enum AVPixelFormat best= AV_PIX_FMT_NONE;
@@ -301,17 +300,10 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
exit_program(1);
}
ist = input_streams[input_files[file_idx]->ist_index + st->index];
if (ist->user_set_discard == AVDISCARD_ALL) {
av_log(NULL, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s "
"matches a disabled input stream.\n", p, fg->graph_desc);
exit_program(1);
}
} else {
/* find the first unused stream of corresponding type */
for (i = 0; i < nb_input_streams; i++) {
ist = input_streams[i];
if (ist->user_set_discard == AVDISCARD_ALL)
continue;
if (ist->dec_ctx->codec_type == type && ist->discard)
break;
}
@@ -747,7 +739,6 @@ static int sub2video_prepare(InputStream *ist, InputFilter *ifilter)
if (!ist->sub2video.frame)
return AVERROR(ENOMEM);
ist->sub2video.last_pts = INT64_MIN;
ist->sub2video.end_pts = INT64_MIN;
return 0;
}
@@ -791,7 +782,7 @@ static int configure_input_video_filter(FilterGraph *fg, InputFilter *ifilter,
sar = ifilter->sample_aspect_ratio;
if(!sar.den)
sar = (AVRational){0,1};
av_bprint_init(&args, 0, AV_BPRINT_SIZE_AUTOMATIC);
av_bprint_init(&args, 0, 1);
av_bprintf(&args,
"video_size=%dx%d:pix_fmt=%d:time_base=%d/%d:"
"pixel_aspect=%d/%d:sws_param=flags=%d",
+15 -85
View File
@@ -183,13 +183,13 @@ static int show_hwaccels(void *optctx, const char *opt, const char *arg)
enum AVHWDeviceType type = AV_HWDEVICE_TYPE_NONE;
int i;
av_log(NULL, AV_LOG_INFO, "Hardware acceleration methods:\n");
printf("Hardware acceleration methods:\n");
while ((type = av_hwdevice_iterate_types(type)) !=
AV_HWDEVICE_TYPE_NONE)
av_log(NULL, AV_LOG_INFO, "%s\n", av_hwdevice_get_type_name(type));
printf("%s\n", av_hwdevice_get_type_name(type));
for (i = 0; hwaccels[i].name; i++)
av_log(NULL, AV_LOG_INFO, "%s\n", hwaccels[i].name);
av_log(NULL, AV_LOG_INFO, "\n");
printf("%s\n", hwaccels[i].name);
printf("\n");
return 0;
}
@@ -278,7 +278,7 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
{
OptionsContext *o = optctx;
StreamMap *m = NULL;
int i, negative = 0, file_idx, disabled = 0;
int i, negative = 0, file_idx;
int sync_file_idx = -1, sync_stream_idx = 0;
char *p, *sync;
char *map;
@@ -313,11 +313,6 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
"match any streams.\n", arg);
exit_program(1);
}
if (input_streams[input_files[sync_file_idx]->ist_index + sync_stream_idx]->user_set_discard == AVDISCARD_ALL) {
av_log(NULL, AV_LOG_FATAL, "Sync stream specification in map %s matches a disabled input "
"stream.\n", arg);
exit_program(1);
}
}
@@ -354,10 +349,6 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
if (check_stream_specifier(input_files[file_idx]->ctx, input_files[file_idx]->ctx->streams[i],
*p == ':' ? p + 1 : p) <= 0)
continue;
if (input_streams[input_files[file_idx]->ist_index + i]->user_set_discard == AVDISCARD_ALL) {
disabled = 1;
continue;
}
GROW_ARRAY(o->stream_maps, o->nb_stream_maps);
m = &o->stream_maps[o->nb_stream_maps - 1];
@@ -377,10 +368,6 @@ static int opt_map(void *optctx, const char *opt, const char *arg)
if (!m) {
if (allow_unused) {
av_log(NULL, AV_LOG_VERBOSE, "Stream map '%s' matches no streams; ignoring.\n", arg);
} else if (disabled) {
av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches disabled streams.\n"
"To ignore this, add a trailing '?' to the map.\n", arg);
exit_program(1);
} else {
av_log(NULL, AV_LOG_FATAL, "Stream map '%s' matches no streams.\n"
"To ignore this, add a trailing '?' to the map.\n", arg);
@@ -460,8 +447,7 @@ static int opt_map_channel(void *optctx, const char *opt, const char *arg)
/* allow trailing ? to map_channel */
if ((allow_unused = strchr(mapchan, '?')))
*allow_unused = 0;
if (m->channel_idx < 0 || m->channel_idx >= st->codecpar->channels ||
input_streams[input_files[m->file_idx]->ist_index + m->stream_idx]->user_set_discard == AVDISCARD_ALL) {
if (m->channel_idx < 0 || m->channel_idx >= st->codecpar->channels) {
if (allow_unused) {
av_log(NULL, AV_LOG_VERBOSE, "mapchan: invalid audio channel #%d.%d.%d\n",
m->file_idx, m->stream_idx, m->channel_idx);
@@ -509,11 +495,11 @@ static int opt_init_hw_device(void *optctx, const char *opt, const char *arg)
{
if (!strcmp(arg, "list")) {
enum AVHWDeviceType type = AV_HWDEVICE_TYPE_NONE;
av_log(NULL, AV_LOG_INFO, "Supported hardware device types:\n");
printf("Supported hardware device types:\n");
while ((type = av_hwdevice_iterate_types(type)) !=
AV_HWDEVICE_TYPE_NONE)
av_log(NULL, AV_LOG_INFO, "%s\n", av_hwdevice_get_type_name(type));
av_log(NULL, AV_LOG_INFO, "\n");
printf("%s\n", av_hwdevice_get_type_name(type));
printf("\n");
exit_program(0);
} else {
return hw_device_init_from_string(arg, NULL);
@@ -770,13 +756,6 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
MATCH_PER_STREAM_OPT(discard, str, discard_str, ic, st);
ist->user_set_discard = AVDISCARD_NONE;
if ((o->video_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) ||
(o->audio_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) ||
(o->subtitle_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) ||
(o->data_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_DATA))
ist->user_set_discard = AVDISCARD_ALL;
if (discard_str && av_opt_eval_int(&cc, discard_opt, discard_str, &ist->user_set_discard) < 0) {
av_log(NULL, AV_LOG_ERROR, "Error parsing discard %s.\n",
discard_str);
@@ -931,14 +910,13 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic)
static void assert_file_overwrite(const char *filename)
{
const char *proto_name = avio_find_protocol_name(filename);
if (file_overwrite && no_file_overwrite) {
fprintf(stderr, "Error, both -y and -n supplied. Exiting.\n");
exit_program(1);
}
if (!file_overwrite) {
const char *proto_name = avio_find_protocol_name(filename);
if (proto_name && !strcmp(proto_name, "file") && avio_check(filename, 0) == 0) {
if (stdin_interaction && !no_file_overwrite) {
fprintf(stderr,"File '%s' already exists. Overwrite ? [y/N] ", filename);
@@ -957,19 +935,6 @@ static void assert_file_overwrite(const char *filename)
}
}
}
if (proto_name && !strcmp(proto_name, "file")) {
for (int i = 0; i < nb_input_files; i++) {
InputFile *file = input_files[i];
if (file->ctx->iformat->flags & AVFMT_NOFILE)
continue;
if (!strcmp(filename, file->ctx->url)) {
av_log(NULL, AV_LOG_FATAL, "Output %s same as Input #%d - exiting\n", filename, i);
av_log(NULL, AV_LOG_WARNING, "FFmpeg cannot edit existing files in-place.\n");
exit_program(1);
}
}
}
}
static void dump_attachment(AVStream *st, const char *filename)
@@ -1148,22 +1113,9 @@ static int open_input_file(OptionsContext *o, const char *filename)
}
}
if (o->start_time != AV_NOPTS_VALUE && o->start_time_eof != AV_NOPTS_VALUE) {
av_log(NULL, AV_LOG_WARNING, "Cannot use -ss and -sseof both, using -ss for %s\n", filename);
o->start_time_eof = AV_NOPTS_VALUE;
}
if (o->start_time_eof != AV_NOPTS_VALUE) {
if (o->start_time_eof >= 0) {
av_log(NULL, AV_LOG_ERROR, "-sseof value must be negative; aborting\n");
exit_program(1);
}
if (ic->duration > 0) {
if (ic->duration>0) {
o->start_time = o->start_time_eof + ic->duration;
if (o->start_time < 0) {
av_log(NULL, AV_LOG_WARNING, "-sseof value seeks to before start of file %s; ignored\n", filename);
o->start_time = AV_NOPTS_VALUE;
}
} else
av_log(NULL, AV_LOG_WARNING, "Cannot use -sseof, duration of %s not known\n", filename);
}
@@ -1180,10 +1132,8 @@ static int open_input_file(OptionsContext *o, const char *filename)
int dts_heuristic = 0;
for (i=0; i<ic->nb_streams; i++) {
const AVCodecParameters *par = ic->streams[i]->codecpar;
if (par->video_delay) {
if (par->video_delay)
dts_heuristic = 1;
break;
}
}
if (dts_heuristic) {
seek_timestamp -= 3*AV_TIME_BASE / 23;
@@ -1384,7 +1334,6 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e
ost->file_index = nb_output_files - 1;
ost->index = idx;
ost->st = st;
ost->forced_kf_ref_pts = AV_NOPTS_VALUE;
st->codecpar->codec_type = type;
ret = choose_encoder(o, oc, ost);
@@ -1691,8 +1640,6 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in
MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st);
MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st);
if (o->nb_filters > 1)
av_log(NULL, AV_LOG_ERROR, "Only '-vf %s' read, ignoring remaining -vf options: Use ',' to separate filters\n", ost->filters);
if (!ost->stream_copy) {
const char *p = NULL;
@@ -1874,8 +1821,6 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in
MATCH_PER_STREAM_OPT(filter_scripts, str, ost->filters_script, oc, st);
MATCH_PER_STREAM_OPT(filters, str, ost->filters, oc, st);
if (o->nb_filters > 1)
av_log(NULL, AV_LOG_ERROR, "Only '-af %s' read, ignoring remaining -af options: Use ',' to separate filters\n", ost->filters);
if (!ost->stream_copy) {
char *sample_fmt = NULL;
@@ -2209,8 +2154,6 @@ static int open_output_file(OptionsContext *o, const char *filename)
int new_area;
ist = input_streams[i];
new_area = ist->st->codecpar->width * ist->st->codecpar->height + 100000000*!!ist->st->codec_info_nb_frames;
if (ist->user_set_discard == AVDISCARD_ALL)
continue;
if((qcr!=MKTAG('A', 'P', 'I', 'C')) && (ist->st->disposition & AV_DISPOSITION_ATTACHED_PIC))
new_area = 1;
if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO &&
@@ -2232,8 +2175,6 @@ static int open_output_file(OptionsContext *o, const char *filename)
int score;
ist = input_streams[i];
score = ist->st->codecpar->channels + 100000000*!!ist->st->codec_info_nb_frames;
if (ist->user_set_discard == AVDISCARD_ALL)
continue;
if (ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO &&
score > best_score) {
best_score = score;
@@ -2255,8 +2196,6 @@ static int open_output_file(OptionsContext *o, const char *filename)
AVCodec const *output_codec =
avcodec_find_encoder(oc->oformat->subtitle_codec);
int input_props = 0, output_props = 0;
if (input_streams[i]->user_set_discard == AVDISCARD_ALL)
continue;
if (output_codec)
output_descriptor = avcodec_descriptor_get(output_codec->id);
if (input_descriptor)
@@ -2278,8 +2217,6 @@ static int open_output_file(OptionsContext *o, const char *filename)
if (!o->data_disable ) {
enum AVCodecID codec_id = av_guess_codec(oc->oformat, NULL, filename, NULL, AVMEDIA_TYPE_DATA);
for (i = 0; codec_id != AV_CODEC_ID_NONE && i < nb_input_streams; i++) {
if (input_streams[i]->user_set_discard == AVDISCARD_ALL)
continue;
if (input_streams[i]->st->codecpar->codec_type == AVMEDIA_TYPE_DATA
&& input_streams[i]->st->codecpar->codec_id == codec_id )
new_data_stream(o, oc, i);
@@ -2318,11 +2255,6 @@ loop_end:
int src_idx = input_files[map->file_index]->ist_index + map->stream_index;
ist = input_streams[input_files[map->file_index]->ist_index + map->stream_index];
if (ist->user_set_discard == AVDISCARD_ALL) {
av_log(NULL, AV_LOG_FATAL, "Stream #%d:%d is disabled and cannot be mapped.\n",
map->file_index, map->stream_index);
exit_program(1);
}
if(o->subtitle_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)
continue;
if(o-> audio_disable && ist->st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)
@@ -3188,7 +3120,7 @@ void show_help_default(const char *opt, const char *arg)
show_usage();
av_log(NULL, AV_LOG_INFO, "Getting help:\n"
printf("Getting help:\n"
" -h -- print basic options\n"
" -h long -- print more options\n"
" -h full -- print all options (including all format and codec specific options, very long)\n"
@@ -3226,7 +3158,7 @@ void show_help_default(const char *opt, const char *arg)
OPT_EXPERT | OPT_AUDIO, OPT_VIDEO, 0);
show_help_options(options, "Subtitle options:",
OPT_SUBTITLE, 0, 0);
av_log(NULL, AV_LOG_INFO, "\n");
printf("\n");
if (show_avoptions) {
int flags = AV_OPT_FLAG_DECODING_PARAM | AV_OPT_FLAG_ENCODING_PARAM;
@@ -3235,9 +3167,7 @@ void show_help_default(const char *opt, const char *arg)
#if CONFIG_SWSCALE
show_help_children(sws_get_class(), flags);
#endif
#if CONFIG_SWRESAMPLE
show_help_children(swr_get_class(), AV_OPT_FLAG_AUDIO_PARAM);
#endif
show_help_children(avfilter_get_class(), AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_FILTERING_PARAM);
show_help_children(av_bsf_get_class(), AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_AUDIO_PARAM | AV_OPT_FLAG_BSF_PARAM);
}
@@ -3417,7 +3347,7 @@ const OptionDef options[] = {
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(start_time) },
"set the start time offset", "time_off" },
{ "sseof", HAS_ARG | OPT_TIME | OPT_OFFSET |
OPT_INPUT, { .off = OFFSET(start_time_eof) },
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(start_time_eof) },
"set the start time offset relative to EOF", "time_off" },
{ "seek_timestamp", HAS_ARG | OPT_INT | OPT_OFFSET |
OPT_INPUT, { .off = OFFSET(seek_timestamp) },
+50 -102
View File
@@ -18,15 +18,6 @@
*/
/*
* CHANGES 02.2019
* --------------------------------------------------------
* - JavaVM registered via av_jni_set_java_vm()
* - registerNewNativeFFmpegPipe() method added
*
* CHANGES 10.2018
* --------------------------------------------------------
* - getBuildConf method added
*
* CHANGES 09.2018
* --------------------------------------------------------
* - Merged with mobileffmpeg_config
@@ -37,11 +28,7 @@
*/
#include <pthread.h>
#include <sys/types.h>
#include <sys/stat.h>
#include "config.h"
#include "libavcodec/jni.h"
#include "libavutil/bprint.h"
#include "mobileffmpeg.h"
#include "fftools_ffmpeg.h"
@@ -95,12 +82,15 @@ JNINativeMethod configMethods[] = {
{"enableNativeRedirection", "()V", (void*) Java_com_arthenica_mobileffmpeg_Config_enableNativeRedirection},
{"disableNativeRedirection", "()V", (void*) Java_com_arthenica_mobileffmpeg_Config_disableNativeRedirection},
{"setNativeLogLevel", "(I)V", (void*) Java_com_arthenica_mobileffmpeg_Config_setNativeLogLevel},
{"getNativeLogLevel", "()I", (void*) Java_com_arthenica_mobileffmpeg_Config_getNativeLogLevel},
{"getNativeFFmpegVersion", "()Ljava/lang/String;", (void*) Java_com_arthenica_mobileffmpeg_Config_getNativeFFmpegVersion},
{"getNativeVersion", "()Ljava/lang/String;", (void*) Java_com_arthenica_mobileffmpeg_Config_getNativeVersion},
{"nativeExecute", "([Ljava/lang/String;)I", (void*) Java_com_arthenica_mobileffmpeg_Config_nativeExecute},
{"nativeCancel", "()V", (void*) Java_com_arthenica_mobileffmpeg_Config_nativeCancel},
{"getNativeBuildConf", "()Ljava/lang/String;", (void*) Java_com_arthenica_mobileffmpeg_Config_getNativeBuildConf}
{"getNativeLogLevel", "()I", (void*) Java_com_arthenica_mobileffmpeg_Config_getNativeLogLevel}
};
/** Prototypes of native functions defined by FFmpeg class. */
JNINativeMethod ffmpegMethods[] = {
{"getNativeFFmpegVersion", "()Ljava/lang/String;", (void*) Java_com_arthenica_mobileffmpeg_Config_getNativeFFmpegVersion},
{"getNativeVersion", "()Ljava/lang/String;", (void*) Java_com_arthenica_mobileffmpeg_Config_getNativeVersion},
{"nativeExecute", "([Ljava/lang/String;)I", (void*) Java_com_arthenica_mobileffmpeg_Config_nativeExecute},
{"nativeCancel", "()V", (void*) Java_com_arthenica_mobileffmpeg_Config_nativeCancel}
};
/** Forward declaration for function defined in fftools_ffmpeg.c */
@@ -242,9 +232,6 @@ void monitorNotify() {
/**
* Adds log data to the end of callback data list.
*
* @param level log level
* @param data log data
*/
void logCallbackDataAdd(int level, const char *data) {
@@ -356,10 +343,10 @@ struct CallbackData *callbackDataRemove() {
/**
* Callback function for FFmpeg logs.
*
* @param ptr pointer to AVClass struct
* @param level log level
* @param format format string
* @param vargs arguments
* \param pointer to AVClass struct
* \param level
* \param format
* \param arguments
*/
void mobileffmpeg_log_callback_function(void *ptr, int level, const char* format, va_list vargs) {
char line[LOG_LINE_SIZE];
@@ -369,10 +356,6 @@ void mobileffmpeg_log_callback_function(void *ptr, int level, const char* format
if (level >= 0) {
level &= 0xff;
}
int activeLogLevel = av_log_get_level();
if ((activeLogLevel == AV_LOG_QUIET) || (level > activeLogLevel)) {
return;
}
avutil_log_format_line(ptr, level, format, vargs, part, &print_prefix);
snprintf(line, sizeof(line), "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
@@ -392,13 +375,13 @@ void mobileffmpeg_log_callback_function(void *ptr, int level, const char* format
/**
* Callback function for FFmpeg statistics.
*
* @param frameNumber last processed frame number
* @param fps frames processed per second
* @param quality quality of the output stream (video only)
* @param size size in bytes
* @param time processed output duration
* @param bitrate output bit rate in kbits/s
* @param speed processing speed = processed duration / operation duration
* \param frameNumber last processed frame number
* \param fps frames processed per second
* \param quality quality of the output stream (video only)
* \param size size in bytes
* \param time processed output duration
* \param bitrate output bit rate in kbits/s
* \param speed processing speed = processed duration / operation duration
*/
void mobileffmpeg_statistics_callback_function(int frameNumber, float fps, float quality, int64_t size, int time, double bitrate, double speed) {
statisticsCallbackDataAdd(frameNumber, fps, quality, size, time, bitrate, speed);
@@ -473,9 +456,9 @@ void *callbackThreadFunction() {
/**
* Called when 'mobileffmpeg' native library is loaded.
*
* @param vm pointer to the running virtual machine
* @param reserved reserved
* @return JNI version needed by 'mobileffmpeg' library
* \param vm pointer to the running virtual machine
* \param reserved reserved
* \return JNI version needed by 'mobileffmpeg' library
*/
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
JNIEnv *env;
@@ -490,7 +473,12 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_FALSE;
}
if ((*env)->RegisterNatives(env, localConfigClass, configMethods, 9) < 0) {
if ((*env)->RegisterNatives(env, localConfigClass, ffmpegMethods, 4) < 0) {
LOGE("OnLoad failed to RegisterNatives for class %s.\n", configClassName);
return JNI_FALSE;
}
if ((*env)->RegisterNatives(env, localConfigClass, configMethods, 4) < 0) {
LOGE("OnLoad failed to RegisterNatives for class %s.\n", configClassName);
return JNI_FALSE;
}
@@ -511,8 +499,6 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_FALSE;
}
av_jni_set_java_vm(vm, NULL);
configClass = (jclass) ((*env)->NewGlobalRef(env, localConfigClass));
redirectionEnabled = 0;
@@ -529,9 +515,9 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
/**
* Sets log level.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* @param level log level
* \param env pointer to native method interface
* \param reference to the class on which this method is invoked
* \param log level
*/
JNIEXPORT void JNICALL Java_com_arthenica_mobileffmpeg_Config_setNativeLogLevel(JNIEnv *env, jclass object, jint level) {
av_log_set_level(level);
@@ -540,8 +526,8 @@ JNIEXPORT void JNICALL Java_com_arthenica_mobileffmpeg_Config_setNativeLogLevel(
/**
* Returns current log level.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* \param env pointer to native method interface
* \param reference to the class on which this method is invoked
*/
JNIEXPORT jint JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeLogLevel(JNIEnv *env, jclass object) {
return av_log_get_level();
@@ -550,8 +536,8 @@ JNIEXPORT jint JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeLogLevel(
/**
* Enables log and statistics redirection.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* \param env pointer to native method interface
* \param reference to the class on which this method is invoked
*/
JNIEXPORT void JNICALL Java_com_arthenica_mobileffmpeg_Config_enableNativeRedirection(JNIEnv *env, jclass object) {
mutexLock();
@@ -577,8 +563,8 @@ JNIEXPORT void JNICALL Java_com_arthenica_mobileffmpeg_Config_enableNativeRedire
/**
* Disables log and statistics redirection.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* \param env pointer to native method interface
* \param reference to the class on which this method is invoked
*/
JNIEXPORT void JNICALL Java_com_arthenica_mobileffmpeg_Config_disableNativeRedirection(JNIEnv *env, jclass object) {
@@ -601,9 +587,9 @@ JNIEXPORT void JNICALL Java_com_arthenica_mobileffmpeg_Config_disableNativeRedir
/**
* Returns FFmpeg version bundled within the library natively.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* @return FFmpeg version string
* \param env pointer to native method interface
* \param object reference to the class on which this method is invoked
* \return FFmpeg version string
*/
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeFFmpegVersion(JNIEnv *env, jclass object) {
return (*env)->NewStringUTF(env, FFMPEG_VERSION);
@@ -612,9 +598,9 @@ JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeFFmpeg
/**
* Returns MobileFFmpeg library version natively.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* @return MobileFFmpeg version string
* \param env pointer to native method interface
* \param object reference to the class on which this method is invoked
* \return MobileFFmpeg version string
*/
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeVersion(JNIEnv *env, jclass object) {
return (*env)->NewStringUTF(env, MOBILE_FFMPEG_VERSION);
@@ -623,10 +609,10 @@ JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeVersio
/**
* Synchronously executes FFmpeg command natively with arguments provided.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* @param stringArray reference to the object holding FFmpeg command arguments
* @return zero on successful execution, non-zero on error
* \param env pointer to native method interface
* \param object reference to the class on which this method is invoked
* \param stringArray reference to the object holding FFmpeg command arguments
* \return zero on successful execution, non-zero on error
*/
JNIEXPORT jint JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeExecute(JNIEnv *env, jclass object, jobjectArray stringArray) {
jstring *tempArray = NULL;
@@ -678,47 +664,9 @@ JNIEXPORT jint JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeExecute(JNIE
/**
* Cancels an ongoing operation natively.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* \param env pointer to native method interface
* \param object reference to the class on which this method is invoked
*/
JNIEXPORT void JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeCancel(JNIEnv *env, jclass object) {
cancel_operation();
}
/**
* Returns build configuration for FFmpeg.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* @return build configuration string
*/
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeBuildConf(JNIEnv *env, jclass object) {
return (*env)->NewStringUTF(env, FFMPEG_CONFIGURATION);
}
/**
* Creates natively a new named pipe to use in FFmpeg operations.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* @param ffmpegPipePath full path of ffmpeg pipe
* @return zero on successful creation, non-zero on error
*/
JNIEXPORT int JNICALL Java_com_arthenica_mobileffmpeg_Config_registerNewNativeFFmpegPipe(JNIEnv *env, jclass object, jstring ffmpegPipePath) {
const char *ffmpegPipePathString = (*env)->GetStringUTFChars(env, ffmpegPipePath, 0);
return mkfifo(ffmpegPipePathString, S_IRWXU | S_IRWXG | S_IROTH);
}
/**
* Returns MobileFFmpeg library build date natively.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* @return MobileFFmpeg library build date
*/
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeBuildDate(JNIEnv *env, jclass object) {
char buildDate[10];
sprintf(buildDate, "%d", MOBILE_FFMPEG_BUILD_DATE);
return (*env)->NewStringUTF(env, buildDate);
}
+1 -22
View File
@@ -27,7 +27,7 @@
#include "libavutil/ffversion.h"
/** Library version string */
#define MOBILE_FFMPEG_VERSION "4.2.1"
#define MOBILE_FFMPEG_VERSION "2.2"
/** Defines tag used for Android logging. */
#define LIB_NAME "mobile-ffmpeg"
@@ -103,25 +103,4 @@ JNIEXPORT jint JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeExecute(JNIE
*/
JNIEXPORT void JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeCancel(JNIEnv *, jclass);
/*
* Class: com_arthenica_mobileffmpeg_Config
* Method: getNativeBuildConf
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeBuildConf(JNIEnv *, jclass);
/*
* Class: com_arthenica_mobileffmpeg_Config
* Method: registerNewNativeFFmpegPipe
* Signature: (Ljava/lang/String)I;
*/
JNIEXPORT int JNICALL Java_com_arthenica_mobileffmpeg_Config_registerNewNativeFFmpegPipe(JNIEnv *env, jclass object, jstring ffmpegPipePath);
/*
* Class: com_arthenica_mobileffmpeg_Config
* Method: getNativeBuildDate
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeBuildDate(JNIEnv *env, jclass object);
#endif /* MOBILE_FFMPEG_H */
@@ -25,16 +25,15 @@ const char *abiDetectClassName = "com/arthenica/mobileffmpeg/AbiDetect";
/** Prototypes of native functions defined by this file. */
JNINativeMethod abiDetectMethods[] = {
{"getNativeAbi", "()Ljava/lang/String;", (void*) Java_com_arthenica_mobileffmpeg_AbiDetect_getNativeAbi},
{"getNativeCpuAbi", "()Ljava/lang/String;", (void*) Java_com_arthenica_mobileffmpeg_AbiDetect_getNativeCpuAbi}
{"getAbi", "()Ljava/lang/String;", (void*) Java_com_arthenica_mobileffmpeg_AbiDetect_getAbi}
};
/**
* Called when 'abidetect' native library is loaded.
*
* @param vm pointer to the running virtual machine
* @param reserved reserved
* @return JNI version needed by 'abidetect' library
* \param vm pointer to the running virtual machine
* \param reserved reserved
* \return JNI version needed by 'abidetect' library
*/
jint JNI_OnLoad(JavaVM *vm, void *reserved) {
JNIEnv *env;
@@ -49,7 +48,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
return JNI_FALSE;
}
if ((*env)->RegisterNatives(env, abiDetectClass, abiDetectMethods, 2) < 0) {
if ((*env)->RegisterNatives(env, abiDetectClass, abiDetectMethods, 1) < 0) {
LOGE("OnLoad failed to RegisterNatives for class %s.\n", abiDetectClassName);
return JNI_FALSE;
}
@@ -58,36 +57,13 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
}
/**
* Returns loaded ABI name.
* Returns running ABI name.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* @return loaded ABI name as UTF string
* \param env pointer to native method interface
* \param object reference to the class on which this method is invoked
* \return running ABI name as UTF string
*/
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_getNativeAbi(JNIEnv *env, jclass object) {
#ifdef MOBILE_FFMPEG_ARM_V7A
return (*env)->NewStringUTF(env, "arm-v7a");
#elif MOBILE_FFMPEG_ARM64_V8A
return (*env)->NewStringUTF(env, "arm64-v8a");
#elif MOBILE_FFMPEG_X86
return (*env)->NewStringUTF(env, "x86");
#elif MOBILE_FFMPEG_X86_64
return (*env)->NewStringUTF(env, "x86_64");
#else
return (*env)->NewStringUTF(env, "unknown");
#endif
}
/**
* Returns ABI name of the running cpu.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* @return ABI name of the running cpu as UTF string
*/
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_getNativeCpuAbi(JNIEnv *env, jclass object) {
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_getAbi(JNIEnv *env, jclass object) {
AndroidCpuFamily family = android_getCpuFamily();
if (family == ANDROID_CPU_FAMILY_ARM) {
@@ -113,18 +89,3 @@ JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_getNativeCpu
return (*env)->NewStringUTF(env, ABI_UNKNOWN);
}
}
/**
* Returns whether MobileFFmpeg release is a long term release or not.
*
* @param env pointer to native method interface
* @param object reference to the class on which this method is invoked
* @return YES or NO
*/
JNIEXPORT jboolean JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_isNativeLTSBuild(JNIEnv *env, jclass object) {
#if defined(MOBILE_FFMPEG_LTS)
return JNI_TRUE;
#else
return JNI_FALSE;
#endif
}
@@ -46,23 +46,9 @@
/*
* Class: com_arthenica_mobileffmpeg_AbiDetect
* Method: getNativeAbi
* Method: getAbi
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_getNativeAbi(JNIEnv *, jclass);
/*
* Class: com_arthenica_mobileffmpeg_AbiDetect
* Method: getNativeCpuAbi
* Signature: ()Ljava/lang/String;
*/
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_getNativeCpuAbi(JNIEnv *, jclass);
/**
* Class: com_arthenica_mobileffmpeg_AbiDetect
* Method: isNativeLTSBuild
* Signature: ()Z
*/
JNIEXPORT jboolean JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_isNativeLTSBuild(JNIEnv *, jclass);
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_getAbi(JNIEnv *, jclass);
#endif /* MOBILE_FFMPEG_ABIDETECT_H */
@@ -29,7 +29,6 @@ package com.arthenica.mobileffmpeg;
public class AbiDetect {
static {
armV7aNeonLoaded = false;
System.loadLibrary("mobileffmpeg-abidetect");
/* ALL LIBRARIES LOADED AT STARTUP */
@@ -37,50 +36,17 @@ public class AbiDetect {
FFmpeg.class.getName();
}
private static boolean armV7aNeonLoaded;
/**
* Default constructor hidden.
*/
private AbiDetect() {
}
static void setArmV7aNeonLoaded(final boolean armV7aNeonLoaded) {
AbiDetect.armV7aNeonLoaded = armV7aNeonLoaded;
}
/**
* <p>Returns loaded ABI name.
* <p>Returns running ABI name.
*
* @return loaded ABI name
* @return running ABI name
*/
public static String getAbi() {
if (armV7aNeonLoaded) {
return "arm-v7a-neon";
} else {
return getNativeAbi();
}
}
/**
* <p>Returns loaded ABI name.
*
* @return loaded ABI name
*/
private native static String getNativeAbi();
/**
* <p>Returns ABI name of the running cpu.
*
* @return ABI name of the running cpu
*/
public native static String getNativeCpuAbi();
/**
* <p>Returns whether MobileFFmpeg release is a long term release or not.
*
* @return YES or NO
*/
native static boolean isNativeLTSBuild();
public native static String getAbi();
}
@@ -27,11 +27,9 @@ import android.util.Log;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicReference;
import static com.arthenica.mobileffmpeg.FFmpeg.getBuildDate;
import static com.arthenica.mobileffmpeg.FFmpeg.getVersion;
/**
@@ -65,8 +63,6 @@ public class Config {
*/
public static final String TAG = "mobile-ffmpeg";
public static final String MOBILE_FFMPEG_PIPE_PREFIX = "mf_pipe_";
private static LogCallback logCallbackFunction;
private static Level activeLogLevel;
@@ -75,40 +71,26 @@ public class Config {
private static Statistics lastReceivedStatistics;
private static final AtomicReference<StringBuffer> systemCommandOutputReference;
private static boolean runningSystemCommand;
private static int lastCreatedPipeIndex;
static {
Log.i(Config.TAG, "Loading mobile-ffmpeg.");
/* ALL LIBRARIES LOADED AT STARTUP */
Abi cpuAbi = Abi.from(AbiDetect.getNativeCpuAbi());
String abiName = AbiDetect.getAbi();
Abi abi = Abi.from(abiName);
FFmpeg.class.getName();
/*
* NEON supported arm-v7a library has a different name
*/
boolean nativeLibraryLoaded = false;
if (cpuAbi == Abi.ABI_ARMV7A_NEON) {
if (AbiDetect.isNativeLTSBuild()) {
/*
* IF CPU SUPPORTS ARM-V7A-NEON THE TRY TO LOAD IT FIRST. IF NOT LOAD DEFAULT ARM-V7A
*/
try {
System.loadLibrary("mobileffmpeg-armv7a-neon");
nativeLibraryLoaded = true;
AbiDetect.setArmV7aNeonLoaded(true);
} catch (final UnsatisfiedLinkError e) {
Log.i(Config.TAG, "NEON supported armeabi-v7a library not found. Loading default armeabi-v7a library.", e);
}
} else {
AbiDetect.setArmV7aNeonLoaded(true);
if (abi == Abi.ABI_ARMV7A_NEON) {
try {
System.loadLibrary("mobileffmpeg-armv7a-neon");
nativeLibraryLoaded = true;
} catch (final UnsatisfiedLinkError e) {
Log.i(Config.TAG, "NEON supported armeabi-v7a library not found. Loading default armeabi-v7a library.", e);
abi = Abi.ABI_ARMV7A;
}
}
@@ -116,7 +98,7 @@ public class Config {
System.loadLibrary("mobileffmpeg");
}
Log.i(Config.TAG, String.format("Loaded mobile-ffmpeg-%s-%s-%s-%s.", getPackageName(), AbiDetect.getAbi(), getVersion(), getBuildDate()));
Log.i(Config.TAG, String.format("Loaded mobile-ffmpeg-%s-%s.", abi.getName(), getVersion()));
/* NATIVE LOG LEVEL IS RECEIVED ONLY ON STARTUP */
activeLogLevel = Level.from(getNativeLogLevel());
@@ -124,12 +106,6 @@ public class Config {
lastReceivedStatistics = new Statistics();
Config.enableRedirection();
systemCommandOutputReference = new AtomicReference<>();
systemCommandOutputReference.set(new StringBuffer());
runningSystemCommand = false;
lastCreatedPipeIndex = 0;
}
/**
@@ -209,23 +185,11 @@ public class Config {
final Level level = Level.from(levelValue);
final String text = new String(logMessage);
if (runningSystemCommand) {
// REDIRECT SYSTEM OUTPUT
if (activeLogLevel != Level.AV_LOG_QUIET && levelValue <= activeLogLevel.getValue()) {
systemCommandOutputReference.get().append(text);
}
return;
}
if (activeLogLevel == Level.AV_LOG_QUIET || levelValue > activeLogLevel.getValue()) {
// LOG NEITHER PRINTED NOR FORWARDED
return;
}
// ALWAYS REDIRECT COMMAND OUTPUT
FFmpeg.appendCommandOutput(text);
if (logCallbackFunction != null) {
logCallbackFunction.apply(new LogMessage(level, text));
} else {
@@ -269,16 +233,16 @@ public class Config {
* <p>Statistics redirection method called by JNI/native part.
*
* @param videoFrameNumber last processed frame number for videos
* @param videoFps frames processed per second for videos
* @param videoQuality quality of the video stream
* @param size size in bytes
* @param time processed duration in milliseconds
* @param bitrate output bit rate in kbits/s
* @param speed processing speed = processed duration / operation duration
* @param videoFps frames processed per second for videos
* @param videoQuality quality of the video stream
* @param size size in bytes
* @param time processed duration in milliseconds
* @param bitrate output bit rate in kbits/s
* @param speed processing speed = processed duration / operation duration
*/
private static void statistics(final int videoFrameNumber, final float videoFps,
final float videoQuality, final long size, final int time,
final double bitrate, final double speed) {
final float videoQuality, final long size, final int time,
final double bitrate, final double speed) {
final Statistics newStatistics = new Statistics(videoFrameNumber, videoFps, videoQuality, size, time, bitrate, speed);
lastReceivedStatistics.update(newStatistics);
@@ -397,119 +361,6 @@ public class Config {
}
}
/**
* <p>Returns package name.
*
* @return guessed package name according to supported external libraries
* @since 3.0
*/
public static String getPackageName() {
return Packages.getPackageName();
}
/**
* <p>Returns supported external libraries.
*
* @return list of supported external libraries
* @since 3.0
*/
public static List<String> getExternalLibraries() {
return Packages.getExternalLibraries();
}
/**
* <p>Creates a new named pipe to use in <code>FFmpeg</code> operations.
*
* <p>Please note that creator is responsible of closing created pipes.
*
* @param context application context to access application data
* @return the full path of named pipe
*/
public static String registerNewFFmpegPipe(final Context context) {
// PIPES ARE CREATED UNDER THE CACHE DIRECTORY
final File cacheDir = context.getCacheDir();
final String newFFmpegPipePath = cacheDir + File.separator + MOBILE_FFMPEG_PIPE_PREFIX + (++lastCreatedPipeIndex);
// FIRST CLOSE OLD PIPES WITH THE SAME NAME
closeFFmpegPipe(newFFmpegPipePath);
int rc = registerNewNativeFFmpegPipe(newFFmpegPipePath);
if (rc == 0) {
return newFFmpegPipePath;
} else {
Log.e(TAG, String.format("Failed to register new FFmpeg pipe %s. Operation failed with rc=%d.", newFFmpegPipePath, rc));
return null;
}
}
/**
* <p>Closes a previously created <code>FFmpeg</code> pipe.
*
* @param ffmpegPipePath full path of ffmpeg pipe
*/
public static void closeFFmpegPipe(final String ffmpegPipePath) {
File file = new File(ffmpegPipePath);
if (file.exists()) {
file.delete();
}
}
/**
* Executes system command. System command is not logged to output.
*
* @param arguments command arguments
* @param commandOutputEndPatternList list of patterns which will indicate that operation has ended
* @param timeout execution timeout
* @return return code
*/
static int systemExecute(final String[] arguments, final List<String> commandOutputEndPatternList, final long timeout) {
systemCommandOutputReference.set(new StringBuffer());
runningSystemCommand = true;
int rc = Config.nativeExecute(arguments);
long totalWaitTime = 0;
try {
while (!systemCommandOutputContainsPattern(commandOutputEndPatternList) && (totalWaitTime < timeout)) {
synchronized (systemCommandOutputReference) {
systemCommandOutputReference.wait(20);
}
totalWaitTime += 20;
}
} catch (final InterruptedException e) {
Log.w(TAG, "systemExecute operation interrupted.", e);
}
runningSystemCommand = false;
nativeCancel();
return rc;
}
private static boolean systemCommandOutputContainsPattern(final List<String> patternList) {
String string = systemCommandOutputReference.get().toString();
for (String pattern : patternList) {
if (string.contains(pattern)) {
return true;
}
}
return false;
}
/**
* Returns output of last executed system command.
*
* @return output of last executed system command
*/
static String getSystemCommandOutput() {
return systemCommandOutputReference.get().toString();
}
/**
* <p>Enables native redirection. Necessary for log and statistics callback functions.
*/
@@ -557,33 +408,10 @@ public class Config {
native static int nativeExecute(final String[] arguments);
/**
* <p>Cancels an ongoing operation natively. This function does not wait for termination to
* complete and returns immediately.
* <p>Cancels an ongoing operation natively.
*
* <p>This function does not wait for termination to complete and returns immediately.
*/
native static void nativeCancel();
/**
* <p>Returns build configuration for <code>FFmpeg</code>.
*
* @return build configuration string
*/
native static String getNativeBuildConf();
/**
* <p>Creates natively a new named pipe to use in <code>FFmpeg</code> operations.
*
* <p>Please note that creator is responsible of closing created pipes.
*
* @param ffmpegPipePath full path of ffmpeg pipe
* @return zero on successful creation, non-zero on error
*/
native static int registerNewNativeFFmpegPipe(final String ffmpegPipePath);
/**
* <p>Returns MobileFFmpeg library build date natively.
*
* @return MobileFFmpeg library build date
*/
native static String getNativeBuildDate();
}
@@ -19,10 +19,6 @@
package com.arthenica.mobileffmpeg;
import android.util.Log;
import java.util.Arrays;
/**
* <p>Main class for FFmpeg operations. Provides {@link #execute(String...)} method to execute
* FFmpeg commands.
@@ -40,10 +36,6 @@ public class FFmpeg {
public static final int RETURN_CODE_CANCEL = 255;
private static int lastReturnCode = 0;
private static StringBuffer lastCommandOutput = new StringBuffer();
static {
AbiDetect.class.getName();
Config.class.getName();
@@ -55,15 +47,6 @@ public class FFmpeg {
private FFmpeg() {
}
/**
* <p>Appends given log output to the last command output.
*
* @param output log output
*/
static void appendCommandOutput(final String output) {
lastCommandOutput.append(output);
}
/**
* <p>Returns FFmpeg version bundled within the library.
*
@@ -79,11 +62,7 @@ public class FFmpeg {
* @return MobileFFmpeg version
*/
public static String getVersion() {
if (AbiDetect.isNativeLTSBuild()) {
return String.format("%s-lts", Config.getNativeVersion());
} else {
return Config.getNativeVersion();
}
return Config.getNativeVersion();
}
/**
@@ -93,112 +72,26 @@ public class FFmpeg {
* @return zero on successful execution, 255 on user cancel and non-zero on error
*/
public static int execute(final String[] arguments) {
lastCommandOutput = new StringBuffer();
lastReturnCode = Config.nativeExecute(arguments);
return lastReturnCode;
return Config.nativeExecute(arguments);
}
/**
* <p>Synchronously executes FFmpeg command provided. Command is split into arguments using
* provided delimiter.
* <p>Synchronously executes FFmpeg with arguments provided.
*
* @param command FFmpeg command
* @param delimiter delimiter used between arguments
* @return zero on successful execution, 255 on user cancel and non-zero on error
* @since 3.0
*/
public static int execute(final String command, final String delimiter) {
return execute((command == null) ? new String[]{""} : command.split((delimiter == null) ? " " : delimiter));
}
/**
* <p>Synchronously executes FFmpeg command provided. Space character is used to split command
* into arguments.
*
* @param command FFmpeg command
* @param arguments FFmpeg command options/arguments in one string
* @return zero on successful execution, 255 on user cancel and non-zero on error
*/
public static int execute(final String command) {
return execute(command, " ");
public static int execute(final String arguments) {
return execute((arguments == null) ? new String[]{""} : arguments.split(" "));
}
/**
* <p>Cancels an ongoing operation. This function does not wait for termination to complete and
* returns immediately.
* <p>Cancels an ongoing operation.
*
* <p>This function does not wait for termination to complete and returns immediately.
*/
public static void cancel() {
Config.nativeCancel();
}
/**
* <p>Returns return code of last executed command.
*
* @return return code of last executed command
* @since 3.0
*/
public static int getLastReturnCode() {
return lastReturnCode;
}
/**
* <p>Returns log output of last executed command. Please note that disabling redirection using
* {@link Config#disableRedirection()} method also disables this functionality.
*
* @return output of last executed command
* @since 3.0
*/
public static String getLastCommandOutput() {
return lastCommandOutput.toString();
}
/**
* <p>Returns media information for given file.
*
* @param path path or uri of media file
* @return media information
* @since 3.0
*/
public static MediaInformation getMediaInformation(final String path) {
return getMediaInformation(path, 10000L);
}
/**
* <p>Returns media information for given file.
*
* @param path path or uri of media file
* @param timeout complete timeout
* @return media information
* @since 3.0
*/
public static MediaInformation getMediaInformation(final String path, final Long timeout) {
int rc = Config.systemExecute(new String[]{"-v", "info", "-hide_banner", "-i", path, "-f", "null", "-"}, Arrays.asList("Press [q] to stop, [?] for help", "No such file or directory", "Input/output error", "Conversion failed"), timeout);
if (rc == 0) {
return MediaInformationParser.from(Config.getSystemCommandOutput());
} else {
Log.i(Config.TAG, Config.getSystemCommandOutput());
return null;
}
}
/**
* <p>Returns whether MobileFFmpeg release is a long term release or not.
*
* @return YES or NO
*/
public static boolean isLTSBuild() {
return AbiDetect.isNativeLTSBuild();
}
/**
* <p>Returns MobileFFmpeg library build date.
*
* @return MobileFFmpeg library build date
*/
public static String getBuildDate() {
return Config.getNativeBuildDate();
}
}
@@ -1,225 +0,0 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
/**
* Media information class.
*
* @since 3.0
*/
public class MediaInformation {
/**
* Format
*/
private String format;
/**
* Path
*/
private String path;
/**
* Duration, in milliseconds
*/
private Long duration;
/**
* Start time, in milliseconds
*/
private Long startTime;
/**
* Bitrate, kb/s
*/
private Long bitrate;
/**
* Metadata map
*/
private Map<String, String> metadata;
/**
* List of streams
*/
private List<StreamInformation> streams;
/**
* Raw unparsed media information
*/
private String rawInformation;
public MediaInformation() {
this.metadata = new HashMap<>();
this.streams = new ArrayList<>();
}
/**
* Returns format.
*
* @return media format
*/
public String getFormat() {
return format;
}
/**
* Sets media format.
*
* @param format media format
*/
public void setFormat(String format) {
this.format = format;
}
/**
* Returns path.
*
* @return media path
*/
public String getPath() {
return path;
}
/**
* Sets path.
*
* @param path media path
*/
public void setPath(String path) {
this.path = path;
}
/**
* Returns duration.
*
* @return media duration in milliseconds
*/
public Long getDuration() {
return duration;
}
/**
* Sets duration.
*
* @param duration media duration in milliseconds
*/
public void setDuration(Long duration) {
this.duration = duration;
}
/**
* Returns start time.
*
* @return media start time in milliseconds
*/
public Long getStartTime() {
return startTime;
}
/**
* Sets start time.
*
* @param startTime media start time in milliseconds
*/
public void setStartTime(Long startTime) {
this.startTime = startTime;
}
/**
* Returns bitrate.
*
* @return media bitrate in kb/s
*/
public Long getBitrate() {
return bitrate;
}
/**
* Sets bitrate.
*
* @param bitrate media bitrate in kb/s
*/
public void setBitrate(Long bitrate) {
this.bitrate = bitrate;
}
/**
* Returns unparsed media information.
*
* @return unparsed media information data
*/
public String getRawInformation() {
return rawInformation;
}
/**
* Sets unparsed media information.
*
* @param rawInformation unparsed media information data
*/
public void setRawInformation(String rawInformation) {
this.rawInformation = rawInformation;
}
/**
* Adds metadata.
*
* @param key metadata key
* @param value metadata value
*/
public void addMetadata(String key, String value) {
this.metadata.put(key, value);
}
/**
* Returns all metadata entries.
*
* @return set of metadata entries
*/
public Set<Map.Entry<String, String>> getMetadataEntries() {
return this.metadata.entrySet();
}
/**
* Adds new stream.
*
* @param stream new stream information
*/
public void addStream(StreamInformation stream) {
this.streams.add(stream);
}
/**
* Returns all streams.
*
* @return list of streams
*/
public List<StreamInformation> getStreams() {
return streams;
}
}
@@ -1,501 +0,0 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg;
import android.util.Log;
import com.arthenica.mobileffmpeg.util.Pair;
import com.arthenica.mobileffmpeg.util.Trio;
import java.math.BigDecimal;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Locale;
/**
* Helper class for {@link MediaInformation}.
*
* @since 3.0
*/
public class MediaInformationParser {
public static SimpleDateFormat DURATION_FORMAT;
public static Date REFERENCE_DURATION;
static {
try {
DURATION_FORMAT = new SimpleDateFormat("kk:mm:ss", Locale.getDefault());
REFERENCE_DURATION = DURATION_FORMAT.parse("00:00:00");
} catch (final ParseException e) {
Log.i(Config.TAG, "Preparing duration reference failed.", e);
DURATION_FORMAT = null;
REFERENCE_DURATION = null;
}
}
/**
* Parses media information command output and builds a {@link MediaInformation} instance.
*
* @param rawCommandOutput media information command output
* @return parsed instance of null if a parsing error occurs
*/
public static MediaInformation from(final String rawCommandOutput) {
final MediaInformation mediaInformation = new MediaInformation();
if (rawCommandOutput != null) {
final String[] split = rawCommandOutput.split("\n");
boolean metadata = false;
StreamInformation lastCreatedStream = null;
final StringBuilder rawInformation = new StringBuilder();
for (final String outputLine : split) {
if (outputLine.startsWith("[")) {
metadata = false;
continue;
}
final String trimmedLine = outputLine.trim();
if (trimmedLine.startsWith("Input")) {
metadata = false;
lastCreatedStream = null;
Pair<String, String> pair = parseInputBlock(trimmedLine);
mediaInformation.setFormat(pair.getFirst());
mediaInformation.setPath(pair.getSecond());
} else if (trimmedLine.startsWith("Duration")) {
metadata = false;
lastCreatedStream = null;
Trio<Long, Long, Long> trio = parseDurationBlock(trimmedLine);
mediaInformation.setDuration(trio.getFirst());
mediaInformation.setStartTime(trio.getSecond());
mediaInformation.setBitrate(trio.getThird());
} else if (trimmedLine.startsWith("Metadata")) {
metadata = true;
} else if (trimmedLine.startsWith("Stream mapping") || trimmedLine.startsWith("Press [q] to stop") || trimmedLine.startsWith("Output")) {
break;
} else if (trimmedLine.startsWith("Stream")) {
metadata = false;
lastCreatedStream = MediaInformationParser.parseStreamBlock(trimmedLine);
mediaInformation.addStream(lastCreatedStream);
} else if (metadata) {
Pair<String, String> pair = parseMetadataBlock(trimmedLine);
if (pair.getFirst() != null && pair.getSecond() != null) {
if (lastCreatedStream != null) {
lastCreatedStream.addMetadata(pair.getFirst(), pair.getSecond());
} else {
mediaInformation.addMetadata(pair.getFirst(), pair.getSecond());
}
}
}
rawInformation.append(outputLine);
rawInformation.append("\n");
}
mediaInformation.setRawInformation(rawInformation.toString());
}
return mediaInformation;
}
static Pair<String, String> parseInputBlock(final String input) {
String format = substring(input, ",", ", from", Collections.<String>emptyList());
String path = substring(input, "\'", "\'", Collections.<String>emptyList());
return new Pair<>(format, path);
}
static Trio<Long, Long, Long> parseDurationBlock(final String line) {
Long duration = parseDuration(substring(line, "Duration:", ",", Collections.singletonList("uration:")));
Long start = parseStartTime(substring(line, "start:", ",", Collections.singletonList("tart:")));
Long bitrate = toLongObject(substring(line, "bitrate:", Arrays.asList("itrate:", "kb/s")));
return new Trio<>(duration, start, bitrate);
}
static Pair<String, String> parseMetadataBlock(final String metadata) {
String key = null;
String value = null;
if (metadata != null) {
int index = metadata.indexOf(':');
if (index > -1) {
key = metadata.substring(0, index).trim();
value = metadata.substring(index + 1).trim();
}
}
return new Pair<>(key, value);
}
static StreamInformation parseStreamBlock(final String input) {
final StreamInformation streamInformation = new StreamInformation();
if (input != null) {
streamInformation.setIndex(parseStreamIndex(input));
int typeBlockStartIndex = index(input, ":", 0, 2);
if (typeBlockStartIndex > -1 && (typeBlockStartIndex < input.length())) {
String[] parts = input.substring(typeBlockStartIndex + 1).split(",");
String typePart = safeGet(parts, 0);
final String type = parseStreamType(typePart);
streamInformation.setType(type);
streamInformation.setCodec(parseStreamCodec(typePart));
streamInformation.setFullCodec(parseStreamFullCodec(typePart));
String part2 = safeGet(parts, 1);
String part3 = safeGet(parts, 2);
String part4 = safeGet(parts, 3);
String part5 = safeGet(parts, 4);
if ("video".equals(type)) {
int lastUsedPart = 1;
if (part2 != null) {
int pStart = count(part2, "(");
int pEnd = count(part2, ")");
while (pStart != pEnd) {
lastUsedPart++;
String newPart = safeGet(parts, lastUsedPart);
if (newPart == null) {
break;
}
part2 = String.format("%s,%s", part2, newPart);
pStart = count(part2, "(");
pEnd = count(part2, ")");
}
streamInformation.setFullFormat(part2.toLowerCase(Locale.getDefault()).trim());
streamInformation.setFormat(part2.replaceAll("\\(.*\\)", "").toLowerCase(Locale.getDefault()).trim());
}
lastUsedPart++;
String videoDimensionPart = safeGet(parts, lastUsedPart);
if (videoDimensionPart != null) {
String videoLayout = videoDimensionPart.toLowerCase(Locale.getDefault()).trim();
Pair<Long, Long> dimensions = parseVideoDimensions(videoLayout);
streamInformation.setWidth(dimensions.getFirst());
streamInformation.setHeight(dimensions.getSecond());
streamInformation.setSampleAspectRatio(parseVideoStreamSampleAspectRatio(videoLayout));
streamInformation.setDisplayAspectRatio(parseVideoStreamDisplayAspectRatio(videoLayout));
}
for (int i = lastUsedPart + 1; i < parts.length; i++) {
String part = parts[i].replaceAll("\\(.*\\)", "").toLowerCase(Locale.getDefault());
if (part.contains("kb/s")) {
streamInformation.setBitrate(toLongObject(part.replaceAll("kb/s", "").trim()));
} else if (part.contains("fps")) {
streamInformation.setAverageFrameRate(part.replaceAll("fps", "").trim());
} else if (part.contains("tbr")) {
streamInformation.setRealFrameRate(part.replaceAll("tbr", "").trim());
} else if (part.contains("tbn")) {
streamInformation.setTimeBase(part.replaceAll("tbn", "").trim());
} else if (part.contains("tbc")) {
streamInformation.setCodecTimeBase(part.replaceAll("tbc", "").trim());
}
}
}
if ("audio".equals(type)) {
if (part2 != null) {
streamInformation.setSampleRate(parseAudioStreamSampleRate(part2));
}
if (part3 != null) {
streamInformation.setChannelLayout(part3.toLowerCase(Locale.getDefault()).trim());
}
if (part4 != null) {
streamInformation.setSampleFormat(part4.toLowerCase(Locale.getDefault()).trim());
}
if (part5 != null) {
streamInformation.setBitrate(toLongObject(part5.toLowerCase(Locale.getDefault()).replaceAll("\\(.*\\)", "").replaceAll("kb/s", "").trim()));
}
}
}
}
return streamInformation;
}
static Pair<Long, Long> parseVideoDimensions(final String input) {
Long width = null;
Long height = null;
if (input != null) {
final String[] dimensions = input.toLowerCase(Locale.getDefault()).replaceAll("\\[.*\\]", "").trim().split("x");
width = toLongObject(safeGet(dimensions, 0));
height = toLongObject(safeGet(dimensions, 1));
}
return new Pair<>(width, height);
}
static String parseVideoStreamSampleAspectRatio(final String input) {
if (input != null) {
String[] parts = input.replaceAll("\\[", "").replaceAll("\\]", "").split(" ");
for (int i = 0; i < parts.length; i++) {
if (parts[i].toLowerCase(Locale.getDefault()).equals("sar")) {
return safeGet(parts, i + 1);
}
}
}
return null;
}
static String parseVideoStreamDisplayAspectRatio(final String input) {
if (input != null) {
String[] parts = input.replaceAll("\\[", "").replaceAll("\\]", "").split(" ");
for (int i = 0; i < parts.length; i++) {
if (parts[i].toLowerCase(Locale.getDefault()).equals("dar")) {
return safeGet(parts, i + 1);
}
}
}
return null;
}
static Long parseAudioStreamSampleRate(final String input) {
if (input != null) {
boolean khz = false;
boolean mhz = false;
String lowerCase = input.toLowerCase(Locale.getDefault());
if (lowerCase.contains("khz")) {
khz = true;
}
if (lowerCase.contains("mhz")) {
mhz = true;
}
String sampleRate = lowerCase
.replaceAll("khz", "")
.replaceAll("mhz", "")
.replaceAll("hz", "")
.trim();
if (khz) {
return 1000 * toLong(sampleRate);
} else if (mhz) {
return 1000000 * toLong(sampleRate);
} else {
return toLong(sampleRate);
}
}
return null;
}
static String parseStreamType(final String input) {
if (input != null) {
if (input.toLowerCase(Locale.getDefault()).contains("audio:")) {
return "audio";
} else if (input.toLowerCase(Locale.getDefault()).contains("video:")) {
return "video";
}
}
return null;
}
static String parseStreamCodec(final String input) {
if (input != null) {
return input.toLowerCase(Locale.getDefault())
.replaceAll("\\(.*\\)", "")
.replaceAll("video:", "")
.replaceAll("audio:", "")
.trim();
}
return null;
}
static String parseStreamFullCodec(final String input) {
if (input != null) {
return input.toLowerCase(Locale.getDefault())
.replaceAll("video:", "")
.replaceAll("audio:", "")
.trim();
}
return null;
}
static Long parseStreamIndex(final String input) {
String substring = substring(input, "Stream #0:", ":", Collections.singletonList("tream #0"));
if (substring != null) {
// DISCARD PARANTHESIS
return toLongObject(substring
.replace(":", "")
.replaceAll("\\(.*\\)", ""));
}
return null;
}
static Long parseDuration(final String duration) {
if (duration == null || duration.equals("N/A")) {
return null;
}
try {
final Date calculated = DURATION_FORMAT.parse(duration);
long secondsPartInMilliseconds = calculated.getTime() - REFERENCE_DURATION.getTime();
int index = duration.indexOf('.');
if (index > -1) {
Long centiSeconds = toLong(duration.substring(index + 1));
secondsPartInMilliseconds += 10 * centiSeconds;
}
return secondsPartInMilliseconds;
} catch (final ParseException e) {
Log.d(Config.TAG, String.format("Parsing duration: %s failed.", duration), e);
return null;
}
}
static Long parseStartTime(final String startTime) {
if (startTime == null || startTime.equals("N/A")) {
return null;
}
try {
BigDecimal bigDecimal = new BigDecimal(startTime);
bigDecimal = bigDecimal.setScale(3, BigDecimal.ROUND_CEILING).multiply(new BigDecimal(1000));
return bigDecimal.longValue();
} catch (NumberFormatException e) {
Log.d(Config.TAG, String.format("Parsing startTime: %s failed.", startTime), e);
return null;
}
}
public static String substring(final String string, final String start, final String end, final List<String> ignoredTokens) {
String extractedSubstring = null;
if (string != null) {
int formatStart = string.indexOf(start);
if (formatStart > -1) {
int formatEnd = string.indexOf(end, formatStart + start.length());
if (formatEnd > -1) {
extractedSubstring = string.substring(formatStart + start.length(), formatEnd);
}
}
}
if ((ignoredTokens != null) && (extractedSubstring != null)) {
for (String token : ignoredTokens) {
extractedSubstring = extractedSubstring.replaceAll(token, "");
}
}
return (extractedSubstring == null) ? null : extractedSubstring.trim();
}
public static String substring(final String string, final String start, final List<String> ignoredTokens) {
String extractedSubstring = null;
if (string != null) {
int formatStart = string.indexOf(start);
if (formatStart > -1) {
extractedSubstring = string.substring(formatStart + 1);
}
}
if ((ignoredTokens != null) && (extractedSubstring != null)) {
for (String token : ignoredTokens) {
extractedSubstring = extractedSubstring.replaceAll(token, "");
}
}
return (extractedSubstring == null) ? null : extractedSubstring.trim();
}
public static int index(final String string, String substring, int startIndex, int n) {
int count = 1;
while (count <= n) {
startIndex = string.indexOf(substring, startIndex + substring.length());
count++;
}
return startIndex;
}
public static int count(final String string, String substring) {
int count = 0;
int index = 0;
do {
index = string.indexOf(substring, index);
if (index >= 0) {
count++;
index = index + substring.length();
}
} while (index >= 0);
return count;
}
private static <K> K safeGet(final K[] array, final int index) {
if (array == null) {
return null;
}
try {
final int size = array.length;
if (size > index) {
return array[index];
} else {
return null;
}
} catch (final ArrayIndexOutOfBoundsException e) {
return null;
}
}
private static long toLong(final String value) {
try {
return Long.parseLong(value);
} catch (NumberFormatException e) {
return 0;
}
}
static Long toLongObject(final String value) {
try {
return Long.parseLong(value);
} catch (NumberFormatException e) {
return null;
}
}
}
@@ -1,267 +0,0 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* <p>Provides helper methods to extract binary package information.
*
* @since 3.0
*/
class Packages {
private static final List<String> supportedExternalLibraries;
static {
supportedExternalLibraries = new ArrayList<>();
supportedExternalLibraries.add("fontconfig");
supportedExternalLibraries.add("freetype");
supportedExternalLibraries.add("fribidi");
supportedExternalLibraries.add("gmp");
supportedExternalLibraries.add("gnutls");
supportedExternalLibraries.add("kvazaar");
supportedExternalLibraries.add("mp3lame");
supportedExternalLibraries.add("libaom");
supportedExternalLibraries.add("libass");
supportedExternalLibraries.add("iconv");
supportedExternalLibraries.add("libilbc");
supportedExternalLibraries.add("libtheora");
supportedExternalLibraries.add("libvidstab");
supportedExternalLibraries.add("libvorbis");
supportedExternalLibraries.add("libvpx");
supportedExternalLibraries.add("libwebp");
supportedExternalLibraries.add("libxml2");
supportedExternalLibraries.add("opencore-amr");
supportedExternalLibraries.add("opus");
supportedExternalLibraries.add("shine");
supportedExternalLibraries.add("snappy");
supportedExternalLibraries.add("soxr");
supportedExternalLibraries.add("speex");
supportedExternalLibraries.add("twolame");
supportedExternalLibraries.add("wavpack");
supportedExternalLibraries.add("x264");
supportedExternalLibraries.add("x265");
supportedExternalLibraries.add("xvid");
}
/**
* Returns enabled external libraries by FFmpeg.
*
* @return enabled external libraries
*/
static List<String> getExternalLibraries() {
final String buildConfiguration = Config.getNativeBuildConf();
final List<String> enabledLibraryList = new ArrayList<>();
for (String supportedExternalLibrary : supportedExternalLibraries) {
if (buildConfiguration.contains("enable-" + supportedExternalLibrary) ||
buildConfiguration.contains("enable-lib" + supportedExternalLibrary)) {
enabledLibraryList.add(supportedExternalLibrary);
}
}
Collections.sort(enabledLibraryList);
return enabledLibraryList;
}
/**
* Returns MobileFFmpeg binary package name.
*
* @return guessed MobileFFmpeg binary package name
*/
static String getPackageName() {
final List<String> externalLibraryList = getExternalLibraries();
final boolean speex = externalLibraryList.contains("speex");
final boolean fribidi = externalLibraryList.contains("fribidi");
final boolean gnutls = externalLibraryList.contains("gnutls");
final boolean xvid = externalLibraryList.contains("xvid");
boolean minGpl = false;
boolean https = false;
boolean httpsGpl = false;
boolean audio = false;
boolean video = false;
boolean full = false;
boolean fullGpl = false;
if (speex && fribidi) {
if (xvid) {
fullGpl = true;
} else {
full = true;
}
} else if (speex) {
audio = true;
} else if (fribidi) {
video = true;
} else if (xvid) {
if (gnutls) {
httpsGpl = true;
} else {
minGpl = true;
}
} else {
if (gnutls) {
https = true;
}
}
if (fullGpl) {
if (externalLibraryList.contains("fontconfig") &&
externalLibraryList.contains("freetype") &&
externalLibraryList.contains("fribidi") &&
externalLibraryList.contains("gmp") &&
externalLibraryList.contains("gnutls") &&
externalLibraryList.contains("kvazaar") &&
externalLibraryList.contains("mp3lame") &&
externalLibraryList.contains("libaom") &&
externalLibraryList.contains("libass") &&
externalLibraryList.contains("iconv") &&
externalLibraryList.contains("libilbc") &&
externalLibraryList.contains("libtheora") &&
externalLibraryList.contains("libvidstab") &&
externalLibraryList.contains("libvorbis") &&
externalLibraryList.contains("libvpx") &&
externalLibraryList.contains("libwebp") &&
externalLibraryList.contains("libxml2") &&
externalLibraryList.contains("opencore-amr") &&
externalLibraryList.contains("opus") &&
externalLibraryList.contains("shine") &&
externalLibraryList.contains("snappy") &&
externalLibraryList.contains("soxr") &&
externalLibraryList.contains("speex") &&
externalLibraryList.contains("twolame") &&
externalLibraryList.contains("wavpack") &&
externalLibraryList.contains("x264") &&
externalLibraryList.contains("x265") &&
externalLibraryList.contains("xvid")) {
return "full-gpl";
} else {
return "custom";
}
}
if (full) {
if (externalLibraryList.contains("fontconfig") &&
externalLibraryList.contains("freetype") &&
externalLibraryList.contains("fribidi") &&
externalLibraryList.contains("gmp") &&
externalLibraryList.contains("gnutls") &&
externalLibraryList.contains("kvazaar") &&
externalLibraryList.contains("mp3lame") &&
externalLibraryList.contains("libaom") &&
externalLibraryList.contains("libass") &&
externalLibraryList.contains("iconv") &&
externalLibraryList.contains("libilbc") &&
externalLibraryList.contains("libtheora") &&
externalLibraryList.contains("libvorbis") &&
externalLibraryList.contains("libvpx") &&
externalLibraryList.contains("libwebp") &&
externalLibraryList.contains("libxml2") &&
externalLibraryList.contains("opencore-amr") &&
externalLibraryList.contains("opus") &&
externalLibraryList.contains("shine") &&
externalLibraryList.contains("snappy") &&
externalLibraryList.contains("soxr") &&
externalLibraryList.contains("speex") &&
externalLibraryList.contains("twolame") &&
externalLibraryList.contains("wavpack")) {
return "full";
} else {
return "custom";
}
}
if (video) {
if (externalLibraryList.contains("fontconfig") &&
externalLibraryList.contains("freetype") &&
externalLibraryList.contains("fribidi") &&
externalLibraryList.contains("kvazaar") &&
externalLibraryList.contains("libaom") &&
externalLibraryList.contains("libass") &&
externalLibraryList.contains("iconv") &&
externalLibraryList.contains("libtheora") &&
externalLibraryList.contains("libvpx") &&
externalLibraryList.contains("libwebp") &&
externalLibraryList.contains("snappy")) {
return "video";
} else {
return "custom";
}
}
if (audio) {
if (externalLibraryList.contains("mp3lame") &&
externalLibraryList.contains("libilbc") &&
externalLibraryList.contains("libvorbis") &&
externalLibraryList.contains("opencore-amr") &&
externalLibraryList.contains("opus") &&
externalLibraryList.contains("shine") &&
externalLibraryList.contains("soxr") &&
externalLibraryList.contains("speex") &&
externalLibraryList.contains("twolame") &&
externalLibraryList.contains("wavpack")) {
return "audio";
} else {
return "custom";
}
}
if (httpsGpl) {
if (externalLibraryList.contains("gmp") &&
externalLibraryList.contains("gnutls") &&
externalLibraryList.contains("libvidstab") &&
externalLibraryList.contains("x264") &&
externalLibraryList.contains("x265") &&
externalLibraryList.contains("xvid")) {
return "https-gpl";
} else {
return "custom";
}
}
if (https) {
if (externalLibraryList.contains("gmp") &&
externalLibraryList.contains("gnutls")) {
return "https";
} else {
return "custom";
}
}
if (minGpl) {
if (externalLibraryList.contains("libvidstab") &&
externalLibraryList.contains("x264") &&
externalLibraryList.contains("x265") &&
externalLibraryList.contains("xvid")) {
return "min-gpl";
} else {
return "custom";
}
}
return "min";
}
}
@@ -1,434 +0,0 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
/**
* Stream information class.
*
* @since 3.0
*/
public class StreamInformation {
/**
* Stream index
*/
private Long index;
private String type;
private String codec;
private String fullCodec;
private String format;
private String fullFormat;
private Long width;
private Long height;
private Long bitrate;
private Long sampleRate;
private String sampleFormat;
private String channelLayout;
/**
* SAR
*/
private String sampleAspectRatio;
/**
* DAR
*/
private String displayAspectRatio;
/**
* fps
*/
private String averageFrameRate;
/**
* tbr
*/
private String realFrameRate;
/**
* tbn
*/
private String timeBase;
/**
* tbc
*/
private String codecTimeBase;
/**
* Metadata map
*/
private final Map<String, String> metadata;
public StreamInformation() {
this.metadata = new HashMap<>();
}
/**
* Returns stream index.
*
* @return stream index, starting from zero
*/
public Long getIndex() {
return index;
}
/**
* Sets stream index.
*
* @param index stream index, starting from zero
*/
public void setIndex(Long index) {
this.index = index;
}
/**
* Returns stream type.
*
* @return stream type; audio or video
*/
public String getType() {
return type;
}
/**
* Sets stream type.
*
* @param type stream type; audio or video
*/
public void setType(String type) {
this.type = type;
}
/**
* Returns stream codec.
*
* @return stream codec
*/
public String getCodec() {
return codec;
}
/**
* Sets stream codec.
*
* @param codec stream codec
*/
public void setCodec(String codec) {
this.codec = codec;
}
/**
* Returns full stream codec.
*
* @return stream codec with additional profile and mode information
*/
public String getFullCodec() {
return fullCodec;
}
/**
* Sets full stream codec.
*
* @param fullCodec stream codec with additional profile and mode information
*/
public void setFullCodec(String fullCodec) {
this.fullCodec = fullCodec;
}
/**
* Returns stream format.
*
* @return stream format
*/
public String getFormat() {
return format;
}
/**
* Sets stream format.
*
* @param format stream format
*/
public void setFormat(String format) {
this.format = format;
}
/**
* Returns full stream format.
*
* @return stream format with
*/
public String getFullFormat() {
return fullFormat;
}
/**
* Sets full stream format.
*
* @param fullFormat stream format with
*/
public void setFullFormat(String fullFormat) {
this.fullFormat = fullFormat;
}
/**
* Returns width.
*
* @return width in pixels
*/
public Long getWidth() {
return width;
}
/**
* Sets width.
*
* @param width width in pixels
*/
public void setWidth(Long width) {
this.width = width;
}
/**
* Returns height.
*
* @return height in pixels
*/
public Long getHeight() {
return height;
}
/**
* Sets height.
*
* @param height height in pixels
*/
public void setHeight(Long height) {
this.height = height;
}
/**
* Returns bitrate.
*
* @return bitrate in kb/s
*/
public Long getBitrate() {
return bitrate;
}
/**
* Sets bitrate.
*
* @param bitrate bitrate in kb/s
*/
public void setBitrate(Long bitrate) {
this.bitrate = bitrate;
}
/**
* Returns sample rate.
*
* @return sample rate in hz
*/
public Long getSampleRate() {
return sampleRate;
}
/**
* Sets sample rate.
*
* @param sampleRate sample rate in hz
*/
public void setSampleRate(Long sampleRate) {
this.sampleRate = sampleRate;
}
/**
* Returns sample format.
*
* @return sample format
*/
public String getSampleFormat() {
return sampleFormat;
}
/**
* Sets sample format.
*
* @param sampleFormat sample format
*/
public void setSampleFormat(String sampleFormat) {
this.sampleFormat = sampleFormat;
}
/**
* Returns channel layout.
*
* @return channel layout
*/
public String getChannelLayout() {
return channelLayout;
}
/**
* Sets channel layout.
*
* @param channelLayout channel layout
*/
public void setChannelLayout(String channelLayout) {
this.channelLayout = channelLayout;
}
/**
* Returns sample aspect ratio.
*
* @return sample aspect ratio
*/
public String getSampleAspectRatio() {
return sampleAspectRatio;
}
/**
* Sets sample aspect ratio.
*
* @param sampleAspectRatio sample aspect ratio
*/
public void setSampleAspectRatio(String sampleAspectRatio) {
this.sampleAspectRatio = sampleAspectRatio;
}
/**
* Returns display aspect ratio.
*
* @return display aspect ratio
*/
public String getDisplayAspectRatio() {
return displayAspectRatio;
}
/**
* Sets display aspect ratio.
*
* @param displayAspectRatio display aspect ratio
*/
public void setDisplayAspectRatio(String displayAspectRatio) {
this.displayAspectRatio = displayAspectRatio;
}
/**
* Returns display aspect ratio.
*
* @return average frame rate in fps
*/
public String getAverageFrameRate() {
return averageFrameRate;
}
/**
* Sets average frame rate.
*
* @param averageFrameRate average frame rate in fps
*/
public void setAverageFrameRate(String averageFrameRate) {
this.averageFrameRate = averageFrameRate;
}
/**
* Returns real frame rate.
*
* @return real frame rate in tbr
*/
public String getRealFrameRate() {
return realFrameRate;
}
/**
* Sets real frame rate.
*
* @param realFrameRate real frame rate in tbr
*/
public void setRealFrameRate(String realFrameRate) {
this.realFrameRate = realFrameRate;
}
/**
* Returns time base.
*
* @return time base in tbn
*/
public String getTimeBase() {
return timeBase;
}
/**
* Sets time base.
*
* @param timeBase time base in tbn
*/
public void setTimeBase(String timeBase) {
this.timeBase = timeBase;
}
/**
* Returns codec time base.
*
* @return codec time base in tbc
*/
public String getCodecTimeBase() {
return codecTimeBase;
}
/**
* Sets codec time base.
*
* @param codecTimeBase codec time base in tbc
*/
public void setCodecTimeBase(String codecTimeBase) {
this.codecTimeBase = codecTimeBase;
}
/**
* Adds metadata.
*
* @param key metadata key
* @param value metadata value
*/
public void addMetadata(String key, String value) {
this.metadata.put(key, value);
}
/**
* Returns all metadata entries.
*
* @return set of metadata entries
*/
public Set<Map.Entry<String, String>> getMetadataEntries() {
return this.metadata.entrySet();
}
}
@@ -1,47 +0,0 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg.util;
public class Pair<A, B> {
/**
* The first element of the pair.
*/
protected A first;
/**
* The second element of the pair.
*/
protected B second;
public Pair(final A first, final B second) {
this.first = first;
this.second = second;
}
public A getFirst() {
return first;
}
public B getSecond() {
return second;
}
}
@@ -1,57 +0,0 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg.util;
public class Trio<A, B, C> {
/**
* The first element of the trio.
*/
protected final A first;
/**
* The second element of the trio.
*/
protected final B second;
/**
* The third element of the trio.
*/
protected final C third;
public Trio(final A first, final B second, final C third) {
this.first = first;
this.second = second;
this.third = third;
}
public A getFirst() {
return first;
}
public B getSecond() {
return second;
}
public C getThird() {
return third;
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

@@ -1,187 +0,0 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg;
import junit.framework.Assert;
import org.junit.Test;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* <p>Tests for {@link Config} class.
*/
public class ConfigTest {
private static final String externalLibrariesCommandOutput = " configuration:\n" +
" --cross-prefix=i686-linux-android-\n" +
" --sysroot=/Users/taner/Library/Android/sdk/ndk-bundle/toolchains/mobile-ffmpeg-i686/sysroot\n" +
" --prefix=/Users/taner/Projects/mobile-ffmpeg/prebuilt/android-x86/ffmpeg\n" +
" --pkg-config=/usr/local/bin/pkg-config --extra-cflags='-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -Wno-unused-function -fstrict-aliasing -fPIC -DANDROID -D__ANDROID__ -D__ANDROID_API__=21 -O2 -I/Users/taner/Library/Android/sdk/ndk-bundle/toolchains/mobile-ffmpeg-i686/sysroot/usr/include -I/Users/taner/Library/Android/sdk/ndk-bundle/toolchains/mobile-ffmpeg-i686/sysroot/usr/local/include'\n" +
" --extra-cxxflags='-std=c++11 -fno-exceptions -fno-rtti'\n" +
" --extra-ldflags='-march=i686 -Wl,--gc-sections,--icf=safe -lc -lm -ldl -llog -lc++_shared -L/Users/taner/Library/Android/sdk/ndk-bundle/toolchains/mobile-ffmpeg-i686/i686-linux-android/lib -L/Users/taner/Library/Android/sdk/ndk-bundle/toolchains/mobile-ffmpeg-i686/sysroot/usr/lib -L/Users/taner/Library/Android/sdk/ndk-bundle/toolchains/mobile-ffmpeg-i686/lib -L/Users/taner/Library/Android/sdk/ndk-bundle/platforms/android-21/arch-x86/usr/lib'\n" +
" --enable-version3\n" +
" --arch=i686\n" +
" --cpu=i686\n" +
" --target-os=android\n" +
" --disable-neon\n" +
" --disable-asm\n" +
" --disable-inline-asm\n" +
" --enable-cross-compile\n" +
" --enable-pic\n" +
" --enable-jni\n" +
" --enable-libvorbis\n" +
" --enable-optimizations\n" +
" --enable-swscale\n" +
" --enable-shared\n" +
" --enable-v4l2-m2m\n" +
" --enable-small\n" +
" --disable-openssl\n" +
" --disable-xmm-clobber-test\n" +
" --disable-debug\n" +
" --disable-neon-clobber-test\n" +
" --disable-programs\n" +
" --disable-postproc\n" +
" --disable-doc\n" +
" --disable-htmlpages\n" +
" --disable-manpages\n" +
" --disable-podpages\n" +
" --disable-txtpages\n" +
" --disable-static\n" +
" --disable-sndio\n" +
" --disable-schannel\n" +
" --disable-securetransport\n" +
" --disable-xlib\n" +
" --disable-cuda\n" +
" --disable-cuvid\n" +
" --disable-nvenc\n" +
" --disable-vaapi\n" +
" --disable-vdpau\n" +
" --disable-videotoolbox\n" +
" --disable-audiotoolbox\n" +
" --disable-appkit\n" +
" --disable-alsa\n" +
" --disable-cuda\n" +
" --disable-cuvid\n" +
" --disable-nvenc\n" +
" --disable-vaapi\n" +
" --disable-vdpau\n" +
" --disable-zlib\n";
@Test
public void getExternalLibraries() {
final List<String> supportedExternalLibraries = new ArrayList<>();
supportedExternalLibraries.add("chromaprint");
supportedExternalLibraries.add("fontconfig");
supportedExternalLibraries.add("freetype");
supportedExternalLibraries.add("fribidi");
supportedExternalLibraries.add("gmp");
supportedExternalLibraries.add("gnutls");
supportedExternalLibraries.add("kvazaar");
supportedExternalLibraries.add("lame");
supportedExternalLibraries.add("libaom");
supportedExternalLibraries.add("libass");
supportedExternalLibraries.add("libiconv");
supportedExternalLibraries.add("libilbc");
supportedExternalLibraries.add("libtheora");
supportedExternalLibraries.add("libvidstab");
supportedExternalLibraries.add("libvorbis");
supportedExternalLibraries.add("libvpx");
supportedExternalLibraries.add("libwebp");
supportedExternalLibraries.add("libxml2");
supportedExternalLibraries.add("opencore-amr");
supportedExternalLibraries.add("opus");
supportedExternalLibraries.add("shine");
supportedExternalLibraries.add("sdl");
supportedExternalLibraries.add("snappy");
supportedExternalLibraries.add("soxr");
supportedExternalLibraries.add("speex");
supportedExternalLibraries.add("tesseract");
supportedExternalLibraries.add("twolame");
supportedExternalLibraries.add("wavpack");
supportedExternalLibraries.add("x264");
supportedExternalLibraries.add("x265");
supportedExternalLibraries.add("xvidcore");
supportedExternalLibraries.add("android-zlib");
supportedExternalLibraries.add("android-media-codec");
final List<String> enabledList = new ArrayList<>();
for (String supportedExternalLibrary : supportedExternalLibraries) {
if (externalLibrariesCommandOutput.contains("enable-" + supportedExternalLibrary) ||
externalLibrariesCommandOutput.contains("enable-lib" + supportedExternalLibrary)) {
enabledList.add(supportedExternalLibrary);
}
}
Collections.sort(enabledList);
Assert.assertNotNull(enabledList);
Assert.assertTrue(enabledList.size() == 1);
}
@Test
public void getPackageName() {
Assert.assertEquals("min", listToPackageName(Collections.singletonList("")));
Assert.assertEquals("min-gpl", listToPackageName(Collections.singletonList("xvidcore")));
Assert.assertEquals("full-gpl", listToPackageName(Arrays.asList("gnutls", "speex", "fribidi", "xvidcore")));
Assert.assertEquals("full", listToPackageName(Arrays.asList("fribidi", "speex")));
Assert.assertEquals("video", listToPackageName(Collections.singletonList("fribidi")));
Assert.assertEquals("audio", listToPackageName(Collections.singletonList("speex")));
Assert.assertEquals("https", listToPackageName(Collections.singletonList("gnutls")));
Assert.assertEquals("https-gpl", listToPackageName(Arrays.asList("gnutls", "xvidcore")));
}
private String listToPackageName(final List<String> externalLibraryList) {
boolean speex = externalLibraryList.contains("speex");
boolean fribidi = externalLibraryList.contains("fribidi");
boolean gnutls = externalLibraryList.contains("gnutls");
boolean xvidcore = externalLibraryList.contains("xvidcore");
if (speex && fribidi) {
if (xvidcore) {
return "full-gpl";
} else {
return "full";
}
} else if (speex) {
return "audio";
} else if (fribidi) {
return "video";
} else if (xvidcore) {
if (gnutls) {
return "https-gpl";
} else {
return "min-gpl";
}
} else {
if (gnutls) {
return "https";
} else {
return "min";
}
}
}
}
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() throws Exception {
assertEquals(4, 2 + 2);
}
}
@@ -1,458 +0,0 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg;
import org.junit.Assert;
import org.junit.Test;
/**
* <p>Tests for {@link FFmpeg} class.
*/
public class FFmpegTest {
private static final String MEDIA_INFORMATION_MP3 =
"Unknown attached picture mimetype: audio/x-wav, skipping.\n" +
"[mp3 @ 0x7ffb94805800] Estimating duration from bitrate, this may be inaccurate\n" +
"Input #0, mp3, from 'beethoven_-_symphony_no_9.mp3':\n" +
" Metadata:\n" +
" comment : \n" +
" album : Symphony No.9\n" +
" compilation : 0\n" +
" date : -1\n" +
" title : Symphony No.9\n" +
" artist : Beethoven\n" +
" album_artist : Beethoven\n" +
" track : -1\n" +
" lyrics-XXX : \n" +
" Duration: 00:03:33.24, start: 0.000000, bitrate: 320 kb/s\n" +
" Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 320 kb/s\n" +
"Stream mapping:\n" +
" Stream #0:0 -> #0:0 (mp3 (mp3float) -> pcm_s16le (native))\n" +
"Press [q] to stop, [?] for help\n" +
"Output #0, null, to 'pipe:':\n" +
" Metadata:\n" +
" comment : \n" +
" album : Symphony No.9\n" +
" compilation : 0\n" +
" date : -1\n" +
" title : Symphony No.9\n" +
" artist : Beethoven\n" +
" album_artist : Beethoven\n" +
" track : -1\n" +
" lyrics-XXX : \n" +
" encoder : Lavf58.12.100\n" +
" Stream #0:0: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s\n" +
" Metadata:\n" +
" encoder : Lavc58.18.100 pcm_s16le\n" +
"size=N/A time=00:03:33.24 bitrate=N/A speed= 618x \n" +
"video:0kB audio:39982kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown";
private static final String MEDIA_INFORMATION_JPG =
"Input #0, image2, from '/data/user/0/com.arthenica.mobileffmpeg.test/cache/colosseum.jpg':\n" +
" Duration: 00:00:00.04, start: 0.000000, bitrate: 391187 kb/s\n" +
" Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 2560x1708 [SAR 1:1 DAR 640:427], 25 tbr, 25 tbn, 25 tbc\n" +
"Stream mapping:\n" +
" Stream #0:0 -> #0:0 (mjpeg (native) -> wrapped_avframe (native))\n" +
"Press [q] to stop, [?] for help\n" +
"Output #0, null, to 'pipe:':\n" +
" Metadata:\n" +
" encoder : Lavf58.18.104\n" +
" Stream #0:0: Video: wrapped_avframe, yuvj420p, 2560x1708 [SAR 1:1 DAR 640:427], q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc\n" +
" Metadata:\n" +
" encoder : Lavc58.31.102 wrapped_avframe\n" +
"frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=0.668x \n" +
"video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown\n";
private static final String MEDIA_INFORMATION_GIF =
"Input #0, gif, from 'advanced_zoom_in_and_pan_with_fade_in_out.gif':\n" +
" Duration: N/A, bitrate: N/A\n" +
" Stream #0:0: Video: gif, bgra, 420x236, 6 fps, 6 tbr, 100 tbn, 100 tbc\n" +
"Stream mapping:\n" +
" Stream #0:0 -> #0:0 (gif (native) -> wrapped_avframe (native))\n" +
"Press [q] to stop, [?] for help\n" +
"Output #0, null, to 'pipe:':\n" +
" Metadata:\n" +
" encoder : Lavf58.12.100\n" +
" Stream #0:0: Video: wrapped_avframe, bgra, 420x236 [SAR 63:64 DAR 6615:3776], q=2-31, 200 kb/s, 6 fps, 6 tbn, 6 tbc\n" +
" Metadata:\n" +
" encoder : Lavc58.18.100 wrapped_avframe\n" +
"frame= 61 fps=0.0 q=-0.0 Lsize=N/A time=00:00:10.16 bitrate=N/A speed= 219x \n" +
"video:32kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown";
private static final String MEDIA_INFORMATION_H264 =
"Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'transition_rotate.mp4':\n" +
" Metadata:\n" +
" major_brand : isom\n" +
" minor_version : 512\n" +
" compatible_brands: isomiso2avc1mp41\n" +
" encoder : Lavf58.12.100\n" +
" Duration: 00:00:15.00, start: 0.000000, bitrate: 7764 kb/s\n" +
" Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 7762 kb/s, 25 fps, 30 tbr, 15360 tbn, 60 tbc (default)\n" +
" Metadata:\n" +
" handler_name : VideoHandler\n" +
"Stream mapping:\n" +
" Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))\n" +
"Press [q] to stop, [?] for help\n" +
"Output #0, null, to 'pipe:':\n" +
" Metadata:\n" +
" major_brand : isom\n" +
" minor_version : 512\n" +
" compatible_brands: isomiso2avc1mp41\n" +
" encoder : Lavf58.12.100\n" +
" Stream #0:0(und): Video: wrapped_avframe, yuv420p, 1280x720 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)\n" +
" Metadata:\n" +
" handler_name : VideoHandler\n" +
" encoder : Lavc58.18.100 wrapped_avframe\n" +
"frame= 375 fps=0.0 q=-0.0 Lsize=N/A time=00:00:15.00 bitrate=N/A speed=35.9x \n" +
"video:196kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown";
private static final String MEDIA_INFORMATION_PNG =
"Input #0, png_pipe, from 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png':\n" +
" Duration: N/A, bitrate: N/A\n" +
" Stream #0:0: Video: png, rgba(pc), 544x184, 25 tbr, 25 tbn, 25 tbc\n" +
"Stream mapping:\n" +
" Stream #0:0 -> #0:0 (png (native) -> wrapped_avframe (native))\n" +
"Press [q] to stop, [?] for help\n" +
"Output #0, null, to 'pipe:':\n" +
" Metadata:\n" +
" encoder : Lavf58.12.100\n" +
" Stream #0:0: Video: wrapped_avframe, rgba, 544x184, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc\n" +
" Metadata:\n" +
" encoder : Lavc58.18.100 wrapped_avframe\n" +
"frame= 1 fps=0.0 q=-0.0 Lsize=N/A time=00:00:00.04 bitrate=N/A speed=27.1x \n" +
"video:1kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown";
private static final String MEDIA_INFORMATION_H264_2 =
"Input #0, h264, from 'test.h264':\n" +
" Duration: N/A, bitrate: N/A\n" +
" Stream #0:0: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1920x1080, 25 fps, 25 tbr, 1200k tbn, 50 tbc\n" +
"Stream mapping:\n" +
" Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))\n" +
"Press [q] to stop, [?] for help\n" +
"Output #0, null, to 'pipe:':\n" +
" Metadata:\n" +
" encoder : Lavf58.12.100\n" +
" Stream #0:0: Video: wrapped_avframe, yuv420p, 1920x1080, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc\n" +
" Metadata:\n" +
" encoder : Lavc58.18.100 wrapped_avframe\n" +
"frame= 360 fps=0.0 q=-0.0 Lsize=N/A time=00:00:14.40 bitrate=N/A speed=25.5x \n" +
"video:188kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown";
private static final String MEDIA_INFORMATION_MP4 =
"Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_2160p_30fps_stereo_abl.mp4':\n" +
" Metadata:\n" +
" major_brand : isom\n" +
" minor_version : 1\n" +
" compatible_brands: isomavc1\n" +
" creation_time : 2013-12-16T17:21:55.000000Z\n" +
" title : Big Buck Bunny, Sunflower version\n" +
" artist : Blender Foundation 2008, Janus Bager Kristensen 2013\n" +
" comment : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net\n" +
" genre : Animation\n" +
" composer : Sacha Goedegebure\n" +
" Duration: 00:10:34.53, start: 0.000000, bitrate: 10385 kb/s\n" +
" Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 3840x4320 [SAR 1:1 DAR 8:9], 9902 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)\n" +
" Metadata:\n" +
" creation_time : 2013-12-16T17:21:55.000000Z\n" +
" handler_name : GPAC ISO Video Handler\n" +
" Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)\n" +
" Metadata:\n" +
" creation_time : 2013-12-16T17:21:58.000000Z\n" +
" handler_name : GPAC ISO Audio Handler\n" +
" Stream #0:2(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 320 kb/s (default)\n" +
" Metadata:\n" +
" creation_time : 2013-12-16T17:21:58.000000Z\n" +
" handler_name : GPAC ISO Audio Handler\n" +
" Side data:\n" +
" audio service type: main\n" +
"Stream mapping:\n" +
" Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))\n" +
" Stream #0:2 -> #0:1 (ac3 (native) -> pcm_s16le (native))\n" +
"Press [q] to stop, [?] for help\n" +
"Output #0, null, to 'pipe:':\n" +
" Metadata:\n" +
" major_brand : isom\n" +
" minor_version : 1\n" +
" compatible_brands: isomavc1\n" +
" composer : Sacha Goedegebure\n" +
" title : Big Buck Bunny, Sunflower version\n" +
" artist : Blender Foundation 2008, Janus Bager Kristensen 2013\n" +
" comment : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net\n" +
" genre : Animation\n" +
" encoder : Lavf58.12.100\n" +
" Stream #0:0(und): Video: wrapped_avframe, yuv420p(progressive), 3840x4320 [SAR 1:1 DAR 8:9], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)\n" +
" Metadata:\n" +
" creation_time : 2013-12-16T17:21:55.000000Z\n" +
" handler_name : GPAC ISO Video Handler\n" +
" encoder : Lavc58.18.100 wrapped_avframe\n" +
" Stream #0:1(und): Audio: pcm_s16le, 48000 Hz, 5.1(side), s16, 4608 kb/s (default)\n" +
" Metadata:\n" +
" creation_time : 2013-12-16T17:21:58.000000Z\n" +
" handler_name : GPAC ISO Audio Handler\n" +
" encoder : Lavc58.18.100 pcm_s16le\n" +
" Side data:\n" +
" audio service type: main\n" +
"frame= 2798 fps= 85 q=-0.0 size=N/A time=00:01:33.33 bitrate=N/A speed=2.85x \n";
private static final String MEDIA_INFORMATION_MP4_2 =
"Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_stereo_arcd.mp4':\n" +
" Metadata:\n" +
" major_brand : isom\n" +
" minor_version : 1\n" +
" compatible_brands: isomavc1\n" +
" creation_time : 2013-12-16T17:49:59.000000Z\n" +
" title : Big Buck Bunny, Sunflower version\n" +
" artist : Blender Foundation 2008, Janus Bager Kristensen 2013\n" +
" comment : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net\n" +
" genre : Animation\n" +
" composer : Sacha Goedegebure\n" +
" Duration: 00:10:34.53, start: 0.000000, bitrate: 4474 kb/s\n" +
" Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 3992 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)\n" +
" Metadata:\n" +
" creation_time : 2013-12-16T17:49:59.000000Z\n" +
" handler_name : GPAC ISO Video Handler\n" +
" Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)\n" +
" Metadata:\n" +
" creation_time : 2013-12-16T17:50:04.000000Z\n" +
" handler_name : GPAC ISO Audio Handler\n" +
" Stream #0:2(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 320 kb/s (default)\n" +
" Metadata:\n" +
" creation_time : 2013-12-16T17:50:04.000000Z\n" +
" handler_name : GPAC ISO Audio Handler\n" +
" Side data:\n" +
" audio service type: main\n" +
"Stream mapping:\n" +
" Stream #0:0 -> #0:0 (h264 (native) -> wrapped_avframe (native))\n" +
" Stream #0:2 -> #0:1 (ac3 (native) -> pcm_s16le (native))\n" +
"Press [q] to stop, [?] for help\n" +
"Output #0, null, to 'pipe:':\n" +
" Metadata:\n" +
" major_brand : isom\n" +
" minor_version : 1\n" +
" compatible_brands: isomavc1\n" +
" composer : Sacha Goedegebure\n" +
" title : Big Buck Bunny, Sunflower version\n" +
" artist : Blender Foundation 2008, Janus Bager Kristensen 2013\n" +
" comment : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net\n" +
" genre : Animation\n" +
" encoder : Lavf58.12.100\n" +
" Stream #0:0(und): Video: wrapped_avframe, yuv420p(progressive), 1920x1080 [SAR 1:1 DAR 16:9], q=2-31, 200 kb/s, 30 fps, 30 tbn, 30 tbc (default)\n" +
" Metadata:\n" +
" creation_time : 2013-12-16T17:49:59.000000Z\n" +
" handler_name : GPAC ISO Video Handler\n" +
" encoder : Lavc58.18.100 wrapped_avframe\n" +
" Stream #0:1(und): Audio: pcm_s16le, 48000 Hz, 5.1(side), s16, 4608 kb/s (default)\n" +
" Metadata:\n" +
" creation_time : 2013-12-16T17:50:04.000000Z\n" +
" handler_name : GPAC ISO Audio Handler\n" +
" encoder : Lavc58.18.100 pcm_s16le\n" +
" Side data:\n" +
" audio service type: main\n" +
"frame=19036 fps=401 q=-0.0 Lsize=N/A time=00:10:34.60 bitrate=N/A speed=13.4x \n" +
"video:9964kB audio:356706kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown";
private static final String MEDIA_INFORMATION_OGG =
"[theora @ 0x7fa30c026e00] 7 bits left in packet 82\n" +
"[ogg @ 0x7fa30c005e00] Broken file, keyframe not correctly marked.\n" +
"Input #0, ogg, from 'trailer_400p.ogg':\n" +
" Duration: 00:00:33.00, start: 0.000000, bitrate: 1057 kb/s\n" +
" Stream #0:0: Video: theora, yuv420p(bt470bg/bt470bg/bt709), 720x400, 25 fps, 25 tbr, 25 tbn, 25 tbc\n" +
" Metadata:\n" +
" ENCODER : ffmpeg2theora 0.19\n" +
" Stream #0:1: Audio: vorbis, 48000 Hz, stereo, fltp, 80 kb/s\n" +
" Metadata:\n" +
" ENCODER : ffmpeg2theora 0.19\n" +
"[theora @ 0x7fa30c1bd600] 7 bits left in packet 82\n" +
"Stream mapping:\n" +
" Stream #0:0 -> #0:0 (theora (native) -> wrapped_avframe (native))\n" +
" Stream #0:1 -> #0:1 (vorbis (native) -> pcm_s16le (native))\n" +
"Press [q] to stop, [?] for help\n" +
"Output #0, null, to 'pipe:':\n" +
" Metadata:\n" +
" encoder : Lavf58.12.100\n" +
" Stream #0:0: Video: wrapped_avframe, yuv420p(progressive), 720x400, q=2-31, 200 kb/s, 25 fps, 25 tbn, 25 tbc\n" +
" Metadata:\n" +
" encoder : Lavc58.18.100 wrapped_avframe\n" +
" Stream #0:1: Audio: pcm_s16le, 48000 Hz, stereo, s16, 1536 kb/s\n" +
" Metadata:\n" +
" encoder : Lavc58.18.100 pcm_s16le\n" +
"[ogg @ 0x7fa30c005e00] Broken file, keyframe not correctly marked.\n" +
" Last message repeated 5 times\n" +
"frame= 813 fps=0.0 q=-0.0 Lsize=N/A time=00:00:33.01 bitrate=N/A speed= 234x \n" +
"video:426kB audio:6190kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: unknown";
@Test
public void mediaInformationMp3() {
MediaInformation mediaInformation = MediaInformationParser.from(MEDIA_INFORMATION_MP3);
Assert.assertNotNull(mediaInformation);
assertMediaInput(mediaInformation, "mp3", "beethoven_-_symphony_no_9.mp3");
assertMediaDuration(mediaInformation, 213240L, 0L, 320L);
Assert.assertNotNull(mediaInformation.getStreams());
Assert.assertEquals(1, mediaInformation.getStreams().size());
assertAudioStream(mediaInformation.getStreams().get(0), 0L, "mp3", "mp3", 48000L, "stereo", "fltp", 320L);
}
@Test
public void mediaInformationJpg() {
MediaInformation mediaInformation = MediaInformationParser.from(MEDIA_INFORMATION_JPG);
Assert.assertNotNull(mediaInformation);
assertMediaInput(mediaInformation, "image2", "/data/user/0/com.arthenica.mobileffmpeg.test/cache/colosseum.jpg");
assertMediaDuration(mediaInformation, 40L, 0L, 391187L);
Assert.assertNotNull(mediaInformation.getStreams());
Assert.assertEquals(1, mediaInformation.getStreams().size());
assertVideoStream(mediaInformation.getStreams().get(0), 0L, "mjpeg", "mjpeg", "yuvj420p", "yuvj420p(pc, bt470bg/unknown/unknown)", 2560L, 1708L, "1:1", "640:427", null, null, "25", "25", "25");
}
@Test
public void mediaInformationGif() {
MediaInformation mediaInformation = MediaInformationParser.from(MEDIA_INFORMATION_GIF);
Assert.assertNotNull(mediaInformation);
assertMediaInput(mediaInformation, "gif", "advanced_zoom_in_and_pan_with_fade_in_out.gif");
assertMediaDuration(mediaInformation, null, null, null);
Assert.assertNotNull(mediaInformation.getStreams());
Assert.assertEquals(1, mediaInformation.getStreams().size());
assertVideoStream(mediaInformation.getStreams().get(0), 0L, "gif", "gif", "bgra", "bgra", 420L, 236L, null, null, null, "6", "6", "100", "100");
}
@Test
public void mediaInformationH264() {
MediaInformation mediaInformation = MediaInformationParser.from(MEDIA_INFORMATION_H264);
Assert.assertNotNull(mediaInformation);
assertMediaInput(mediaInformation, "mov,mp4,m4a,3gp,3g2,mj2", "transition_rotate.mp4");
assertMediaDuration(mediaInformation, 15000L, 0L, 7764L);
Assert.assertNotNull(mediaInformation.getStreams());
Assert.assertEquals(1, mediaInformation.getStreams().size());
assertVideoStream(mediaInformation.getStreams().get(0), 0L, "h264", "h264 (main) (avc1 / 0x31637661)", "yuv420p", "yuv420p", 1280L, 720L, "1:1", "16:9", 7762L, "25", "30", "15360", "60");
}
@Test
public void mediaInformationPng() {
MediaInformation mediaInformation = MediaInformationParser.from(MEDIA_INFORMATION_PNG);
Assert.assertNotNull(mediaInformation);
assertMediaInput(mediaInformation, "png_pipe", "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png");
assertMediaDuration(mediaInformation, null, null, null);
Assert.assertNotNull(mediaInformation.getStreams());
Assert.assertEquals(1, mediaInformation.getStreams().size());
assertVideoStream(mediaInformation.getStreams().get(0), 0L, "png", "png", "rgba", "rgba(pc)", 544L, 184L, null, null, null, null, "25", "25", "25");
}
@Test
public void mediaInformationH2642() {
MediaInformation mediaInformation = MediaInformationParser.from(MEDIA_INFORMATION_H264_2);
Assert.assertNotNull(mediaInformation);
assertMediaInput(mediaInformation, "h264", "test.h264");
assertMediaDuration(mediaInformation, null, null, null);
Assert.assertNotNull(mediaInformation.getStreams());
Assert.assertEquals(1, mediaInformation.getStreams().size());
assertVideoStream(mediaInformation.getStreams().get(0), 0L, "h264", "h264 (main)", "yuv420p", "yuv420p(tv, bt709, progressive)", 1920L, 1080L, null, null, null, "25", "25", "1200k", "50");
}
@Test
public void mediaInformationMp4() {
MediaInformation mediaInformation = MediaInformationParser.from(MEDIA_INFORMATION_MP4);
Assert.assertNotNull(mediaInformation);
assertMediaInput(mediaInformation, "mov,mp4,m4a,3gp,3g2,mj2", "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_2160p_30fps_stereo_abl.mp4");
assertMediaDuration(mediaInformation, 634530L, 0L, 10385L);
Assert.assertNotNull(mediaInformation.getStreams());
Assert.assertEquals(3, mediaInformation.getStreams().size());
assertVideoStream(mediaInformation.getStreams().get(0), 0L, "h264", "h264 (high) (avc1 / 0x31637661)", "yuv420p", "yuv420p", 3840L, 4320L, "1:1", "8:9", 9902L, "30", "30", "30k", "60");
assertAudioStream(mediaInformation.getStreams().get(1), 1L, "mp3", "mp3 (mp4a / 0x6134706d)", 48000L, "stereo", "fltp", 160L);
assertAudioStream(mediaInformation.getStreams().get(2), 2L, "ac3", "ac3 (ac-3 / 0x332d6361)", 48000L, "5.1(side)", "fltp", 320L);
}
@Test
public void mediaInformationMp42() {
MediaInformation mediaInformation = MediaInformationParser.from(MEDIA_INFORMATION_MP4_2);
Assert.assertNotNull(mediaInformation);
assertMediaInput(mediaInformation, "mov,mp4,m4a,3gp,3g2,mj2", "http://distribution.bbb3d.renderfarming.net/video/mp4/bbb_sunflower_1080p_30fps_stereo_arcd.mp4");
assertMediaDuration(mediaInformation, 634530L, 0L, 4474L);
Assert.assertNotNull(mediaInformation.getStreams());
Assert.assertEquals(3, mediaInformation.getStreams().size());
assertVideoStream(mediaInformation.getStreams().get(0), 0L, "h264", "h264 (high) (avc1 / 0x31637661)", "yuv420p", "yuv420p", 1920L, 1080L, "1:1", "16:9", 3992L, "30", "30", "30k", "60");
assertAudioStream(mediaInformation.getStreams().get(1), 1L, "mp3", "mp3 (mp4a / 0x6134706d)", 48000L, "stereo", "fltp", 160L);
assertAudioStream(mediaInformation.getStreams().get(2), 2L, "ac3", "ac3 (ac-3 / 0x332d6361)", 48000L, "5.1(side)", "fltp", 320L);
}
@Test
public void mediaInformationOgg() {
MediaInformation mediaInformation = MediaInformationParser.from(MEDIA_INFORMATION_OGG);
Assert.assertNotNull(mediaInformation);
assertMediaInput(mediaInformation, "ogg", "trailer_400p.ogg");
assertMediaDuration(mediaInformation, 33000L, 0L, 1057L);
Assert.assertNotNull(mediaInformation.getStreams());
Assert.assertEquals(2, mediaInformation.getStreams().size());
assertVideoStream(mediaInformation.getStreams().get(0), 0L, "theora", "theora", "yuv420p", "yuv420p(bt470bg/bt470bg/bt709)", 720L, 400L, null, null, null, "25", "25", "25", "25");
assertAudioStream(mediaInformation.getStreams().get(1), 1L, "vorbis", "vorbis", 48000L, "stereo", "fltp", 80L);
}
private void assertMediaInput(MediaInformation mediaInformation, String format, String path) {
Assert.assertEquals(format, mediaInformation.getFormat());
Assert.assertEquals(path, mediaInformation.getPath());
}
private void assertMediaDuration(MediaInformation mediaInformation, Long duration, Long startTime, Long bitrate) {
Assert.assertEquals(duration, mediaInformation.getDuration());
Assert.assertEquals(startTime, mediaInformation.getStartTime());
Assert.assertEquals(bitrate, mediaInformation.getBitrate());
}
private void assertAudioStream(StreamInformation streamInformation, Long index, String codec, String fullCodec, Long sampleRate, String channelLayout, String sampleFormat, Long bitrate) {
Assert.assertEquals(index, streamInformation.getIndex());
Assert.assertEquals("audio", streamInformation.getType());
Assert.assertEquals(codec, streamInformation.getCodec());
Assert.assertEquals(fullCodec, streamInformation.getFullCodec());
Assert.assertEquals(sampleRate, streamInformation.getSampleRate());
Assert.assertEquals(channelLayout, streamInformation.getChannelLayout());
Assert.assertEquals(sampleFormat, streamInformation.getSampleFormat());
Assert.assertEquals(bitrate, streamInformation.getBitrate());
}
private void assertVideoStream(StreamInformation streamInformation, Long index, String codec, String fullCodec, String format, String fullFormat, Long width, Long height, String sar, String dar, Long bitrate, String averageFrameRate, String realFrameRate, String timeBase, String codecTimeBase) {
Assert.assertEquals(index, streamInformation.getIndex());
Assert.assertEquals("video", streamInformation.getType());
Assert.assertEquals(codec, streamInformation.getCodec());
Assert.assertEquals(fullCodec, streamInformation.getFullCodec());
Assert.assertEquals(format, streamInformation.getFormat());
Assert.assertEquals(fullFormat, streamInformation.getFullFormat());
Assert.assertEquals(width, streamInformation.getWidth());
Assert.assertEquals(height, streamInformation.getHeight());
Assert.assertEquals(sar, streamInformation.getSampleAspectRatio());
Assert.assertEquals(dar, streamInformation.getDisplayAspectRatio());
Assert.assertEquals(bitrate, streamInformation.getBitrate());
Assert.assertEquals(averageFrameRate, streamInformation.getAverageFrameRate());
Assert.assertEquals(realFrameRate, streamInformation.getRealFrameRate());
Assert.assertEquals(timeBase, streamInformation.getTimeBase());
Assert.assertEquals(codecTimeBase, streamInformation.getCodecTimeBase());
}
}
@@ -1,300 +0,0 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg;
import com.arthenica.mobileffmpeg.util.Pair;
import com.arthenica.mobileffmpeg.util.Trio;
import junit.framework.Assert;
import org.junit.Test;
public class MediaInformationTest {
@Test
public void parseVideoStream() {
parseVideoStreamBlock(" Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 2560x1708 [SAR 1:1 DAR 640:427], 25 tbr, 25 tbn, 25 tbc", 0L, "mjpeg", "mjpeg", "yuvj420p", "yuvj420p(pc, bt470bg/unknown/unknown)", 2560L, 1708L, "1:1", "640:427", null, null, "25", "25", "25");
parseVideoStreamBlock(" Stream #0:0: Video: gif, bgra, 420x236, 6 fps, 6 tbr, 100 tbn, 100 tbc", 0L, "gif",
"gif", "bgra", "bgra", 420L, 236L, null, null, null, "6", "6", "100", "100");
parseVideoStreamBlock(" Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 7762 kb/s, 25 fps, 30 tbr, 15360 tbn, 60 tbc (default)", 0L, "h264", "h264 (main) (avc1 / 0x31637661)", "yuv420p", "yuv420p", 1280L, 720L, "1:1", "16:9", 7762L, "25", "30", "15360", "60");
parseVideoStreamBlock(" Stream #0:0: Video: png, rgba(pc), 544x184, 25 tbr, 25 tbn, 25 tbc", 0L, "png", "png", "rgba", "rgba(pc)", 544L, 184L, null, null, null, null, "25", "25", "25");
parseVideoStreamBlock(" Stream #0:0: Video: h264 (Main), yuv420p(tv, bt709, progressive), 1920x1080, 25 fps, 25 tbr, 1200k tbn, 50 tbc", 0L, "h264", "h264 (main)", "yuv420p", "yuv420p(tv, bt709, progressive)", 1920L, 1080L, null, null, null, "25", "25", "1200k", "50");
parseVideoStreamBlock(" Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 3840x4320 [SAR 1:1 DAR 8:9], 9902 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)", 0L, "h264", "h264 (high) (avc1 / 0x31637661)", "yuv420p", "yuv420p", 3840L, 4320L, "1:1", "8:9", 9902L, "30", "30", "30k", "60");
parseVideoStreamBlock(" Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 3992 kb/s, 30 fps, 30 tbr, 30k tbn, 60 tbc (default)", 0L, "h264", "h264 (high) (avc1 / 0x31637661)", "yuv420p", "yuv420p", 1920L, 1080L, "1:1", "16:9", 3992L, "30", "30", "30k", "60");
parseVideoStreamBlock(" Stream #0:0: Video: theora, yuv420p(bt470bg/bt470bg/bt709), 720x400, 25 fps, 25 tbr, 25 tbn, 25 tbc", 0L, "theora", "theora", "yuv420p", "yuv420p(bt470bg/bt470bg/bt709)", 720L, 400L, null, null, null, "25", "25", "25", "25");
}
@Test
public void parseAudioStream() {
parseAudioStreamBlock("Stream #0:0: Audio: adpcm_ms ([2][0][0][0] / 0x0002), 22050 Hz, stereo, s16, 176 kb/s", 0L, "adpcm_ms", "adpcm_ms ([2][0][0][0] / 0x0002)", 22050L, "stereo", "s16", 176L);
parseAudioStreamBlock("Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz, mono, s16, 705 kb/s", 0L, "pcm_s16le", "pcm_s16le ([1][0][0][0] / 0x0001)", 44100L, "mono", "s16", 705L);
parseAudioStreamBlock("Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, mono, s32 (24 bit), 1152 kb/s", 0L, "pcm_s24le", "pcm_s24le ([1][0][0][0] / 0x0001)", 48000L, "mono", "s32 (24 bit)", 1152L);
parseAudioStreamBlock("Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 192 kb/s", 0L, "mp3", "mp3", 48000L, "stereo", "fltp", 192L);
parseAudioStreamBlock("Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 128 kb/s", 0L, "vorbis", "vorbis", 44100L, "stereo", "fltp", 128L);
parseAudioStreamBlock("Stream #0:0: Audio: pcm_u8 ([1][0][0][0] / 0x0001), 44100 Hz, stereo, u8, 705 kb/s", 0L, "pcm_u8", "pcm_u8 ([1][0][0][0] / 0x0001)", 44100L, "stereo", "u8", 705L);
parseAudioStreamBlock("Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)", 1L, "mp3", "mp3 (mp4a / 0x6134706d)", 48000L, "stereo", "fltp", 160L);
parseAudioStreamBlock("Stream #0:2(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 320 kb/s (default)", 2L, "ac3", "ac3 (ac-3 / 0x332d6361)", 48000L, "5.1(side)", "fltp", 320L);
parseAudioStreamBlock("Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 160 kb/s (default)", 1L, "mp3", "mp3 (mp4a / 0x6134706d)", 48000L, "stereo", "fltp", 160L);
parseAudioStreamBlock("Stream #0:2(und): Audio: ac3 (ac-3 / 0x332D6361), 48000 Hz, 5.1(side), fltp, 320 kb/s (default)", 2L, "ac3", "ac3 (ac-3 / 0x332d6361)", 48000L, "5.1(side)", "fltp", 320L);
}
@Test
public void index() {
Assert.assertEquals(7, MediaInformationParser.index("one:two:three:", ":", 0, 2));
Assert.assertEquals(13, MediaInformationParser.index("one:two:three:", ":", 0, 3));
Assert.assertEquals(8, MediaInformationParser.index("one::two::three::", "::", 0, 2));
}
@Test
public void count() {
Assert.assertEquals(3, MediaInformationParser.count("one:two:three:", ":"));
Assert.assertEquals(2, MediaInformationParser.count("one,two:three,four", ","));
}
@Test
public void parseAverageFrameRate() {
Assert.assertEquals("24", "24 fps".replaceAll("fps", "").trim());
Assert.assertEquals("30", "30 fps".replaceAll("fps", "").trim());
}
@Test
public void parseBitrate() {
Assert.assertEquals((Long) 3992L, MediaInformationParser.toLongObject("3992 kb/s".replaceAll("kb/s", "").trim()));
Assert.assertEquals((Long) 7762L, MediaInformationParser.toLongObject("7762 kb/s".replaceAll("kb/s", "").trim()));
}
@Test
public void parseVideoStreamDisplayAspectRatio() {
Assert.assertEquals(null, MediaInformationParser.parseVideoStreamDisplayAspectRatio(""));
Assert.assertEquals(null, MediaInformationParser.parseVideoStreamDisplayAspectRatio("544x184"));
Assert.assertEquals("640:427", MediaInformationParser.parseVideoStreamDisplayAspectRatio("2560x1708 [SAR 1:1 DAR 640:427]"));
Assert.assertEquals("8:9", MediaInformationParser.parseVideoStreamDisplayAspectRatio("3840x4320 [SAR 1:1 DAR 8:9]"));
}
@Test
public void parseVideoStreamSampleAspectRatio() {
Assert.assertEquals(null, MediaInformationParser.parseVideoStreamSampleAspectRatio(""));
Assert.assertEquals(null, MediaInformationParser.parseVideoStreamSampleAspectRatio("544x184"));
Assert.assertEquals("1:1", MediaInformationParser.parseVideoStreamSampleAspectRatio("2560x1708 [SAR 1:1 DAR 640:427]"));
Assert.assertEquals("1:1", MediaInformationParser.parseVideoStreamSampleAspectRatio("3840x4320 [SAR 1:1 DAR 8:9]"));
}
@Test
public void parseVideoDimensions() {
parseVideoDimensions("", null, null);
parseVideoDimensions("544x184", 544L, 184L);
parseVideoDimensions("720x400", 720L, 400L);
parseVideoDimensions("2560x1708 [SAR 1:1 DAR 640:427]", 2560L, 1708L);
parseVideoDimensions("3840x4320 [SAR 1:1 DAR 8:9]", 3840L, 4320L);
}
@Test
public void parseAudioSampleRate() {
Assert.assertEquals((Long) 44000L, MediaInformationParser.parseAudioStreamSampleRate("44000"));
Assert.assertEquals((Long) 44000L, MediaInformationParser.parseAudioStreamSampleRate("44 khz"));
Assert.assertEquals((Long) 44100L, MediaInformationParser.parseAudioStreamSampleRate("44100"));
Assert.assertEquals((Long) 5000000L, MediaInformationParser.parseAudioStreamSampleRate("5 mhz"));
}
@Test
public void parseAudioStreamType() {
Assert.assertEquals("video", MediaInformationParser.parseStreamType("Video: theora"));
Assert.assertEquals("video", MediaInformationParser.parseStreamType("Video: png"));
Assert.assertEquals("video", MediaInformationParser.parseStreamType("Video: h264 (Main)"));
Assert.assertEquals("audio", MediaInformationParser.parseStreamType("Audio: adpcm_ms ([2][0][0][0] / 0x0002)"));
Assert.assertEquals("audio", MediaInformationParser.parseStreamType("Audio: mp3 (mp4a / 0x6134706D)"));
Assert.assertEquals("audio", MediaInformationParser.parseStreamType("Audio: pcm_u8 ([1][0][0][0] / 0x0001)"));
}
@Test
public void parseStreamCodec() {
Assert.assertEquals("theora", MediaInformationParser.parseStreamCodec("Video: theora"));
Assert.assertEquals("png", MediaInformationParser.parseStreamCodec("Video: png"));
Assert.assertEquals("h264", MediaInformationParser.parseStreamCodec("Video: h264 (Main)"));
Assert.assertEquals("adpcm_ms", MediaInformationParser.parseStreamCodec("Audio: adpcm_ms ([2][0][0][0] / 0x0002)"));
Assert.assertEquals("mp3", MediaInformationParser.parseStreamCodec("Audio: mp3 (mp4a / 0x6134706D)"));
Assert.assertEquals("pcm_u8", MediaInformationParser.parseStreamCodec("Audio: pcm_u8 ([1][0][0][0] / 0x0001)"));
}
@Test
public void parseStreamFullCodec() {
Assert.assertEquals("theora", MediaInformationParser.parseStreamFullCodec("Video: theora"));
Assert.assertEquals("png", MediaInformationParser.parseStreamFullCodec("Video: png"));
Assert.assertEquals("h264 (main)", MediaInformationParser.parseStreamFullCodec("Video: h264 (Main)"));
Assert.assertEquals("adpcm_ms ([2][0][0][0] / 0x0002)", MediaInformationParser.parseStreamFullCodec("Audio: adpcm_ms ([2][0][0][0] / 0x0002)"));
Assert.assertEquals("mp3 (mp4a / 0x6134706d)", MediaInformationParser.parseStreamFullCodec("Audio: mp3 (mp4a / 0x6134706D)"));
Assert.assertEquals("pcm_u8 ([1][0][0][0] / 0x0001)", MediaInformationParser.parseStreamFullCodec("Audio: pcm_u8 ([1][0][0][0] / 0x0001)"));
}
@Test
public void parseStreamIndex() {
Assert.assertEquals((Long) 0L, MediaInformationParser.parseStreamIndex("Stream #0:0(und): Audio"));
Assert.assertEquals((Long) 1L, MediaInformationParser.parseStreamIndex("Stream #0:1(und): Video"));
Assert.assertEquals((Long) 2L, MediaInformationParser.parseStreamIndex("Stream #0:2(und): Audio"));
Assert.assertEquals((Long) 0L, MediaInformationParser.parseStreamIndex("Stream #0:0: Video"));
Assert.assertEquals((Long) 1L, MediaInformationParser.parseStreamIndex("Stream #0:1: Audio"));
Assert.assertEquals((Long) 2L, MediaInformationParser.parseStreamIndex("Stream #0:2: Video"));
}
@Test
public void parseDuration() {
parseDuration(null, null);
parseDuration("", null);
parseDuration("N/A", null);
parseDuration("00:03:33.24", 213240L);
parseDuration("00:10:34.53", 634530L);
parseDuration("00:00:00.04", 40L);
parseDuration("00:00:15.00", 15000L);
}
@Test
public void parseStartTime() {
parseStartTime(null, null);
parseStartTime("", null);
parseStartTime("N/A", null);
parseStartTime("0.000000", 0L);
parseStartTime("10.003000", 10003L);
parseStartTime("324.000000", 324000L);
parseStartTime("-4.000000", -4000L);
parseStartTime("14.00030", 14001L);
parseStartTime("14.00080", 14001L);
}
@Test
public void parseDurationBlock() {
parseDurationBlock(" Duration: 00:03:33.24, start: 0.000000, bitrate: 320 kb/s", 213240L, 0L, 320L);
parseDurationBlock(" Duration: 00:00:00.04, start: 0.000000, bitrate: 391187 kb/s", 40L, 0L, 391187L);
parseDurationBlock(" Duration: N/A, bitrate: N/A", null, null, null);
parseDurationBlock(" Duration: 00:00:15.00, start: 0.000000, bitrate: 7764 kb/s", 15000L, 0L, 7764L);
parseDurationBlock(" Duration: 00:10:34.53, start: 0.000000, bitrate: 4474 kb/s", 634530L, 0L, 4474L);
}
@Test
public void parseInputBlock() {
parseInputBlock("Input #0,", null, null);
parseInputBlock("Input #0, ogg, from 'trailer_400p.ogg':", "ogg", "trailer_400p.ogg");
parseInputBlock("Input #0, mp3, from 'beethoven_-_symphony_no_9.mp3':", "mp3", "beethoven_-_symphony_no_9.mp3");
parseInputBlock("Input #0, image2, from '/data/user/0/com.arthenica.mobileffmpeg.test/cache/colosseum.jpg':", "image2", "/data/user/0/com.arthenica.mobileffmpeg.test/cache/colosseum.jpg");
parseInputBlock("Input #0, gif, from 'advanced_zoom_in_and_pan_with_fade_in_out.gif':", "gif", "advanced_zoom_in_and_pan_with_fade_in_out.gif");
parseInputBlock("Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'transition_rotate.mp4':", "mov,mp4,m4a,3gp,3g2,mj2", "transition_rotate.mp4");
parseInputBlock("Input #0, png_pipe, from 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png':", "png_pipe", "https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png");
}
@Test
public void parseMetadataBlock() {
parseMetadataBlock(" ENCODER:", "ENCODER", "");
parseMetadataBlock(" ENCODER:ffmpeg2theora 0.19", "ENCODER", "ffmpeg2theora 0.19");
parseMetadataBlock(" ENCODER : ffmpeg2theora 0.19", "ENCODER", "ffmpeg2theora 0.19");
parseMetadataBlock(" creation_time : 2013-12-16T17:50:04.000000Z", "creation_time", "2013-12-16T17:50:04.000000Z");
parseMetadataBlock(" handler_name : GPAC ISO Audio Handler", "handler_name", "GPAC ISO Audio Handler");
parseMetadataBlock(" comment : Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net", "comment", "Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net");
parseMetadataBlock(" minor_version : 1", "minor_version", "1");
parseMetadataBlock(" encoder : Lavf58.12.100", "encoder", "Lavf58.12.100");
parseMetadataBlock(" title : Planet X", "title", "Planet X");
parseMetadataBlock(" compatible_brands: isomiso2avc1mp41", "compatible_brands", "isomiso2avc1mp41");
}
private void parseVideoStreamBlock(String input, Long index, String codec, String fullCodec, String format, String fullFormat, Long width, Long height, String sampleAspectRatio, String displayAspectRatio, Long bitrate, String averageFrameRate, String realFrameRate, String timeBase, String codecTimeBase) {
StreamInformation stream = MediaInformationParser.parseStreamBlock(input);
Assert.assertNotNull(stream);
Assert.assertEquals(index, stream.getIndex());
Assert.assertEquals("video", stream.getType());
Assert.assertEquals(codec, stream.getCodec());
Assert.assertEquals(fullCodec, stream.getFullCodec());
Assert.assertEquals(format, stream.getFormat());
Assert.assertEquals(fullFormat, stream.getFullFormat());
Assert.assertEquals(width, stream.getWidth());
Assert.assertEquals(height, stream.getHeight());
Assert.assertEquals(sampleAspectRatio, stream.getSampleAspectRatio());
Assert.assertEquals(displayAspectRatio, stream.getDisplayAspectRatio());
Assert.assertEquals(bitrate, stream.getBitrate());
Assert.assertEquals(averageFrameRate, stream.getAverageFrameRate());
Assert.assertEquals(realFrameRate, stream.getRealFrameRate());
Assert.assertEquals(timeBase, stream.getTimeBase());
Assert.assertEquals(codecTimeBase, stream.getCodecTimeBase());
}
private void parseAudioStreamBlock(String input, Long index, String codec, String fullCodec, Long sampleRate, String channelLayout, String sampleFormat, Long bitrate) {
StreamInformation stream = MediaInformationParser.parseStreamBlock(input);
Assert.assertNotNull(stream);
Assert.assertEquals(index, stream.getIndex());
Assert.assertEquals("audio", stream.getType());
Assert.assertEquals(codec, stream.getCodec());
Assert.assertEquals(fullCodec, stream.getFullCodec());
Assert.assertEquals(sampleRate, stream.getSampleRate());
Assert.assertEquals(channelLayout, stream.getChannelLayout());
Assert.assertEquals(sampleFormat, stream.getSampleFormat());
Assert.assertEquals(bitrate, stream.getBitrate());
}
private void parseVideoDimensions(String value, Long width, Long height) {
Pair<Long, Long> videoDimensions = MediaInformationParser.parseVideoDimensions(value);
Assert.assertNotNull(videoDimensions);
Assert.assertEquals(width, videoDimensions.getFirst());
Assert.assertEquals(height, videoDimensions.getSecond());
}
private void parseDuration(String value, Long expected) {
Long duration = MediaInformationParser.parseDuration(value);
Assert.assertEquals(expected, duration);
}
private void parseStartTime(String value, Long expected) {
Long duration = MediaInformationParser.parseStartTime(value);
Assert.assertEquals(expected, duration);
}
private void parseDurationBlock(String value, Long first, Long second, Long third) {
Trio<Long, Long, Long> pair = MediaInformationParser.parseDurationBlock(value);
Assert.assertNotNull(pair);
Assert.assertEquals(first, pair.getFirst());
Assert.assertEquals(second, pair.getSecond());
Assert.assertEquals(third, pair.getThird());
}
private void parseInputBlock(String value, String first, String second) {
Pair<String, String> pair = MediaInformationParser.parseInputBlock(value);
Assert.assertNotNull(pair);
Assert.assertEquals(first, pair.getFirst());
Assert.assertEquals(second, pair.getSecond());
}
private void parseMetadataBlock(String value, String first, String second) {
Pair<String, String> pair = MediaInformationParser.parseMetadataBlock(value);
Assert.assertNotNull(pair);
Assert.assertNotNull(pair.getFirst());
Assert.assertNotNull(pair.getSecond());
Assert.assertEquals(first, pair.getFirst());
Assert.assertEquals(second, pair.getSecond());
}
}
+3 -1
View File
@@ -1,12 +1,14 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.2'
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
Binary file not shown.
+2 -1
View File
@@ -1,5 +1,6 @@
#Thu Mar 15 21:50:32 EET 2018
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
+44 -56
View File
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
#!/usr/bin/env bash
##############################################################################
##
@@ -6,6 +6,42 @@
##
##############################################################################
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn ( ) {
echo "$*"
}
die ( ) {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
esac
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
@@ -24,46 +60,6 @@ cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
@@ -89,7 +85,7 @@ location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
@@ -154,19 +150,11 @@ if $cygwin ; then
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
function splitJvmOpts() {
JVM_OPTS=("$@")
}
APP_ARGS=$(save "$@")
eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
Vendored Executable → Regular
+10 -4
View File
@@ -8,14 +8,14 @@
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
@@ -46,9 +46,10 @@ echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
@rem Get command-line arguments, handling Windowz variants
if not "%OS%" == "Windows_NT" goto win9xME_args
if "%@eval[2+2]" == "4" goto 4NT_args
:win9xME_args
@rem Slurp the command line arguments.
@@ -59,6 +60,11 @@ set _SKIP=2
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
goto execute
:4NT_args
@rem Get arguments from the 4NT Shell from JP Software
set CMD_LINE_ARGS=%$
:execute
@rem Setup the command line
-1
View File
@@ -1,2 +1 @@
/Application.mk
/Android.mk.tmp
+1 -15
View File
@@ -4,20 +4,6 @@ $(call import-add-path, $(LOCAL_PATH))
MY_ARM_MODE := arm
MY_PATH := ../app/src/main/cpp
# DEFINE ARCH FLAGS
ifeq ($(TARGET_ARCH_ABI), armeabi-v7a)
MY_ARCH_FLAGS := ARM_V7A
endif
ifeq ($(TARGET_ARCH_ABI), arm64-v8a)
MY_ARCH_FLAGS := ARM64_V8A
endif
ifeq ($(TARGET_ARCH_ABI), x86)
MY_ARCH_FLAGS := X86
endif
ifeq ($(TARGET_ARCH_ABI), x86_64)
MY_ARCH_FLAGS := X86_64
endif
include $(CLEAR_VARS)
LOCAL_ARM_MODE := $(MY_ARM_MODE)
LOCAL_MODULE := cpufeatures
@@ -31,7 +17,7 @@ include $(CLEAR_VARS)
LOCAL_ARM_MODE := $(MY_ARM_MODE)
LOCAL_MODULE := mobileffmpeg-abidetect
LOCAL_SRC_FILES := $(MY_PATH)/mobileffmpeg_abidetect.c
LOCAL_CFLAGS := -Wall -Wextra -Werror -Wno-unused-parameter -I${LOCAL_PATH}/../../prebuilt/android-$(TARGET_ARCH)/ffmpeg/include -I$(NDK_ROOT)/sources/android/cpufeatures -DMOBILE_FFMPEG_${MY_ARCH_FLAGS}
LOCAL_CFLAGS := -Wall -Wextra -Werror -Wno-unused-parameter -I${LOCAL_PATH}/../../prebuilt/android-$(TARGET_ARCH)/ffmpeg/include -I$(NDK_ROOT)/sources/android/cpufeatures
LOCAL_LDLIBS := -llog -lz -landroid
LOCAL_SHARED_LIBRARIES := cpufeatures
include $(BUILD_SHARED_LIBRARY)
+1
View File
@@ -1,3 +1,4 @@
/build
/.idea/
/gradle/
/local.properties
+12 -41
View File
@@ -1,60 +1,31 @@
apply plugin: 'com.android.application'
android {
signingConfigs {
localConfig {
keyAlias 'androiddebugkey'
storeFile file(System.getProperty("user.home") + '/.android/debug.keystore')
storePassword 'android'
keyPassword 'android'
}
}
compileSdkVersion 28
compileSdkVersion 27
defaultConfig {
applicationId "com.arthenica.mobileffmpeg.test"
minSdkVersion 24
targetSdkVersion 28
versionCode 240421
versionName "4.2.1"
minSdkVersion 21
targetSdkVersion 27
versionCode 22
versionName "2.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled true
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
splits {
abi {
enable true
reset()
include "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
universalApk false
}
}
}
ext.abiCodes = ['x86':1, 'x86_64':2, 'armeabi-v7a':3, 'arm64-v8a':4]
import com.android.build.OutputFile
android.applicationVariants.all { variant ->
variant.outputs.each {
output ->
def baseAbiVersionCode = project.ext.abiCodes.get(output.getFilter(OutputFile.ABI))
output.versionCodeOverride = baseAbiVersionCode + variant.versionCode
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.arthenica:mobile-ffmpeg-full:4.2.1'
// implementation project(':app')
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.arthenica:mobile-ffmpeg-full:2.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}
Binary file not shown.
@@ -1,5 +0,0 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
-172
View File
@@ -1,172 +0,0 @@
#!/usr/bin/env sh
##############################################################################
##
## Gradle start up script for UN*X
##
##############################################################################
# Attempt to set APP_HOME
# Resolve links: $0 may be a link
PRG="$0"
# Need this for relative symlinks.
while [ -h "$PRG" ] ; do
ls=`ls -ld "$PRG"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '/.*' > /dev/null; then
PRG="$link"
else
PRG=`dirname "$PRG"`"/$link"
fi
done
SAVED="`pwd`"
cd "`dirname \"$PRG\"`/" >/dev/null
APP_HOME="`pwd -P`"
cd "$SAVED" >/dev/null
APP_NAME="Gradle"
APP_BASE_NAME=`basename "$0"`
# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS=""
# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
warn () {
echo "$*"
}
die () {
echo
echo "$*"
echo
exit 1
}
# OS specific support (must be 'true' or 'false').
cygwin=false
msys=false
darwin=false
nonstop=false
case "`uname`" in
CYGWIN* )
cygwin=true
;;
Darwin* )
darwin=true
;;
MINGW* )
msys=true
;;
NONSTOP* )
nonstop=true
;;
esac
CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
# Determine the Java command to use to start the JVM.
if [ -n "$JAVA_HOME" ] ; then
if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
# IBM's JDK on AIX uses strange locations for the executables
JAVACMD="$JAVA_HOME/jre/sh/java"
else
JAVACMD="$JAVA_HOME/bin/java"
fi
if [ ! -x "$JAVACMD" ] ; then
die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
else
JAVACMD="java"
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
# Increase the maximum file descriptors if we can.
if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ] ; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
MAX_FD="$MAX_FD_LIMIT"
fi
ulimit -n $MAX_FD
if [ $? -ne 0 ] ; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi
# For Darwin, add options to specify how the application appears in the dock
if $darwin; then
GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
fi
# For Cygwin, switch paths to Windows format before running java
if $cygwin ; then
APP_HOME=`cygpath --path --mixed "$APP_HOME"`
CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
JAVACMD=`cygpath --unix "$JAVACMD"`
# We build the pattern for arguments to be converted via cygpath
ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
SEP=""
for dir in $ROOTDIRSRAW ; do
ROOTDIRS="$ROOTDIRS$SEP$dir"
SEP="|"
done
OURCYGPATTERN="(^($ROOTDIRS))"
# Add a user-defined pattern to the cygpath arguments
if [ "$GRADLE_CYGPATTERN" != "" ] ; then
OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
fi
# Now convert the arguments - kludge to limit ourselves to /bin/sh
i=0
for arg in "$@" ; do
CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
else
eval `echo args$i`="\"$arg\""
fi
i=$((i+1))
done
case $i in
(0) set -- ;;
(1) set -- "$args0" ;;
(2) set -- "$args0" "$args1" ;;
(3) set -- "$args0" "$args1" "$args2" ;;
(4) set -- "$args0" "$args1" "$args2" "$args3" ;;
(5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
(6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
(7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
(8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
(9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
esac
fi
# Escape application args
save () {
for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
echo " "
}
APP_ARGS=$(save "$@")
# Collect all arguments for the java command, following the shell quoting and substitution rules
eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
cd "$(dirname "$0")"
fi
exec "$JAVACMD" "$@"
-84
View File
@@ -1,84 +0,0 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto init
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:init
@rem Get command-line arguments, handling Windows variants
if not "%OS%" == "Windows_NT" goto win9xME_args
:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2
:win9xME_args_slurp
if "x%~1" == "x" goto execute
set CMD_LINE_ARGS=%*
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+14 -5
View File
@@ -5,8 +5,17 @@
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
-keep class com.arthenica.mobileffmpeg.Config {
native <methods>;
void log(int, byte[]);
void statistics(int, float, float, long , int, double, double);
}
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
@@ -7,9 +7,6 @@
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" android:required="true" />
<application
android:allowBackup="true"
@@ -18,7 +15,8 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:largeHeap="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme"
tools:replace="android:icon">
<activity android:name="com.arthenica.mobileffmpeg.test.MainActivity"
android:theme="@style/AppTheme">
<intent-filter>
@@ -25,7 +25,6 @@ import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.method.ScrollingMovementMethod;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
@@ -78,7 +77,6 @@ public class AudioTabFragment extends Fragment implements AdapterView.OnItemSele
@Override
public void onClick(View v) {
encodeAudio();
// encodeChromaprint();
}
});
encodeButton.setEnabled(false);
@@ -186,20 +184,6 @@ public class AudioTabFragment extends Fragment implements AdapterView.OnItemSele
}, ffmpegCommand);
}
protected void encodeChromaprint() {
File audioSampleFile = getAudioSampleFile();
Log.d(TAG, "Testing AUDIO encoding with 'chromaprint' muxer");
final String ffmpegCommand = String.format("-v quiet -i %s -f chromaprint -fp_format 2 -", audioSampleFile.getAbsolutePath());
Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", ffmpegCommand));
int returnCode = FFmpeg.execute(ffmpegCommand);
Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode));
}
public void createAudioSample() {
android.util.Log.d(TAG, "Creating AUDIO sample before the test.");
@@ -208,7 +192,7 @@ public class AudioTabFragment extends Fragment implements AdapterView.OnItemSele
audioSampleFile.delete();
}
String ffmpegCommand = String.format("-hide_banner -y -f lavfi -i sine=frequency=1000:duration=5 -c:a pcm_s16le %s", audioSampleFile.getAbsolutePath());
String ffmpegCommand = String.format("-y -f lavfi -i sine=frequency=1000:duration=5 -c:a pcm_s16le %s", audioSampleFile.getAbsolutePath());
android.util.Log.d(TAG, String.format("Sample file is created with '%s'", ffmpegCommand));
@@ -227,9 +211,6 @@ public class AudioTabFragment extends Fragment implements AdapterView.OnItemSele
String extension;
switch (audioCodec) {
case "mp2 (twolame)":
extension = "mpg";
break;
case "mp3 (liblame)":
case "mp3 (libshine)":
extension = "mp3";
@@ -297,28 +278,26 @@ public class AudioTabFragment extends Fragment implements AdapterView.OnItemSele
String audioOutputFile = getAudioOutputFile().getAbsolutePath();
switch (audioCodec) {
case "mp2 (twolame)":
return String.format("-hide_banner -y -i %s -c:a mp2 -b:a 192k %s", audioSampleFile, audioOutputFile);
case "mp3 (liblame)":
return String.format("-hide_banner -y -i %s -c:a libmp3lame -qscale:a 2 %s", audioSampleFile, audioOutputFile);
return String.format("-y -i %s -c:a libmp3lame -qscale:a 2 %s", audioSampleFile, audioOutputFile);
case "mp3 (libshine)":
return String.format("-hide_banner -y -i %s -c:a libshine -qscale:a 2 %s", audioSampleFile, audioOutputFile);
return String.format("-y -i %s -c:a libshine -qscale:a 2 %s", audioSampleFile, audioOutputFile);
case "vorbis":
return String.format("-hide_banner -y -i %s -c:a libvorbis -b:a 64k %s", audioSampleFile, audioOutputFile);
return String.format("-y -i %s -c:a libvorbis -b:a 64k %s", audioSampleFile, audioOutputFile);
case "opus":
return String.format("-hide_banner -y -i %s -c:a libopus -b:a 64k -vbr on -compression_level 10 %s", audioSampleFile, audioOutputFile);
return String.format("-y -i %s -c:a libopus -b:a 64k -vbr on -compression_level 10 %s", audioSampleFile, audioOutputFile);
case "amr":
return String.format("-hide_banner -y -i %s -ar 8000 -ab 12.2k -c:a libopencore_amrnb %s", audioSampleFile, audioOutputFile);
return String.format("-y -i %s -ar 8000 -ab 12.2k %s", audioSampleFile, audioOutputFile);
case "ilbc":
return String.format("-hide_banner -y -i %s -c:a ilbc -ar 8000 -b:a 15200 %s", audioSampleFile, audioOutputFile);
return String.format("-y -i %s -c:a ilbc -ar 8000 -b:a 15200 %s", audioSampleFile, audioOutputFile);
case "speex":
return String.format("-hide_banner -y -i %s -c:a libspeex -ar 16000 %s", audioSampleFile, audioOutputFile);
return String.format("-y -i %s -c:a libspeex -ar 16000 %s", audioSampleFile, audioOutputFile);
case "wavpack":
return String.format("-hide_banner -y -i %s -c:a wavpack -b:a 64k %s", audioSampleFile, audioOutputFile);
return String.format("-y -i %s -c:a wavpack -b:a 64k %s", audioSampleFile, audioOutputFile);
default:
// soxr
return String.format("-hide_banner -y -i %s -af aresample=resampler=soxr -ar 44100 %s", audioSampleFile, audioOutputFile);
return String.format("-y -i %s -af aresample=resampler=soxr -ar 44100 %s", audioSampleFile, audioOutputFile);
}
}
@@ -117,13 +117,13 @@ public class CommandTabFragment extends Fragment {
public void runFFmpeg() {
clearLog();
final String ffmpegCommand = String.format("-hide_banner %s", commandText.getText().toString());
final String ffmpegCommand = commandText.getText().toString();
android.util.Log.d(MainActivity.TAG, "Testing COMMAND synchronously.");
android.util.Log.d(MainActivity.TAG, String.format("FFmpeg process started with arguments\n\'%s\'", ffmpegCommand));
int result = FFmpeg.execute(ffmpegCommand, " ");
int result = FFmpeg.execute(ffmpegCommand);
android.util.Log.d(MainActivity.TAG, String.format("FFmpeg process exited with rc %d", result));
@@ -135,7 +135,7 @@ public class CommandTabFragment extends Fragment {
public void runFFmpegAsync() {
clearLog();
final String ffmpegCommand = String.format("-hide_banner %s", commandText.getText().toString());
final String ffmpegCommand = commandText.getText().toString();
android.util.Log.d(MainActivity.TAG, "Testing COMMAND asynchronously.");
@@ -39,7 +39,7 @@ import java.util.concurrent.Callable;
public class HttpsTabFragment extends Fragment {
public static final String HTTPS_TEST_DEFAULT_URL = "https://upload.wikimedia.org/wikipedia/commons/thumb/4/4b/FFmpeg-Logo.svg/568px-FFmpeg-Logo.svg.png";
public static final String HTTPS_TEST_DEFAULT_URL = "https://download.blender.org/peach/trailer/trailer_400p.ogg";
private MainActivity mainActivity;
private EditText urlText;
@@ -119,7 +119,7 @@ public class HttpsTabFragment extends Fragment {
}
// HTTPS COMMAND ARGUMENTS
final String ffmpegCommand = String.format("-hide_banner -i %s -f null -", testUrl);
final String ffmpegCommand = String.format("-hide_banner -i %s", testUrl);
android.util.Log.d(MainActivity.TAG, String.format("FFmpeg process started with arguments\n'%s'", ffmpegCommand));
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2019 Taner Sener
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
@@ -27,7 +27,6 @@ import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Color;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.support.v4.app.ActivityCompat;
@@ -41,8 +40,9 @@ import android.widget.Button;
import android.widget.TextView;
import com.arthenica.mobileffmpeg.Config;
import com.arthenica.mobileffmpeg.util.AsyncCommandTask;
import com.arthenica.mobileffmpeg.FFmpeg;
import com.arthenica.mobileffmpeg.util.RunCallback;
import com.arthenica.mobileffmpeg.util.AsynchronousTaskService;
import java.io.File;
import java.io.FileOutputStream;
@@ -52,18 +52,20 @@ import java.util.HashMap;
import java.util.Queue;
import java.util.concurrent.Callable;
import java.util.concurrent.ConcurrentLinkedQueue;
import java.util.concurrent.Future;
public class MainActivity extends AppCompatActivity {
public static final String TAG = "mobile-ffmpeg-test";
public static final int REQUEST_EXTERNAL_STORAGE = 1;
public static String[] PERMISSIONS_ALL = {
public static String[] PERMISSIONS_STORAGE = {
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.CAMERA
Manifest.permission.WRITE_EXTERNAL_STORAGE
};
protected static final AsynchronousTaskService asynchronousTaskService = new AsynchronousTaskService();
protected static final Queue<Callable> actionQueue = new ConcurrentLinkedQueue<>();
protected static final Handler handler = new Handler();
@@ -109,7 +111,7 @@ public class MainActivity extends AppCompatActivity {
}
final ViewPager viewPager = findViewById(R.id.pager);
viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager(), this, 7));
viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager(), this, 6));
waitForUIAction();
@@ -117,19 +119,7 @@ public class MainActivity extends AppCompatActivity {
int permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.WRITE_EXTERNAL_STORAGE);
if (permission != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
PERMISSIONS_ALL,
REQUEST_EXTERNAL_STORAGE);
}
permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
if (permission != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
PERMISSIONS_ALL,
REQUEST_EXTERNAL_STORAGE);
}
permission = ActivityCompat.checkSelfPermission(this, Manifest.permission.CAMERA);
if (permission != PackageManager.PERMISSION_GRANTED) {
ActivityCompat.requestPermissions(this,
PERMISSIONS_ALL,
PERMISSIONS_STORAGE,
REQUEST_EXTERNAL_STORAGE);
}
@@ -153,10 +143,21 @@ public class MainActivity extends AppCompatActivity {
*
* @param runCallback callback function to receive result of this execution
* @param arguments FFmpeg command options/arguments
* @return <code>Future</code> instance of asynchronous operation started
*/
public static void executeAsync(final RunCallback runCallback, final String arguments) {
final AsyncCommandTask asyncCommandTask = new AsyncCommandTask(runCallback);
asyncCommandTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, arguments);
public static Future executeAsync(final RunCallback runCallback, final String arguments) {
return asynchronousTaskService.runAsynchronously(new Callable<Integer>() {
@Override
public Integer call() {
int returnCode = FFmpeg.execute(arguments);
if (runCallback != null) {
runCallback.apply(returnCode);
}
return returnCode;
}
});
}
public static void waitForUIAction() {
@@ -55,9 +55,6 @@ public class PagerAdapter extends FragmentPagerAdapter {
case 5: {
return VidStabTabFragment.newInstance(mainActivity);
}
case 6: {
return PipeTabFragment.newInstance(mainActivity);
}
default: {
return null;
}
@@ -90,9 +87,6 @@ public class PagerAdapter extends FragmentPagerAdapter {
case 5: {
return mainActivity.getString(R.string.vidstab_tab);
}
case 6: {
return mainActivity.getString(R.string.pipe_tab);
}
default: {
return null;
}
@@ -1,282 +0,0 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg.test;
import android.app.AlertDialog;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.MediaController;
import android.widget.TextView;
import android.widget.VideoView;
import com.arthenica.mobileffmpeg.Config;
import com.arthenica.mobileffmpeg.LogCallback;
import com.arthenica.mobileffmpeg.LogMessage;
import com.arthenica.mobileffmpeg.Statistics;
import com.arthenica.mobileffmpeg.StatisticsCallback;
import com.arthenica.mobileffmpeg.util.AsyncCatImageTask;
import com.arthenica.mobileffmpeg.util.RunCallback;
import java.io.File;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.concurrent.Callable;
import static com.arthenica.mobileffmpeg.FFmpeg.RETURN_CODE_SUCCESS;
import static com.arthenica.mobileffmpeg.test.MainActivity.TAG;
public class PipeTabFragment extends Fragment {
private MainActivity mainActivity;
private VideoView videoView;
private AlertDialog progressDialog;
private Statistics statistics;
@Override
public View onCreateView(@NonNull final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
return inflater.inflate(R.layout.fragment_pipe_tab, container, false);
}
@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
if (getView() != null) {
View createButton = getView().findViewById(R.id.createButton);
if (createButton != null) {
createButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
createVideo();
}
});
}
videoView = getView().findViewById(R.id.videoPlayerFrame);
}
progressDialog = mainActivity.createProgressDialog("Creating video");
}
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
setActive();
}
}
public void setMainActivity(MainActivity mainActivity) {
this.mainActivity = mainActivity;
}
public static PipeTabFragment newInstance(final MainActivity mainActivity) {
final PipeTabFragment fragment = new PipeTabFragment();
fragment.setMainActivity(mainActivity);
return fragment;
}
public void enableLogCallback() {
Config.enableLogCallback(new LogCallback() {
@Override
public void apply(LogMessage message) {
Log.d(MainActivity.TAG, message.getText());
}
});
}
public void enableStatisticsCallback() {
Config.enableStatisticsCallback(new StatisticsCallback() {
@Override
public void apply(final Statistics newStatistics) {
MainActivity.addUIAction(new Callable() {
@Override
public Object call() {
PipeTabFragment.this.statistics = newStatistics;
updateProgressDialog();
return null;
}
});
}
});
}
void startAsyncCatImageProcess(final String imagePath, final String namedPipePath) {
AsyncCatImageTask asyncTask = new AsyncCatImageTask();
asyncTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, imagePath, namedPipePath);
}
public void createVideo() {
final File image1File = new File(mainActivity.getCacheDir(), "colosseum.jpg");
final File image2File = new File(mainActivity.getCacheDir(), "pyramid.jpg");
final File image3File = new File(mainActivity.getCacheDir(), "tajmahal.jpg");
final File videoFile = getVideoFile();
String pipe1 = Config.registerNewFFmpegPipe(mainActivity);
String pipe2 = Config.registerNewFFmpegPipe(mainActivity);
String pipe3 = Config.registerNewFFmpegPipe(mainActivity);
try {
// IF VIDEO IS PLAYING STOP PLAYBACK
videoView.stopPlayback();
if (videoFile.exists()) {
videoFile.delete();
}
Log.d(TAG, "Testing PIPE with 'mpeg4' codec");
showProgressDialog();
mainActivity.resourceToFile(R.drawable.colosseum, image1File);
mainActivity.resourceToFile(R.drawable.pyramid, image2File);
mainActivity.resourceToFile(R.drawable.tajmahal, image3File);
final String ffmpegCommand = Video.generateCreateVideoWithPipesScript(pipe1, pipe2, pipe3, videoFile.getAbsolutePath());
Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", ffmpegCommand));
MainActivity.executeAsync(new RunCallback() {
@Override
public void apply(final int returnCode) {
Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode));
hideProgressDialog();
MainActivity.addUIAction(new Callable() {
@Override
public Object call() {
if (returnCode == RETURN_CODE_SUCCESS) {
Log.d(TAG, "Create completed successfully; playing video.");
playVideo();
} else {
Popup.show(mainActivity, "Create failed. Please check log for the details.");
Log.d(TAG, String.format("Create failed with rc=%d", returnCode));
}
return null;
}
});
}
}, ffmpegCommand);
// START ASYNC PROCESSES AFTER INITIATING FFMPEG COMMAND
startAsyncCatImageProcess(image1File.getAbsolutePath(), pipe1);
startAsyncCatImageProcess(image2File.getAbsolutePath(), pipe2);
startAsyncCatImageProcess(image3File.getAbsolutePath(), pipe3);
} catch (IOException e) {
Log.e(TAG, "Create video failed", e);
Popup.show(mainActivity, "Create video failed");
}
}
protected void playVideo() {
MediaController mediaController = new MediaController(mainActivity);
mediaController.setAnchorView(videoView);
videoView.setVideoURI(Uri.parse("file://" + getVideoFile().getAbsolutePath()));
videoView.setMediaController(mediaController);
videoView.requestFocus();
videoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
videoView.setBackgroundColor(0x00000000);
}
});
videoView.setOnErrorListener(new MediaPlayer.OnErrorListener() {
@Override
public boolean onError(MediaPlayer mp, int what, int extra) {
videoView.stopPlayback();
return false;
}
});
videoView.start();
}
protected File getVideoFile() {
return new File(mainActivity.getFilesDir(), "video.mp4");
}
public void setActive() {
Log.i(MainActivity.TAG, "Pipe Tab Activated");
enableLogCallback();
enableStatisticsCallback();
Popup.show(mainActivity, Tooltip.PIPE_TEST_TOOLTIP_TEXT);
}
protected void showProgressDialog() {
// CLEAN STATISTICS
statistics = null;
Config.resetStatistics();
progressDialog.show();
}
protected void updateProgressDialog() {
if (statistics == null) {
return;
}
int timeInMilliseconds = this.statistics.getTime();
if (timeInMilliseconds > 0) {
int totalVideoDuration = 9000;
String completePercentage = new BigDecimal(timeInMilliseconds).multiply(new BigDecimal(100)).divide(new BigDecimal(totalVideoDuration), 0, BigDecimal.ROUND_HALF_UP).toString();
TextView textView = progressDialog.findViewById(R.id.progressDialogText);
if (textView != null) {
textView.setText(String.format("Creating video: %% %s", completePercentage));
}
}
}
protected void hideProgressDialog() {
progressDialog.dismiss();
MainActivity.addUIAction(new Callable() {
@Override
public Object call() {
PipeTabFragment.this.progressDialog = mainActivity.createProgressDialog("Creating video");
return null;
}
});
}
}
@@ -39,7 +39,4 @@ public interface Tooltip {
// VID.STAB TEST
String VIDSTAB_TEST_TOOLTIP_TEXT = "Click the button to stabilize video. Original video will play above and stabilized video will play below";
// PIPE TEST
String PIPE_TEST_TOOLTIP_TEXT = "Click the button to create a video using pipe redirection. Created video will play inside the frame below";
}
@@ -20,36 +20,15 @@
package com.arthenica.mobileffmpeg.test;
/**
* <p>Generates FFmpeg scripts to create videos from provided images.
* <p>Generates an FFmpeg command to create a 640x427 video from provided images.
*
* @author Taner Sener
*/
public class Video {
static String generateCreateVideoWithPipesScript(final String image1Pipe, final String image2Pipe, final String image3Pipe, final String videoFilePath) {
public static String generateEncodeVideoScript(final String image1Path, final String image2Path, final String image3Path, final String videoFilePath, final String videoCodec, final String customOptions) {
return
"-hide_banner -y -i " + image1Pipe + " " +
"-i " + image2Pipe + " " +
"-i " + image3Pipe + " " +
"-filter_complex " +
"[0:v]loop=loop=-1:size=1:start=0,setpts=PTS-STARTPTS,scale=w=\'if(gte(iw/ih,640/427),min(iw,640),-1)\':h=\'if(gte(iw/ih,640/427),-1,min(ih,427))\',scale=trunc(iw/2)*2:trunc(ih/2)*2,setsar=sar=1/1,split=2[stream1out1][stream1out2];" +
"[1:v]loop=loop=-1:size=1:start=0,setpts=PTS-STARTPTS,scale=w=\'if(gte(iw/ih,640/427),min(iw,640),-1)\':h=\'if(gte(iw/ih,640/427),-1,min(ih,427))\',scale=trunc(iw/2)*2:trunc(ih/2)*2,setsar=sar=1/1,split=2[stream2out1][stream2out2];" +
"[2:v]loop=loop=-1:size=1:start=0,setpts=PTS-STARTPTS,scale=w=\'if(gte(iw/ih,640/427),min(iw,640),-1)\':h=\'if(gte(iw/ih,640/427),-1,min(ih,427))\',scale=trunc(iw/2)*2:trunc(ih/2)*2,setsar=sar=1/1,split=2[stream3out1][stream3out2];" +
"[stream1out1]pad=width=640:height=427:x=(640-iw)/2:y=(427-ih)/2:color=#00000000,trim=duration=3,select=lte(n\\,90)[stream1overlaid];" +
"[stream1out2]pad=width=640:height=427:x=(640-iw)/2:y=(427-ih)/2:color=#00000000,trim=duration=1,select=lte(n\\,30)[stream1ending];" +
"[stream2out1]pad=width=640:height=427:x=(640-iw)/2:y=(427-ih)/2:color=#00000000,trim=duration=2,select=lte(n\\,60)[stream2overlaid];" +
"[stream2out2]pad=width=640:height=427:x=(640-iw)/2:y=(427-ih)/2:color=#00000000,trim=duration=1,select=lte(n\\,30),split=2[stream2starting][stream2ending];" +
"[stream3out1]pad=width=640:height=427:x=(640-iw)/2:y=(427-ih)/2:color=#00000000,trim=duration=2,select=lte(n\\,60)[stream3overlaid];" +
"[stream3out2]pad=width=640:height=427:x=(640-iw)/2:y=(427-ih)/2:color=#00000000,trim=duration=1,select=lte(n\\,30)[stream3starting];" +
"[stream2starting][stream1ending]blend=all_expr=\'if(gte(X,(W/2)*T/1)*lte(X,W-(W/2)*T/1),B,A)\':shortest=1[stream2blended];" +
"[stream3starting][stream2ending]blend=all_expr=\'if(gte(X,(W/2)*T/1)*lte(X,W-(W/2)*T/1),B,A)\':shortest=1[stream3blended];" +
"[stream1overlaid][stream2blended][stream2overlaid][stream3blended][stream3overlaid]concat=n=5:v=1:a=0,scale=w=640:h=424,format=yuv420p[video]" +
" -map [video] -vsync 2 -async 1 -c:v mpeg4 -r 30 " + videoFilePath;
}
static String generateEncodeVideoScript(final String image1Path, final String image2Path, final String image3Path, final String videoFilePath, final String videoCodec, final String customOptions) {
return
"-hide_banner -y -loop 1 -i " + image1Path + " " +
"-y -loop 1 -i " + image1Path + " " +
"-loop 1 -i " + image2Path + " " +
"-loop 1 -i " + image3Path + " " +
"-filter_complex " +
@@ -68,9 +47,9 @@ public class Video {
" -map [video] -vsync 2 -async 1 " + customOptions + "-c:v " + videoCodec.toLowerCase() + " -r 30 " + videoFilePath;
}
static String generateShakingVideoScript(final String image1Path, final String image2Path, final String image3Path, final String videoFilePath) {
public static String generateShakingVideoScript(final String image1Path, final String image2Path, final String image3Path, final String videoFilePath) {
return
"-hide_banner -y -loop 1 -i " + image1Path + " " +
"-y -loop 1 -i " + image1Path + " " +
"-loop 1 -i " + image2Path + " " +
"-loop 1 -i " + image3Path + " " +
"-f lavfi -i color=black:s=640x427 " +
@@ -38,12 +38,11 @@ import android.widget.TextView;
import android.widget.VideoView;
import com.arthenica.mobileffmpeg.Config;
import com.arthenica.mobileffmpeg.FFmpeg;
import com.arthenica.mobileffmpeg.LogCallback;
import com.arthenica.mobileffmpeg.LogMessage;
import com.arthenica.mobileffmpeg.util.RunCallback;
import com.arthenica.mobileffmpeg.Statistics;
import com.arthenica.mobileffmpeg.StatisticsCallback;
import com.arthenica.mobileffmpeg.util.RunCallback;
import java.io.File;
import java.io.IOException;
@@ -85,7 +84,6 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele
@Override
public void onClick(View v) {
encodeVideo();
// encodeWebp();
}
});
}
@@ -215,28 +213,6 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele
}
}
protected void encodeWebp() {
final File imageFile = new File(mainActivity.getCacheDir(), "colosseum.jpg");
final File outputFile = new File(mainActivity.getFilesDir(), "video.webp");
try {
mainActivity.resourceToFile(R.drawable.colosseum, imageFile);
Log.d(TAG, "Testing VIDEO encoding with 'webp' codec");
final String ffmpegCommand = String.format("-hide_banner -i %s %s", imageFile.getAbsolutePath(), outputFile.getAbsolutePath());
Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", ffmpegCommand));
int returnCode = FFmpeg.execute(ffmpegCommand);
Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode));
} catch (IOException e) {
Log.e(TAG, "Encode webp failed", e);
Popup.show(mainActivity, "Encode webp failed");
}
}
protected void playVideo() {
MediaController mediaController = new MediaController(mainActivity);
mediaController.setAnchorView(videoView);
@@ -262,8 +238,6 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele
}
public String getSelectedVideoCodec() {
// NOTE THAT MPEG4 CODEC IS ASSIGNED HERE
String videoCodec = selectedCodec;
// VIDEO CODEC SPINNER HAS BASIC NAMES, FFMPEG NEEDS LONGER AND EXACT CODEC NAMES.
@@ -346,8 +320,6 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele
case "hap":
return "-format hap_q ";
default:
// mpeg4, x264, xvid
return "";
}
}
@@ -1,49 +0,0 @@
/*
* Copyright (c) 2018-2019 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg.util;
import android.os.AsyncTask;
import android.util.Log;
import java.io.IOException;
import static com.arthenica.mobileffmpeg.test.MainActivity.TAG;
public class AsyncCatImageTask extends AsyncTask<String, Integer, Integer> {
@Override
protected Integer doInBackground(String... inputs) {
try {
final String asyncCommand = "cat " + inputs[0] + " > " + inputs[1];
Log.d(TAG, String.format("Starting async cat image command: %s", asyncCommand));
final Process process = Runtime.getRuntime().exec(new String[]{"sh", "-c", asyncCommand});
int rc = process.waitFor();
Log.d(TAG, String.format("Async cat image command: %s exited with %d.", asyncCommand, rc));
return rc;
} catch (final IOException | InterruptedException e) {
Log.e(TAG, String.format("Async cat image command failed for %s.", inputs[0]), e);
return -1;
}
}
}
@@ -1,46 +0,0 @@
/*
* Copyright (c) 2018-2019 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg.util;
import android.os.AsyncTask;
import com.arthenica.mobileffmpeg.FFmpeg;
public class AsyncCommandTask extends AsyncTask<String, Integer, Integer> {
private final RunCallback runCallback;
public AsyncCommandTask(final RunCallback runCallback) {
this.runCallback = runCallback;
}
@Override
protected Integer doInBackground(final String... arguments) {
return FFmpeg.execute(arguments[0], " ");
}
@Override
protected void onPostExecute(final Integer rc) {
if (runCallback != null) {
runCallback.apply(rc);
}
}
}
@@ -0,0 +1,53 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg.util;
import android.support.annotation.NonNull;
import java.text.MessageFormat;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.atomic.AtomicInteger;
public class AsyncThreadFactory implements ThreadFactory {
protected static final String DEFAULT_THREAD_NAME_PREFIX = "AsyncTaskThread";
protected static AtomicInteger threadCounter;
static {
threadCounter = new AtomicInteger(1);
}
private final String namePrefix;
public AsyncThreadFactory() {
this(DEFAULT_THREAD_NAME_PREFIX);
}
public AsyncThreadFactory(final String namePrefix) {
this.namePrefix = namePrefix;
}
@Override
public Thread newThread(@NonNull final Runnable runnable) {
return new Thread(runnable, MessageFormat.format("{0}-{1,number,#}", namePrefix, threadCounter.getAndIncrement()));
}
}
@@ -0,0 +1,121 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg.util;
import android.util.Log;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.Callable;
import java.util.concurrent.Future;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
public class AsynchronousTaskService {
protected static final String TAG = "mobile-ffmpeg-android";
protected final BlockingQueue<Runnable> queue;
protected final Object executorServiceLock;
protected ThreadPoolExecutor executorService;
protected int coreThreadPoolSize;
protected int maximumThreadPoolSize;
protected int keepAliveTimeInSeconds;
public AsynchronousTaskService() {
this(1, 5, 30);
}
public AsynchronousTaskService(final int coreThreadPoolSize, final int maximumThreadPoolSize, final int keepAliveTimeInSeconds) {
this.executorServiceLock = new Object();
this.queue = new LinkedBlockingQueue<>();
this.executorService = null;
this.coreThreadPoolSize = coreThreadPoolSize;
this.maximumThreadPoolSize = maximumThreadPoolSize;
this.keepAliveTimeInSeconds = keepAliveTimeInSeconds;
}
public void init(final int coreThreadPoolSize, final int maximumThreadPoolSize, final int keepAliveTimeInSeconds) {
this.coreThreadPoolSize = coreThreadPoolSize;
this.maximumThreadPoolSize = maximumThreadPoolSize;
this.keepAliveTimeInSeconds = keepAliveTimeInSeconds;
}
public void initializeExecutorService() {
synchronized (executorServiceLock) {
if (executorService != null) {
executorService.shutdown();
}
executorService = new ThreadPoolExecutor(coreThreadPoolSize, maximumThreadPoolSize, keepAliveTimeInSeconds, TimeUnit.SECONDS, queue, new AsyncThreadFactory());
}
}
public <T> Future<T> runAsynchronously(final Callable<T> callable) {
/* INITIALIZE EXECUTOR SERVICE ONLY IF NECESSARY */
if (executorService == null) {
initializeExecutorService();
}
final String className = callable.getClass().getSimpleName();
try {
return executorService.submit(callable);
} catch (Exception e) {
Log.w(TAG, String.format("Failed to run asynchronous task %s. Running it synchronously.", className), e);
return runSynchronously(callable);
}
}
public <T> Future<T> runSynchronously(final Callable<T> callable) {
T called = null;
/* INITIALIZE EXECUTOR SERVICE ONLY IF NECESSARY */
if (executorService == null) {
initializeExecutorService();
}
final String className = callable.getClass().getSimpleName();
try {
called = callable.call();
return new SynchronousResultFuture<>(called, true);
} catch (final Exception e) {
Log.d(TAG, "Failed to run asynchronous task " + className + " synchronously.", e);
return new SynchronousResultFuture<>(called, true);
}
}
public void shutdown() {
if (executorService != null) {
synchronized (executorServiceLock) {
executorService.shutdown();
}
}
}
}
@@ -0,0 +1,63 @@
/*
* Copyright (c) 2018 Taner Sener
*
* This file is part of MobileFFmpeg.
*
* MobileFFmpeg is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* MobileFFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with MobileFFmpeg. If not, see <http://www.gnu.org/licenses/>.
*/
package com.arthenica.mobileffmpeg.util;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
public class SynchronousResultFuture<V> implements Future<V> {
protected final V v;
protected final boolean completed;
public SynchronousResultFuture(final V v, final boolean completed) {
this.v = v;
this.completed = completed;
}
@Override
public boolean cancel(final boolean mayInterruptIfRunning) {
return false;
}
@Override
public boolean isCancelled() {
return !completed;
}
@Override
public boolean isDone() {
return completed;
}
@Override
public V get() throws InterruptedException, ExecutionException {
return v;
}
@Override
public V get(final long timeout, final TimeUnit unit) throws InterruptedException, ExecutionException, TimeoutException {
return v;
}
}
@@ -1,41 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center"
android:orientation="vertical"
tools:context=".PipeTabFragment">
<LinearLayout
android:id="@+id/createButtonLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center">
<Button
android:id="@+id/createButton"
android:layout_width="90dp"
android:layout_height="36dp"
android:layout_marginBottom="20dp"
android:layout_marginTop="20dp"
android:background="@drawable/rounded_button"
android:fontFamily="sans-serif"
android:gravity="center"
android:text="@string/video_create_button_text"
android:textAlignment="center"
android:textColor="@android:color/white"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<VideoView
android:id="@+id/videoPlayerFrame"
android:layout_width="wrap_content"
android:background="@drawable/rounded_video_frame"
android:layout_height="0dp"
android:layout_gravity="bottom"
android:layout_margin="20dp"
android:layout_weight="1" />
</LinearLayout>
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="audio_codec">
<item>mp2 (twolame)</item>
<item>mp3 (liblame)</item>
<item>mp3 (libshine)</item>
<item>vorbis</item>
@@ -6,12 +6,10 @@
<string name="audio_tab">AUDIO</string>
<string name="subtitle_tab">SUBTITLE</string>
<string name="vidstab_tab">VID.STAB</string>
<string name="pipe_tab">PIPE</string>
<string name="command_text_input_placeholder">Enter command</string>
<string name="command_run_async_button_text">RUN ASYNC</string>
<string name="command_run_button_text">RUN</string>
<string name="video_encode_button_text">ENCODE</string>
<string name="video_create_button_text">CREATE</string>
<string name="https_get_info_button_text">GET INFO</string>
<string name="https_text_input_placeholder">Enter https url</string>
<string name="audio_encode_button_text">ENCODE</string>
Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

+8 -9
View File
@@ -47,21 +47,20 @@ cmake -Wno-dev \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
-DCMAKE_SYSROOT="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot" \
-DCMAKE_FIND_ROOT_PATH="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot" \
-DCMAKE_SYSROOT="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot" \
-DCMAKE_FIND_ROOT_PATH="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME}" \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AS" \
-DCMAKE_SYSTEM_PROCESSOR=$(get_cmake_target_processor) \
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$AS" \
-DFFT_LIB=kissfft \
-DCMAKE_SYSTEM_PROCESSOR=$(get_cmake_target_processor) \
-DBUILD_SHARED_LIBS=0 .. || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# CREATE PACKAGE CONFIG MANUALLY
create_chromaprint_package_config "1.4.3"
+111 -191
View File
@@ -46,21 +46,16 @@ get_library_name() {
25) echo "soxr" ;;
26) echo "libaom" ;;
27) echo "chromaprint" ;;
28) echo "twolame" ;;
29) echo "sdl" ;;
30) echo "tesseract" ;;
31) echo "giflib" ;;
32) echo "jpeg" ;;
33) echo "libogg" ;;
34) echo "libpng" ;;
35) echo "libuuid" ;;
36) echo "nettle" ;;
37) echo "tiff" ;;
38) echo "expat" ;;
39) echo "libsndfile" ;;
40) echo "leptonica" ;;
41) echo "android-zlib" ;;
42) echo "android-media-codec" ;;
28) echo "giflib" ;;
29) echo "jpeg" ;;
30) echo "libogg" ;;
31) echo "libpng" ;;
32) echo "libuuid" ;;
33) echo "nettle" ;;
34) echo "tiff" ;;
35) echo "expat" ;;
36) echo "android-zlib" ;;
37) echo "android-media-codec" ;;
esac
}
@@ -91,42 +86,23 @@ get_target_host() {
esac
}
get_clang_target_host() {
get_toolchain() {
case ${ARCH} in
arm-v7a | arm-v7a-neon)
echo "armv7a-linux-androideabi${API}"
echo "arm"
;;
arm64-v8a)
echo "aarch64-linux-android${API}"
echo "aarch64"
;;
x86)
echo "i686-linux-android${API}"
echo "i686"
;;
x86-64)
echo "x86_64-linux-android${API}"
echo "x86_64"
;;
esac
}
get_toolchain() {
HOST_OS=$(uname -s)
case ${HOST_OS} in
Darwin) HOST_OS=darwin;;
Linux) HOST_OS=linux;;
FreeBsd) HOST_OS=freebsd;;
CYGWIN*|*_NT-*) HOST_OS=cygwin;;
esac
HOST_ARCH=$(uname -m)
case ${HOST_ARCH} in
i?86) HOST_ARCH=x86;;
x86_64|amd64) HOST_ARCH=x86_64;;
esac
echo "${HOST_OS}-${HOST_ARCH}"
}
get_cmake_target_processor() {
case ${ARCH} in
arm-v7a | arm-v7a-neon)
@@ -150,11 +126,7 @@ get_target_build() {
echo "arm"
;;
arm-v7a-neon)
if [[ ! -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then
echo "arm/neon"
else
echo "arm"
fi
echo "arm/neon"
;;
arm64-v8a)
echo "arm64"
@@ -203,89 +175,67 @@ get_android_arch() {
}
get_common_includes() {
echo "-I${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot/usr/include -I${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot/usr/local/include"
echo "-I${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot/usr/include -I${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot/usr/local/include"
}
get_common_cflags() {
if [[ ! -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then
local LTS_BUILD__FLAG="-DMOBILE_FFMPEG_LTS "
fi
echo "-fstrict-aliasing -fPIC -DANDROID ${LTS_BUILD__FLAG}-D__ANDROID__ -D__ANDROID_API__=${API}"
echo "-fstrict-aliasing -fPIC -DANDROID -D__ANDROID__ -D__ANDROID_API__=${API}"
}
get_arch_specific_cflags() {
case ${ARCH} in
arm-v7a)
echo "-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp -DMOBILE_FFMPEG_ARM_V7A"
echo "-march=armv7-a -mfpu=vfpv3-d16 -mfloat-abi=softfp"
;;
arm-v7a-neon)
echo "-march=armv7-a -mfpu=neon -mfloat-abi=softfp -DMOBILE_FFMPEG_ARM_V7A_NEON"
echo "-march=armv7-a -mfpu=neon -mfloat-abi=softfp"
;;
arm64-v8a)
echo "-march=armv8-a -DMOBILE_FFMPEG_ARM64_V8A"
echo "-march=armv8-a"
;;
x86)
echo "-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32 -DMOBILE_FFMPEG_X86"
echo "-march=i686 -mtune=intel -mssse3 -mfpmath=sse -m32"
;;
x86-64)
echo "-march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -DMOBILE_FFMPEG_X86_64"
echo "-march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel"
;;
esac
}
get_size_optimization_cflags() {
local ARCH_OPTIMIZATION=""
ARCH_OPTIMIZATION=""
case ${ARCH} in
arm-v7a | arm-v7a-neon)
case $1 in
ffmpeg)
ARCH_OPTIMIZATION="-flto -O2 -ffunction-sections -fdata-sections"
;;
*)
ARCH_OPTIMIZATION="-Os -ffunction-sections -fdata-sections"
;;
esac
;;
arm64-v8a)
case $1 in
ffmpeg | nettle)
ARCH_OPTIMIZATION="-flto -fuse-ld=gold -O2 -ffunction-sections -fdata-sections"
;;
*)
ARCH_OPTIMIZATION="-Os -ffunction-sections -fdata-sections"
;;
esac
arm-v7a | arm-v7a-neon | arm64-v8a)
if [[ $1 -eq libwebp ]]; then
ARCH_OPTIMIZATION="-Os"
else
ARCH_OPTIMIZATION="-Os -finline-limit=64"
fi
;;
x86 | x86-64)
case $1 in
ffmpeg)
ARCH_OPTIMIZATION="-flto -Os -ffunction-sections -fdata-sections"
;;
*)
ARCH_OPTIMIZATION="-Os -ffunction-sections -fdata-sections"
;;
esac
if [[ $1 -eq libvpx ]]; then
ARCH_OPTIMIZATION="-O2"
else
ARCH_OPTIMIZATION="-O2 -finline-limit=300"
fi
;;
esac
local LIB_OPTIMIZATION=""
LIB_OPTIMIZATION=""
echo "${ARCH_OPTIMIZATION} ${LIB_OPTIMIZATION}"
}
get_app_specific_cflags() {
local APP_FLAGS=""
APP_FLAGS=""
case $1 in
xvidcore)
APP_FLAGS=""
;;
ffmpeg)
APP_FLAGS="-Wno-unused-function -DBIONIC_IOCTL_NO_SIGNEDNESS_OVERLOAD"
;;
shine)
ffmpeg | shine)
APP_FLAGS="-Wno-unused-function"
;;
soxr | snappy | libwebp)
@@ -303,66 +253,42 @@ get_app_specific_cflags() {
}
get_cflags() {
local ARCH_FLAGS=$(get_arch_specific_cflags)
local APP_FLAGS=$(get_app_specific_cflags $1)
local COMMON_FLAGS=$(get_common_cflags)
if [[ -z ${MOBILE_FFMPEG_DEBUG} ]]; then
local OPTIMIZATION_FLAGS=$(get_size_optimization_cflags $1)
else
local OPTIMIZATION_FLAGS="${MOBILE_FFMPEG_DEBUG}"
fi
local COMMON_INCLUDES=$(get_common_includes)
ARCH_FLAGS=$(get_arch_specific_cflags)
APP_FLAGS=$(get_app_specific_cflags $1)
COMMON_FLAGS=$(get_common_cflags)
OPTIMIZATION_FLAGS=$(get_size_optimization_cflags $1)
COMMON_INCLUDES=$(get_common_includes)
echo "${ARCH_FLAGS} ${APP_FLAGS} ${COMMON_FLAGS} ${OPTIMIZATION_FLAGS} ${COMMON_INCLUDES}"
}
get_cxxflags() {
if [[ -z ${MOBILE_FFMPEG_DEBUG} ]]; then
local OPTIMIZATION_FLAGS="-Os -ffunction-sections -fdata-sections"
else
local OPTIMIZATION_FLAGS="${MOBILE_FFMPEG_DEBUG}"
fi
case $1 in
gnutls)
echo "-std=c++11 -fno-rtti ${OPTIMIZATION_FLAGS}"
;;
ffmpeg)
if [[ -z ${MOBILE_FFMPEG_DEBUG} ]]; then
echo "-std=c++11 -fno-exceptions -fno-rtti -flto -O2 -ffunction-sections -fdata-sections"
else
echo "-std=c++11 -fno-exceptions -fno-rtti ${MOBILE_FFMPEG_DEBUG}"
fi
echo "-std=c++11 -fno-rtti"
;;
opencore-amr)
echo "${OPTIMIZATION_FLAGS}"
echo ""
;;
x265)
echo "-std=c++11 -fno-exceptions ${OPTIMIZATION_FLAGS}"
echo "-std=c++11 -fno-exceptions"
;;
*)
echo "-std=c++11 -fno-exceptions -fno-rtti ${OPTIMIZATION_FLAGS}"
echo "-std=c++11 -fno-exceptions -fno-rtti"
;;
esac
}
get_common_linked_libraries() {
local COMMON_LIBRARY_PATHS="-L${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/${TARGET_HOST}/lib -L${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot/usr/lib/${TARGET_HOST}/${API} -L${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/lib"
local COMMON_LIBRARY_PATHS="-L${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/${TARGET_HOST}/lib -L${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot/usr/lib -L${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/lib"
case $1 in
ffmpeg)
if [[ -z ${MOBILE_FFMPEG_LTS_BUILD} ]]; then
echo "-lc -lm -ldl -llog -lcamera2ndk -lmediandk ${COMMON_LIBRARY_PATHS}"
else
echo "-lc -lm -ldl -llog ${COMMON_LIBRARY_PATHS}"
fi
echo "-lc -lm -ldl -llog -lc++_shared ${COMMON_LIBRARY_PATHS}"
;;
libvpx)
echo "-lc -lm ${COMMON_LIBRARY_PATHS}"
;;
tesseract | x265)
echo "-lc -lm -ldl -llog -lc++_shared ${COMMON_LIBRARY_PATHS}"
;;
*)
echo "-lc -lm -ldl -llog ${COMMON_LIBRARY_PATHS}"
;;
@@ -372,24 +298,10 @@ get_common_linked_libraries() {
get_size_optimization_ldflags() {
case ${ARCH} in
arm64-v8a)
case $1 in
ffmpeg | nettle)
echo "-Wl,--gc-sections -flto -fuse-ld=gold -O2 -ffunction-sections -fdata-sections -finline-functions"
;;
*)
echo "-Wl,--gc-sections -Os -ffunction-sections -fdata-sections"
;;
esac
echo "-Wl,--gc-sections"
;;
*)
case $1 in
ffmpeg)
echo "-Wl,--gc-sections,--icf=safe -flto -O2 -ffunction-sections -fdata-sections -finline-functions"
;;
*)
echo "-Wl,--gc-sections,--icf=safe -Os -ffunction-sections -fdata-sections"
;;
esac
echo "-Wl,--gc-sections,--icf=safe"
;;
esac
}
@@ -415,13 +327,9 @@ get_arch_specific_ldflags() {
}
get_ldflags() {
local ARCH_FLAGS=$(get_arch_specific_ldflags)
if [[ -z ${MOBILE_FFMPEG_DEBUG} ]]; then
local OPTIMIZATION_FLAGS="$(get_size_optimization_ldflags $1)"
else
local OPTIMIZATION_FLAGS="${MOBILE_FFMPEG_DEBUG}"
fi
local COMMON_LINKED_LIBS=$(get_common_linked_libraries $1)
ARCH_FLAGS=$(get_arch_specific_ldflags)
OPTIMIZATION_FLAGS=$(get_size_optimization_ldflags)
COMMON_LINKED_LIBS=$(get_common_linked_libraries $1)
echo "${ARCH_FLAGS} ${OPTIMIZATION_FLAGS} ${COMMON_LINKED_LIBS}"
}
@@ -558,7 +466,7 @@ libdir=\${prefix}/lib
includedir=\${prefix}/include
Name: aom
Description: AV1 codec library v${AOM_VERSION}.
Description: AV1 codec library v0.1.0.
Version: ${AOM_VERSION}
Requires:
@@ -733,29 +641,6 @@ Cflags: -I\${includedir}
EOF
}
create_tesseract_package_config() {
local TESSERACT_VERSION="$1"
cat > "${INSTALL_PKG_CONFIG_DIR}/tesseract.pc" << EOF
prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/tesseract
exec_prefix=\${prefix}
bindir=\${exec_prefix}/bin
datarootdir=\${prefix}/share
datadir=\${datarootdir}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include
Name: tesseract
Description: An OCR Engine that was developed at HP Labs between 1985 and 1995... and now at Google.
URL: https://github.com/tesseract-ocr/tesseract
Version: ${TESSERACT_VERSION}
Requires: lept, libjpeg, libpng, giflib, zlib, libwebp, libtiff-4
Libs: -L\${libdir} -ltesseract -lc++_shared
Cflags: -I\${includedir}
EOF
}
create_uuid_package_config() {
local UUID_VERSION="$1"
@@ -789,7 +674,7 @@ Version: ${X265_VERSION}
Requires:
Libs: -L\${libdir} -lx265
Libs.private: -lm -lgcc -lgcc -ldl -lgcc -lgcc -ldl -lc++_shared
Libs.private: -lm -lgcc -lgcc -ldl -lgcc -lgcc -ldl
Cflags: -I\${includedir}
EOF
}
@@ -814,10 +699,10 @@ EOF
}
create_zlib_package_config() {
ZLIB_VERSION=$(grep '#define ZLIB_VERSION' ${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot/usr/include/zlib.h | grep -Eo '\".*\"' | sed -e 's/\"//g')
ZLIB_VERSION=$(grep '#define ZLIB_VERSION' ${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot/usr/include/zlib.h | grep -Eo '\".*\"' | sed -e 's/\"//g')
cat > "${INSTALL_PKG_CONFIG_DIR}/zlib.pc" << EOF
prefix=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot/usr
prefix=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot/usr
exec_prefix=\${prefix}
libdir=${ANDROID_NDK_ROOT}/platforms/android-${API}/arch-${TOOLCHAIN_ARCH}/usr/lib
includedir=\${prefix}/include
@@ -895,15 +780,15 @@ download_gpl_library_source() {
GPL_LIB_DEST_DIR="libvidstab"
;;
x264)
GPL_LIB_URL="ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20190328-2245-stable.tar.bz2"
GPL_LIB_FILE="x264-snapshot-20190328-2245-stable.tar.bz2"
GPL_LIB_ORIG_DIR="x264-snapshot-20190328-2245-stable"
GPL_LIB_URL="ftp://ftp.videolan.org/pub/videolan/x264/snapshots/x264-snapshot-20181107-2245-stable.tar.bz2"
GPL_LIB_FILE="x264-snapshot-20181107-2245-stable.tar.bz2"
GPL_LIB_ORIG_DIR="x264-snapshot-20181107-2245-stable"
GPL_LIB_DEST_DIR="x264"
;;
x265)
GPL_LIB_URL="https://download.videolan.org/pub/videolan/x265/x265_3.0.tar.gz"
GPL_LIB_FILE="x265-3.0.tar.gz"
GPL_LIB_ORIG_DIR="x265_3.0"
GPL_LIB_URL="https://download.videolan.org/pub/videolan/x265/x265_2.9.tar.gz"
GPL_LIB_FILE="x265-2.9.tar.gz"
GPL_LIB_ORIG_DIR="x265_2.9"
GPL_LIB_DEST_DIR="x265"
;;
xvidcore)
@@ -983,13 +868,13 @@ download_gpl_library_source() {
}
set_toolchain_clang_paths() {
export PATH=$PATH:${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin
export PATH=$PATH:${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin
TARGET_HOST=$(get_target_host)
export AR=${TARGET_HOST}-ar
export CC=$(get_clang_target_host)-clang
export CXX=$(get_clang_target_host)-clang++
export CC=${TARGET_HOST}-clang
export CXX=${TARGET_HOST}-clang++
if [ "$1" == "x264" ]; then
export AS=${CC}
@@ -997,12 +882,6 @@ set_toolchain_clang_paths() {
export AS=${TARGET_HOST}-as
fi
case ${ARCH} in
arm64-v8a)
export ac_cv_c_bigendian=no
;;
esac
export LD=${TARGET_HOST}-ld
export RANLIB=${TARGET_HOST}-ranlib
export STRIP=${TARGET_HOST}-strip
@@ -1021,6 +900,47 @@ set_toolchain_clang_paths() {
prepare_inline_sed
}
set_toolchain_gcc_paths() {
export PATH=$PATH:${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin
TARGET_HOST=$(get_target_host)
export AR=${TARGET_HOST}-ar
export CC=${TARGET_HOST}-gcc
export CXX=${TARGET_HOST}-g++
if [ "$1" == "x264" ]; then
export AS=${CC}
else
export AS=${TARGET_HOST}-as
fi
export LD=${TARGET_HOST}-ld
export RANLIB=${TARGET_HOST}-ranlib
export STRIP=${TARGET_HOST}-strip
export INSTALL_PKG_CONFIG_DIR="${BASEDIR}/prebuilt/android-$(get_target_build)/pkgconfig"
export ZLIB_PACKAGE_CONFIG_PATH="${INSTALL_PKG_CONFIG_DIR}/zlib.pc"
if [ ! -d ${INSTALL_PKG_CONFIG_DIR} ]; then
mkdir -p ${INSTALL_PKG_CONFIG_DIR}
fi
if [ ! -f ${ZLIB_PACKAGE_CONFIG_PATH} ]; then
create_zlib_package_config
fi
prepare_inline_sed
}
create_toolchain() {
local TOOLCHAIN_DIR="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-"${TOOLCHAIN}
if [ ! -d ${TOOLCHAIN_DIR} ]; then
${ANDROID_NDK_ROOT}/build/tools/make_standalone_toolchain.py --arch ${TOOLCHAIN_ARCH} --api ${API} --stl libc++ --install-dir ${TOOLCHAIN_DIR} || exit 1
fi
}
build_cpufeatures() {
# CLEAN OLD BUILD
@@ -1033,9 +953,9 @@ build_cpufeatures() {
echo -e "\nINFO: Building cpu-features for for ${ARCH}\n" 1>>${BASEDIR}/build.log 2>&1
# THEN BUILD FOR THIS ABI
$(get_clang_target_host)-clang -c ${ANDROID_NDK_ROOT}/sources/android/cpufeatures/cpu-features.c -o ${ANDROID_NDK_ROOT}/sources/android/cpufeatures/cpu-features.o 1>>${BASEDIR}/build.log 2>&1
${TARGET_HOST}-clang -c ${ANDROID_NDK_ROOT}/sources/android/cpufeatures/cpu-features.c -o ${ANDROID_NDK_ROOT}/sources/android/cpufeatures/cpu-features.o 1>>${BASEDIR}/build.log 2>&1
${TARGET_HOST}-ar rcs ${ANDROID_NDK_ROOT}/sources/android/cpufeatures/libcpufeatures.a ${ANDROID_NDK_ROOT}/sources/android/cpufeatures/cpu-features.o 1>>${BASEDIR}/build.log 2>&1
$(get_clang_target_host)-clang -shared ${ANDROID_NDK_ROOT}/sources/android/cpufeatures/cpu-features.o -o ${ANDROID_NDK_ROOT}/sources/android/cpufeatures/libcpufeatures.so 1>>${BASEDIR}/build.log 2>&1
${TARGET_HOST}-clang -shared ${ANDROID_NDK_ROOT}/sources/android/cpufeatures/cpu-features.o -o ${ANDROID_NDK_ROOT}/sources/android/cpufeatures/libcpufeatures.so 1>>${BASEDIR}/build.log 2>&1
create_cpufeatures_package_config
}
+2 -2
View File
@@ -45,7 +45,7 @@ fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--without-docbook \
--without-xmlwf \
--enable-static \
@@ -53,7 +53,7 @@ fi
--disable-fast-install \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# MANUALLY COPY PKG-CONFIG FILES
cp ./expat.pc ${INSTALL_PKG_CONFIG_DIR}
+11 -56
View File
@@ -74,9 +74,8 @@ case ${ARCH} in
esac
CONFIGURE_POSTFIX=""
HIGH_PRIORITY_INCLUDES=""
for library in {1..43}
for library in {1..38}
do
if [[ ${!library} -eq 1 ]]; then
ENABLED_LIBRARY=$(get_library_name $((library - 1)))
@@ -138,7 +137,6 @@ do
CFLAGS+=" $(pkg-config --cflags libiconv)"
LDFLAGS+=" $(pkg-config --libs --static libiconv)"
CONFIGURE_POSTFIX+=" --enable-iconv"
HIGH_PRIORITY_INCLUDES+=" $(pkg-config --cflags libiconv)"
;;
libilbc)
CFLAGS+=" $(pkg-config --cflags libilbc)"
@@ -194,11 +192,6 @@ do
LDFLAGS+=" $(pkg-config --libs --static shine)"
CONFIGURE_POSTFIX+=" --enable-libshine"
;;
sdl)
CFLAGS+=" $(pkg-config --cflags sdl2)"
LDFLAGS+=" $(pkg-config --libs --static sdl2)"
CONFIGURE_POSTFIX+=" --enable-sdl2"
;;
snappy)
CFLAGS+=" $(pkg-config --cflags snappy)"
LDFLAGS+=" $(pkg-config --libs --static snappy)"
@@ -214,18 +207,6 @@ do
LDFLAGS+=" $(pkg-config --libs --static speex)"
CONFIGURE_POSTFIX+=" --enable-libspeex"
;;
tesseract)
CFLAGS+=" $(pkg-config --cflags tesseract)"
LDFLAGS+=" $(pkg-config --libs --static tesseract)"
CFLAGS+=" $(pkg-config --cflags giflib)"
LDFLAGS+=" $(pkg-config --libs --static giflib)"
CONFIGURE_POSTFIX+=" --enable-libtesseract"
;;
twolame)
CFLAGS+=" $(pkg-config --cflags twolame)"
LDFLAGS+=" $(pkg-config --libs --static twolame)"
CONFIGURE_POSTFIX+=" --enable-libtwolame"
;;
wavpack)
CFLAGS+=" $(pkg-config --cflags wavpack)"
LDFLAGS+=" $(pkg-config --libs --static wavpack)"
@@ -280,9 +261,7 @@ do
else
# THE FOLLOWING LIBRARIES SHOULD BE EXPLICITLY DISABLED TO PREVENT AUTODETECT
if [[ ${library} -eq 30 ]]; then
CONFIGURE_POSTFIX+=" --disable-sdl2"
elif [[ ${library} -eq 42 ]]; then
if [[ ${library} -eq 37 ]]; then
CONFIGURE_POSTFIX+=" --disable-zlib"
fi
fi
@@ -290,60 +269,35 @@ done
LDFLAGS+=" -L${ANDROID_NDK_ROOT}/platforms/android-${API}/arch-${TOOLCHAIN_ARCH}/usr/lib"
# OPTIMIZE FOR SPEED INSTEAD OF SIZE
if [[ -z ${MOBILE_FFMPEG_OPTIMIZED_FOR_SPEED} ]]; then
SIZE_OPTIONS="--enable-small";
else
SIZE_OPTIONS="";
fi
# SET DEBUG OPTIONS
if [[ -z ${MOBILE_FFMPEG_DEBUG} ]]; then
DEBUG_OPTIONS="--disable-debug --enable-lto";
else
DEBUG_OPTIONS="--enable-debug";
fi
cd ${BASEDIR}/src/${LIB_NAME} || exit 1
echo -n -e "\n${LIB_NAME}: "
make distclean 2>/dev/null 1>/dev/null
export CFLAGS="${HIGH_PRIORITY_INCLUDES} ${CFLAGS}"
export CXXFLAGS="${CXXFLAGS}"
export LDFLAGS="${LDFLAGS}"
# USE HIGHER LIMITS FOR FFMPEG LINKING
ulimit -n 2048 1>>${BASEDIR}/build.log 2>&1
./configure \
--cross-prefix="${TARGET_HOST}-" \
--sysroot="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot" \
--sysroot="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot" \
--prefix="${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME}" \
--pkg-config="${HOST_PKG_CONFIG_PATH}" \
--extra-cflags="${CFLAGS}" \
--extra-cxxflags="${CXXFLAGS}" \
--extra-ldflags="${LDFLAGS}" \
--enable-version3 \
--arch="${TARGET_ARCH}" \
--cpu="${TARGET_CPU}" \
--cc="${CC}" \
--cxx="${CXX}" \
--target-os=android \
${ASM_FLAGS} \
--enable-cross-compile \
--enable-pic \
--enable-jni \
--enable-optimizations \
--enable-small \
--enable-swscale \
--enable-shared \
--disable-v4l2-m2m \
--disable-outdev=v4l2 \
--disable-outdev=fbdev \
--disable-indev=v4l2 \
--disable-indev=fbdev \
${SIZE_OPTIONS} \
--disable-openssl \
--disable-xmm-clobber-test \
${DEBUG_OPTIONS} \
--disable-debug \
--disable-neon-clobber-test \
--disable-programs \
--disable-postproc \
@@ -355,6 +309,7 @@ ulimit -n 2048 1>>${BASEDIR}/build.log 2>&1
--disable-static \
--disable-sndio \
--disable-schannel \
--disable-sdl2 \
--disable-securetransport \
--disable-xlib \
--disable-cuda \
@@ -363,7 +318,6 @@ ulimit -n 2048 1>>${BASEDIR}/build.log 2>&1
--disable-vaapi \
--disable-vdpau \
--disable-videotoolbox \
--disable-audiotoolbox \
--disable-appkit \
--disable-alsa \
--disable-cuda \
@@ -371,6 +325,7 @@ ulimit -n 2048 1>>${BASEDIR}/build.log 2>&1
--disable-nvenc \
--disable-vaapi \
--disable-vdpau \
--disable-videotoolbox \
${CONFIGURE_POSTFIX} 1>>${BASEDIR}/build.log 2>&1
if [ $? -ne 0 ]; then
@@ -378,7 +333,7 @@ if [ $? -ne 0 ]; then
exit 1
fi
make -j$(get_cpu_count) 1>>${BASEDIR}/build.log 2>&1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) 1>>${BASEDIR}/build.log 2>&1
if [ $? -ne 0 ]; then
echo "failed"
+1 -1
View File
@@ -57,7 +57,7 @@ fi
--disable-docs \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# CREATE PACKAGE CONFIG MANUALLY
create_fontconfig_package_config "2.13.1"
+3 -3
View File
@@ -47,7 +47,7 @@ export LIBPNG_LIBS="-L${BASEDIR}/prebuilt/android-$(get_target_build)/libpng/lib
--with-pic \
--with-zlib \
--with-png \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--without-harfbuzz \
--without-bzip2 \
--without-fsref \
@@ -60,9 +60,9 @@ export LIBPNG_LIBS="-L${BASEDIR}/prebuilt/android-$(get_target_build)/libpng/lib
--disable-mmap \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# CREATE PACKAGE CONFIG MANUALLY
create_freetype_package_config "23.0.17"
create_freetype_package_config "22.0.16"
make install || exit 1
+2 -2
View File
@@ -46,7 +46,7 @@ fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--enable-static \
--disable-shared \
--disable-fast-install \
@@ -54,7 +54,7 @@ fi
--disable-deprecated \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# MANUALLY COPY PKG-CONFIG FILES
cp ./*.pc ${INSTALL_PKG_CONFIG_DIR}
+2 -2
View File
@@ -46,13 +46,13 @@ fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--enable-static \
--disable-shared \
--disable-fast-install \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# CREATE PACKAGE CONFIG MANUALLY
create_giflib_package_config "5.1.4"
+2 -2
View File
@@ -45,7 +45,7 @@ fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--enable-static \
--disable-assembly \
--disable-shared \
@@ -53,7 +53,7 @@ fi
--disable-maintainer-mode \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# CREATE PACKAGE CONFIG MANUALLY
create_gmp_package_config "6.1.2"
+2 -2
View File
@@ -56,7 +56,7 @@ fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--with-included-libtasn1 \
--with-included-unistring \
--without-idn \
@@ -75,7 +75,7 @@ fi
--disable-maintainer-mode \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# CREATE PACKAGE CONFIG MANUALLY
create_gnutls_package_config "3.5.19"
+11 -11
View File
@@ -47,26 +47,26 @@ cmake -Wno-dev \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
-DCMAKE_SYSROOT="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot" \
-DCMAKE_FIND_ROOT_PATH="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot" \
-DCMAKE_SYSROOT="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot" \
-DCMAKE_FIND_ROOT_PATH="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME}" \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CC" \
-DCMAKE_CXX_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CXX" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AS" \
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$CC" \
-DCMAKE_CXX_COMPILER="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$CXX" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$AS" \
-DENABLE_PIC=1 \
-DENABLE_STATIC=1 \
-DENABLE_SHARED=0 \
-DWITH_JPEG8=1 \
-DWITH_SIMD=1 \
-DWITH_TURBOJPEG=0 \
-DWITH_JAVA=0 \
-DCMAKE_SYSTEM_PROCESSOR=$(get_cmake_target_processor) .. || exit 1
-DCMAKE_SYSTEM_PROCESSOR=$(get_cmake_target_processor) \
-DENABLE_SHARED=0 .. || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# MANUALLY COPY PKG-CONFIG FILES
cp ${BASEDIR}/src/${LIB_NAME}/build/pkgscripts/libjpeg.pc ${INSTALL_PKG_CONFIG_DIR}
+2 -2
View File
@@ -46,13 +46,13 @@ fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--enable-static \
--disable-shared \
--disable-fast-install \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# MANUALLY COPY PKG-CONFIG FILES
cp ./src/kvazaar.pc ${INSTALL_PKG_CONFIG_DIR}
+2 -2
View File
@@ -46,7 +46,7 @@ fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--with-libiconv-prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/libiconv \
--enable-static \
--disable-shared \
@@ -57,7 +57,7 @@ fi
--disable-gtktest \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# CREATE PACKAGE CONFIG MANUALLY
create_libmp3lame_package_config "3.100"
-82
View File
@@ -1,82 +0,0 @@
#!/bin/bash
if [[ -z ${ANDROID_NDK_ROOT} ]]; then
echo -e "(*) ANDROID_NDK_ROOT not defined\n"
exit 1
fi
if [[ -z ${ARCH} ]]; then
echo -e "(*) ARCH not defined\n"
exit 1
fi
if [[ -z ${API} ]]; then
echo -e "(*) API not defined\n"
exit 1
fi
if [[ -z ${BASEDIR} ]]; then
echo -e "(*) BASEDIR not defined\n"
exit 1
fi
# ENABLE COMMON FUNCTIONS
. ${BASEDIR}/build/android-common.sh
# PREPARING PATHS & DEFINING ${INSTALL_PKG_CONFIG_DIR}
LIB_NAME="leptonica"
set_toolchain_clang_paths ${LIB_NAME}
# PREPARING FLAGS
TARGET_HOST=$(get_target_host)
export CFLAGS=$(get_cflags ${LIB_NAME})
export CXXFLAGS=$(get_cxxflags ${LIB_NAME})
export CPPFLAGS="-I${BASEDIR}/prebuilt/android-$(get_target_build)/giflib/include"
export LDFLAGS="$(get_ldflags ${LIB_NAME}) -L${BASEDIR}/prebuilt/android-$(get_target_build)/giflib/lib -lgif"
export PKG_CONFIG_LIBDIR="${INSTALL_PKG_CONFIG_DIR}"
export LIBPNG_CFLAGS="$(pkg-config --cflags libpng)"
export LIBPNG_LIBS="$(pkg-config --libs --static libpng)"
export LIBWEBP_CFLAGS="$(pkg-config --cflags libwebp)"
export LIBWEBP_LIBS="$(pkg-config --libs --static libwebp)"
export LIBTIFF_CFLAGS="$(pkg-config --cflags libtiff-4)"
export LIBTIFF_LIBS="$(pkg-config --libs --static libtiff-4)"
export ZLIB_CFLAGS="$(pkg-config --cflags zlib)"
export ZLIB_LIBS="$(pkg-config --libs --static zlib)"
export JPEG_CFLAGS="$(pkg-config --cflags libjpeg)"
export JPEG_LIBS="$(pkg-config --libs --static libjpeg)"
cd ${BASEDIR}/src/${LIB_NAME} || exit 1
make distclean 2>/dev/null 1>/dev/null
# RECONFIGURING IF REQUESTED
if [[ ${RECONF_leptonica} -eq 1 ]]; then
autoreconf_library ${LIB_NAME}
fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-zlib \
--with-libpng \
--with-jpeg \
--with-giflib \
--with-libtiff \
--with-libwebp \
--enable-static \
--disable-shared \
--disable-fast-install \
--disable-programs \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
# MANUALLY COPY PKG-CONFIG FILES
cp lept.pc ${INSTALL_PKG_CONFIG_DIR}
make install || exit 1
+9 -10
View File
@@ -67,17 +67,16 @@ cmake -Wno-dev \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
-DCMAKE_SYSROOT="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot" \
-DCMAKE_FIND_ROOT_PATH="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot" \
-DCMAKE_SYSROOT="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot" \
-DCMAKE_FIND_ROOT_PATH="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_INSTALL_PREFIX="${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME}" \
-DCMAKE_CXX_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CXX" \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AS" \
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
-DCMAKE_CXX_COMPILER="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$CXX" \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$AS" \
${ARCH_OPTIONS} \
-DENABLE_TESTS=0 \
-DENABLE_EXAMPLES=0 \
@@ -86,9 +85,9 @@ cmake -Wno-dev \
-DAOM_TARGET_CPU=generic \
-DBUILD_SHARED_LIBS=0 .. || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# CREATE PACKAGE CONFIG MANUALLY
create_libaom_package_config "1.0.0"
create_libaom_package_config "0.1.0"
make install || exit 1
+2 -2
View File
@@ -59,7 +59,7 @@ esac
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--disable-libtool-lock \
--enable-static \
--disable-shared \
@@ -71,7 +71,7 @@ esac
${ASM_FLAGS} \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# MANUALLY COPY PKG-CONFIG FILES
cp ./*.pc ${INSTALL_PKG_CONFIG_DIR}
+2 -2
View File
@@ -45,14 +45,14 @@ fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--enable-static \
--disable-shared \
--disable-fast-install \
--disable-rpath \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# CREATE PACKAGE CONFIG MANUALLY
create_libiconv_package_config "1.15"
+2 -2
View File
@@ -45,13 +45,13 @@ fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--enable-static \
--disable-shared \
--disable-fast-install \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# MANUALLY COPY PKG-CONFIG FILES
cp ./libilbc.pc ${INSTALL_PKG_CONFIG_DIR}
+2 -2
View File
@@ -45,13 +45,13 @@ fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--enable-static \
--disable-shared \
--disable-fast-install \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# MANUALLY COPY PKG-CONFIG FILES
cp ogg.pc ${INSTALL_PKG_CONFIG_DIR}
+2 -2
View File
@@ -61,7 +61,7 @@ fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--enable-static \
--disable-shared \
--disable-fast-install \
@@ -70,7 +70,7 @@ fi
${CPU_SPECIFIC_OPTIONS} \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# MANUALLY COPY PKG-CONFIG FILES
cp ./*.pc ${INSTALL_PKG_CONFIG_DIR}
-63
View File
@@ -1,63 +0,0 @@
#!/bin/bash
if [[ -z ${ANDROID_NDK_ROOT} ]]; then
echo -e "(*) ANDROID_NDK_ROOT not defined\n"
exit 1
fi
if [[ -z ${ARCH} ]]; then
echo -e "(*) ARCH not defined\n"
exit 1
fi
if [[ -z ${API} ]]; then
echo -e "(*) API not defined\n"
exit 1
fi
if [[ -z ${BASEDIR} ]]; then
echo -e "(*) BASEDIR not defined\n"
exit 1
fi
# ENABLE COMMON FUNCTIONS
. ${BASEDIR}/build/android-common.sh
# PREPARING PATHS & DEFINING ${INSTALL_PKG_CONFIG_DIR}
LIB_NAME="libsndfile"
set_toolchain_clang_paths ${LIB_NAME}
# PREPARING FLAGS
TARGET_HOST=$(get_target_host)
export CFLAGS=$(get_cflags ${LIB_NAME})
export CXXFLAGS=$(get_cxxflags ${LIB_NAME})
export LDFLAGS=$(get_ldflags ${LIB_NAME})
export PKG_CONFIG_LIBDIR="${INSTALL_PKG_CONFIG_DIR}"
cd ${BASEDIR}/src/${LIB_NAME} || exit 1
make distclean 2>/dev/null 1>/dev/null
if [[ ! -f ${BASEDIR}/src/${LIB_NAME}/configure ]] || [[ ${RECONF_libsndfile} -eq 1 ]]; then
autoreconf_library ${LIB_NAME}
fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--enable-static \
--disable-shared \
--disable-fast-install \
--disable-sqlite \
--disable-alsa \
--disable-full-suite \
--disable-external-libs \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
# MANUALLY COPY PKG-CONFIG FILES
cp ./*.pc ${INSTALL_PKG_CONFIG_DIR}
make install || exit 1
+1 -1
View File
@@ -55,7 +55,7 @@ fi
--disable-valgrind-testing \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# MANUALLY COPY PKG-CONFIG FILES
cp theoradec.pc ${INSTALL_PKG_CONFIG_DIR}
+2 -2
View File
@@ -45,13 +45,13 @@ fi
./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--enable-static \
--disable-shared \
--disable-fast-install \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# AUTO-GENERATED PKG-CONFIG FILE IS WRONG. CREATING IT MANUALLY
create_uuid_package_config "1.0.3"
+7 -8
View File
@@ -57,22 +57,21 @@ cmake -Wno-dev \
-DCMAKE_C_FLAGS="${CFLAGS}" \
-DCMAKE_CXX_FLAGS="${CXXFLAGS}" \
-DCMAKE_EXE_LINKER_FLAGS="${LDFLAGS}" \
-DCMAKE_SYSROOT="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot" \
-DCMAKE_FIND_ROOT_PATH="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot" \
-DCMAKE_SYSROOT="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot" \
-DCMAKE_FIND_ROOT_PATH="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot" \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX="${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME}" \
-DCMAKE_SYSTEM_NAME=Generic \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/bin/$AS" \
-DCMAKE_POSITION_INDEPENDENT_CODE=1 \
-DCMAKE_C_COMPILER="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$CC" \
-DCMAKE_LINKER="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$LD" \
-DCMAKE_AR="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$AR" \
-DCMAKE_AS="${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/bin/$AS" \
-DUSE_OMP=0 \
${ASM_FLAGS} \
-DCMAKE_SYSTEM_PROCESSOR=$(get_cmake_target_processor) \
-DBUILD_SHARED_LIBS=0 .. || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# MANUALLY COPY PKG-CONFIG FILES
cp vidstab.pc ${INSTALL_PKG_CONFIG_DIR}
+8 -9
View File
@@ -25,7 +25,7 @@ fi
# PREPARING PATHS & DEFINING ${INSTALL_PKG_CONFIG_DIR}
LIB_NAME="libvorbis"
set_toolchain_clang_paths ${LIB_NAME}
set_toolchain_gcc_paths ${LIB_NAME}
# PREPARING FLAGS
TARGET_HOST=$(get_target_host)
@@ -37,16 +37,15 @@ cd ${BASEDIR}/src/${LIB_NAME} || exit 1
make distclean 2>/dev/null 1>/dev/null
# -mno-ieee-fp option is not compatible with clang. removing it
${SED_INLINE} 's/\-mno-ieee-fp//g' ${BASEDIR}/src/${LIB_NAME}/configure.ac
# RECONFIGURING IF REQUESTED
if [[ ${RECONF_libvorbis} -eq 1 ]]; then
autoreconf_library ${LIB_NAME}
fi
# ALWAYS RECONFIGURE
autoreconf_library ${LIB_NAME}
./configure \
PKG_CONFIG= ./configure \
--prefix=${BASEDIR}/prebuilt/android-$(get_target_build)/${LIB_NAME} \
--with-pic \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/${TOOLCHAIN}/sysroot \
--with-sysroot=${ANDROID_NDK_ROOT}/toolchains/mobile-ffmpeg-${TOOLCHAIN}/sysroot \
--with-ogg-includes=${BASEDIR}/prebuilt/android-$(get_target_build)/libogg/include \
--with-ogg-libraries=${BASEDIR}/prebuilt/android-$(get_target_build)/libogg/lib \
--enable-static \
@@ -57,7 +56,7 @@ autoreconf_library ${LIB_NAME}
--disable-oggtest \
--host=${TARGET_HOST} || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# CREATE PACKAGE CONFIG MANUALLY
create_libvorbis_package_config "1.3.6"
+1 -2
View File
@@ -80,7 +80,6 @@ make distclean 2>/dev/null 1>/dev/null
--enable-spatial-resampling \
--enable-small \
--enable-static \
--disable-realtime-only \
--disable-shared \
--disable-debug \
--disable-gprof \
@@ -99,7 +98,7 @@ make distclean 2>/dev/null 1>/dev/null
--disable-debug-libs \
--disable-internal-stats || exit 1
make -j$(get_cpu_count) || exit 1
make ${MOBILE_FFMPEG_DEBUG} -j$(get_cpu_count) || exit 1
# MANUALLY COPY PKG-CONFIG FILES
cp ./*.pc ${INSTALL_PKG_CONFIG_DIR}

Some files were not shown because too many files have changed in this diff Show More