Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 7e821df9a5 | |||
| ce7e8f55eb | |||
| 19ffadd640 |
@@ -1,3 +0,0 @@
|
||||
open_collective: mobile-ffmpeg
|
||||
patreon: tanersener
|
||||
custom: ['https://buymeacoff.ee/tanersener','https://paypal.me/teodosiyminchev']
|
||||
@@ -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.co) 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.
|
||||
@@ -1,136 +0,0 @@
|
||||
branches:
|
||||
only:
|
||||
- master
|
||||
- development
|
||||
sudo: false
|
||||
git:
|
||||
quiet: true
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- autoconf
|
||||
- automake
|
||||
- libtool
|
||||
- pkg-config
|
||||
- curl
|
||||
- git
|
||||
- cmake
|
||||
- gcc
|
||||
- gperf
|
||||
- texinfo
|
||||
- yasm
|
||||
- nasm
|
||||
- bison
|
||||
- autogen
|
||||
- patch
|
||||
homebrew:
|
||||
packages:
|
||||
- nasm
|
||||
update: true
|
||||
matrix:
|
||||
include:
|
||||
- name: "Android Main Build"
|
||||
language: android
|
||||
dist : trusty
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- platform-tools
|
||||
- build-tools-28.0.3
|
||||
- android-24
|
||||
- extra-google-google_play_services
|
||||
- extra-google-m2repository
|
||||
- extra-android-m2repository
|
||||
install:
|
||||
- echo y | sdkmanager "ndk-bundle"
|
||||
- echo y | sdkmanager "cmake;3.10.2.4988404"
|
||||
- echo y | sdkmanager "lldb;3.1"
|
||||
before_install:
|
||||
- touch $HOME/.android/repositories.cfg
|
||||
before_script:
|
||||
- export ANDROID_NDK_ROOT=$ANDROID_HOME/ndk-bundle
|
||||
- rm -f ./build.log
|
||||
after_success:
|
||||
- grep -e INFO ./build.log | grep build
|
||||
after_failure:
|
||||
- tail -30 ./build.log
|
||||
- tail -30 ./src/ffmpeg/ffbuild/config.log
|
||||
script:
|
||||
- bash ./android.sh --no-output-redirection
|
||||
- name: "Android LTS Build"
|
||||
language: android
|
||||
dist : trusty
|
||||
android:
|
||||
components:
|
||||
- tools
|
||||
- platform-tools
|
||||
- build-tools-28.0.3
|
||||
- android-16
|
||||
- android-21
|
||||
- extra-google-google_play_services
|
||||
- extra-google-m2repository
|
||||
- extra-android-m2repository
|
||||
install:
|
||||
- echo y | sdkmanager "ndk-bundle"
|
||||
- echo y | sdkmanager "cmake;3.10.2.4988404"
|
||||
- echo y | sdkmanager "lldb;3.1"
|
||||
before_install:
|
||||
- touch $HOME/.android/repositories.cfg
|
||||
before_script:
|
||||
- export ANDROID_NDK_ROOT=$ANDROID_HOME/ndk-bundle
|
||||
- rm -f ./build.log
|
||||
after_success:
|
||||
- grep -e INFO ./build.log | grep build
|
||||
after_failure:
|
||||
- tail -30 ./build.log
|
||||
- tail -30 ./src/ffmpeg/ffbuild/config.log
|
||||
script:
|
||||
- bash ./android.sh --lts --no-output-redirection
|
||||
- name: "iOS Main Build"
|
||||
language: objective-c
|
||||
osx_image: xcode10.2
|
||||
before_script:
|
||||
- rm -f ./build.log
|
||||
after_success:
|
||||
- grep -e INFO ./build.log | grep build
|
||||
after_failure:
|
||||
- tail -30 ./build.log
|
||||
- tail -30 ./src/ffmpeg/ffbuild/config.log
|
||||
script:
|
||||
- bash ./ios.sh --no-output-redirection
|
||||
- name: "iOS LTS Build"
|
||||
language: objective-c
|
||||
osx_image: xcode7.3
|
||||
before_script:
|
||||
- rm -f ./build.log
|
||||
after_success:
|
||||
- grep -e INFO ./build.log | grep build
|
||||
after_failure:
|
||||
- tail -30 ./build.log
|
||||
- tail -30 ./src/ffmpeg/ffbuild/config.log
|
||||
script:
|
||||
- bash ./ios.sh --lts --no-output-redirection
|
||||
- name: "tvOS Main Build"
|
||||
language: objective-c
|
||||
osx_image: xcode10.2
|
||||
before_script:
|
||||
- rm -f ./build.log
|
||||
after_success:
|
||||
- grep -e INFO ./build.log | grep build
|
||||
after_failure:
|
||||
- tail -30 ./build.log
|
||||
- tail -30 ./src/ffmpeg/ffbuild/config.log
|
||||
script:
|
||||
- bash ./tvos.sh --no-output-redirection
|
||||
- name: "tvOS LTS Build"
|
||||
language: objective-c
|
||||
osx_image: xcode7.3
|
||||
before_script:
|
||||
- rm -f ./build.log
|
||||
after_success:
|
||||
- grep -e INFO ./build.log | grep build
|
||||
after_failure:
|
||||
- tail -30 ./build.log
|
||||
- tail -30 ./src/ffmpeg/ffbuild/config.log
|
||||
script:
|
||||
- bash ./tvos.sh --lts --no-output-redirection
|
||||
@@ -1,65 +1,51 @@
|
||||
# MobileFFmpeg [](https://opencollective.com/mobile-ffmpeg)    [](https://travis-ci.org/tanersener/mobile-ffmpeg)
|
||||
# MobileFFmpeg [](https://gitter.im/mobile-ffmpeg/Lobby?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)   
|
||||
|
||||
FFmpeg for Android, iOS and tvOS
|
||||
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-v3.x/docs/assets/mobile-ffmpeg-logo-v7.png" width="320">
|
||||
|
||||
### 1. Features
|
||||
- Includes both `FFmpeg` and `FFprobe`
|
||||
- Use binaries available at `Github`/`JCenter`/`CocoaPods` or build your own version with external libraries you need
|
||||
- Supports
|
||||
- Android, iOS and tvOS
|
||||
- FFmpeg `v3.4.x`, `v4.0.x`, `v4.1`, `v4.2` and `v4.3-dev` releases
|
||||
- 28 external libraries
|
||||
- Both Android and IOS
|
||||
- FFmpeg `v3.4.x`, `v4.0.x` and `v4.1-dev-x` (master) releases
|
||||
- 27 external libraries
|
||||
|
||||
`chromaprint`, `fontconfig`, `freetype`, `fribidi`, `gmp`, `gnutls`, `kvazaar`, `lame`, `libaom`, `libass`, `libiconv`, `libilbc`, `libtheora`, `libvorbis`, `libvpx`, `libwebp`, `libxml2`, `opencore-amr`, `openh264`, `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`, `sdl`, `shine`, `snappy`, `soxr`, `speex`, `tesseract`, `twolame`, `wavpack`
|
||||
|
||||
- 4 external libraries with GPL license
|
||||
|
||||
`vid.stab`, `x264`, `x265`, `xvidcore`
|
||||
|
||||
- Concurrent execution
|
||||
|
||||
- Exposes both FFmpeg library and MobileFFmpeg wrapper library capabilities
|
||||
- Includes cross-compile instructions for 44 open-source libraries
|
||||
- Creates shared libraries (.so for Android, .dylib for IOS)
|
||||
- Includes cross-compile instructions for 43 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`, `openh264`, `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`, `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`
|
||||
|
||||
- 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)
|
||||
- Creates Android archive with .aar extension
|
||||
- Supports `API Level 16+`
|
||||
|
||||
#### 1.2 iOS
|
||||
- Builds `armv7`, `armv7s`, `arm64`, `arm64e`, `i386` and `x86_64` architectures
|
||||
- Supports `bzip2`, `zlib`, `iconv` system libraries and `AudioToolbox`, `CoreImage`, `VideoToolbox`, `AVFoundation` system frameworks
|
||||
- Objective-C API
|
||||
- Camera access
|
||||
#### 1.2 IOS
|
||||
- Builds `armv7`, `armv7s`, `arm64`, `i386` and `x86_64` architectures
|
||||
- Supports `bzip2`, `zlib` system libraries and `AudioToolbox`, `CoreImage`, `VideoToolbox`, `AVFoundation` system frameworks
|
||||
- `ARC` enabled library
|
||||
- Built with `-fembed-bitcode` flag
|
||||
- Creates static framework and static universal (fat) library (.a)
|
||||
- Supports `iOS SDK 9.3` or later
|
||||
|
||||
#### 1.3 tvOS
|
||||
- Builds `arm64` and `x86_64` architectures
|
||||
- Supports `bzip2`, `zlib`, `iconv` system libraries and `AudioToolbox`, `CoreImage`, `VideoToolbox` system frameworks
|
||||
- Objective-C API
|
||||
- `ARC` enabled library
|
||||
- Built with `-fembed-bitcode` flag
|
||||
- Creates static framework and static universal (fat) library (.a)
|
||||
- Supports `tvOS SDK 9.2` or later
|
||||
- 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
|
||||
Published binaries are available at [Github](https://github.com/tanersener/mobile-ffmpeg/releases), [JCenter](https://bintray.com/bintray/jcenter) and [CocoaPods](https://cocoapods.org).
|
||||
Binaries are available at [Github](https://github.com/tanersener/mobile-ffmpeg/releases), [JCenter](https://bintray.com/bintray/jcenter) and [CocoaPods](https://cocoapods.org).
|
||||
|
||||
There are eight different `mobile-ffmpeg` packages. Below you can see which system libraries and external libraries are enabled in each of them.
|
||||
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).
|
||||
|
||||
Please remember that some parts of `FFmpeg` are licensed under the `GPL` and only `GPL` licensed `mobile-ffmpeg` packages include them.
|
||||
There are eight different binary packages. Below you can see which system libraries and external libraries are enabled in each of them.
|
||||
|
||||
<table>
|
||||
<thead>
|
||||
@@ -82,10 +68,10 @@ Please remember that some parts of `FFmpeg` are licensed under the `GPL` and onl
|
||||
<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>chromaprint</sup><br><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>
|
||||
<td align="center"><sup>chromaprint</sup><br><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>sdl</sup><br><sup>shine</sup><br><sup>snappy</sup><br><sup>soxr</sup><br><sup>speex</sup><br><sup>tesseract</sup><br><sup>twolame</sup><br><sup>wavpack</sup></td>
|
||||
<td align="center"><sup>chromaprint</sup><br><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>sdl</sup><br><sup>shine</sup><br><sup>snappy</sup><br><sup>soxr</sup><br><sup>speex</sup><br><sup>tesseract</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>
|
||||
@@ -93,11 +79,7 @@ Please remember that some parts of `FFmpeg` are licensed under the `GPL` and onl
|
||||
</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>iconv</sup><br><sup>VideoToolbox</sup><br><sup>bzip2</sup></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td align="center"><sup>tvos system libraries</sup></td>
|
||||
<td align="center" colspan=8><sup>zlib</sup><br><sup>AudioToolbox</sup><br><sup>CoreImage</sup><br><sup>iconv</sup><br><sup>VideoToolbox</sup><br><sup>bzip2</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>
|
||||
@@ -108,89 +90,53 @@ Please remember that some parts of `FFmpeg` are licensed under the `GPL` and onl
|
||||
|
||||
- `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
|
||||
|
||||
- `AVFoundation` is not available on `tvOS`, `VideoToolbox` is not available on `tvOS` LTS releases
|
||||
|
||||
- Since `v4.3.1`, `iOS` and `tvOS` releases started to use `iconv` system library instead of `iconv` external library
|
||||
- `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`
|
||||
|
||||
#### 2.1 Android
|
||||
1. Add MobileFFmpeg dependency to your `build.gradle` in `mobile-ffmpeg-<package name>` format
|
||||
1. Add MobileFFmpeg dependency from `jcenter()`
|
||||
```
|
||||
dependencies {
|
||||
implementation 'com.arthenica:mobile-ffmpeg-full:4.3.1'
|
||||
dependencies {`
|
||||
implementation 'com.arthenica:mobile-ffmpeg-full:3.0'
|
||||
}
|
||||
```
|
||||
|
||||
2. Execute FFmpeg commands.
|
||||
2. Execute commands.
|
||||
```
|
||||
import com.arthenica.mobileffmpeg.Config;
|
||||
import com.arthenica.mobileffmpeg.FFmpeg;
|
||||
|
||||
int rc = FFmpeg.execute("-i file1.mp4 -c:v mpeg4 file2.mp4");
|
||||
|
||||
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 the output below.", rc));
|
||||
Config.printLastCommandOutput(Log.INFO);
|
||||
}
|
||||
FFmpeg.execute("-i file1.mp4 -c:v mpeg4 file2.mp4");
|
||||
```
|
||||
|
||||
3. Execute FFprobe commands.
|
||||
3. Check execution output.
|
||||
```
|
||||
import com.arthenica.mobileffmpeg.Config;
|
||||
import com.arthenica.mobileffmpeg.FFprobe;
|
||||
|
||||
int rc = FFprobe.execute("-i file1.mp4");
|
||||
|
||||
if (rc == RETURN_CODE_SUCCESS) {
|
||||
Log.i(Config.TAG, "Command execution completed successfully.");
|
||||
} else {
|
||||
Log.i(Config.TAG, String.format("Command execution failed with rc=%d and the output below.", rc));
|
||||
Config.printLastCommandOutput(Log.INFO);
|
||||
}
|
||||
```
|
||||
|
||||
4. Check execution output later.
|
||||
```
|
||||
int rc = Config.getLastReturnCode();
|
||||
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 the output below.", rc));
|
||||
Config.printLastCommandOutput(Log.INFO);
|
||||
Log.i(Config.TAG, String.format("Command execution failed with rc=%d and output=%s.", rc, output));
|
||||
}
|
||||
```
|
||||
|
||||
5. Stop an ongoing FFmpeg operation.
|
||||
4. Stop an ongoing operation.
|
||||
```
|
||||
FFmpeg.cancel();
|
||||
```
|
||||
|
||||
6. Get media information for a file.
|
||||
5. Get media information for a file.
|
||||
```
|
||||
MediaInformation info = FFprobe.getMediaInformation("<file path or uri>");
|
||||
MediaInformation info = FFmpeg.getMediaInformation('<file path or uri>');
|
||||
```
|
||||
|
||||
7. Record video using Android camera.
|
||||
```
|
||||
FFmpeg.execute("-f android_camera -i 0:0 -r 30 -pixel_format bgr0 -t 00:00:05 <record file path>");
|
||||
```
|
||||
|
||||
8. List enabled external libraries.
|
||||
6. List enabled external libraries.
|
||||
```
|
||||
List<String> externalLibraries = Config.getExternalLibraries();
|
||||
```
|
||||
|
||||
9. Enable log callback.
|
||||
7. Enable log callback.
|
||||
```
|
||||
Config.enableLogCallback(new LogCallback() {
|
||||
public void apply(LogMessage message) {
|
||||
@@ -199,7 +145,7 @@ Please remember that some parts of `FFmpeg` are licensed under the `GPL` and onl
|
||||
});
|
||||
```
|
||||
|
||||
10. Enable statistics callback.
|
||||
8. Enable statistics callback.
|
||||
```
|
||||
Config.enableStatisticsCallback(new StatisticsCallback() {
|
||||
public void apply(Statistics newStatistics) {
|
||||
@@ -208,65 +154,33 @@ Please remember that some parts of `FFmpeg` are licensed under the `GPL` and onl
|
||||
});
|
||||
```
|
||||
|
||||
11. Set log level.
|
||||
9. Set log level.
|
||||
```
|
||||
Config.setLogLevel(Level.AV_LOG_FATAL);
|
||||
```
|
||||
|
||||
12. Register custom fonts directory.
|
||||
10. Register custom fonts directory.
|
||||
```
|
||||
Config.setFontDirectory(this, "<folder with fonts>", Collections.EMPTY_MAP);
|
||||
```
|
||||
|
||||
#### 2.2 iOS / tvOS
|
||||
1. Add MobileFFmpeg dependency to your `Podfile` in `mobile-ffmpeg-<package name>` format
|
||||
|
||||
- iOS
|
||||
#### 2.2 IOS
|
||||
1. Add MobileFFmpeg pod to your `Podfile`
|
||||
```
|
||||
pod 'mobile-ffmpeg-full', '~> 4.3.1'
|
||||
pod 'mobile-ffmpeg-full', '~> 3.0'
|
||||
```
|
||||
|
||||
- tvOS
|
||||
2. Execute commands.
|
||||
```
|
||||
pod 'mobile-ffmpeg-tvos-full', '~> 4.3.1'
|
||||
```
|
||||
|
||||
2. Execute FFmpeg commands.
|
||||
```
|
||||
#import <mobileffmpeg/MobileFFmpegConfig.h>
|
||||
#import <mobileffmpeg/MobileFFmpeg.h>
|
||||
|
||||
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, [MobileFFmpegConfig getLastCommandOutput]);
|
||||
}
|
||||
[MobileFFmpeg execute: @"-i file1.mp4 -c:v mpeg4 file2.mp4"];
|
||||
```
|
||||
|
||||
3. Execute FFprobe commands.
|
||||
3. Check execution output.
|
||||
```
|
||||
#import <mobileffmpeg/MobileFFmpegConfig.h>
|
||||
#import <mobileffmpeg/MobileFFprobe.h>
|
||||
|
||||
int rc = [MobileFFprobe execute: @"-i file1.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, [MobileFFmpegConfig getLastCommandOutput]);
|
||||
}
|
||||
```
|
||||
|
||||
4. Check execution output later.
|
||||
```
|
||||
int rc = [MobileFFmpegConfig getLastReturnCode];
|
||||
NSString *output = [MobileFFmpegConfig getLastCommandOutput];
|
||||
int rc = [MobileFFmpeg getLastReturnCode];
|
||||
NSString *output = [MobileFFmpeg getLastCommandOutput];
|
||||
|
||||
if (rc == RETURN_CODE_SUCCESS) {
|
||||
NSLog(@"Command execution completed successfully.\n");
|
||||
@@ -277,281 +191,144 @@ Please remember that some parts of `FFmpeg` are licensed under the `GPL` and onl
|
||||
}
|
||||
```
|
||||
|
||||
5. Stop an ongoing FFmpeg operation.
|
||||
4. Stop an ongoing operation.
|
||||
```
|
||||
[MobileFFmpeg cancel];
|
||||
```
|
||||
|
||||
6. Get media information for a file.
|
||||
5. Get media information for a file.
|
||||
```
|
||||
MediaInformation *mediaInformation = [MobileFFprobe getMediaInformation:@"<file path or uri>"];
|
||||
MediaInformation *mediaInformation = [MobileFFmpeg getMediaInformation:@"<file path or uri>"];
|
||||
```
|
||||
|
||||
7. Record video and audio using iOS camera. This operation is not supported on `tvOS` since `AVFoundation` is not available on `tvOS`.
|
||||
|
||||
6. List enabled external libraries.
|
||||
```
|
||||
[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];
|
||||
NASArray *externalLibraries = [MobileFFmpegConfig getExternalLibraries];
|
||||
```
|
||||
|
||||
8. List enabled external libraries.
|
||||
7. Enable log callback.
|
||||
```
|
||||
NSArray *externalLibraries = [MobileFFmpegConfig getExternalLibraries];
|
||||
```
|
||||
|
||||
9. Enable log callback.
|
||||
```
|
||||
[MobileFFmpegConfig setLogDelegate:self];
|
||||
|
||||
- (void)logCallback: (int)level :(NSString*)message {
|
||||
dispatch_async(dispatch_get_main_queue(), ^{
|
||||
NSLog(@"%@", message);
|
||||
});
|
||||
}
|
||||
...
|
||||
[MobileFFmpegConfig setLogDelegate:self];
|
||||
```
|
||||
|
||||
10. Enable statistics callback.
|
||||
8. 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];
|
||||
```
|
||||
|
||||
11. Set log level.
|
||||
9. Set log level.
|
||||
```
|
||||
[MobileFFmpegConfig setLogLevel:AV_LOG_FATAL];
|
||||
```
|
||||
|
||||
12. Register custom fonts directory.
|
||||
10. Register custom fonts directory.
|
||||
```
|
||||
[MobileFFmpegConfig setFontDirectory:@"<folder with fonts>" with:nil];
|
||||
```
|
||||
|
||||
#### 2.3 Manual Installation
|
||||
##### 2.3.1 Android
|
||||
|
||||
You can import `MobileFFmpeg` aar packages in `Android Studio` using the `File` -> `New` -> `New Module` -> `Import .JAR/.AAR Package` menu.
|
||||
|
||||
##### 2.3.2 iOS / tvOS
|
||||
|
||||
iOS and tvOS frameworks can be installed manually using the [Importing Frameworks](https://github.com/tanersener/mobile-ffmpeg/wiki/Importing-Frameworks) guide.
|
||||
If you want to use universal binaries please refer to [Using Universal Binaries](https://github.com/tanersener/mobile-ffmpeg/wiki/Using-Universal-Binaries) guide.
|
||||
|
||||
#### 2.4 Test Application
|
||||
#### 2.3 Test Application
|
||||
You can see how MobileFFmpeg is used inside an application by running test applications provided.
|
||||
There is an `Android` test application under the `android/test-app` folder, an `iOS` test application under the
|
||||
`ios/test-app` folder and a `tvOS` test application under the `tvos/test-app` folder.
|
||||
There is an Android test application under the `android/test-app` folder and an IOS test application, which requires
|
||||
`Xcode 9.x` or later, under the `ios/test-app` folder. Both applications are identical and supports command
|
||||
execution, video encoding, accessing https, encoding audio, burning subtitles and video stabilization.
|
||||
|
||||
All applications are identical and supports command execution, video encoding, accessing https, encoding audio,
|
||||
burning subtitles, video stabilization and pipe operations.
|
||||
|
||||
<img src="https://github.com/tanersener/mobile-ffmpeg/blob/master/docs/assets/android_test_app.gif" width="240">
|
||||
<img src="https://github.com/tanersener/mobile-ffmpeg/blob/master/docs/assets/ios_test_app.gif" width="240">
|
||||
|
||||
### 3. Versions
|
||||
|
||||
`MobileFFmpeg` version number is aligned with `FFmpeg` since version `4.2`.
|
||||
- `MobileFFmpeg v1.x` is the previous stable, includes `FFmpeg v3.4.4`
|
||||
|
||||
In previous versions, `MobileFFmpeg` version of a release and `FFmpeg` version included in that release was different.
|
||||
The following table lists `FFmpeg` versions used in `MobileFFmpeg` releases.
|
||||
|
||||
- `dev` part in `FFmpeg` version number indicates that `FFmpeg` source is pulled from the `FFmpeg` `master` branch.
|
||||
Exact version number is obtained using `git describe --tags`.
|
||||
- `MobileFFmpeg v2.x` is the current stable, includes `FFmpeg v4.0.2`
|
||||
|
||||
| MobileFFmpeg Version | FFmpeg Version | Release Date |
|
||||
| :----: | :----: |:----: |
|
||||
| [4.3.1](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v4.3.1) | 4.3-dev-1944 | Jan 25, 2020 |
|
||||
| [4.3.1.LTS](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v4.3.1.LTS) | 4.3-dev-1944 | Jan 25, 2020 |
|
||||
| [4.3](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v4.3) | 4.3-dev-1181 | Oct 27, 2019 |
|
||||
| [4.2.2](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v4.2.2) | 4.2-dev-1824 | July 3, 2019 |
|
||||
| [4.2.2.LTS](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v4.2.2.LTS) | 4.2-dev-1824 | July 3, 2019 |
|
||||
| [4.2.1](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v4.2.1) | 4.2-dev-1156 | Apr 2, 2019 |
|
||||
| [4.2](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v4.2) | 4.2-dev-480 | Jan 3, 2019 |
|
||||
| [4.2.LTS](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v4.2.LTS) | 4.2-dev-480 | Jan 3, 2019 |
|
||||
| [3.1](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v3.1) | 4.1-10 | Dec 11, 2018 |
|
||||
| [3.0](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v3.0) | 4.1-dev-1517 | Oct 25, 2018 |
|
||||
| [2.2](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v2.2) | 4.0.3 | Nov 10, 2018 |
|
||||
| [2.1.1](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v2.1.1) | 4.0.2 | Sep 19, 2018 |
|
||||
| [2.1](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v2.1) | 4.0.2 | Sep 5, 2018 |
|
||||
| [2.0](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v2.0) | 4.0.1 | Jun 30, 2018 |
|
||||
| [1.2](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v1.2) | 3.4.4 | Aug 30, 2018|
|
||||
| [1.1](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v1.1) | 3.4.2 | Jun 18, 2018 |
|
||||
| [1.0](https://github.com/tanersener/mobile-ffmpeg/releases/tag/v1.0) | 3.4.2 | Jun 6, 2018 |
|
||||
- `MobileFFmpeg v3.x` is the next stable, includes `FFmpeg v4.1-dev-1517`
|
||||
|
||||
### 4. LTS Releases
|
||||
|
||||
Starting from `v4.2`, `MobileFFmpeg` binaries are published in two different variants: `Main Release` and `LTS Release`.
|
||||
|
||||
- Main releases include complete functionality of the library and support the latest SDK/API features.
|
||||
|
||||
- LTS releases are customized to support a wider range of devices. They are built using older API/SDK versions, so some features are not available on them.
|
||||
|
||||
This table shows the differences between two variants.
|
||||
|
||||
| | Main Release | LTS Release |
|
||||
| :----: | :----: | :----: |
|
||||
| Android API Level | 24 | 16 |
|
||||
| Android Camera Access | Yes | - |
|
||||
| Android Architectures | arm-v7a-neon<br/>arm64-v8a<br/>x86<br/>x86-64 | arm-v7a<br/>arm-v7a-neon<br/>arm64-v8a<br/>x86<br/>x86-64 |
|
||||
| Xcode Support | 10.1 | 7.3.1 |
|
||||
| iOS SDK | 12.1 | 9.3 |
|
||||
| iOS Architectures | arm64<br/>arm64e<br/>x86-64 | armv7<br/>arm64<br/>i386<br/>x86-64 |
|
||||
| tvOS SDK | 10.2 | 9.2 |
|
||||
| tvOS Architectures | arm64<br/>x86-64 | arm64<br/>x86-64 |
|
||||
|
||||
### 5. Building
|
||||
|
||||
Build scripts from `master` and `development` branches are tested periodically. See the latest status from the table below.
|
||||
|
||||
| branch | status |
|
||||
| :---: | :---: |
|
||||
| master | [](https://travis-ci.org/tanersener/mobile-ffmpeg) |
|
||||
| development | [](https://travis-ci.org/tanersener/mobile-ffmpeg) |
|
||||
|
||||
|
||||
#### 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 autogen patch
|
||||
```
|
||||
Some of these packages are not mandatory for the default build.
|
||||
Please visit [Android Prerequisites](https://github.com/tanersener/mobile-ffmpeg/wiki/Android-Prerequisites),
|
||||
[iOS Prerequisites](https://github.com/tanersener/mobile-ffmpeg/wiki/iOS-Prerequisites) and
|
||||
[tvOS Prerequisites](https://github.com/tanersener/mobile-ffmpeg/wiki/tvOS-Prerequisites) for the details.
|
||||
Please visit [Android Prerequisites](https://github.com/tanersener/mobile-ffmpeg/wiki/Android-Prerequisites) and
|
||||
[IOS Prerequisites](https://github.com/tanersener/mobile-ffmpeg/wiki/IOS-Prerequisites) for the details.
|
||||
|
||||
2. Android builds require these additional packages.
|
||||
- **Android SDK 4.1 Jelly Bean (API Level 16)** or later
|
||||
- **Android NDK r20** or later with LLDB and CMake
|
||||
- **Android SDK 5.0 Lollipop (API Level 21)** or later
|
||||
- **Android NDK r17c** or later with LLDB and CMake
|
||||
- **gradle 4.4** or later
|
||||
|
||||
3. iOS builds need these extra packages and tools.
|
||||
3. IOS builds need these extra packages and tools.
|
||||
- **IOS SDK 8.0.x** or later
|
||||
- **Xcode 7.3.1** or later
|
||||
- **iOS SDK 9.3** or later
|
||||
- **Command Line Tools**
|
||||
|
||||
4. tvOS builds need these extra packages and tools.
|
||||
- **Xcode 7.3.1** or later
|
||||
- **tvOS SDK 9.2** or later
|
||||
- **Command Line Tools**
|
||||
#### 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.
|
||||
|
||||
#### 5.2 Build Scripts
|
||||
Use `android.sh`, `ios.sh` and `tvos.sh` to build MobileFFmpeg for each platform.
|
||||
|
||||
All three scripts support additional options and
|
||||
can be customized to enable/disable specific external libraries and/or architectures. Please refer to wiki pages of
|
||||
[android.sh](https://github.com/tanersener/mobile-ffmpeg/wiki/android.sh),
|
||||
[ios.sh](https://github.com/tanersener/mobile-ffmpeg/wiki/ios.sh) and
|
||||
[tvos.sh](https://github.com/tanersener/mobile-ffmpeg/wiki/tvos.sh) to see all available build options.
|
||||
##### 5.2.1 Android
|
||||
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.
|
||||
##### 4.2.1 Android
|
||||
```
|
||||
export ANDROID_HOME=<Android SDK Path>
|
||||
export ANDROID_NDK_ROOT=<Android NDK Path>
|
||||
./android.sh
|
||||
```
|
||||
|
||||
<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
|
||||
./ios.sh
|
||||
```
|
||||
|
||||
<img src="https://github.com/tanersener/mobile-ffmpeg/blob/master/docs/assets/ios_custom.gif" width="600">
|
||||
|
||||
##### 5.2.3 tvOS
|
||||
```
|
||||
./tvos.sh
|
||||
```
|
||||
|
||||
<img src="https://github.com/tanersener/mobile-ffmpeg/blob/master/docs/assets/tvos_custom.gif" width="600">
|
||||
|
||||
|
||||
##### 5.2.4 Building LTS Binaries
|
||||
|
||||
Use `--lts` option to build lts binaries for each platform.
|
||||
|
||||
#### 5.3 Build Output
|
||||
|
||||
All libraries created by the top level build scripts (`android.sh`, `ios.sh` and `tvos.sh`) can be found under
|
||||
the `prebuilt` directory.
|
||||
|
||||
- `Android` archive (.aar file) is located under the `android-aar` folder
|
||||
- `iOS` frameworks are located under the `ios-framework`folder
|
||||
- `iOS` universal binaries are located under the `ios-universal`folder
|
||||
- `tvOS` frameworks are located under the `tvos-framework`folder
|
||||
- `tvOS` universal binaries are located under the `tvos-universal`folder
|
||||
|
||||
#### 5.4 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.
|
||||
from the top level build scripts.
|
||||
Their source code is not included in the repository and downloaded when enabled.
|
||||
|
||||
#### 5.5 External Libraries
|
||||
`build` directory includes build scripts of all external libraries. Two scripts exist for each external library,
|
||||
one for `Android` and one for `iOS / tvOS`. Each of these two scripts contains options/flags used to cross-compile the
|
||||
library on the specified mobile platform.
|
||||
#### 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.
|
||||
|
||||
CPU optimizations (`ASM`) are enabled for most of the external libraries. Details and exceptions can be found under the
|
||||
[ASM Support](https://github.com/tanersener/mobile-ffmpeg/wiki/ASM-Support) wiki page.
|
||||
|
||||
### 6. Documentation
|
||||
### 5. Documentation
|
||||
|
||||
A more detailed documentation is available at [Wiki](https://github.com/tanersener/mobile-ffmpeg/wiki).
|
||||
|
||||
### 7. Contributors
|
||||
|
||||
#### 7.1 Code Contributors
|
||||
|
||||
This project exists thanks to all the people who contribute. [[Contribute](CONTRIBUTING.md)].
|
||||
<a href="https://github.com/tanersener/mobile-ffmpeg/graphs/contributors"><img src="https://opencollective.com/mobile-ffmpeg/contributors.svg?width=890&button=false" /></a>
|
||||
|
||||
#### 7.2 Financial Contributors
|
||||
|
||||
Become a financial contributor and help us sustain our community. [[Contribute](https://opencollective.com/mobile-ffmpeg/contribute)]
|
||||
|
||||
##### 7.2.1 Individuals
|
||||
|
||||
<a href="https://opencollective.com/mobile-ffmpeg"><img src="https://opencollective.com/mobile-ffmpeg/individuals.svg?width=890"></a>
|
||||
|
||||
##### 7.2.2 Organizations
|
||||
|
||||
Support this project with your organization. Your logo will show up here with a link to your website. [[Contribute](https://opencollective.com/mobile-ffmpeg/contribute)]
|
||||
|
||||
<a href="https://opencollective.com/mobile-ffmpeg/organization/0/website"><img src="https://opencollective.com/mobile-ffmpeg/organization/0/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/mobile-ffmpeg/organization/1/website"><img src="https://opencollective.com/mobile-ffmpeg/organization/1/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/mobile-ffmpeg/organization/2/website"><img src="https://opencollective.com/mobile-ffmpeg/organization/2/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/mobile-ffmpeg/organization/3/website"><img src="https://opencollective.com/mobile-ffmpeg/organization/3/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/mobile-ffmpeg/organization/4/website"><img src="https://opencollective.com/mobile-ffmpeg/organization/4/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/mobile-ffmpeg/organization/5/website"><img src="https://opencollective.com/mobile-ffmpeg/organization/5/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/mobile-ffmpeg/organization/6/website"><img src="https://opencollective.com/mobile-ffmpeg/organization/6/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/mobile-ffmpeg/organization/7/website"><img src="https://opencollective.com/mobile-ffmpeg/organization/7/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/mobile-ffmpeg/organization/8/website"><img src="https://opencollective.com/mobile-ffmpeg/organization/8/avatar.svg"></a>
|
||||
<a href="https://opencollective.com/mobile-ffmpeg/organization/9/website"><img src="https://opencollective.com/mobile-ffmpeg/organization/9/avatar.svg"></a>
|
||||
|
||||
### 8. 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.
|
||||
|
||||
`openh264` source code included in this repository is licensed under the 2-clause BSD License but this license does
|
||||
not cover the `MPEG LA` licensing fees. If you build `mobile-ffmpeg` with `openh264` and distribute that library, then
|
||||
you are subject to pay `MPEG LA` licensing fees. Refer to [OpenH264 FAQ](https://www.openh264.org/faq.html) page for
|
||||
the details. Please note that `mobile-ffmpeg` does not publish a binary with `openh264` inside.
|
||||
`strip-frameworks.sh` script included and distributed is published under the [Apache License version 2.0](https://www.apache.org/licenses/LICENSE-2.0).
|
||||
|
||||
`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).
|
||||
|
||||
In test applications; embedded fonts are licensed under the [SIL Open Font License](https://opensource.org/licenses/OFL-1.1), other digital assets are published in the public domain.
|
||||
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.
|
||||
|
||||
### 9. 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.
|
||||
|
||||
### 10. 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)
|
||||
|
||||
@@ -39,34 +39,31 @@ LIBRARY_CHROMAPRINT=27
|
||||
LIBRARY_TWOLAME=28
|
||||
LIBRARY_SDL=29
|
||||
LIBRARY_TESSERACT=30
|
||||
LIBRARY_OPENH264=31
|
||||
LIBRARY_GIFLIB=32
|
||||
LIBRARY_JPEG=33
|
||||
LIBRARY_LIBOGG=34
|
||||
LIBRARY_LIBPNG=35
|
||||
LIBRARY_LIBUUID=36
|
||||
LIBRARY_NETTLE=37
|
||||
LIBRARY_TIFF=38
|
||||
LIBRARY_EXPAT=39
|
||||
LIBRARY_SNDFILE=40
|
||||
LIBRARY_LEPTONICA=41
|
||||
LIBRARY_ZLIB=42
|
||||
LIBRARY_MEDIA_CODEC=43
|
||||
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
|
||||
|
||||
# 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 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 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
|
||||
|
||||
RECONF_LIBRARIES=()
|
||||
REBUILD_LIBRARIES=()
|
||||
# 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')
|
||||
@@ -82,18 +79,16 @@ without any external libraries enabled. Options can be used to disable ABIs and/
|
||||
Please note that GPL libraries (external libraries with GPL license) need --enable-gpl flag to be set explicitly. \
|
||||
When compilation ends an Android Archive (AAR) file is created with enabled platforms inside.\n"
|
||||
|
||||
echo -e "Usage: ./"$COMMAND" [OPTION]...\n"
|
||||
echo -e "Usage: ./"$COMMAND" [OPTION]...\n"
|
||||
|
||||
echo -e "Specify environment variables as VARIABLE=VALUE to override default build options.\n"
|
||||
|
||||
echo -e "Options:"
|
||||
|
||||
echo -e " -h, --help\t\t\tdisplay this help and exit"
|
||||
echo -e " -v, --version\t\t\tdisplay version information 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 16+ devices"
|
||||
echo -e " -f, --force\t\t\tignore warnings\n"
|
||||
echo -e " -S, --speed\t\t\toptimize for speed instead of size\n"
|
||||
|
||||
echo -e "Licensing options:"
|
||||
|
||||
@@ -130,7 +125,6 @@ When compilation ends an Android Archive (AAR) file is created with enabled plat
|
||||
echo -e " --enable-libwebp\t\tbuild with libwebp [no]"
|
||||
echo -e " --enable-libxml2\t\tbuild with libxml2 [no]"
|
||||
echo -e " --enable-opencore-amr\t\tbuild with opencore-amr [no]"
|
||||
echo -e " --enable-openh264\t\tbuild with openh264 [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]"
|
||||
@@ -158,7 +152,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\
|
||||
@@ -173,75 +167,24 @@ skip_library() {
|
||||
export ${SKIP_VARIABLE}=1
|
||||
}
|
||||
|
||||
no_output_redirection() {
|
||||
export NO_OUTPUT_REDIRECTION=1
|
||||
}
|
||||
|
||||
no_workspace_cleanup_library() {
|
||||
NO_WORKSPACE_CLEANUP_VARIABLE=$(echo "NO_WORKSPACE_CLEANUP_$1" | sed "s/\-/\_/g")
|
||||
|
||||
export ${NO_WORKSPACE_CLEANUP_VARIABLE}=1
|
||||
}
|
||||
|
||||
no_link_time_optimization() {
|
||||
export NO_LINK_TIME_OPTIMIZATION=1
|
||||
}
|
||||
|
||||
enable_debug() {
|
||||
export MOBILE_FFMPEG_DEBUG="-g"
|
||||
|
||||
BUILD_TYPE_ID+="debug "
|
||||
export MOBILE_FFMPEG_DEBUG="-d"
|
||||
}
|
||||
|
||||
optimize_for_speed() {
|
||||
export MOBILE_FFMPEG_OPTIMIZED_FOR_SPEED="1"
|
||||
}
|
||||
|
||||
enable_lts_build() {
|
||||
export MOBILE_FFMPEG_LTS_BUILD="1"
|
||||
|
||||
# USING API LEVEL 16 / Android 4.1 (JELLY BEAN)
|
||||
export API=16
|
||||
}
|
||||
|
||||
reconf_library() {
|
||||
local RECONF_VARIABLE=$(echo "RECONF_$1" | sed "s/\-/\_/g")
|
||||
local library_supported=0
|
||||
RECONF_VARIABLE=$(echo "RECONF_$1" | sed "s/\-/\_/g")
|
||||
|
||||
for library in {1..42}
|
||||
do
|
||||
library_name=$(get_library_name $((library - 1)))
|
||||
|
||||
if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == $1 ]]; then
|
||||
export ${RECONF_VARIABLE}=1
|
||||
RECONF_LIBRARIES+=($1)
|
||||
library_supported=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${library_supported} -eq 0 ]]; then
|
||||
echo -e "INFO: --reconf flag detected for library $1 is not supported.\n" 1>>${BASEDIR}/build.log 2>&1
|
||||
fi
|
||||
export ${RECONF_VARIABLE}=1
|
||||
}
|
||||
|
||||
rebuild_library() {
|
||||
local REBUILD_VARIABLE=$(echo "REBUILD_$1" | sed "s/\-/\_/g")
|
||||
local library_supported=0
|
||||
REBUILD_VARIABLE=$(echo "REBUILD_$1" | sed "s/\-/\_/g")
|
||||
|
||||
for library in {1..42}
|
||||
do
|
||||
library_name=$(get_library_name $((library - 1)))
|
||||
|
||||
if [[ $1 != "ffmpeg" ]] && [[ ${library_name} == $1 ]]; then
|
||||
export ${REBUILD_VARIABLE}=1
|
||||
REBUILD_LIBRARIES+=($1)
|
||||
library_supported=1
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ ${library_supported} -eq 0 ]]; then
|
||||
echo -e "INFO: --rebuild flag detected for library $1 is not supported.\n" 1>>${BASEDIR}/build.log 2>&1
|
||||
fi
|
||||
export ${REBUILD_VARIABLE}=1
|
||||
}
|
||||
|
||||
enable_library() {
|
||||
@@ -342,9 +285,6 @@ set_library() {
|
||||
opencore-amr)
|
||||
ENABLED_LIBRARIES[LIBRARY_OPENCOREAMR]=$2
|
||||
;;
|
||||
openh264)
|
||||
ENABLED_LIBRARIES[LIBRARY_OPENH264]=$2
|
||||
;;
|
||||
opus)
|
||||
ENABLED_LIBRARIES[LIBRARY_OPUS]=$2
|
||||
;;
|
||||
@@ -477,7 +417,7 @@ print_enabled_libraries() {
|
||||
let enabled=0;
|
||||
|
||||
# FIRST BUILT-IN LIBRARIES
|
||||
for library in {42..43}
|
||||
for library in {41..42}
|
||||
do
|
||||
if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then
|
||||
if [[ ${enabled} -ge 1 ]]; then
|
||||
@@ -489,7 +429,7 @@ print_enabled_libraries() {
|
||||
done
|
||||
|
||||
# THEN EXTERNAL LIBRARIES
|
||||
for library in {0..31}
|
||||
for library in {0..30}
|
||||
do
|
||||
if [[ ${ENABLED_LIBRARIES[$library]} -eq 1 ]]; then
|
||||
if [[ ${enabled} -ge 1 ]]; then
|
||||
@@ -507,63 +447,7 @@ print_enabled_libraries() {
|
||||
fi
|
||||
}
|
||||
|
||||
print_reconfigure_requested_libraries() {
|
||||
local counter=0;
|
||||
|
||||
for RECONF_LIBRARY in "${RECONF_LIBRARIES[@]}"
|
||||
do
|
||||
if [[ ${counter} -eq 0 ]]; then
|
||||
echo -n "Reconfigure: "
|
||||
else
|
||||
echo -n ", "
|
||||
fi
|
||||
|
||||
echo -n ${RECONF_LIBRARY}
|
||||
|
||||
counter=$((${counter} + 1));
|
||||
done
|
||||
|
||||
if [[ ${counter} -gt 0 ]]; then
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
print_rebuild_requested_libraries() {
|
||||
local counter=0;
|
||||
|
||||
for REBUILD_LIBRARY in "${REBUILD_LIBRARIES[@]}"
|
||||
do
|
||||
if [[ ${counter} -eq 0 ]]; then
|
||||
echo -n "Rebuild: "
|
||||
else
|
||||
echo -n ", "
|
||||
fi
|
||||
|
||||
echo -n ${REBUILD_LIBRARY}
|
||||
|
||||
counter=$((${counter} + 1));
|
||||
done
|
||||
|
||||
if [[ ${counter} -gt 0 ]]; then
|
||||
echo ""
|
||||
fi
|
||||
}
|
||||
|
||||
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 ]] || [[ ${ENABLED_LIBRARIES[$LIBRARY_OPENH264]} -eq 1 ]] || [[ ${ENABLED_LIBRARIES[$LIBRARY_SNAPPY]} -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
|
||||
@@ -571,42 +455,29 @@ 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_LDFLAGS := -Wl,--hash-style=both
|
||||
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)
|
||||
-V | --version)
|
||||
display_version
|
||||
exit 0
|
||||
;;
|
||||
@@ -615,29 +486,12 @@ do
|
||||
|
||||
skip_library ${SKIP_LIBRARY}
|
||||
;;
|
||||
--no-output-redirection)
|
||||
no_output_redirection
|
||||
;;
|
||||
--no-workspace-cleanup-*)
|
||||
NO_WORKSPACE_CLEANUP_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-[A-Za-z]*-[A-Za-z]*-//g'`
|
||||
|
||||
no_workspace_cleanup_library ${NO_WORKSPACE_CLEANUP_LIBRARY}
|
||||
;;
|
||||
--no-link-time-optimization)
|
||||
no_link_time_optimization
|
||||
;;
|
||||
-d | --debug)
|
||||
enable_debug
|
||||
;;
|
||||
-s | --speed)
|
||||
-S | --speed)
|
||||
optimize_for_speed
|
||||
;;
|
||||
-l | --lts)
|
||||
BUILD_LTS="1"
|
||||
;;
|
||||
-f | --force)
|
||||
BUILD_FORCE="1"
|
||||
;;
|
||||
--reconf-*)
|
||||
CONF_LIBRARY=`echo $1 | sed -e 's/^--[A-Za-z]*-//g'`
|
||||
|
||||
@@ -649,7 +503,7 @@ do
|
||||
rebuild_library ${BUILD_LIBRARY}
|
||||
;;
|
||||
--full)
|
||||
for library in {0..43}
|
||||
for library in {0..42}
|
||||
do
|
||||
if [[ $library -ne 18 ]] && [[ $library -ne 19 ]] && [[ $library -ne 20 ]] && [[ $library -ne 21 ]]; then
|
||||
enable_library $(get_library_name $library)
|
||||
@@ -676,47 +530,17 @@ do
|
||||
shift
|
||||
done;
|
||||
|
||||
# DETECT BUILD TYPE
|
||||
rm -f ${BASEDIR}/android/jni/Android.mk 1>>${BASEDIR}/build.log 2>&1
|
||||
rm -f ${BASEDIR}/android/app/build.gradle 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
|
||||
cp ${BASEDIR}/tools/release/android/build.lts.gradle ${BASEDIR}/android/app/build.gradle 1>>${BASEDIR}/build.log 2>&1
|
||||
else
|
||||
cp ${BASEDIR}/tools/ndk/Android.mk ${BASEDIR}/android/jni/Android.mk 1>>${BASEDIR}/build.log 2>&1
|
||||
cp ${BASEDIR}/tools/release/android/build.gradle ${BASEDIR}/android/app/build.gradle 1>>${BASEDIR}/build.log 2>&1
|
||||
|
||||
if [[ -z ${BUILD_FORCE} ]] && [[ ${ENABLED_ARCHITECTURES[${ARCH_ARM_V7A}]} -eq 1 ]]; then
|
||||
echo -e "INFO: Disabled arm-v7a architecture which is not included in Main releases.\n" 1>>${BASEDIR}/build.log 2>&1
|
||||
disable_arch "arm-v7a"
|
||||
fi
|
||||
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
|
||||
|
||||
if [[ -z ${ANDROID_HOME} ]]; then
|
||||
echo "ANDROID_HOME not defined"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo -e "\nBuilding 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
|
||||
ENABLED_ARCHITECTURES[ARCH_ARM_V7A]=1
|
||||
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"
|
||||
echo -e "(*) arm-v7a architecture enabled since arm-v7a-neon will be built\n" 1>>${BASEDIR}/build.log 2>&1
|
||||
@@ -724,8 +548,6 @@ fi
|
||||
|
||||
print_enabled_architectures
|
||||
print_enabled_libraries
|
||||
print_reconfigure_requested_libraries
|
||||
print_rebuild_requested_libraries
|
||||
|
||||
# CHECKING GPL LIBRARIES
|
||||
for gpl_library in {18..21}
|
||||
@@ -748,28 +570,33 @@ do
|
||||
fi
|
||||
done
|
||||
|
||||
# SAVE API VALUE
|
||||
export ORIGINAL_API=${API};
|
||||
# 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
|
||||
if [[ ( ${run_arch} -eq ${ARCH_ARM64_V8A} || ${run_arch} -eq ${ARCH_X86_64} ) && ${API} < 21 ]] ; then
|
||||
|
||||
# 64 bit ABIs supported after API 21
|
||||
export API=21
|
||||
else
|
||||
export API=${ORIGINAL_API}
|
||||
fi
|
||||
|
||||
export ARCH=$(get_arch_name $run_arch)
|
||||
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..44}
|
||||
for library in {1..43}
|
||||
do
|
||||
library_name=$(get_library_name $((library - 1)))
|
||||
unset $(echo "OK_${library_name}" | sed "s/\-/\_/g")
|
||||
@@ -778,8 +605,6 @@ do
|
||||
fi
|
||||
done
|
||||
|
||||
export API=${ORIGINAL_API}
|
||||
|
||||
rm -f ${BASEDIR}/android/build/.neon 1>>${BASEDIR}/build.log 2>&1
|
||||
ANDROID_ARCHITECTURES=""
|
||||
if [[ ${ENABLED_ARCHITECTURES[1]} -eq 1 ]]; then
|
||||
@@ -826,14 +651,14 @@ if [[ ! -z ${ANDROID_ARCHITECTURES} ]]; then
|
||||
|
||||
echo -e -n "\n\nCreating Android archive under prebuilt/android-aar: "
|
||||
|
||||
./gradlew app:clean app:assembleRelease app:testReleaseUnitTest 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-release.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,10 +1,12 @@
|
||||
*.iml
|
||||
.gradle
|
||||
local.properties
|
||||
/local.properties
|
||||
/.idea/workspace.xml
|
||||
/.idea/libraries
|
||||
.DS_Store
|
||||
build
|
||||
captures
|
||||
/build
|
||||
/captures
|
||||
.externalNativeBuild
|
||||
.idea
|
||||
obj
|
||||
libs
|
||||
/.idea/
|
||||
/obj/
|
||||
/libs/
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
/build
|
||||
/local.properties
|
||||
@@ -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.3.1
|
||||
PROJECT_NUMBER = 3.0
|
||||
|
||||
# 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
|
||||
|
||||
@@ -1,17 +1,15 @@
|
||||
apply plugin: 'com.android.library'
|
||||
|
||||
android {
|
||||
compileSdkVersion 29
|
||||
|
||||
compileSdkVersion 27
|
||||
defaultConfig {
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 29
|
||||
versionCode 240431
|
||||
versionName "4.3.1"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 27
|
||||
versionCode 30
|
||||
versionName "3.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
project.archivesBaseName = "mobile-ffmpeg"
|
||||
consumerProguardFiles 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
@@ -28,6 +26,14 @@ android {
|
||||
testOptions {
|
||||
unitTests.returnDefaultValues = true
|
||||
}
|
||||
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.all { output ->
|
||||
if (outputFile != null && outputFileName.endsWith('.aar')) {
|
||||
outputFileName = "${archivesBaseName}-${android.defaultConfig.versionName}.aar"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task javadoc(type: Javadoc) {
|
||||
@@ -37,6 +43,16 @@ task javadoc(type: Javadoc) {
|
||||
source = android.sourceSets.main.java.srcDirs
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation "androidx.test.ext:junit:1.1.1"
|
||||
afterEvaluate {
|
||||
javadoc.classpath += files(android.libraryVariants.collect { variant ->
|
||||
variant.javaCompile.classpath.files
|
||||
})
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
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'
|
||||
}
|
||||
|
||||
@@ -5,12 +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 *;
|
||||
#}
|
||||
|
||||
-keep class com.arthenica.mobileffmpeg.AbiDetect {
|
||||
native <methods>;
|
||||
}
|
||||
# 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
|
||||
|
||||
@@ -8,24 +8,22 @@ buildscript {
|
||||
jcenter()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:3.5.3'
|
||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.4'
|
||||
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"
|
||||
project.archivesBaseName = releaseProject
|
||||
consumerProguardFiles 'proguard-rules.pro'
|
||||
}
|
||||
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
@@ -39,13 +37,11 @@ android {
|
||||
}
|
||||
}
|
||||
|
||||
testOptions {
|
||||
unitTests.returnDefaultValues = true
|
||||
}
|
||||
|
||||
libraryVariants.all { variant ->
|
||||
variant.outputs.all {
|
||||
outputFileName = "${archivesBaseName}-${android.defaultConfig.versionName}.aar"
|
||||
variant.outputs.all { output ->
|
||||
if (outputFile != null && outputFileName.endsWith('.aar')) {
|
||||
outputFileName = "${archivesBaseName}-${android.defaultConfig.versionName}.aar"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -131,7 +127,7 @@ bintray {
|
||||
websiteUrl = siteUrl
|
||||
vcsUrl = gitUrl
|
||||
licenses = allLicenses
|
||||
dryRun = true
|
||||
dryRun = false
|
||||
publish = false
|
||||
override = false
|
||||
publicDownloadNumbers = false
|
||||
@@ -162,8 +158,18 @@ artifacts {
|
||||
archives sourcesJar
|
||||
}
|
||||
|
||||
afterEvaluate {
|
||||
javadoc.classpath += files(android.libraryVariants.collect { variant ->
|
||||
variant.javaCompile.classpath.files
|
||||
})
|
||||
}
|
||||
|
||||
dependencies {
|
||||
testImplementation "androidx.test.ext:junit:1.1.1"
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
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'
|
||||
}
|
||||
|
||||
allprojects {
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() throws Exception {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.arthenica.mobileffmpeg", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,11 @@
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.arthenica.mobileffmpeg">
|
||||
|
||||
<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>
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
/android_lts_support.o
|
||||
/libandroidltssupport.a
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008 The Android Open Source Project
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
||||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
|
||||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <malloc.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if __ANDROID_API__ < 17
|
||||
|
||||
int posix_memalign(void** memptr, size_t alignment, size_t size) {
|
||||
if ((alignment & (alignment - 1)) != 0 || alignment == 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
if (alignment % sizeof(void*) != 0) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
*memptr = memalign(alignment, size);
|
||||
if (*memptr == NULL) {
|
||||
return errno;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* __ANDROID_API__ < 17 */
|
||||
|
||||
double log2(double x) {
|
||||
return (log(x) / M_LN2);
|
||||
}
|
||||
|
||||
float log2f(float x) {
|
||||
return (float) log2((double) x);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}; /* end of extern "C" */
|
||||
#endif
|
||||
@@ -20,14 +20,6 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 01.2020
|
||||
* - ffprobe support changes
|
||||
* - (optindex < argc) validation in parse_options() method updated with (optindex >= argc) check
|
||||
*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
* - log_callback_report method re-added to fix -report option issues
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and parent header
|
||||
@@ -93,19 +85,15 @@
|
||||
|
||||
static int init_report(const char *env);
|
||||
extern void mobileffmpeg_log_callback_function(void *ptr, int level, const char* format, va_list vargs);
|
||||
extern void (*report_callback)(int, float, float, int64_t, int, double, double);
|
||||
|
||||
__thread char *program_name;
|
||||
__thread int program_birth_year;
|
||||
AVDictionary *sws_dict;
|
||||
AVDictionary *swr_opts;
|
||||
AVDictionary *format_opts, *codec_opts, *resample_opts;
|
||||
|
||||
__thread AVDictionary *sws_dict;
|
||||
__thread AVDictionary *swr_opts;
|
||||
__thread AVDictionary *format_opts, *codec_opts, *resample_opts;
|
||||
|
||||
FILE *report_file;
|
||||
int report_file_level = AV_LOG_DEBUG;
|
||||
__thread int hide_banner = 0;
|
||||
__thread int longjmp_value = 0;
|
||||
static FILE *report_file;
|
||||
static int report_file_level = AV_LOG_DEBUG;
|
||||
int hide_banner = 0;
|
||||
int longjmp_value = 0;
|
||||
|
||||
enum show_muxdemuxers {
|
||||
SHOW_DEFAULT,
|
||||
@@ -127,29 +115,9 @@ void uninit_opts(void)
|
||||
av_dict_free(&resample_opts);
|
||||
}
|
||||
|
||||
void log_callback_report(void *ptr, int level, const char *fmt, va_list vl)
|
||||
{
|
||||
va_list vl2;
|
||||
char line[1024];
|
||||
static int print_prefix = 1;
|
||||
|
||||
va_copy(vl2, vl);
|
||||
if (report_callback == NULL) {
|
||||
av_log_default_callback(ptr, level, fmt, vl);
|
||||
} else {
|
||||
mobileffmpeg_log_callback_function(ptr, level, fmt, vl);
|
||||
}
|
||||
av_log_format_line(ptr, level, fmt, vl2, line, sizeof(line), &print_prefix);
|
||||
va_end(vl2);
|
||||
if (report_file_level >= level) {
|
||||
fputs(line, report_file);
|
||||
fflush(report_file);
|
||||
}
|
||||
}
|
||||
|
||||
void init_dynload(void)
|
||||
{
|
||||
#if HAVE_SETDLLDIRECTORY
|
||||
#ifdef _WIN32
|
||||
/* Calling SetDllDirectory with the empty string (but not NULL) removes the
|
||||
* current working directory from the DLL search path as a security pre-caution. */
|
||||
SetDllDirectory("");
|
||||
@@ -223,7 +191,7 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,
|
||||
continue;
|
||||
|
||||
if (first) {
|
||||
av_log(NULL, AV_LOG_STDERR, "%s\n", msg);
|
||||
printf("%s\n", msg);
|
||||
first = 0;
|
||||
}
|
||||
av_strlcpy(buf, po->name, sizeof(buf));
|
||||
@@ -231,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_STDERR, "-%-17s %s\n", buf, po->help);
|
||||
printf("-%-17s %s\n", buf, po->help);
|
||||
}
|
||||
av_log(NULL, AV_LOG_STDERR, "\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
void show_help_children(const AVClass *class, int flags)
|
||||
@@ -241,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_STDERR, "\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
while ((child = av_opt_child_class_next(class, child)))
|
||||
@@ -433,14 +401,12 @@ void parse_options(void *optctx, int argc, char **argv, const OptionDef *options
|
||||
continue;
|
||||
}
|
||||
opt++;
|
||||
if (optindex >= argc) {
|
||||
if ((ret = parse_option(optctx, opt, NULL, options)) < 0)
|
||||
exit_program(1);
|
||||
} else {
|
||||
|
||||
if (optindex < argc) {
|
||||
if ((ret = parse_option(optctx, opt, argv[optindex], options)) < 0)
|
||||
exit_program(1);
|
||||
optindex += ret;
|
||||
}
|
||||
optindex += ret;
|
||||
} else {
|
||||
if (parse_arg_function)
|
||||
parse_arg_function(optctx, opt);
|
||||
@@ -507,7 +473,7 @@ int locate_option(int argc, char **argv, const OptionDef *options,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void dump_argument(const char *a)
|
||||
static void dump_argument(const char *a)
|
||||
{
|
||||
const unsigned char *p;
|
||||
|
||||
@@ -846,7 +812,7 @@ do { \
|
||||
if (optindex < argc) {
|
||||
arg = argv[optindex++];
|
||||
} else {
|
||||
arg = NULL;
|
||||
arg = "";
|
||||
}
|
||||
} else if (po->flags & HAS_ARG) {
|
||||
GET_ARG(arg);
|
||||
@@ -890,8 +856,8 @@ do { \
|
||||
}
|
||||
|
||||
if (octx->cur_group.nb_opts || codec_opts || format_opts || resample_opts)
|
||||
av_log(NULL, AV_LOG_WARNING, "Trailing option(s) found in the "
|
||||
"command: may be ignored.\n");
|
||||
av_log(NULL, AV_LOG_WARNING, "Trailing options were found on the "
|
||||
"commandline.\n");
|
||||
|
||||
av_log(NULL, AV_LOG_DEBUG, "Finished splitting the commandline.\n");
|
||||
|
||||
@@ -1017,12 +983,11 @@ static void expand_filename_template(AVBPrint *bp, const char *template,
|
||||
}
|
||||
}
|
||||
|
||||
int init_report(const char *env)
|
||||
static int init_report(const char *env)
|
||||
{
|
||||
char *filename_template = NULL;
|
||||
char *key, *val;
|
||||
int ret, count = 0;
|
||||
int prog_loglevel, envlevel = 0;
|
||||
time_t now;
|
||||
struct tm *tm;
|
||||
AVBPrint filename;
|
||||
@@ -1054,7 +1019,6 @@ int init_report(const char *env)
|
||||
av_log(NULL, AV_LOG_FATAL, "Invalid report file level\n");
|
||||
exit_program(1);
|
||||
}
|
||||
envlevel = 1;
|
||||
} else {
|
||||
av_log(NULL, AV_LOG_ERROR, "Unknown key '%s' in FFREPORT\n", key);
|
||||
}
|
||||
@@ -1071,10 +1035,6 @@ int init_report(const char *env)
|
||||
return AVERROR(ENOMEM);
|
||||
}
|
||||
|
||||
prog_loglevel = av_log_get_level();
|
||||
if (!envlevel)
|
||||
report_file_level = FFMAX(report_file_level, prog_loglevel);
|
||||
|
||||
report_file = fopen(filename.str, "w");
|
||||
if (!report_file) {
|
||||
int ret = AVERROR(errno);
|
||||
@@ -1082,20 +1042,19 @@ int init_report(const char *env)
|
||||
filename.str, strerror(errno));
|
||||
return ret;
|
||||
}
|
||||
av_log_set_callback(log_callback_report);
|
||||
av_log_set_callback(mobileffmpeg_log_callback_function);
|
||||
av_log(NULL, AV_LOG_INFO,
|
||||
"%s started on %04d-%02d-%02d at %02d:%02d:%02d\n"
|
||||
"Report written to \"%s\"\n"
|
||||
"Log level: %d\n",
|
||||
"Report written to \"%s\"\n",
|
||||
program_name,
|
||||
tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
|
||||
tm->tm_hour, tm->tm_min, tm->tm_sec,
|
||||
filename.str, report_file_level);
|
||||
filename.str);
|
||||
av_bprint_finalize(&filename, NULL);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int opt_report(void *optctx, const char *opt, const char *arg)
|
||||
int opt_report(const char *opt)
|
||||
{
|
||||
return init_report(NULL);
|
||||
}
|
||||
@@ -1137,7 +1096,7 @@ void print_error(const char *filename, int err)
|
||||
av_log(NULL, AV_LOG_ERROR, "%s: %s\n", filename, errbuf_ptr);
|
||||
}
|
||||
|
||||
__thread int warned_cfg = 0;
|
||||
static int warned_cfg = 0;
|
||||
|
||||
#define INDENT 1
|
||||
#define SHOW_VERSION 2
|
||||
@@ -1237,6 +1196,7 @@ void show_banner(int argc, char **argv, const OptionDef *options)
|
||||
|
||||
int show_version(void *optctx, const char *opt, const char *arg)
|
||||
{
|
||||
av_log_set_callback(mobileffmpeg_log_callback_function);
|
||||
print_program_info (SHOW_COPYRIGHT, AV_LOG_INFO);
|
||||
print_all_libs_info(SHOW_VERSION, AV_LOG_INFO);
|
||||
|
||||
@@ -1245,6 +1205,7 @@ int show_version(void *optctx, const char *opt, const char *arg)
|
||||
|
||||
int show_buildconf(void *optctx, const char *opt, const char *arg)
|
||||
{
|
||||
av_log_set_callback(mobileffmpeg_log_callback_function);
|
||||
print_buildconf (INDENT|0, AV_LOG_INFO);
|
||||
|
||||
return 0;
|
||||
@@ -1253,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_STDERR,
|
||||
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_STDERR,
|
||||
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"
|
||||
@@ -1273,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_STDERR,
|
||||
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"
|
||||
@@ -1289,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_STDERR,
|
||||
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"
|
||||
@@ -1304,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_STDERR,
|
||||
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"
|
||||
@@ -1340,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_STDERR, "%s\n"
|
||||
printf("%s\n"
|
||||
" D. = Demuxing supported\n"
|
||||
" .E = Muxing supported\n"
|
||||
" --\n", device_only ? "Devices:" : "File formats:");
|
||||
@@ -1385,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_STDERR, " %s%s %-15s %s\n",
|
||||
printf(" %s%s %-15s %s\n",
|
||||
decode ? "D" : " ",
|
||||
encode ? "E" : " ",
|
||||
name,
|
||||
@@ -1418,97 +1379,97 @@ int show_devices(void *optctx, const char *opt, const char *arg)
|
||||
if (codec->field) { \
|
||||
const type *p = codec->field; \
|
||||
\
|
||||
av_log(NULL, AV_LOG_STDERR, " Supported " list_name ":"); \
|
||||
printf(" Supported " list_name ":"); \
|
||||
while (*p != term) { \
|
||||
get_name(*p); \
|
||||
av_log(NULL, AV_LOG_STDERR, " %s", name); \
|
||||
printf(" %s", name); \
|
||||
p++; \
|
||||
} \
|
||||
av_log(NULL, AV_LOG_STDERR, "\n"); \
|
||||
printf("\n"); \
|
||||
} \
|
||||
|
||||
static void print_codec(const AVCodec *c)
|
||||
{
|
||||
int encoder = av_codec_is_encoder(c);
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, "%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_STDERR, " General capabilities: ");
|
||||
printf(" General capabilities: ");
|
||||
if (c->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)
|
||||
av_log(NULL, AV_LOG_STDERR, "horizband ");
|
||||
printf("horizband ");
|
||||
if (c->capabilities & AV_CODEC_CAP_DR1)
|
||||
av_log(NULL, AV_LOG_STDERR, "dr1 ");
|
||||
printf("dr1 ");
|
||||
if (c->capabilities & AV_CODEC_CAP_TRUNCATED)
|
||||
av_log(NULL, AV_LOG_STDERR, "trunc ");
|
||||
printf("trunc ");
|
||||
if (c->capabilities & AV_CODEC_CAP_DELAY)
|
||||
av_log(NULL, AV_LOG_STDERR, "delay ");
|
||||
printf("delay ");
|
||||
if (c->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME)
|
||||
av_log(NULL, AV_LOG_STDERR, "small ");
|
||||
printf("small ");
|
||||
if (c->capabilities & AV_CODEC_CAP_SUBFRAMES)
|
||||
av_log(NULL, AV_LOG_STDERR, "subframes ");
|
||||
printf("subframes ");
|
||||
if (c->capabilities & AV_CODEC_CAP_EXPERIMENTAL)
|
||||
av_log(NULL, AV_LOG_STDERR, "exp ");
|
||||
printf("exp ");
|
||||
if (c->capabilities & AV_CODEC_CAP_CHANNEL_CONF)
|
||||
av_log(NULL, AV_LOG_STDERR, "chconf ");
|
||||
printf("chconf ");
|
||||
if (c->capabilities & AV_CODEC_CAP_PARAM_CHANGE)
|
||||
av_log(NULL, AV_LOG_STDERR, "paramchange ");
|
||||
printf("paramchange ");
|
||||
if (c->capabilities & AV_CODEC_CAP_VARIABLE_FRAME_SIZE)
|
||||
av_log(NULL, AV_LOG_STDERR, "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_STDERR, "threads ");
|
||||
printf("threads ");
|
||||
if (c->capabilities & AV_CODEC_CAP_AVOID_PROBING)
|
||||
av_log(NULL, AV_LOG_STDERR, "avoidprobe ");
|
||||
printf("avoidprobe ");
|
||||
if (c->capabilities & AV_CODEC_CAP_INTRA_ONLY)
|
||||
av_log(NULL, AV_LOG_STDERR, "intraonly ");
|
||||
printf("intraonly ");
|
||||
if (c->capabilities & AV_CODEC_CAP_LOSSLESS)
|
||||
av_log(NULL, AV_LOG_STDERR, "lossless ");
|
||||
printf("lossless ");
|
||||
if (c->capabilities & AV_CODEC_CAP_HARDWARE)
|
||||
av_log(NULL, AV_LOG_STDERR, "hardware ");
|
||||
printf("hardware ");
|
||||
if (c->capabilities & AV_CODEC_CAP_HYBRID)
|
||||
av_log(NULL, AV_LOG_STDERR, "hybrid ");
|
||||
printf("hybrid ");
|
||||
if (!c->capabilities)
|
||||
av_log(NULL, AV_LOG_STDERR, "none");
|
||||
av_log(NULL, AV_LOG_STDERR, "\n");
|
||||
printf("none");
|
||||
printf("\n");
|
||||
|
||||
if (c->type == AVMEDIA_TYPE_VIDEO ||
|
||||
c->type == AVMEDIA_TYPE_AUDIO) {
|
||||
av_log(NULL, AV_LOG_STDERR, " 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_STDERR, "frame and slice"); break;
|
||||
case AV_CODEC_CAP_FRAME_THREADS: av_log(NULL, AV_LOG_STDERR, "frame"); break;
|
||||
case AV_CODEC_CAP_SLICE_THREADS: av_log(NULL, AV_LOG_STDERR, "slice"); break;
|
||||
case AV_CODEC_CAP_AUTO_THREADS : av_log(NULL, AV_LOG_STDERR, "auto"); break;
|
||||
default: av_log(NULL, AV_LOG_STDERR, "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_STDERR, "\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (avcodec_get_hw_config(c, 0)) {
|
||||
av_log(NULL, AV_LOG_STDERR, " Supported hardware devices: ");
|
||||
printf(" 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_STDERR, "%s ", av_hwdevice_get_type_name(config->device_type));
|
||||
printf("%s ", av_hwdevice_get_type_name(config->device_type));
|
||||
}
|
||||
av_log(NULL, AV_LOG_STDERR, "\n");
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
if (c->supported_framerates) {
|
||||
const AVRational *fps = c->supported_framerates;
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, " Supported framerates:");
|
||||
printf(" Supported framerates:");
|
||||
while (fps->num) {
|
||||
av_log(NULL, AV_LOG_STDERR, " %d/%d", fps->num, fps->den);
|
||||
printf(" %d/%d", fps->num, fps->den);
|
||||
fps++;
|
||||
}
|
||||
av_log(NULL, AV_LOG_STDERR, "\n");
|
||||
printf("\n");
|
||||
}
|
||||
PRINT_CODEC_SUPPORTED(c, pix_fmts, enum AVPixelFormat, "pixel formats",
|
||||
AV_PIX_FMT_NONE, GET_PIX_FMT_NAME);
|
||||
@@ -1583,12 +1544,12 @@ static void print_codecs_for_id(enum AVCodecID id, int encoder)
|
||||
{
|
||||
const AVCodec *codec = NULL;
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, " (%s: ", encoder ? "encoders" : "decoders");
|
||||
printf(" (%s: ", encoder ? "encoders" : "decoders");
|
||||
|
||||
while ((codec = next_codec_for_id(id, codec, encoder)))
|
||||
av_log(NULL, AV_LOG_STDERR, "%s ", codec->name);
|
||||
printf("%s ", codec->name);
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, ")");
|
||||
printf(")");
|
||||
}
|
||||
|
||||
int show_codecs(void *optctx, const char *opt, const char *arg)
|
||||
@@ -1596,7 +1557,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_STDERR, "Codecs:\n"
|
||||
printf("Codecs:\n"
|
||||
" D..... = Decoding supported\n"
|
||||
" .E.... = Encoding supported\n"
|
||||
" ..V... = Video codec\n"
|
||||
@@ -1613,16 +1574,16 @@ int show_codecs(void *optctx, const char *opt, const char *arg)
|
||||
if (strstr(desc->name, "_deprecated"))
|
||||
continue;
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, " ");
|
||||
av_log(NULL, AV_LOG_STDERR, avcodec_find_decoder(desc->id) ? "D" : ".");
|
||||
av_log(NULL, AV_LOG_STDERR, 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_STDERR, "%c", get_media_type_char(desc->type));
|
||||
av_log(NULL, AV_LOG_STDERR, (desc->props & AV_CODEC_PROP_INTRA_ONLY) ? "I" : ".");
|
||||
av_log(NULL, AV_LOG_STDERR, (desc->props & AV_CODEC_PROP_LOSSY) ? "L" : ".");
|
||||
av_log(NULL, AV_LOG_STDERR, (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_STDERR, " %-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 */
|
||||
@@ -1640,7 +1601,7 @@ int show_codecs(void *optctx, const char *opt, const char *arg)
|
||||
}
|
||||
}
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, "\n");
|
||||
printf("\n");
|
||||
}
|
||||
av_free(codecs);
|
||||
return 0;
|
||||
@@ -1651,7 +1612,7 @@ static void print_codecs(int encoder)
|
||||
const AVCodecDescriptor **codecs;
|
||||
unsigned i, nb_codecs = get_codecs_sorted(&codecs);
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, "%s:\n"
|
||||
printf("%s:\n"
|
||||
" V..... = Video\n"
|
||||
" A..... = Audio\n"
|
||||
" S..... = Subtitle\n"
|
||||
@@ -1667,18 +1628,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_STDERR, " %c", get_media_type_char(desc->type));
|
||||
av_log(NULL, AV_LOG_STDERR, (codec->capabilities & AV_CODEC_CAP_FRAME_THREADS) ? "F" : ".");
|
||||
av_log(NULL, AV_LOG_STDERR, (codec->capabilities & AV_CODEC_CAP_SLICE_THREADS) ? "S" : ".");
|
||||
av_log(NULL, AV_LOG_STDERR, (codec->capabilities & AV_CODEC_CAP_EXPERIMENTAL) ? "X" : ".");
|
||||
av_log(NULL, AV_LOG_STDERR, (codec->capabilities & AV_CODEC_CAP_DRAW_HORIZ_BAND)?"B" : ".");
|
||||
av_log(NULL, AV_LOG_STDERR, (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_STDERR, " %-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_STDERR, " (codec %s)", desc->name);
|
||||
printf(" (codec %s)", desc->name);
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, "\n");
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
av_free(codecs);
|
||||
@@ -1701,10 +1662,10 @@ int show_bsfs(void *optctx, const char *opt, const char *arg)
|
||||
const AVBitStreamFilter *bsf = NULL;
|
||||
void *opaque = NULL;
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, "Bitstream filters:\n");
|
||||
printf("Bitstream filters:\n");
|
||||
while ((bsf = av_bsf_iterate(&opaque)))
|
||||
av_log(NULL, AV_LOG_STDERR, "%s\n", bsf->name);
|
||||
av_log(NULL, AV_LOG_STDERR, "\n");
|
||||
printf("%s\n", bsf->name);
|
||||
printf("\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1713,13 +1674,13 @@ int show_protocols(void *optctx, const char *opt, const char *arg)
|
||||
void *opaque = NULL;
|
||||
const char *name;
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, "Supported file protocols:\n"
|
||||
printf("Supported file protocols:\n"
|
||||
"Input:\n");
|
||||
while ((name = avio_enum_protocols(&opaque, 0)))
|
||||
av_log(NULL, AV_LOG_STDERR, " %s\n", name);
|
||||
av_log(NULL, AV_LOG_STDERR, "Output:\n");
|
||||
printf(" %s\n", name);
|
||||
printf("Output:\n");
|
||||
while ((name = avio_enum_protocols(&opaque, 1)))
|
||||
av_log(NULL, AV_LOG_STDERR, " %s\n", name);
|
||||
printf(" %s\n", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -1732,7 +1693,7 @@ int show_filters(void *optctx, const char *opt, const char *arg)
|
||||
int i, j;
|
||||
const AVFilterPad *pad;
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, "Filters:\n"
|
||||
printf("Filters:\n"
|
||||
" T.. = Timeline support\n"
|
||||
" .S. = Slice threading\n"
|
||||
" ..C = Command support\n"
|
||||
@@ -1758,14 +1719,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_STDERR, " %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_STDERR, "No filters available: libavfilter disabled\n");
|
||||
printf("No filters available: libavfilter disabled\n");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
@@ -1776,10 +1737,10 @@ int show_colors(void *optctx, const char *opt, const char *arg)
|
||||
const uint8_t *rgb;
|
||||
int i;
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, "%-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_STDERR, "%-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;
|
||||
}
|
||||
@@ -1788,7 +1749,7 @@ int show_pix_fmts(void *optctx, const char *opt, const char *arg)
|
||||
{
|
||||
const AVPixFmtDescriptor *pix_desc = NULL;
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, "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"
|
||||
@@ -1804,7 +1765,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_STDERR, "%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' : '.',
|
||||
@@ -1823,24 +1784,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_STDERR, "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_STDERR, "%-14s %s\n", name, descr);
|
||||
printf("%-14s %s\n", name, descr);
|
||||
}
|
||||
av_log(NULL, AV_LOG_STDERR, "\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_STDERR, "%-14s ", name);
|
||||
printf("%-14s ", name);
|
||||
for (j = 1; j; j <<= 1)
|
||||
if ((layout & j))
|
||||
av_log(NULL, AV_LOG_STDERR, "%s%s", (layout & (j - 1)) ? "+" : "", av_get_channel_name(j));
|
||||
av_log(NULL, AV_LOG_STDERR, "\n");
|
||||
printf("%s%s", (layout & (j - 1)) ? "+" : "", av_get_channel_name(j));
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
@@ -1851,7 +1812,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_STDERR, "%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;
|
||||
}
|
||||
|
||||
@@ -1899,10 +1860,10 @@ static void show_help_demuxer(const char *name)
|
||||
return;
|
||||
}
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, "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_STDERR, " 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);
|
||||
@@ -1918,23 +1879,23 @@ static void show_help_muxer(const char *name)
|
||||
return;
|
||||
}
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, "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_STDERR, " Common extensions: %s.\n", fmt->extensions);
|
||||
printf(" Common extensions: %s.\n", fmt->extensions);
|
||||
if (fmt->mime_type)
|
||||
av_log(NULL, AV_LOG_STDERR, " 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_STDERR, " 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_STDERR, " 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_STDERR, " Default subtitle codec: %s.\n", desc->name);
|
||||
printf(" Default subtitle codec: %s.\n", desc->name);
|
||||
}
|
||||
|
||||
if (fmt->priv_class)
|
||||
@@ -1956,40 +1917,40 @@ static void show_help_filter(const char *name)
|
||||
return;
|
||||
}
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, "Filter %s\n", f->name);
|
||||
printf("Filter %s\n", f->name);
|
||||
if (f->description)
|
||||
av_log(NULL, AV_LOG_STDERR, " %s\n", f->description);
|
||||
printf(" %s\n", f->description);
|
||||
|
||||
if (f->flags & AVFILTER_FLAG_SLICE_THREADS)
|
||||
av_log(NULL, AV_LOG_STDERR, " slice threading supported\n");
|
||||
printf(" slice threading supported\n");
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, " Inputs:\n");
|
||||
printf(" Inputs:\n");
|
||||
count = avfilter_pad_count(f->inputs);
|
||||
for (i = 0; i < count; i++) {
|
||||
av_log(NULL, AV_LOG_STDERR, " #%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_STDERR, " dynamic (depending on the options)\n");
|
||||
printf(" dynamic (depending on the options)\n");
|
||||
else if (!count)
|
||||
av_log(NULL, AV_LOG_STDERR, " none (source filter)\n");
|
||||
printf(" none (source filter)\n");
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, " Outputs:\n");
|
||||
printf(" Outputs:\n");
|
||||
count = avfilter_pad_count(f->outputs);
|
||||
for (i = 0; i < count; i++) {
|
||||
av_log(NULL, AV_LOG_STDERR, " #%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_STDERR, " dynamic (depending on the options)\n");
|
||||
printf(" dynamic (depending on the options)\n");
|
||||
else if (!count)
|
||||
av_log(NULL, AV_LOG_STDERR, " 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_STDERR, "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");
|
||||
@@ -2009,7 +1970,7 @@ static void show_help_bsf(const char *name)
|
||||
return;
|
||||
}
|
||||
|
||||
av_log(NULL, AV_LOG_STDERR, "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)
|
||||
@@ -2019,6 +1980,7 @@ static void show_help_bsf(const char *name)
|
||||
int show_help(void *optctx, const char *opt, const char *arg)
|
||||
{
|
||||
char *topic, *par;
|
||||
av_log_set_callback(mobileffmpeg_log_callback_function);
|
||||
|
||||
topic = av_strdup(arg ? arg : "");
|
||||
if (!topic)
|
||||
@@ -2028,11 +1990,7 @@ int show_help(void *optctx, const char *opt, const char *arg)
|
||||
*par++ = 0;
|
||||
|
||||
if (!*topic) {
|
||||
if (program_name && !strcmp(program_name, "ffmpeg")) {
|
||||
show_help_default_ffmpeg(topic, par);
|
||||
} else {
|
||||
show_help_default_ffprobe(topic, par);
|
||||
}
|
||||
show_help_default(topic, par);
|
||||
} else if (!strcmp(topic, "decoder")) {
|
||||
show_help_codec(par, 0);
|
||||
} else if (!strcmp(topic, "encoder")) {
|
||||
@@ -2048,11 +2006,7 @@ int show_help(void *optctx, const char *opt, const char *arg)
|
||||
} else if (!strcmp(topic, "bsf")) {
|
||||
show_help_bsf(par);
|
||||
} else {
|
||||
if (program_name && !strcmp(program_name, "ffmpeg")) {
|
||||
show_help_default_ffmpeg(topic, par);
|
||||
} else {
|
||||
show_help_default_ffprobe(topic, par);
|
||||
}
|
||||
show_help_default(topic, par);
|
||||
}
|
||||
|
||||
av_freep(&topic);
|
||||
@@ -2084,7 +2038,7 @@ FILE *get_preset_file(char *filename, size_t filename_size,
|
||||
av_strlcpy(filename, preset_name, filename_size);
|
||||
f = fopen(filename, "r");
|
||||
} else {
|
||||
#if HAVE_GETMODULEHANDLE
|
||||
#ifdef _WIN32
|
||||
char datadir[MAX_PATH], *ls;
|
||||
base[2] = NULL;
|
||||
|
||||
@@ -2252,20 +2206,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_STDERR, "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_STDERR, "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_STDERR, "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_STDERR, "%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);
|
||||
}
|
||||
|
||||
@@ -2282,20 +2236,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_STDERR, "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_STDERR, "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_STDERR, "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_STDERR, "%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);
|
||||
}
|
||||
|
||||
@@ -2321,7 +2275,7 @@ static int show_sinks_sources_parse_arg(const char *arg, char **dev, AVDictionar
|
||||
}
|
||||
}
|
||||
} else
|
||||
av_log(NULL, AV_LOG_STDERR, "\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;
|
||||
}
|
||||
|
||||
@@ -20,17 +20,6 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 01.2020
|
||||
* - ffprobe support changes
|
||||
* - AV_LOG_STDERR introduced
|
||||
*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
*
|
||||
* CHANGES 03.2019
|
||||
* --------------------------------------------------------
|
||||
* - config.h include removed
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and include guards
|
||||
@@ -46,6 +35,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "libavcodec/avcodec.h"
|
||||
#include "libavfilter/avfilter.h"
|
||||
#include "libavformat/avformat.h"
|
||||
@@ -55,28 +45,22 @@
|
||||
#undef main /* We don't want SDL to override our main() */
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Defines logs printed to stderr by ffmpeg. They are not filtered and always redirected.
|
||||
*/
|
||||
#define AV_LOG_STDERR -16
|
||||
|
||||
/**
|
||||
* program name, defined by the program for show_version().
|
||||
*/
|
||||
extern __thread char *program_name;
|
||||
extern const char program_name[];
|
||||
|
||||
/**
|
||||
* program birth year, defined by the program for show_banner()
|
||||
*/
|
||||
extern __thread int program_birth_year;
|
||||
extern const int program_birth_year;
|
||||
|
||||
extern __thread AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
|
||||
extern __thread AVFormatContext *avformat_opts;
|
||||
extern __thread AVDictionary *sws_dict;
|
||||
extern __thread AVDictionary *swr_opts;
|
||||
extern __thread AVDictionary *format_opts, *codec_opts, *resample_opts;
|
||||
extern __thread int hide_banner;
|
||||
extern __thread int find_stream_info;
|
||||
extern AVCodecContext *avcodec_opts[AVMEDIA_TYPE_NB];
|
||||
extern AVFormatContext *avformat_opts;
|
||||
extern AVDictionary *sws_dict;
|
||||
extern AVDictionary *swr_opts;
|
||||
extern AVDictionary *format_opts, *codec_opts, *resample_opts;
|
||||
extern int hide_banner;
|
||||
|
||||
/**
|
||||
* Register a program-specific cleanup routine.
|
||||
@@ -126,7 +110,7 @@ int opt_default(void *optctx, const char *opt, const char *arg);
|
||||
*/
|
||||
int opt_loglevel(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
int opt_report(void *optctx, const char *opt, const char *arg);
|
||||
int opt_report(const char *opt);
|
||||
|
||||
int opt_max_alloc(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
@@ -228,6 +212,47 @@ typedef struct OptionDef {
|
||||
void show_help_options(const OptionDef *options, const char *msg, int req_flags,
|
||||
int rej_flags, int alt_flags);
|
||||
|
||||
#if CONFIG_AVDEVICE
|
||||
#define CMDUTILS_COMMON_OPTIONS_AVDEVICE \
|
||||
{ "sources" , OPT_EXIT | HAS_ARG, { .func_arg = show_sources }, \
|
||||
"list sources of the input device", "device" }, \
|
||||
{ "sinks" , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks }, \
|
||||
"list sinks of the output device", "device" }, \
|
||||
|
||||
#else
|
||||
#define CMDUTILS_COMMON_OPTIONS_AVDEVICE
|
||||
#endif
|
||||
|
||||
#define CMDUTILS_COMMON_OPTIONS \
|
||||
{ "L", OPT_EXIT, { .func_arg = show_license }, "show license" }, \
|
||||
{ "h", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
|
||||
{ "?", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
|
||||
{ "help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
|
||||
{ "-help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" }, \
|
||||
{ "version", OPT_EXIT, { .func_arg = show_version }, "show version" }, \
|
||||
{ "buildconf", OPT_EXIT, { .func_arg = show_buildconf }, "show build configuration" }, \
|
||||
{ "formats", OPT_EXIT, { .func_arg = show_formats }, "show available formats" }, \
|
||||
{ "muxers", OPT_EXIT, { .func_arg = show_muxers }, "show available muxers" }, \
|
||||
{ "demuxers", OPT_EXIT, { .func_arg = show_demuxers }, "show available demuxers" }, \
|
||||
{ "devices", OPT_EXIT, { .func_arg = show_devices }, "show available devices" }, \
|
||||
{ "codecs", OPT_EXIT, { .func_arg = show_codecs }, "show available codecs" }, \
|
||||
{ "decoders", OPT_EXIT, { .func_arg = show_decoders }, "show available decoders" }, \
|
||||
{ "encoders", OPT_EXIT, { .func_arg = show_encoders }, "show available encoders" }, \
|
||||
{ "bsfs", OPT_EXIT, { .func_arg = show_bsfs }, "show available bit stream filters" }, \
|
||||
{ "protocols", OPT_EXIT, { .func_arg = show_protocols }, "show available protocols" }, \
|
||||
{ "filters", OPT_EXIT, { .func_arg = show_filters }, "show available filters" }, \
|
||||
{ "pix_fmts", OPT_EXIT, { .func_arg = show_pix_fmts }, "show available pixel formats" }, \
|
||||
{ "layouts", OPT_EXIT, { .func_arg = show_layouts }, "show standard channel layouts" }, \
|
||||
{ "sample_fmts", OPT_EXIT, { .func_arg = show_sample_fmts }, "show available audio sample formats" }, \
|
||||
{ "colors", OPT_EXIT, { .func_arg = show_colors }, "show available color names" }, \
|
||||
{ "loglevel", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \
|
||||
{ "v", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" }, \
|
||||
{ "report", 0, { (void*)opt_report }, "generate a report" }, \
|
||||
{ "max_alloc", HAS_ARG, { .func_arg = opt_max_alloc }, "set maximum size of a single allocated block", "bytes" }, \
|
||||
{ "cpuflags", HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "force specific cpu flags", "flags" }, \
|
||||
{ "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner}, "do not show program banner", "hide_banner" }, \
|
||||
CMDUTILS_COMMON_OPTIONS_AVDEVICE \
|
||||
|
||||
/**
|
||||
* Show help for all options with given flags in class and all its
|
||||
* children.
|
||||
@@ -235,11 +260,10 @@ void show_help_options(const OptionDef *options, const char *msg, int req_flags,
|
||||
void show_help_children(const AVClass *class, int flags);
|
||||
|
||||
/**
|
||||
* Per-fftool specific help handlers. Implemented in each
|
||||
* Per-fftool specific help handler. Implemented in each
|
||||
* fftool, called by show_help().
|
||||
*/
|
||||
void show_help_default_ffmpeg(const char *opt, const char *arg);
|
||||
void show_help_default_ffprobe(const char *opt, const char *arg);
|
||||
void show_help_default(const char *opt, const char *arg);
|
||||
|
||||
/**
|
||||
* Generic -h handler common to all fftools.
|
||||
|
||||
@@ -24,12 +24,6 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 01.2020
|
||||
* - ffprobe support changes
|
||||
*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and parent headers
|
||||
@@ -41,10 +35,10 @@
|
||||
*
|
||||
* CHANGES 07.2018
|
||||
* --------------------------------------------------------
|
||||
* - main() function renamed as ffmpeg_execute()
|
||||
* - main() function renamed as execute()
|
||||
* - exit_program() implemented with setjmp
|
||||
* - extern longjmp_value added to access exit code stored in exit_program()
|
||||
* - ffmpeg_var_cleanup() method added
|
||||
* - cleanup() method added
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
@@ -132,6 +126,9 @@
|
||||
|
||||
#include "libavutil/avassert.h"
|
||||
|
||||
const char program_name[] = "ffmpeg";
|
||||
const int program_birth_year = 2000;
|
||||
|
||||
static FILE *vstats_file;
|
||||
|
||||
const char *const forced_keyframes_const_names[] = {
|
||||
@@ -154,85 +151,39 @@ static BenchmarkTimeStamps get_benchmark_time_stamps(void);
|
||||
static int64_t getmaxrss(void);
|
||||
static int ifilter_has_all_input_formats(FilterGraph *fg);
|
||||
|
||||
__thread int run_as_daemon = 0;
|
||||
__thread int nb_frames_dup = 0;
|
||||
__thread unsigned dup_warning = 1000;
|
||||
__thread int nb_frames_drop = 0;
|
||||
__thread int64_t decode_error_stat[2];
|
||||
static int run_as_daemon = 0;
|
||||
static int nb_frames_dup = 0;
|
||||
static unsigned dup_warning = 1000;
|
||||
static int nb_frames_drop = 0;
|
||||
static int64_t decode_error_stat[2];
|
||||
|
||||
__thread int want_sdp = 1;
|
||||
static int want_sdp = 1;
|
||||
|
||||
__thread BenchmarkTimeStamps current_time;
|
||||
__thread AVIOContext *progress_avio = NULL;
|
||||
static BenchmarkTimeStamps current_time;
|
||||
AVIOContext *progress_avio = NULL;
|
||||
|
||||
__thread uint8_t *subtitle_out;
|
||||
static uint8_t *subtitle_out;
|
||||
|
||||
__thread InputStream **input_streams = NULL;
|
||||
__thread int nb_input_streams = 0;
|
||||
__thread InputFile **input_files = NULL;
|
||||
__thread int nb_input_files = 0;
|
||||
InputStream **input_streams = NULL;
|
||||
int nb_input_streams = 0;
|
||||
InputFile **input_files = NULL;
|
||||
int nb_input_files = 0;
|
||||
|
||||
__thread OutputStream **output_streams = NULL;
|
||||
__thread int nb_output_streams = 0;
|
||||
__thread OutputFile **output_files = NULL;
|
||||
__thread int nb_output_files = 0;
|
||||
OutputStream **output_streams = NULL;
|
||||
int nb_output_streams = 0;
|
||||
OutputFile **output_files = NULL;
|
||||
int nb_output_files = 0;
|
||||
|
||||
__thread FilterGraph **filtergraphs;
|
||||
__thread int nb_filtergraphs;
|
||||
FilterGraph **filtergraphs;
|
||||
int nb_filtergraphs;
|
||||
|
||||
void (*report_callback)(int, float, float, int64_t, int, double, double) = NULL;
|
||||
|
||||
extern __thread int file_overwrite;
|
||||
extern __thread int no_file_overwrite;
|
||||
extern __thread int ignore_unknown_streams;
|
||||
extern __thread int copy_unknown_streams;
|
||||
extern int opt_map(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_map_channel(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_recording_timestamp(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_data_frames(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_progress(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_target(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_vsync(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_abort_on(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_qscale(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_profile(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_filter_complex(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_filter_complex_script(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_attach(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_video_frames(void *optctx, const char *opt, const char *arg);
|
||||
extern __thread int intra_only;
|
||||
extern int opt_video_codec(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_sameq(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_timecode(void *optctx, const char *opt, const char *arg);
|
||||
extern __thread int do_psnr;
|
||||
extern int opt_vstats_file(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_vstats(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_video_frames(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_old2new(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_streamid(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_bitrate(void *optctx, const char *opt, const char *arg);
|
||||
extern int show_hwaccels(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_video_filters(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_audio_frames(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_audio_qscale(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_audio_codec(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_channel_layout(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_preset(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_audio_filters(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_subtitle_codec(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_video_channel(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_video_standard(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_sdp_file(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_data_codec(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_init_hw_device(void *optctx, const char *opt, const char *arg);
|
||||
extern int opt_filter_hw_device(void *optctx, const char *opt, const char *arg);
|
||||
extern __thread int input_sync;
|
||||
static void (*report_callback)(int, float, float, int64_t, int, double, double) = NULL;
|
||||
|
||||
#if HAVE_TERMIOS_H
|
||||
|
||||
/* init terminal so that we can grab keys */
|
||||
__thread struct termios oldtty;
|
||||
__thread int restore_tty;
|
||||
static struct termios oldtty;
|
||||
static int restore_tty;
|
||||
#endif
|
||||
|
||||
#if HAVE_THREADS
|
||||
@@ -402,12 +353,12 @@ void term_exit(void)
|
||||
term_exit_sigsafe();
|
||||
}
|
||||
|
||||
volatile int received_sigterm = 0;
|
||||
volatile int received_nb_signals = 0;
|
||||
__thread atomic_int transcode_init_done = ATOMIC_VAR_INIT(0);
|
||||
__thread volatile int ffmpeg_exited = 0;
|
||||
__thread int main_ffmpeg_return_code = 0;
|
||||
extern __thread int longjmp_value;
|
||||
static volatile int received_sigterm = 0;
|
||||
static volatile int received_nb_signals = 0;
|
||||
static atomic_int transcode_init_done = ATOMIC_VAR_INIT(0);
|
||||
static volatile int ffmpeg_exited = 0;
|
||||
static int main_return_code = 0;
|
||||
extern int longjmp_value;
|
||||
|
||||
static void
|
||||
sigterm_handler(int sig)
|
||||
@@ -545,14 +496,12 @@ static int read_key(void)
|
||||
return -1;
|
||||
}
|
||||
|
||||
int decode_interrupt_cb(void *ctx);
|
||||
|
||||
int decode_interrupt_cb(void *ctx)
|
||||
static int decode_interrupt_cb(void *ctx)
|
||||
{
|
||||
return received_nb_signals > atomic_load(&transcode_init_done);
|
||||
}
|
||||
|
||||
__thread const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL };
|
||||
const AVIOInterruptCB int_cb = { decode_interrupt_cb, NULL };
|
||||
|
||||
static void ffmpeg_cleanup(int ret)
|
||||
{
|
||||
@@ -641,7 +590,6 @@ static void ffmpeg_cleanup(int ret)
|
||||
ost->audio_channels_mapped = 0;
|
||||
|
||||
av_dict_free(&ost->sws_dict);
|
||||
av_dict_free(&ost->swr_opts);
|
||||
|
||||
avcodec_free_context(&ost->enc_ctx);
|
||||
avcodec_parameters_free(&ost->ref_par);
|
||||
@@ -890,7 +838,7 @@ static void write_packet(OutputFile *of, AVPacket *pkt, OutputStream *ost, int u
|
||||
ret = av_interleaved_write_frame(s, pkt);
|
||||
if (ret < 0) {
|
||||
print_error("av_interleaved_write_frame()", ret);
|
||||
main_ffmpeg_return_code = 1;
|
||||
main_return_code = 1;
|
||||
close_all_output_streams(ost, MUXER_FINISHED | ENCODER_FINISHED, ENCODER_FINISHED);
|
||||
}
|
||||
av_packet_unref(pkt);
|
||||
@@ -1154,7 +1102,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) {
|
||||
@@ -1272,8 +1219,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;
|
||||
@@ -1288,9 +1233,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;
|
||||
@@ -1362,8 +1315,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);
|
||||
@@ -1400,6 +1351,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.
|
||||
@@ -1563,6 +1515,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:
|
||||
@@ -2155,13 +2109,12 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
|
||||
InputFile *f = input_files [ist->file_index];
|
||||
int64_t start_time = (of->start_time == AV_NOPTS_VALUE) ? 0 : of->start_time;
|
||||
int64_t ost_tb_start_time = av_rescale_q(start_time, AV_TIME_BASE_Q, ost->mux_timebase);
|
||||
AVPacket opkt;
|
||||
AVPacket opkt = { 0 };
|
||||
|
||||
av_init_packet(&opkt);
|
||||
|
||||
// EOF: flush output bitstream filters.
|
||||
if (!pkt) {
|
||||
av_init_packet(&opkt);
|
||||
opkt.data = NULL;
|
||||
opkt.size = 0;
|
||||
output_packet(of, &opkt, ost, 1);
|
||||
return;
|
||||
}
|
||||
@@ -2200,11 +2153,10 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
|
||||
if (ost->enc_ctx->codec_type == AVMEDIA_TYPE_VIDEO)
|
||||
ost->sync_opts++;
|
||||
|
||||
if (av_packet_ref(&opkt, pkt) < 0)
|
||||
exit_program(1);
|
||||
|
||||
if (pkt->pts != AV_NOPTS_VALUE)
|
||||
opkt.pts = av_rescale_q(pkt->pts, ist->st->time_base, ost->mux_timebase) - ost_tb_start_time;
|
||||
else
|
||||
opkt.pts = AV_NOPTS_VALUE;
|
||||
|
||||
if (pkt->dts == AV_NOPTS_VALUE)
|
||||
opkt.dts = av_rescale_q(ist->dts, AV_TIME_BASE_Q, ost->mux_timebase);
|
||||
@@ -2223,6 +2175,18 @@ static void do_streamcopy(InputStream *ist, OutputStream *ost, const AVPacket *p
|
||||
|
||||
opkt.duration = av_rescale_q(pkt->duration, ist->st->time_base, ost->mux_timebase);
|
||||
|
||||
opkt.flags = pkt->flags;
|
||||
|
||||
if (pkt->buf) {
|
||||
opkt.buf = av_buffer_ref(pkt->buf);
|
||||
if (!opkt.buf)
|
||||
exit_program(1);
|
||||
}
|
||||
opkt.data = pkt->data;
|
||||
opkt.size = pkt->size;
|
||||
|
||||
av_copy_packet_side_data(&opkt, pkt);
|
||||
|
||||
output_packet(of, &opkt, ost, 0);
|
||||
}
|
||||
|
||||
@@ -2283,6 +2247,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:
|
||||
@@ -2296,13 +2263,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)
|
||||
@@ -2467,12 +2427,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;
|
||||
@@ -2932,7 +2894,7 @@ static void print_sdp(void)
|
||||
av_sdp_create(avc, j, sdp, sizeof(sdp));
|
||||
|
||||
if (!sdp_filename) {
|
||||
av_log(NULL, AV_LOG_STDERR, "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) {
|
||||
@@ -3495,7 +3457,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];
|
||||
@@ -4029,9 +3991,7 @@ static OutputStream *choose_output(void)
|
||||
av_rescale_q(ost->st->cur_dts, ost->st->time_base,
|
||||
AV_TIME_BASE_Q);
|
||||
if (ost->st->cur_dts == AV_NOPTS_VALUE)
|
||||
av_log(NULL, AV_LOG_DEBUG,
|
||||
"cur_dts is invalid st:%d (%d) [init:%d i_done:%d finish:%d] (this is harmless if it occurs once at the start per stream)\n",
|
||||
ost->st->index, ost->st->id, ost->initialized, ost->inputs_done, ost->finished);
|
||||
av_log(NULL, AV_LOG_DEBUG, "cur_dts is invalid (this is harmless if it occurs once at the start per stream)\n");
|
||||
|
||||
if (!ost->initialized && !ost->inputs_done)
|
||||
return ost;
|
||||
@@ -4349,7 +4309,7 @@ static int seek_to_start(InputFile *ifile, AVFormatContext *is)
|
||||
int i, ret, has_audio = 0;
|
||||
int64_t duration = 0;
|
||||
|
||||
ret = avformat_seek_file(is, -1, INT64_MIN, is->start_time, is->start_time, 0);
|
||||
ret = av_seek_frame(is, -1, is->start_time, 0);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
@@ -4628,10 +4588,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)
|
||||
@@ -4994,8 +4951,8 @@ static void log_callback_null(void *ptr, int level, const char *fmt, va_list vl)
|
||||
{
|
||||
}
|
||||
|
||||
void ffmpeg_var_cleanup() {
|
||||
main_ffmpeg_return_code = 0;
|
||||
void cleanup() {
|
||||
main_return_code = 0;
|
||||
longjmp_value = 0;
|
||||
received_sigterm = 0;
|
||||
received_nb_signals = 0;
|
||||
@@ -5034,449 +4991,15 @@ void cancel_operation()
|
||||
sigterm_handler(SIGINT);
|
||||
}
|
||||
|
||||
__thread OptionDef *ffmpeg_options = NULL;
|
||||
|
||||
int ffmpeg_execute(int argc, char **argv)
|
||||
int execute(int argc, char **argv)
|
||||
{
|
||||
char _program_name[] = "ffmpeg";
|
||||
program_name = (char*)&_program_name;
|
||||
program_birth_year = 2000;
|
||||
|
||||
#define OFFSET(x) offsetof(OptionsContext, x)
|
||||
OptionDef options[] = {
|
||||
|
||||
/* main options */
|
||||
{ "L", OPT_EXIT, { .func_arg = show_license }, "show license" },
|
||||
{ "h", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" },
|
||||
{ "?", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" },
|
||||
{ "help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" },
|
||||
{ "-help", OPT_EXIT, { .func_arg = show_help }, "show help", "topic" },
|
||||
{ "version", OPT_EXIT, { .func_arg = show_version }, "show version" },
|
||||
{ "buildconf", OPT_EXIT, { .func_arg = show_buildconf }, "show build configuration" },
|
||||
{ "formats", OPT_EXIT, { .func_arg = show_formats }, "show available formats" },
|
||||
{ "muxers", OPT_EXIT, { .func_arg = show_muxers }, "show available muxers" },
|
||||
{ "demuxers", OPT_EXIT, { .func_arg = show_demuxers }, "show available demuxers" },
|
||||
{ "devices", OPT_EXIT, { .func_arg = show_devices }, "show available devices" },
|
||||
{ "codecs", OPT_EXIT, { .func_arg = show_codecs }, "show available codecs" },
|
||||
{ "decoders", OPT_EXIT, { .func_arg = show_decoders }, "show available decoders" },
|
||||
{ "encoders", OPT_EXIT, { .func_arg = show_encoders }, "show available encoders" },
|
||||
{ "bsfs", OPT_EXIT, { .func_arg = show_bsfs }, "show available bit stream filters" },
|
||||
{ "protocols", OPT_EXIT, { .func_arg = show_protocols }, "show available protocols" },
|
||||
{ "filters", OPT_EXIT, { .func_arg = show_filters }, "show available filters" },
|
||||
{ "pix_fmts", OPT_EXIT, { .func_arg = show_pix_fmts }, "show available pixel formats" },
|
||||
{ "layouts", OPT_EXIT, { .func_arg = show_layouts }, "show standard channel layouts" },
|
||||
{ "sample_fmts", OPT_EXIT, { .func_arg = show_sample_fmts }, "show available audio sample formats" },
|
||||
{ "colors", OPT_EXIT, { .func_arg = show_colors }, "show available color names" },
|
||||
{ "loglevel", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" },
|
||||
{ "v", HAS_ARG, { .func_arg = opt_loglevel }, "set logging level", "loglevel" },
|
||||
{ "report", 0, { .func_arg = opt_report }, "generate a report" },
|
||||
{ "max_alloc", HAS_ARG, { .func_arg = opt_max_alloc }, "set maximum size of a single allocated block", "bytes" },
|
||||
{ "cpuflags", HAS_ARG | OPT_EXPERT, { .func_arg = opt_cpuflags }, "force specific cpu flags", "flags" },
|
||||
{ "hide_banner", OPT_BOOL | OPT_EXPERT, {&hide_banner}, "do not show program banner", "hide_banner" },
|
||||
|
||||
#if CONFIG_AVDEVICE
|
||||
{ "sources" , OPT_EXIT | HAS_ARG, { .func_arg = show_sources },
|
||||
"list sources of the input device", "device" },
|
||||
{ "sinks" , OPT_EXIT | HAS_ARG, { .func_arg = show_sinks },
|
||||
"list sinks of the output device", "device" },
|
||||
#endif
|
||||
|
||||
{ "f", HAS_ARG | OPT_STRING | OPT_OFFSET |
|
||||
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(format) },
|
||||
"force format", "fmt" },
|
||||
{ "y", OPT_BOOL, { &file_overwrite },
|
||||
"overwrite output files" },
|
||||
{ "n", OPT_BOOL, { &no_file_overwrite },
|
||||
"never overwrite output files" },
|
||||
{ "ignore_unknown", OPT_BOOL, { &ignore_unknown_streams },
|
||||
"Ignore unknown stream types" },
|
||||
{ "copy_unknown", OPT_BOOL | OPT_EXPERT, { ©_unknown_streams },
|
||||
"Copy unknown stream types" },
|
||||
{ "c", HAS_ARG | OPT_STRING | OPT_SPEC |
|
||||
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(codec_names) },
|
||||
"codec name", "codec" },
|
||||
{ "codec", HAS_ARG | OPT_STRING | OPT_SPEC |
|
||||
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(codec_names) },
|
||||
"codec name", "codec" },
|
||||
{ "pre", HAS_ARG | OPT_STRING | OPT_SPEC |
|
||||
OPT_OUTPUT, { .off = OFFSET(presets) },
|
||||
"preset name", "preset" },
|
||||
{ "map", HAS_ARG | OPT_EXPERT | OPT_PERFILE |
|
||||
OPT_OUTPUT, { .func_arg = opt_map },
|
||||
"set input stream mapping",
|
||||
"[-]input_file_id[:stream_specifier][,sync_file_id[:stream_specifier]]" },
|
||||
{ "map_channel", HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_map_channel },
|
||||
"map an audio channel from one stream to another", "file.stream.channel[:syncfile.syncstream]" },
|
||||
{ "map_metadata", HAS_ARG | OPT_STRING | OPT_SPEC |
|
||||
OPT_OUTPUT, { .off = OFFSET(metadata_map) },
|
||||
"set metadata information of outfile from infile",
|
||||
"outfile[,metadata]:infile[,metadata]" },
|
||||
{ "map_chapters", HAS_ARG | OPT_INT | OPT_EXPERT | OPT_OFFSET |
|
||||
OPT_OUTPUT, { .off = OFFSET(chapters_input_file) },
|
||||
"set chapters mapping", "input_file_index" },
|
||||
{ "t", HAS_ARG | OPT_TIME | OPT_OFFSET |
|
||||
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(recording_time) },
|
||||
"record or transcode \"duration\" seconds of audio/video",
|
||||
"duration" },
|
||||
{ "to", HAS_ARG | OPT_TIME | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(stop_time) },
|
||||
"record or transcode stop time", "time_stop" },
|
||||
{ "fs", HAS_ARG | OPT_INT64 | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(limit_filesize) },
|
||||
"set the limit file size in bytes", "limit_size" },
|
||||
{ "ss", HAS_ARG | OPT_TIME | OPT_OFFSET |
|
||||
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) },
|
||||
"set the start time offset relative to EOF", "time_off" },
|
||||
{ "seek_timestamp", HAS_ARG | OPT_INT | OPT_OFFSET |
|
||||
OPT_INPUT, { .off = OFFSET(seek_timestamp) },
|
||||
"enable/disable seeking by timestamp with -ss" },
|
||||
{ "accurate_seek", OPT_BOOL | OPT_OFFSET | OPT_EXPERT |
|
||||
OPT_INPUT, { .off = OFFSET(accurate_seek) },
|
||||
"enable/disable accurate seeking with -ss" },
|
||||
{ "itsoffset", HAS_ARG | OPT_TIME | OPT_OFFSET |
|
||||
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(input_ts_offset) },
|
||||
"set the input ts offset", "time_off" },
|
||||
{ "itsscale", HAS_ARG | OPT_DOUBLE | OPT_SPEC |
|
||||
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(ts_scale) },
|
||||
"set the input ts scale", "scale" },
|
||||
{ "timestamp", HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_recording_timestamp },
|
||||
"set the recording timestamp ('now' to set the current time)", "time" },
|
||||
{ "metadata", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(metadata) },
|
||||
"add metadata", "string=string" },
|
||||
{ "program", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(program) },
|
||||
"add program with specified streams", "title=string:st=number..." },
|
||||
{ "dframes", HAS_ARG | OPT_PERFILE | OPT_EXPERT |
|
||||
OPT_OUTPUT, { .func_arg = opt_data_frames },
|
||||
"set the number of data frames to output", "number" },
|
||||
{ "benchmark", OPT_BOOL | OPT_EXPERT, { &do_benchmark },
|
||||
"add timings for benchmarking" },
|
||||
{ "benchmark_all", OPT_BOOL | OPT_EXPERT, { &do_benchmark_all },
|
||||
"add timings for each task" },
|
||||
{ "progress", HAS_ARG | OPT_EXPERT, { .func_arg = opt_progress },
|
||||
"write program-readable progress information", "url" },
|
||||
{ "stdin", OPT_BOOL | OPT_EXPERT, { &stdin_interaction },
|
||||
"enable or disable interaction on standard input" },
|
||||
{ "timelimit", HAS_ARG | OPT_EXPERT, { .func_arg = opt_timelimit },
|
||||
"set max runtime in seconds in CPU user time", "limit" },
|
||||
{ "dump", OPT_BOOL | OPT_EXPERT, { &do_pkt_dump },
|
||||
"dump each input packet" },
|
||||
{ "hex", OPT_BOOL | OPT_EXPERT, { &do_hex_dump },
|
||||
"when dumping packets, also dump the payload" },
|
||||
{ "re", OPT_BOOL | OPT_EXPERT | OPT_OFFSET |
|
||||
OPT_INPUT, { .off = OFFSET(rate_emu) },
|
||||
"read input at native frame rate", "" },
|
||||
{ "target", HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_target },
|
||||
"specify target file type (\"vcd\", \"svcd\", \"dvd\", \"dv\" or \"dv50\" "
|
||||
"with optional prefixes \"pal-\", \"ntsc-\" or \"film-\")", "type" },
|
||||
{ "vsync", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vsync },
|
||||
"video sync method", "" },
|
||||
{ "frame_drop_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &frame_drop_threshold },
|
||||
"frame drop threshold", "" },
|
||||
{ "async", HAS_ARG | OPT_INT | OPT_EXPERT, { &audio_sync_method },
|
||||
"audio sync method", "" },
|
||||
{ "adrift_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &audio_drift_threshold },
|
||||
"audio drift threshold", "threshold" },
|
||||
{ "copyts", OPT_BOOL | OPT_EXPERT, { ©_ts },
|
||||
"copy timestamps" },
|
||||
{ "start_at_zero", OPT_BOOL | OPT_EXPERT, { &start_at_zero },
|
||||
"shift input timestamps to start at 0 when using copyts" },
|
||||
{ "copytb", HAS_ARG | OPT_INT | OPT_EXPERT, { ©_tb },
|
||||
"copy input stream time base when stream copying", "mode" },
|
||||
{ "shortest", OPT_BOOL | OPT_EXPERT | OPT_OFFSET |
|
||||
OPT_OUTPUT, { .off = OFFSET(shortest) },
|
||||
"finish encoding within shortest input" },
|
||||
{ "bitexact", OPT_BOOL | OPT_EXPERT | OPT_OFFSET |
|
||||
OPT_OUTPUT | OPT_INPUT, { .off = OFFSET(bitexact) },
|
||||
"bitexact mode" },
|
||||
{ "apad", OPT_STRING | HAS_ARG | OPT_SPEC |
|
||||
OPT_OUTPUT, { .off = OFFSET(apad) },
|
||||
"audio pad", "" },
|
||||
{ "dts_delta_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &dts_delta_threshold },
|
||||
"timestamp discontinuity delta threshold", "threshold" },
|
||||
{ "dts_error_threshold", HAS_ARG | OPT_FLOAT | OPT_EXPERT, { &dts_error_threshold },
|
||||
"timestamp error delta threshold", "threshold" },
|
||||
{ "xerror", OPT_BOOL | OPT_EXPERT, { &exit_on_error },
|
||||
"exit on error", "error" },
|
||||
{ "abort_on", HAS_ARG | OPT_EXPERT, { .func_arg = opt_abort_on },
|
||||
"abort on the specified condition flags", "flags" },
|
||||
{ "copyinkf", OPT_BOOL | OPT_EXPERT | OPT_SPEC |
|
||||
OPT_OUTPUT, { .off = OFFSET(copy_initial_nonkeyframes) },
|
||||
"copy initial non-keyframes" },
|
||||
{ "copypriorss", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(copy_prior_start) },
|
||||
"copy or discard frames before start time" },
|
||||
{ "frames", OPT_INT64 | HAS_ARG | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(max_frames) },
|
||||
"set the number of frames to output", "number" },
|
||||
{ "tag", OPT_STRING | HAS_ARG | OPT_SPEC |
|
||||
OPT_EXPERT | OPT_OUTPUT | OPT_INPUT, { .off = OFFSET(codec_tags) },
|
||||
"force codec tag/fourcc", "fourcc/tag" },
|
||||
{ "q", HAS_ARG | OPT_EXPERT | OPT_DOUBLE |
|
||||
OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(qscale) },
|
||||
"use fixed quality scale (VBR)", "q" },
|
||||
{ "qscale", HAS_ARG | OPT_EXPERT | OPT_PERFILE |
|
||||
OPT_OUTPUT, { .func_arg = opt_qscale },
|
||||
"use fixed quality scale (VBR)", "q" },
|
||||
{ "profile", HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_profile },
|
||||
"set profile", "profile" },
|
||||
{ "filter", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filters) },
|
||||
"set stream filtergraph", "filter_graph" },
|
||||
{ "filter_threads", HAS_ARG | OPT_INT, { &filter_nbthreads },
|
||||
"number of non-complex filter threads" },
|
||||
{ "filter_script", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(filter_scripts) },
|
||||
"read stream filtergraph description from a file", "filename" },
|
||||
{ "reinit_filter", HAS_ARG | OPT_INT | OPT_SPEC | OPT_INPUT, { .off = OFFSET(reinit_filters) },
|
||||
"reinit filtergraph on input parameter changes", "" },
|
||||
{ "filter_complex", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex },
|
||||
"create a complex filtergraph", "graph_description" },
|
||||
{ "filter_complex_threads", HAS_ARG | OPT_INT, { &filter_complex_nbthreads },
|
||||
"number of threads for -filter_complex" },
|
||||
{ "lavfi", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex },
|
||||
"create a complex filtergraph", "graph_description" },
|
||||
{ "filter_complex_script", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_complex_script },
|
||||
"read complex filtergraph description from a file", "filename" },
|
||||
{ "stats", OPT_BOOL, { &print_stats },
|
||||
"print progress report during encoding", },
|
||||
{ "attach", HAS_ARG | OPT_PERFILE | OPT_EXPERT |
|
||||
OPT_OUTPUT, { .func_arg = opt_attach },
|
||||
"add an attachment to the output file", "filename" },
|
||||
{ "dump_attachment", HAS_ARG | OPT_STRING | OPT_SPEC |
|
||||
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(dump_attachment) },
|
||||
"extract an attachment into a file", "filename" },
|
||||
{ "stream_loop", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_INPUT |
|
||||
OPT_OFFSET, { .off = OFFSET(loop) }, "set number of times input stream shall be looped", "loop count" },
|
||||
{ "debug_ts", OPT_BOOL | OPT_EXPERT, { &debug_ts },
|
||||
"print timestamp debugging info" },
|
||||
{ "max_error_rate", HAS_ARG | OPT_FLOAT, { &max_error_rate },
|
||||
"ratio of errors (0.0: no errors, 1.0: 100% errors) above which ffmpeg returns an error instead of success.", "maximum error rate" },
|
||||
{ "discard", OPT_STRING | HAS_ARG | OPT_SPEC |
|
||||
OPT_INPUT, { .off = OFFSET(discard) },
|
||||
"discard", "" },
|
||||
{ "disposition", OPT_STRING | HAS_ARG | OPT_SPEC |
|
||||
OPT_OUTPUT, { .off = OFFSET(disposition) },
|
||||
"disposition", "" },
|
||||
{ "thread_queue_size", HAS_ARG | OPT_INT | OPT_OFFSET | OPT_EXPERT | OPT_INPUT,
|
||||
{ .off = OFFSET(thread_queue_size) },
|
||||
"set the maximum number of queued packets from the demuxer" },
|
||||
{ "find_stream_info", OPT_BOOL | OPT_PERFILE | OPT_INPUT | OPT_EXPERT, { &find_stream_info },
|
||||
"read and decode the streams to fill missing information with heuristics" },
|
||||
|
||||
/* video options */
|
||||
{ "vframes", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_video_frames },
|
||||
"set the number of video frames to output", "number" },
|
||||
{ "r", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC |
|
||||
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(frame_rates) },
|
||||
"set frame rate (Hz value, fraction or abbreviation)", "rate" },
|
||||
{ "s", OPT_VIDEO | HAS_ARG | OPT_SUBTITLE | OPT_STRING | OPT_SPEC |
|
||||
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(frame_sizes) },
|
||||
"set frame size (WxH or abbreviation)", "size" },
|
||||
{ "aspect", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_SPEC |
|
||||
OPT_OUTPUT, { .off = OFFSET(frame_aspect_ratios) },
|
||||
"set aspect ratio (4:3, 16:9 or 1.3333, 1.7777)", "aspect" },
|
||||
{ "pix_fmt", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC |
|
||||
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(frame_pix_fmts) },
|
||||
"set pixel format", "format" },
|
||||
{ "bits_per_raw_sample", OPT_VIDEO | OPT_INT | HAS_ARG, { &frame_bits_per_raw_sample },
|
||||
"set the number of bits per raw sample", "number" },
|
||||
{ "intra", OPT_VIDEO | OPT_BOOL | OPT_EXPERT, { &intra_only },
|
||||
"deprecated use -g 1" },
|
||||
{ "vn", OPT_VIDEO | OPT_BOOL | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,{ .off = OFFSET(video_disable) },
|
||||
"disable video" },
|
||||
{ "rc_override", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC |
|
||||
OPT_OUTPUT, { .off = OFFSET(rc_overrides) },
|
||||
"rate control override for specific intervals", "override" },
|
||||
{ "vcodec", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_INPUT |
|
||||
OPT_OUTPUT, { .func_arg = opt_video_codec },
|
||||
"force video codec ('copy' to copy stream)", "codec" },
|
||||
{ "sameq", OPT_VIDEO | OPT_EXPERT , { .func_arg = opt_sameq },
|
||||
"Removed" },
|
||||
{ "same_quant", OPT_VIDEO | OPT_EXPERT , { .func_arg = opt_sameq },
|
||||
"Removed" },
|
||||
{ "timecode", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_timecode },
|
||||
"set initial TimeCode value.", "hh:mm:ss[:;.]ff" },
|
||||
{ "pass", OPT_VIDEO | HAS_ARG | OPT_SPEC | OPT_INT | OPT_OUTPUT, { .off = OFFSET(pass) },
|
||||
"select the pass number (1 to 3)", "n" },
|
||||
{ "passlogfile", OPT_VIDEO | HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC |
|
||||
OPT_OUTPUT, { .off = OFFSET(passlogfiles) },
|
||||
"select two pass log file name prefix", "prefix" },
|
||||
{ "deinterlace", OPT_VIDEO | OPT_BOOL | OPT_EXPERT, { &do_deinterlace },
|
||||
"this option is deprecated, use the yadif filter instead" },
|
||||
{ "psnr", OPT_VIDEO | OPT_BOOL | OPT_EXPERT, { &do_psnr },
|
||||
"calculate PSNR of compressed frames" },
|
||||
{ "vstats", OPT_VIDEO | OPT_EXPERT , { .func_arg = opt_vstats },
|
||||
"dump video coding statistics to file" },
|
||||
{ "vstats_file", OPT_VIDEO | HAS_ARG | OPT_EXPERT , { .func_arg = opt_vstats_file },
|
||||
"dump video coding statistics to file", "file" },
|
||||
{ "vstats_version", OPT_VIDEO | OPT_INT | HAS_ARG | OPT_EXPERT , { &vstats_version },
|
||||
"Version of the vstats format to use."},
|
||||
{ "vf", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_video_filters },
|
||||
"set video filters", "filter_graph" },
|
||||
{ "intra_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC |
|
||||
OPT_OUTPUT, { .off = OFFSET(intra_matrices) },
|
||||
"specify intra matrix coeffs", "matrix" },
|
||||
{ "inter_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC |
|
||||
OPT_OUTPUT, { .off = OFFSET(inter_matrices) },
|
||||
"specify inter matrix coeffs", "matrix" },
|
||||
{ "chroma_intra_matrix", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_STRING | OPT_SPEC |
|
||||
OPT_OUTPUT, { .off = OFFSET(chroma_intra_matrices) },
|
||||
"specify intra matrix coeffs", "matrix" },
|
||||
{ "top", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_INT| OPT_SPEC |
|
||||
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(top_field_first) },
|
||||
"top=1/bottom=0/auto=-1 field first", "" },
|
||||
{ "vtag", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_PERFILE |
|
||||
OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_old2new },
|
||||
"force video tag/fourcc", "fourcc/tag" },
|
||||
{ "qphist", OPT_VIDEO | OPT_BOOL | OPT_EXPERT , { &qp_hist },
|
||||
"show QP histogram" },
|
||||
{ "force_fps", OPT_VIDEO | OPT_BOOL | OPT_EXPERT | OPT_SPEC |
|
||||
OPT_OUTPUT, { .off = OFFSET(force_fps) },
|
||||
"force the selected framerate, disable the best supported framerate selection" },
|
||||
{ "streamid", OPT_VIDEO | HAS_ARG | OPT_EXPERT | OPT_PERFILE |
|
||||
OPT_OUTPUT, { .func_arg = opt_streamid },
|
||||
"set the value of an outfile streamid", "streamIndex:value" },
|
||||
{ "force_key_frames", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
|
||||
OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(forced_key_frames) },
|
||||
"force key frames at specified timestamps", "timestamps" },
|
||||
{ "ab", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_bitrate },
|
||||
"audio bitrate (please use -b:a)", "bitrate" },
|
||||
{ "b", OPT_VIDEO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_bitrate },
|
||||
"video bitrate (please use -b:v)", "bitrate" },
|
||||
{ "hwaccel", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
|
||||
OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccels) },
|
||||
"use HW accelerated decoding", "hwaccel name" },
|
||||
{ "hwaccel_device", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
|
||||
OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_devices) },
|
||||
"select a device for HW acceleration", "devicename" },
|
||||
{ "hwaccel_output_format", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
|
||||
OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_output_formats) },
|
||||
"select output format used with HW accelerated decoding", "format" },
|
||||
#if CONFIG_VIDEOTOOLBOX
|
||||
{ "videotoolbox_pixfmt", HAS_ARG | OPT_STRING | OPT_EXPERT, { &videotoolbox_pixfmt}, "" },
|
||||
#endif
|
||||
{ "hwaccels", OPT_EXIT, { .func_arg = show_hwaccels },
|
||||
"show available HW acceleration methods" },
|
||||
{ "autorotate", HAS_ARG | OPT_BOOL | OPT_SPEC |
|
||||
OPT_EXPERT | OPT_INPUT, { .off = OFFSET(autorotate) },
|
||||
"automatically insert correct rotate filters" },
|
||||
|
||||
/* audio options */
|
||||
{ "aframes", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_frames },
|
||||
"set the number of audio frames to output", "number" },
|
||||
{ "aq", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_qscale },
|
||||
"set audio quality (codec-specific)", "quality", },
|
||||
{ "ar", OPT_AUDIO | HAS_ARG | OPT_INT | OPT_SPEC |
|
||||
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(audio_sample_rate) },
|
||||
"set audio sampling rate (in Hz)", "rate" },
|
||||
{ "ac", OPT_AUDIO | HAS_ARG | OPT_INT | OPT_SPEC |
|
||||
OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(audio_channels) },
|
||||
"set number of audio channels", "channels" },
|
||||
{ "an", OPT_AUDIO | OPT_BOOL | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT,{ .off = OFFSET(audio_disable) },
|
||||
"disable audio" },
|
||||
{ "acodec", OPT_AUDIO | HAS_ARG | OPT_PERFILE |
|
||||
OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_audio_codec },
|
||||
"force audio codec ('copy' to copy stream)", "codec" },
|
||||
{ "atag", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_PERFILE |
|
||||
OPT_OUTPUT, { .func_arg = opt_old2new },
|
||||
"force audio tag/fourcc", "fourcc/tag" },
|
||||
{ "vol", OPT_AUDIO | HAS_ARG | OPT_INT, { &audio_volume },
|
||||
"change audio volume (256=normal)" , "volume" },
|
||||
{ "sample_fmt", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_SPEC |
|
||||
OPT_STRING | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(sample_fmts) },
|
||||
"set sample format", "format" },
|
||||
{ "channel_layout", OPT_AUDIO | HAS_ARG | OPT_EXPERT | OPT_PERFILE |
|
||||
OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_channel_layout },
|
||||
"set channel layout", "layout" },
|
||||
{ "af", OPT_AUDIO | HAS_ARG | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_audio_filters },
|
||||
"set audio filters", "filter_graph" },
|
||||
{ "guess_layout_max", OPT_AUDIO | HAS_ARG | OPT_INT | OPT_SPEC | OPT_EXPERT | OPT_INPUT, { .off = OFFSET(guess_layout_max) },
|
||||
"set the maximum number of channels to try to guess the channel layout" },
|
||||
|
||||
/* subtitle options */
|
||||
{ "sn", OPT_SUBTITLE | OPT_BOOL | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(subtitle_disable) },
|
||||
"disable subtitle" },
|
||||
{ "scodec", OPT_SUBTITLE | HAS_ARG | OPT_PERFILE | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_subtitle_codec },
|
||||
"force subtitle codec ('copy' to copy stream)", "codec" },
|
||||
{ "stag", OPT_SUBTITLE | HAS_ARG | OPT_EXPERT | OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_old2new }
|
||||
, "force subtitle tag/fourcc", "fourcc/tag" },
|
||||
{ "fix_sub_duration", OPT_BOOL | OPT_EXPERT | OPT_SUBTITLE | OPT_SPEC | OPT_INPUT, { .off = OFFSET(fix_sub_duration) },
|
||||
"fix subtitles duration" },
|
||||
{ "canvas_size", OPT_SUBTITLE | HAS_ARG | OPT_STRING | OPT_SPEC | OPT_INPUT, { .off = OFFSET(canvas_sizes) },
|
||||
"set canvas size (WxH or abbreviation)", "size" },
|
||||
|
||||
/* grab options */
|
||||
{ "vc", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_video_channel },
|
||||
"deprecated, use -channel", "channel" },
|
||||
{ "tvstd", HAS_ARG | OPT_EXPERT | OPT_VIDEO, { .func_arg = opt_video_standard },
|
||||
"deprecated, use -standard", "standard" },
|
||||
{ "isync", OPT_BOOL | OPT_EXPERT, { &input_sync }, "this option is deprecated and does nothing", "" },
|
||||
|
||||
/* muxer options */
|
||||
{ "muxdelay", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(mux_max_delay) },
|
||||
"set the maximum demux-decode delay", "seconds" },
|
||||
{ "muxpreload", OPT_FLOAT | HAS_ARG | OPT_EXPERT | OPT_OFFSET | OPT_OUTPUT, { .off = OFFSET(mux_preload) },
|
||||
"set the initial demux-decode delay", "seconds" },
|
||||
{ "sdp_file", HAS_ARG | OPT_EXPERT | OPT_OUTPUT, { .func_arg = opt_sdp_file },
|
||||
"specify a file in which to print sdp information", "file" },
|
||||
|
||||
{ "time_base", HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(time_bases) },
|
||||
"set the desired time base hint for output stream (1:24, 1:48000 or 0.04166, 2.0833e-5)", "ratio" },
|
||||
{ "enc_time_base", HAS_ARG | OPT_STRING | OPT_EXPERT | OPT_SPEC | OPT_OUTPUT, { .off = OFFSET(enc_time_bases) },
|
||||
"set the desired time base for the encoder (1:24, 1:48000 or 0.04166, 2.0833e-5). "
|
||||
"two special values are defined - "
|
||||
"0 = use frame rate (video) or sample rate (audio),"
|
||||
"-1 = match source time base", "ratio" },
|
||||
|
||||
{ "bsf", HAS_ARG | OPT_STRING | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(bitstream_filters) },
|
||||
"A comma-separated list of bitstream filters", "bitstream_filters" },
|
||||
{ "absf", HAS_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_old2new },
|
||||
"deprecated", "audio bitstream_filters" },
|
||||
{ "vbsf", OPT_VIDEO | HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_old2new },
|
||||
"deprecated", "video bitstream_filters" },
|
||||
|
||||
{ "apre", HAS_ARG | OPT_AUDIO | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset },
|
||||
"set the audio options to the indicated preset", "preset" },
|
||||
{ "vpre", OPT_VIDEO | HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset },
|
||||
"set the video options to the indicated preset", "preset" },
|
||||
{ "spre", HAS_ARG | OPT_SUBTITLE | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset },
|
||||
"set the subtitle options to the indicated preset", "preset" },
|
||||
{ "fpre", HAS_ARG | OPT_EXPERT| OPT_PERFILE | OPT_OUTPUT, { .func_arg = opt_preset },
|
||||
"set options from indicated preset file", "filename" },
|
||||
|
||||
{ "max_muxing_queue_size", HAS_ARG | OPT_INT | OPT_SPEC | OPT_EXPERT | OPT_OUTPUT, { .off = OFFSET(max_muxing_queue_size) },
|
||||
"maximum number of packets that can be buffered while waiting for all streams to initialize", "packets" },
|
||||
|
||||
/* data codec support */
|
||||
{ "dcodec", HAS_ARG | OPT_DATA | OPT_PERFILE | OPT_EXPERT | OPT_INPUT | OPT_OUTPUT, { .func_arg = opt_data_codec },
|
||||
"force data codec ('copy' to copy stream)", "codec" },
|
||||
{ "dn", OPT_BOOL | OPT_VIDEO | OPT_OFFSET | OPT_INPUT | OPT_OUTPUT, { .off = OFFSET(data_disable) },
|
||||
"disable data" },
|
||||
|
||||
#if CONFIG_VAAPI
|
||||
{ "vaapi_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_vaapi_device },
|
||||
"set VAAPI hardware device (DRM path or X11 display name)", "device" },
|
||||
#endif
|
||||
|
||||
#if CONFIG_QSV
|
||||
{ "qsv_device", HAS_ARG | OPT_STRING | OPT_EXPERT, { &qsv_device },
|
||||
"set QSV hardware device (DirectX adapter index, DRM path or X11 display name)", "device"},
|
||||
#endif
|
||||
|
||||
{ "init_hw_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_init_hw_device },
|
||||
"initialise hardware device", "args" },
|
||||
{ "filter_hw_device", HAS_ARG | OPT_EXPERT, { .func_arg = opt_filter_hw_device },
|
||||
"set hardware device used when filtering", "device" },
|
||||
|
||||
{ NULL, },
|
||||
};
|
||||
|
||||
ffmpeg_options = options;
|
||||
|
||||
int i, ret;
|
||||
BenchmarkTimeStamps ti;
|
||||
|
||||
int savedCode = setjmp(ex_buf__);
|
||||
if (savedCode == 0) {
|
||||
|
||||
ffmpeg_var_cleanup();
|
||||
cleanup();
|
||||
|
||||
init_dynload();
|
||||
|
||||
@@ -5518,6 +5041,11 @@ int ffmpeg_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;
|
||||
@@ -5541,11 +5069,11 @@ int ffmpeg_execute(int argc, char **argv)
|
||||
if ((decode_error_stat[0] + decode_error_stat[1]) * max_error_rate < decode_error_stat[1])
|
||||
exit_program(69);
|
||||
|
||||
exit_program(received_nb_signals ? 255 : main_ffmpeg_return_code);
|
||||
exit_program(received_nb_signals ? 255 : main_return_code);
|
||||
|
||||
} else {
|
||||
main_ffmpeg_return_code = longjmp_value;
|
||||
main_return_code = longjmp_value;
|
||||
}
|
||||
|
||||
return main_ffmpeg_return_code;
|
||||
return main_return_code;
|
||||
}
|
||||
|
||||
@@ -17,16 +17,6 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 01.2020
|
||||
* - ffprobe support changes
|
||||
*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
*
|
||||
* CHANGES 03.2019
|
||||
* --------------------------------------------------------
|
||||
* - config.h include removed
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and include guards
|
||||
@@ -41,6 +31,8 @@
|
||||
#ifndef FFTOOLS_FFMPEG_H
|
||||
#define FFTOOLS_FFMPEG_H
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <signal.h>
|
||||
@@ -92,7 +84,7 @@ typedef struct HWAccel {
|
||||
} HWAccel;
|
||||
|
||||
typedef struct HWDevice {
|
||||
const char *name;
|
||||
char *name;
|
||||
enum AVHWDeviceType type;
|
||||
AVBufferRef *device_ref;
|
||||
} HWDevice;
|
||||
@@ -584,61 +576,63 @@ typedef struct OutputFile {
|
||||
int header_written;
|
||||
} OutputFile;
|
||||
|
||||
extern __thread InputStream **input_streams;
|
||||
extern __thread int nb_input_streams;
|
||||
extern __thread InputFile **input_files;
|
||||
extern __thread int nb_input_files;
|
||||
extern InputStream **input_streams;
|
||||
extern int nb_input_streams;
|
||||
extern InputFile **input_files;
|
||||
extern int nb_input_files;
|
||||
|
||||
extern __thread OutputStream **output_streams;
|
||||
extern __thread int nb_output_streams;
|
||||
extern __thread OutputFile **output_files;
|
||||
extern __thread int nb_output_files;
|
||||
extern OutputStream **output_streams;
|
||||
extern int nb_output_streams;
|
||||
extern OutputFile **output_files;
|
||||
extern int nb_output_files;
|
||||
|
||||
extern __thread FilterGraph **filtergraphs;
|
||||
extern __thread int nb_filtergraphs;
|
||||
extern FilterGraph **filtergraphs;
|
||||
extern int nb_filtergraphs;
|
||||
|
||||
extern __thread char *vstats_filename;
|
||||
extern __thread char *sdp_filename;
|
||||
extern char *vstats_filename;
|
||||
extern char *sdp_filename;
|
||||
|
||||
extern __thread float audio_drift_threshold;
|
||||
extern __thread float dts_delta_threshold;
|
||||
extern __thread float dts_error_threshold;
|
||||
extern float audio_drift_threshold;
|
||||
extern float dts_delta_threshold;
|
||||
extern float dts_error_threshold;
|
||||
|
||||
extern __thread int audio_volume;
|
||||
extern __thread int audio_sync_method;
|
||||
extern __thread int video_sync_method;
|
||||
extern __thread float frame_drop_threshold;
|
||||
extern __thread int do_benchmark;
|
||||
extern __thread int do_benchmark_all;
|
||||
extern __thread int do_deinterlace;
|
||||
extern __thread int do_hex_dump;
|
||||
extern __thread int do_pkt_dump;
|
||||
extern __thread int copy_ts;
|
||||
extern __thread int start_at_zero;
|
||||
extern __thread int copy_tb;
|
||||
extern __thread int debug_ts;
|
||||
extern __thread int exit_on_error;
|
||||
extern __thread int abort_on_flags;
|
||||
extern __thread int print_stats;
|
||||
extern __thread int qp_hist;
|
||||
extern __thread int stdin_interaction;
|
||||
extern __thread int frame_bits_per_raw_sample;
|
||||
extern __thread AVIOContext *progress_avio;
|
||||
extern __thread float max_error_rate;
|
||||
extern __thread char *videotoolbox_pixfmt;
|
||||
extern int audio_volume;
|
||||
extern int audio_sync_method;
|
||||
extern int video_sync_method;
|
||||
extern float frame_drop_threshold;
|
||||
extern int do_benchmark;
|
||||
extern int do_benchmark_all;
|
||||
extern int do_deinterlace;
|
||||
extern int do_hex_dump;
|
||||
extern int do_pkt_dump;
|
||||
extern int copy_ts;
|
||||
extern int start_at_zero;
|
||||
extern int copy_tb;
|
||||
extern int debug_ts;
|
||||
extern int exit_on_error;
|
||||
extern int abort_on_flags;
|
||||
extern int print_stats;
|
||||
extern int qp_hist;
|
||||
extern int stdin_interaction;
|
||||
extern int frame_bits_per_raw_sample;
|
||||
extern AVIOContext *progress_avio;
|
||||
extern float max_error_rate;
|
||||
extern char *videotoolbox_pixfmt;
|
||||
|
||||
extern __thread int filter_nbthreads;
|
||||
extern __thread int filter_complex_nbthreads;
|
||||
extern __thread int vstats_version;
|
||||
extern int filter_nbthreads;
|
||||
extern int filter_complex_nbthreads;
|
||||
extern int vstats_version;
|
||||
|
||||
extern __thread const AVIOInterruptCB int_cb;
|
||||
extern const AVIOInterruptCB int_cb;
|
||||
|
||||
extern const OptionDef options[];
|
||||
extern const HWAccel hwaccels[];
|
||||
extern __thread AVBufferRef *hw_device_ctx;
|
||||
extern AVBufferRef *hw_device_ctx;
|
||||
#if CONFIG_QSV
|
||||
extern __thread char *qsv_device;
|
||||
extern char *qsv_device;
|
||||
#endif
|
||||
extern __thread HWDevice *filter_hw_device;
|
||||
extern HWDevice *filter_hw_device;
|
||||
|
||||
|
||||
void term_init(void);
|
||||
void term_exit(void);
|
||||
@@ -687,75 +681,4 @@ void set_report_callback(void (*callback)(int, float, float, int64_t, int, doubl
|
||||
|
||||
void cancel_operation();
|
||||
|
||||
int opt_map(void *optctx, const char *opt, const char *arg);
|
||||
int opt_map_channel(void *optctx, const char *opt, const char *arg);
|
||||
int opt_recording_timestamp(void *optctx, const char *opt, const char *arg);
|
||||
int opt_data_frames(void *optctx, const char *opt, const char *arg);
|
||||
int opt_progress(void *optctx, const char *opt, const char *arg);
|
||||
int opt_target(void *optctx, const char *opt, const char *arg);
|
||||
int opt_vsync(void *optctx, const char *opt, const char *arg);
|
||||
int opt_abort_on(void *optctx, const char *opt, const char *arg);
|
||||
int opt_qscale(void *optctx, const char *opt, const char *arg);
|
||||
int opt_profile(void *optctx, const char *opt, const char *arg);
|
||||
int opt_filter_complex(void *optctx, const char *opt, const char *arg);
|
||||
int opt_filter_complex_script(void *optctx, const char *opt, const char *arg);
|
||||
int opt_attach(void *optctx, const char *opt, const char *arg);
|
||||
int opt_video_frames(void *optctx, const char *opt, const char *arg);
|
||||
int opt_video_codec(void *optctx, const char *opt, const char *arg);
|
||||
int opt_sameq(void *optctx, const char *opt, const char *arg);
|
||||
int opt_timecode(void *optctx, const char *opt, const char *arg);
|
||||
|
||||
int opt_vstats_file(void *optctx, const char *opt, const char *arg);
|
||||
int opt_vstats(void *optctx, const char *opt, const char *arg);
|
||||
int opt_video_frames(void *optctx, const char *opt, const char *arg);
|
||||
int opt_old2new(void *optctx, const char *opt, const char *arg);
|
||||
int opt_streamid(void *optctx, const char *opt, const char *arg);
|
||||
int opt_bitrate(void *optctx, const char *opt, const char *arg);
|
||||
int show_hwaccels(void *optctx, const char *opt, const char *arg);
|
||||
int opt_video_filters(void *optctx, const char *opt, const char *arg);
|
||||
int opt_audio_frames(void *optctx, const char *opt, const char *arg);
|
||||
int opt_audio_qscale(void *optctx, const char *opt, const char *arg);
|
||||
int opt_audio_codec(void *optctx, const char *opt, const char *arg);
|
||||
int opt_channel_layout(void *optctx, const char *opt, const char *arg);
|
||||
int opt_preset(void *optctx, const char *opt, const char *arg);
|
||||
int opt_audio_filters(void *optctx, const char *opt, const char *arg);
|
||||
int opt_subtitle_codec(void *optctx, const char *opt, const char *arg);
|
||||
int opt_video_channel(void *optctx, const char *opt, const char *arg);
|
||||
int opt_video_standard(void *optctx, const char *opt, const char *arg);
|
||||
int opt_sdp_file(void *optctx, const char *opt, const char *arg);
|
||||
int opt_data_codec(void *optctx, const char *opt, const char *arg);
|
||||
int opt_init_hw_device(void *optctx, const char *opt, const char *arg);
|
||||
int opt_filter_hw_device(void *optctx, const char *opt, const char *arg);
|
||||
void add_input_streams(OptionsContext *o, AVFormatContext *ic);
|
||||
void assert_file_overwrite(const char *filename);
|
||||
void dump_attachment(AVStream *st, const char *filename);
|
||||
uint8_t *get_line(AVIOContext *s);
|
||||
void uninit_options(OptionsContext *o);
|
||||
void init_options(OptionsContext *o);
|
||||
AVDictionary *strip_specifiers(AVDictionary *dict);
|
||||
void parse_meta_type(char *arg, char *type, int *index, const char **stream_spec);
|
||||
int fftools_copy_metadata(char *outspec, char *inspec, AVFormatContext *oc, AVFormatContext *ic, OptionsContext *o);
|
||||
AVCodec *find_codec_or_die(const char *name, enum AVMediaType type, int encoder);
|
||||
AVCodec *choose_decoder(OptionsContext *o, AVFormatContext *s, AVStream *st);
|
||||
int open_input_file(OptionsContext *o, const char *filename);
|
||||
int get_preset_file_2(const char *preset_name, const char *codec_name, AVIOContext **s);
|
||||
int choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost);
|
||||
OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index);
|
||||
void parse_matrix_coeffs(uint16_t *dest, const char *str);
|
||||
uint8_t *fftools_read_file(const char *filename);
|
||||
char *get_ost_filters(OptionsContext *o, AVFormatContext *oc, OutputStream *ost);
|
||||
void check_streamcopy_filters(OptionsContext *o, AVFormatContext *oc, const OutputStream *ost, enum AVMediaType type);
|
||||
OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
OutputStream *new_data_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
OutputStream *new_unknown_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
OutputStream *new_attachment_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc, int source_index);
|
||||
int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata);
|
||||
void init_output_filter(OutputFilter *ofilter, OptionsContext *o, AVFormatContext *oc);
|
||||
int init_complex_filters(void);
|
||||
int open_output_file(OptionsContext *o, const char *filename);
|
||||
int opt_default_new(OptionsContext *o, const char *opt, const char *arg);
|
||||
int open_files(OptionGroupList *l, const char *inout, int (*open_file)(OptionsContext*, const char*));
|
||||
|
||||
#endif /* FFTOOLS_FFMPEG_H */
|
||||
|
||||
@@ -301,17 +301,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 +740,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;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,9 +17,6 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 12.2019
|
||||
* - Concurrent execution support
|
||||
*
|
||||
* CHANGES 08.2018
|
||||
* --------------------------------------------------------
|
||||
* - fftools_ prefix added to file name and parent header
|
||||
@@ -31,8 +28,8 @@
|
||||
|
||||
#include "fftools_ffmpeg.h"
|
||||
|
||||
__thread int nb_hw_devices;
|
||||
__thread HWDevice **hw_devices;
|
||||
static int nb_hw_devices;
|
||||
static HWDevice **hw_devices;
|
||||
|
||||
static HWDevice *hw_device_get_by_type(enum AVHWDeviceType type)
|
||||
{
|
||||
@@ -108,7 +105,7 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
// -> av_hwdevice_ctx_create_derived()
|
||||
|
||||
AVDictionary *options = NULL;
|
||||
const char *type_name = NULL, *name = NULL, *device = NULL;
|
||||
char *type_name = NULL, *name = NULL, *device = NULL;
|
||||
enum AVHWDeviceType type;
|
||||
HWDevice *dev, *src;
|
||||
AVBufferRef *device_ref = NULL;
|
||||
@@ -164,13 +161,11 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
++p;
|
||||
q = strchr(p, ',');
|
||||
if (q) {
|
||||
if (q - p > 0) {
|
||||
device = av_strndup(p, q - p);
|
||||
if (!device) {
|
||||
err = AVERROR(ENOMEM);
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
err = av_dict_parse_string(&options, q + 1, "=", ",", 0);
|
||||
if (err < 0) {
|
||||
errmsg = "failed to parse options";
|
||||
@@ -179,8 +174,7 @@ int hw_device_init_from_string(const char *arg, HWDevice **dev_out)
|
||||
}
|
||||
|
||||
err = av_hwdevice_ctx_create(&device_ref, type,
|
||||
q ? device : p[0] ? p : NULL,
|
||||
options, 0);
|
||||
device ? device : p, options, 0);
|
||||
if (err < 0)
|
||||
goto fail;
|
||||
|
||||
|
||||
@@ -18,20 +18,6 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* CHANGES 08.2019
|
||||
* --------------------------------------------------------
|
||||
* - lastCommandOutput methods introduced
|
||||
* - AV_LOG_STDERR introduced
|
||||
*
|
||||
* CHANGES 04.2019
|
||||
* --------------------------------------------------------
|
||||
* - setNativeEnvironmentVariable method added
|
||||
*
|
||||
* CHANGES 02.2019
|
||||
* --------------------------------------------------------
|
||||
* - JavaVM registered via av_jni_set_java_vm()
|
||||
* - registerNewNativeFFmpegPipe() method added
|
||||
*
|
||||
* CHANGES 10.2018
|
||||
* --------------------------------------------------------
|
||||
* - getBuildConf method added
|
||||
@@ -46,15 +32,11 @@
|
||||
*/
|
||||
|
||||
#include <pthread.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "config.h"
|
||||
#include "libavcodec/jni.h"
|
||||
#include "libavutil/bprint.h"
|
||||
#include "fftools_ffmpeg.h"
|
||||
#include "mobileffmpeg.h"
|
||||
#include "mobileffprobe.h"
|
||||
#include "fftools_ffmpeg.h"
|
||||
|
||||
/** Callback data structure */
|
||||
struct CallbackData {
|
||||
@@ -79,10 +61,6 @@ pthread_mutex_t lockMutex;
|
||||
pthread_mutex_t monitorMutex;
|
||||
pthread_cond_t monitorCondition;
|
||||
|
||||
/** Last command output variables */
|
||||
pthread_mutex_t logMutex;
|
||||
static char *lastCommandOutput;
|
||||
|
||||
pthread_t callbackThread;
|
||||
int redirectionEnabled;
|
||||
|
||||
@@ -101,18 +79,9 @@ static jmethodID logMethod;
|
||||
/** Global reference of statistics redirection method in Java */
|
||||
static jmethodID statisticsMethod;
|
||||
|
||||
/** Global reference of String class in Java */
|
||||
static jclass stringClass;
|
||||
|
||||
/** Global reference of String constructor in Java */
|
||||
static jmethodID stringConstructor;
|
||||
|
||||
/** Full name of the Config class */
|
||||
const char *configClassName = "com/arthenica/mobileffmpeg/Config";
|
||||
|
||||
/** Full name of String class */
|
||||
const char *stringClassName = "java/lang/String";
|
||||
|
||||
/** Prototypes of native functions defined by Config class. */
|
||||
JNINativeMethod configMethods[] = {
|
||||
{"enableNativeRedirection", "()V", (void*) Java_com_arthenica_mobileffmpeg_Config_enableNativeRedirection},
|
||||
@@ -121,24 +90,19 @@ JNINativeMethod configMethods[] = {
|
||||
{"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},
|
||||
{"nativeFFmpegExecute", "([Ljava/lang/String;)I", (void*) Java_com_arthenica_mobileffmpeg_Config_nativeFFmpegExecute},
|
||||
{"nativeFFmpegCancel", "()V", (void*) Java_com_arthenica_mobileffmpeg_Config_nativeFFmpegCancel},
|
||||
{"nativeFFprobeExecute", "([Ljava/lang/String;)I", (void*) Java_com_arthenica_mobileffmpeg_Config_nativeFFprobeExecute},
|
||||
{"registerNewNativeFFmpegPipe", "(Ljava/lang/String;)I", (void*) Java_com_arthenica_mobileffmpeg_Config_registerNewNativeFFmpegPipe},
|
||||
{"getNativeBuildDate", "()Ljava/lang/String;", (void*) Java_com_arthenica_mobileffmpeg_Config_getNativeBuildDate},
|
||||
{"setNativeEnvironmentVariable", "(Ljava/lang/String;Ljava/lang/String;)I", (void*) Java_com_arthenica_mobileffmpeg_Config_setNativeEnvironmentVariable}
|
||||
{"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}
|
||||
};
|
||||
|
||||
/** Forward declaration for function defined in fftools_ffmpeg.c */
|
||||
int ffmpeg_execute(int argc, char **argv);
|
||||
int execute(int argc, char **argv);
|
||||
|
||||
/** DEFINES LINE SIZE USED FOR LOGGING */
|
||||
#define LOG_LINE_SIZE 1024
|
||||
|
||||
static const char *avutil_log_get_level_str(int level) {
|
||||
switch (level) {
|
||||
case AV_LOG_STDERR:
|
||||
return "stderr";
|
||||
case AV_LOG_QUIET:
|
||||
return "quiet";
|
||||
case AV_LOG_DEBUG:
|
||||
@@ -225,17 +189,6 @@ void monitorInit() {
|
||||
pthread_condattr_destroy(&cattributes);
|
||||
}
|
||||
|
||||
void logInit() {
|
||||
pthread_mutexattr_t attributes;
|
||||
pthread_mutexattr_init(&attributes);
|
||||
pthread_mutexattr_settype(&attributes, PTHREAD_MUTEX_RECURSIVE_NP);
|
||||
|
||||
pthread_mutex_init(&logMutex, &attributes);
|
||||
pthread_mutexattr_destroy(&attributes);
|
||||
|
||||
lastCommandOutput = NULL;
|
||||
}
|
||||
|
||||
void mutexUnInit() {
|
||||
pthread_mutex_destroy(&lockMutex);
|
||||
}
|
||||
@@ -245,72 +198,14 @@ void monitorUnInit() {
|
||||
pthread_cond_destroy(&monitorCondition);
|
||||
}
|
||||
|
||||
void logUnInit() {
|
||||
pthread_mutex_destroy(&logMutex);
|
||||
}
|
||||
|
||||
void mutexLock() {
|
||||
pthread_mutex_lock(&lockMutex);
|
||||
}
|
||||
|
||||
void lastCommandOutputLock() {
|
||||
pthread_mutex_lock(&logMutex);
|
||||
}
|
||||
|
||||
void mutexUnlock() {
|
||||
pthread_mutex_unlock(&lockMutex);
|
||||
}
|
||||
|
||||
void lastCommandOutputUnlock() {
|
||||
pthread_mutex_unlock(&logMutex);
|
||||
}
|
||||
|
||||
void clearLastCommandOutput() {
|
||||
lastCommandOutputLock();
|
||||
|
||||
if (lastCommandOutput != NULL) {
|
||||
av_free(lastCommandOutput);
|
||||
lastCommandOutput = NULL;
|
||||
}
|
||||
|
||||
lastCommandOutputUnlock();
|
||||
}
|
||||
|
||||
void appendLastCommandOutput(const char *logMessage) {
|
||||
size_t length = 0;
|
||||
char *tempLastCommandOutput = NULL;
|
||||
size_t logMessageLength = strlen(logMessage);
|
||||
|
||||
if (logMessageLength <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
lastCommandOutputLock();
|
||||
|
||||
if (lastCommandOutput == NULL) {
|
||||
length = logMessageLength + 1;
|
||||
|
||||
lastCommandOutput = (char*)av_malloc(length);
|
||||
memcpy(lastCommandOutput, logMessage, length);
|
||||
} else {
|
||||
size_t length1 = strlen(lastCommandOutput);
|
||||
length = length1 + logMessageLength + 1;
|
||||
|
||||
char *newLastCommandOutput = (char*)av_malloc(length);
|
||||
memcpy(newLastCommandOutput, lastCommandOutput, length1);
|
||||
memcpy(newLastCommandOutput + length1, logMessage, logMessageLength + 1);
|
||||
|
||||
tempLastCommandOutput = lastCommandOutput;
|
||||
lastCommandOutput = newLastCommandOutput;
|
||||
}
|
||||
|
||||
lastCommandOutputUnlock();
|
||||
|
||||
if (tempLastCommandOutput != NULL) {
|
||||
av_free(tempLastCommandOutput);
|
||||
}
|
||||
}
|
||||
|
||||
void monitorWait(int milliSeconds) {
|
||||
struct timeval tp;
|
||||
struct timespec ts;
|
||||
@@ -339,18 +234,15 @@ 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) {
|
||||
|
||||
// CREATE DATA STRUCT FIRST
|
||||
struct CallbackData *newData = (struct CallbackData*)av_malloc(sizeof(struct CallbackData));
|
||||
struct CallbackData *newData = (struct CallbackData*)malloc(sizeof(struct CallbackData));
|
||||
newData->type = 1;
|
||||
newData->logLevel = level;
|
||||
size_t dataSize = strlen(data) + 1;
|
||||
newData->logData = (char*)av_malloc(dataSize);
|
||||
newData->logData = (char*)malloc(dataSize);
|
||||
memcpy(newData->logData, data, dataSize);
|
||||
newData->next = NULL;
|
||||
|
||||
@@ -383,7 +275,7 @@ void logCallbackDataAdd(int level, const char *data) {
|
||||
void statisticsCallbackDataAdd(int frameNumber, float fps, float quality, int64_t size, int time, double bitrate, double speed) {
|
||||
|
||||
// CREATE DATA STRUCT FIRST
|
||||
struct CallbackData *newData = (struct CallbackData*)av_malloc(sizeof(struct CallbackData));
|
||||
struct CallbackData *newData = (struct CallbackData*)malloc(sizeof(struct CallbackData));
|
||||
newData->type = 2;
|
||||
newData->statisticsFrameNumber = frameNumber;
|
||||
newData->statisticsFps = fps;
|
||||
@@ -453,10 +345,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];
|
||||
@@ -466,40 +358,32 @@ void mobileffmpeg_log_callback_function(void *ptr, int level, const char* format
|
||||
if (level >= 0) {
|
||||
level &= 0xff;
|
||||
}
|
||||
int activeLogLevel = av_log_get_level();
|
||||
|
||||
// AV_LOG_STDERR logs are always redirected
|
||||
if ((activeLogLevel == AV_LOG_QUIET && level != AV_LOG_STDERR) || (level > activeLogLevel)) {
|
||||
return;
|
||||
}
|
||||
|
||||
avutil_log_format_line(ptr, level, format, vargs, part, &print_prefix);
|
||||
avutil_log_sanitize(part[0].str);
|
||||
avutil_log_sanitize(part[1].str);
|
||||
avutil_log_sanitize(part[2].str);
|
||||
avutil_log_sanitize(part[3].str);
|
||||
|
||||
snprintf(line, sizeof(line), "%s%s%s%s", part[0].str, part[1].str, part[2].str, part[3].str);
|
||||
|
||||
logCallbackDataAdd(level, line);
|
||||
appendLastCommandOutput(line);
|
||||
avutil_log_sanitize(part[0].str);
|
||||
logCallbackDataAdd(level, part[0].str);
|
||||
avutil_log_sanitize(part[1].str);
|
||||
logCallbackDataAdd(level, part[1].str);
|
||||
avutil_log_sanitize(part[2].str);
|
||||
logCallbackDataAdd(level, part[2].str);
|
||||
avutil_log_sanitize(part[3].str);
|
||||
logCallbackDataAdd(level, part[3].str);
|
||||
|
||||
av_bprint_finalize(part, NULL);
|
||||
av_bprint_finalize(part+1, NULL);
|
||||
av_bprint_finalize(part+2, NULL);
|
||||
av_bprint_finalize(part+3, NULL);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
@@ -541,7 +425,7 @@ void *callbackThreadFunction() {
|
||||
(*env)->DeleteLocalRef(env, byteArray);
|
||||
|
||||
// CLEAN LOG DATA
|
||||
av_free(callbackData->logData);
|
||||
free(callbackData->logData);
|
||||
|
||||
} else {
|
||||
|
||||
@@ -557,7 +441,7 @@ void *callbackThreadFunction() {
|
||||
|
||||
// CLEAN STRUCT
|
||||
callbackData->next = NULL;
|
||||
av_free(callbackData);
|
||||
free(callbackData);
|
||||
|
||||
} else {
|
||||
monitorWait(100);
|
||||
@@ -574,9 +458,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;
|
||||
@@ -591,44 +475,28 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
if ((*env)->RegisterNatives(env, localConfigClass, configMethods, 12) < 0) {
|
||||
if ((*env)->RegisterNatives(env, localConfigClass, configMethods, 9) < 0) {
|
||||
LOGE("OnLoad failed to RegisterNatives for class %s.\n", configClassName);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
jclass localStringClass = (*env)->FindClass(env, stringClassName);
|
||||
if (localStringClass == NULL) {
|
||||
LOGE("OnLoad failed to FindClass %s.\n", stringClassName);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
(*env)->GetJavaVM(env, &globalVm);
|
||||
|
||||
logMethod = (*env)->GetStaticMethodID(env, localConfigClass, "log", "(I[B)V");
|
||||
if (logMethod == NULL) {
|
||||
LOGE("OnLoad thread failed to GetStaticMethodID for %s.\n", "log");
|
||||
LOGE("OnLoad thread failed to GetMethodID for %s.\n", "log");
|
||||
(*globalVm)->DetachCurrentThread(globalVm);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
statisticsMethod = (*env)->GetStaticMethodID(env, localConfigClass, "statistics", "(IFFJIDD)V");
|
||||
if (logMethod == NULL) {
|
||||
LOGE("OnLoad thread failed to GetStaticMethodID for %s.\n", "statistics");
|
||||
LOGE("OnLoad thread failed to GetMethodID for %s.\n", "statistics");
|
||||
(*globalVm)->DetachCurrentThread(globalVm);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
stringConstructor = (*env)->GetMethodID(env, localStringClass, "<init>", "([BLjava/lang/String;)V");
|
||||
if (stringConstructor == NULL) {
|
||||
LOGE("OnLoad thread failed to GetMethodID for %s.\n", "<init>");
|
||||
(*globalVm)->DetachCurrentThread(globalVm);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
av_jni_set_java_vm(vm, NULL);
|
||||
|
||||
configClass = (jclass) ((*env)->NewGlobalRef(env, localConfigClass));
|
||||
stringClass = (jclass) ((*env)->NewGlobalRef(env, localStringClass));
|
||||
|
||||
redirectionEnabled = 0;
|
||||
|
||||
@@ -637,7 +505,6 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
|
||||
mutexInit();
|
||||
monitorInit();
|
||||
logInit();
|
||||
|
||||
return JNI_VERSION_1_6;
|
||||
}
|
||||
@@ -645,9 +512,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);
|
||||
@@ -656,8 +523,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();
|
||||
@@ -666,8 +533,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();
|
||||
@@ -693,8 +560,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) {
|
||||
|
||||
@@ -717,9 +584,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);
|
||||
@@ -728,23 +595,23 @@ 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Synchronously executes FFmpeg natively with arguments provided.
|
||||
* 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_nativeFFmpegExecute(JNIEnv *env, jclass object, jobjectArray stringArray) {
|
||||
JNIEXPORT jint JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeExecute(JNIEnv *env, jclass object, jobjectArray stringArray) {
|
||||
jstring *tempArray = NULL;
|
||||
int argumentCount = 1;
|
||||
char **argv = NULL;
|
||||
@@ -753,15 +620,15 @@ JNIEXPORT jint JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeFFmpegExecut
|
||||
int programArgumentCount = (*env)->GetArrayLength(env, stringArray);
|
||||
argumentCount = programArgumentCount + 1;
|
||||
|
||||
tempArray = (jstring *) av_malloc(sizeof(jstring) * programArgumentCount);
|
||||
tempArray = (jstring *) malloc(sizeof(jstring) * programArgumentCount);
|
||||
}
|
||||
|
||||
/* PRESERVE USAGE FORMAT
|
||||
*
|
||||
* ffmpeg <arguments>
|
||||
*/
|
||||
argv = (char **)av_malloc(sizeof(char*) * (argumentCount));
|
||||
argv[0] = (char *)av_malloc(sizeof(char) * (strlen(LIB_NAME) + 1));
|
||||
argv = (char **)malloc(sizeof(char*) * (argumentCount));
|
||||
argv[0] = (char *)malloc(sizeof(char) * (strlen(LIB_NAME) + 1));
|
||||
strcpy(argv[0], LIB_NAME);
|
||||
|
||||
// PREPARE
|
||||
@@ -774,11 +641,8 @@ JNIEXPORT jint JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeFFmpegExecut
|
||||
}
|
||||
}
|
||||
|
||||
// LAST COMMAND OUTPUT SHOULD BE CLEARED BEFORE STARTING A NEW EXECUTION
|
||||
clearLastCommandOutput();
|
||||
|
||||
// RUN
|
||||
int retCode = ffmpeg_execute(argumentCount, argv);
|
||||
int retCode = execute(argumentCount, argv);
|
||||
|
||||
// CLEANUP
|
||||
if (tempArray != NULL) {
|
||||
@@ -786,85 +650,31 @@ JNIEXPORT jint JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeFFmpegExecut
|
||||
(*env)->ReleaseStringUTFChars(env, tempArray[i], argv[i + 1]);
|
||||
}
|
||||
|
||||
av_free(tempArray);
|
||||
free(tempArray);
|
||||
}
|
||||
av_free(argv[0]);
|
||||
av_free(argv);
|
||||
free(argv[0]);
|
||||
free(argv);
|
||||
|
||||
return retCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cancels an ongoing FFmpeg operation natively.
|
||||
* 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_nativeFFmpegCancel(JNIEnv *env, jclass object) {
|
||||
JNIEXPORT void JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeCancel(JNIEnv *env, jclass object) {
|
||||
cancel_operation();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates natively a new named pipe to use in FFmpeg operations.
|
||||
* Returns build configuration for FFmpeg.
|
||||
*
|
||||
* @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
|
||||
* \param env pointer to native method interface
|
||||
* \param object reference to the class on which this method is invoked
|
||||
* \return build configuration string
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an environment variable natively
|
||||
*
|
||||
* @param env pointer to native method interface
|
||||
* @param object reference to the class on which this method is invoked
|
||||
* @param variableName environment variable name
|
||||
* @param variableValue environment variable value
|
||||
* @return zero on success, non-zero on error
|
||||
*/
|
||||
JNIEXPORT int JNICALL Java_com_arthenica_mobileffmpeg_Config_setNativeEnvironmentVariable(JNIEnv *env, jclass object, jstring variableName, jstring variableValue) {
|
||||
const char *variableNameString = (*env)->GetStringUTFChars(env, variableName, 0);
|
||||
const char *variableValueString = (*env)->GetStringUTFChars(env, variableValue, 0);
|
||||
|
||||
return setenv(variableNameString, variableValueString, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns log output of the last executed command natively.
|
||||
*
|
||||
* @param env pointer to native method interface
|
||||
* @param object reference to the class on which this method is invoked
|
||||
* @return output of the last executed command
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeLastCommandOutput(JNIEnv *env, jclass object) {
|
||||
if (lastCommandOutput != NULL) {
|
||||
int size = strlen(lastCommandOutput);
|
||||
|
||||
if (size > 0) {
|
||||
jbyteArray byteArray = (*env)->NewByteArray(env, size);
|
||||
(*env)->SetByteArrayRegion(env, byteArray, 0, size, lastCommandOutput);
|
||||
jstring charsetName = (*env)->NewStringUTF(env, "UTF-8");
|
||||
return (jstring) (*env)->NewObject(env, stringClass, stringConstructor, byteArray, charsetName);
|
||||
}
|
||||
}
|
||||
|
||||
return (*env)->NewStringUTF(env, "");
|
||||
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeBuildConf(JNIEnv *env, jclass object) {
|
||||
return (*env)->NewStringUTF(env, FFMPEG_CONFIGURATION);
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#include "libavutil/ffversion.h"
|
||||
|
||||
/** Library version string */
|
||||
#define MOBILE_FFMPEG_VERSION "4.3.1"
|
||||
#define MOBILE_FFMPEG_VERSION "3.0"
|
||||
|
||||
/** Defines tag used for Android logging. */
|
||||
#define LIB_NAME "mobile-ffmpeg"
|
||||
@@ -91,44 +91,23 @@ JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeVersio
|
||||
|
||||
/*
|
||||
* Class: com_arthenica_mobileffmpeg_Config
|
||||
* Method: nativeFFmpegExecute
|
||||
* Method: nativeExecute
|
||||
* Signature: ([Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeFFmpegExecute(JNIEnv *, jclass, jobjectArray);
|
||||
JNIEXPORT jint JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeExecute(JNIEnv *, jclass, jobjectArray);
|
||||
|
||||
/*
|
||||
* Class: com_arthenica_mobileffmpeg_Config
|
||||
* Method: nativeFFmpegCancel
|
||||
* Method: nativeCancel
|
||||
* Signature: ()V
|
||||
*/
|
||||
JNIEXPORT void JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeFFmpegCancel(JNIEnv *, jclass);
|
||||
JNIEXPORT void JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeCancel(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
|
||||
* Method: getNativeBuildConf
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeBuildDate(JNIEnv *env, jclass object);
|
||||
|
||||
/**
|
||||
* Class: com_arthenica_mobileffmpeg_Config
|
||||
* Method: setNativeEnvironmentVariable
|
||||
* Signature: (Ljava/lang/String;Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT int JNICALL Java_com_arthenica_mobileffmpeg_Config_setNativeEnvironmentVariable(JNIEnv *env, jclass object, jstring variableName, jstring variableValue);
|
||||
|
||||
/*
|
||||
* Class: com_arthenica_mobileffmpeg_Config
|
||||
* Method: getNativeLastCommandOutput
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeLastCommandOutput(JNIEnv *env, jclass object);
|
||||
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_Config_getNativeBuildConf(JNIEnv *, jclass);
|
||||
|
||||
#endif /* MOBILE_FFMPEG_H */
|
||||
@@ -18,7 +18,6 @@
|
||||
*/
|
||||
|
||||
#include "cpu-features.h"
|
||||
#include "fftools_ffmpeg.h"
|
||||
#include "mobileffmpeg_abidetect.h"
|
||||
|
||||
/** Full name of the Java class that owns native functions in this file. */
|
||||
@@ -27,17 +26,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},
|
||||
{"isNativeLTSBuild", "()Z", (void*) Java_com_arthenica_mobileffmpeg_AbiDetect_isNativeLTSBuild},
|
||||
{"getNativeBuildConf", "()Ljava/lang/String;", (void*) Java_com_arthenica_mobileffmpeg_AbiDetect_getNativeBuildConf}
|
||||
{"getCpuAbi", "()Ljava/lang/String;", (void*) Java_com_arthenica_mobileffmpeg_AbiDetect_getCpuAbi}
|
||||
};
|
||||
|
||||
/**
|
||||
* 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;
|
||||
@@ -52,7 +49,7 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
return JNI_FALSE;
|
||||
}
|
||||
|
||||
if ((*env)->RegisterNatives(env, abiDetectClass, abiDetectMethods, 4) < 0) {
|
||||
if ((*env)->RegisterNatives(env, abiDetectClass, abiDetectMethods, 2) < 0) {
|
||||
LOGE("OnLoad failed to RegisterNatives for class %s.\n", abiDetectClassName);
|
||||
return JNI_FALSE;
|
||||
}
|
||||
@@ -63,9 +60,9 @@ jint JNI_OnLoad(JavaVM *vm, void *reserved) {
|
||||
/**
|
||||
* Returns loaded 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 loaded ABI name as UTF string
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_getNativeAbi(JNIEnv *env, jclass object) {
|
||||
|
||||
@@ -86,11 +83,11 @@ JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_getNativeAbi
|
||||
/**
|
||||
* 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
|
||||
* \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_getCpuAbi(JNIEnv *env, jclass object) {
|
||||
AndroidCpuFamily family = android_getCpuFamily();
|
||||
|
||||
if (family == ANDROID_CPU_FAMILY_ARM) {
|
||||
@@ -116,29 +113,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
|
||||
}
|
||||
|
||||
/**
|
||||
* 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_AbiDetect_getNativeBuildConf(JNIEnv *env, jclass object) {
|
||||
return (*env)->NewStringUTF(env, FFMPEG_CONFIGURATION);
|
||||
}
|
||||
|
||||
@@ -53,23 +53,10 @@ JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_getNativeAbi
|
||||
|
||||
/*
|
||||
* Class: com_arthenica_mobileffmpeg_AbiDetect
|
||||
* Method: getNativeCpuAbi
|
||||
* Method: getCpuAbi
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_getNativeCpuAbi(JNIEnv *, jclass);
|
||||
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_getCpuAbi(JNIEnv *, jclass);
|
||||
|
||||
/**
|
||||
* Class: com_arthenica_mobileffmpeg_AbiDetect
|
||||
* Method: isNativeLTSBuild
|
||||
* Signature: ()Z
|
||||
*/
|
||||
JNIEXPORT jboolean JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_isNativeLTSBuild(JNIEnv *, jclass);
|
||||
|
||||
/*
|
||||
* Class: com_arthenica_mobileffmpeg_AbiDetect
|
||||
* Method: getNativeBuildConf
|
||||
* Signature: ()Ljava/lang/String;
|
||||
*/
|
||||
JNIEXPORT jstring JNICALL Java_com_arthenica_mobileffmpeg_AbiDetect_getNativeBuildConf(JNIEnv *, jclass);
|
||||
|
||||
#endif /* MOBILE_FFMPEG_ABIDETECT_H */
|
||||
|
||||
@@ -1,24 +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/>.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <setjmp.h>
|
||||
|
||||
/** Holds information to implement exception handling. */
|
||||
__thread jmp_buf ex_buf__;
|
||||
@@ -24,6 +24,6 @@
|
||||
#include <setjmp.h>
|
||||
|
||||
/** Holds information to implement exception handling. */
|
||||
extern __thread jmp_buf ex_buf__;
|
||||
jmp_buf ex_buf__;
|
||||
|
||||
#endif // MOBILE_FFMPEG_EXCEPTION_H
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 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/>.
|
||||
*/
|
||||
|
||||
#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"
|
||||
|
||||
/** Forward declaration for function defined in fftools_ffprobe.c */
|
||||
int ffprobe_execute(int argc, char **argv);
|
||||
|
||||
/** Forward declaration for function defined in mobileffmpeg.c */
|
||||
void clearLastCommandOutput();
|
||||
|
||||
/**
|
||||
* Synchronously executes FFprobe 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 FFprobe command arguments
|
||||
* @return zero on successful execution, non-zero on error
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeFFprobeExecute(JNIEnv *env, jclass object, jobjectArray stringArray) {
|
||||
jstring *tempArray = NULL;
|
||||
int argumentCount = 1;
|
||||
char **argv = NULL;
|
||||
|
||||
if (stringArray != NULL) {
|
||||
int programArgumentCount = (*env)->GetArrayLength(env, stringArray);
|
||||
argumentCount = programArgumentCount + 1;
|
||||
|
||||
tempArray = (jstring *) av_malloc(sizeof(jstring) * programArgumentCount);
|
||||
}
|
||||
|
||||
/* PRESERVE USAGE FORMAT
|
||||
*
|
||||
* ffprobe <arguments>
|
||||
*/
|
||||
argv = (char **)av_malloc(sizeof(char*) * (argumentCount));
|
||||
argv[0] = (char *)av_malloc(sizeof(char) * (strlen(LIB_NAME) + 1));
|
||||
strcpy(argv[0], LIB_NAME);
|
||||
|
||||
// PREPARE
|
||||
if (stringArray != NULL) {
|
||||
for (int i = 0; i < (argumentCount - 1); i++) {
|
||||
tempArray[i] = (jstring) (*env)->GetObjectArrayElement(env, stringArray, i);
|
||||
if (tempArray[i] != NULL) {
|
||||
argv[i + 1] = (char *) (*env)->GetStringUTFChars(env, tempArray[i], 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// LAST COMMAND OUTPUT SHOULD BE CLEARED BEFORE STARTING A NEW EXECUTION
|
||||
clearLastCommandOutput();
|
||||
|
||||
// RUN
|
||||
int retCode = ffprobe_execute(argumentCount, argv);
|
||||
|
||||
// CLEANUP
|
||||
if (tempArray != NULL) {
|
||||
for (int i = 0; i < (argumentCount - 1); i++) {
|
||||
(*env)->ReleaseStringUTFChars(env, tempArray[i], argv[i + 1]);
|
||||
}
|
||||
|
||||
av_free(tempArray);
|
||||
}
|
||||
av_free(argv[0]);
|
||||
av_free(argv);
|
||||
|
||||
return retCode;
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 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/>.
|
||||
*/
|
||||
|
||||
#ifndef MOBILE_FFPROBE_H
|
||||
#define MOBILE_FFPROBE_H
|
||||
|
||||
#include <jni.h>
|
||||
|
||||
/*
|
||||
* Class: com_arthenica_mobileffmpeg_Config
|
||||
* Method: nativeFFprobeExecute
|
||||
* Signature: ([Ljava/lang/String;)I
|
||||
*/
|
||||
JNIEXPORT jint JNICALL Java_com_arthenica_mobileffmpeg_Config_nativeFFprobeExecute(JNIEnv *, jclass, jobjectArray);
|
||||
|
||||
#endif /* MOBILE_FFPROBE_H */
|
||||
@@ -19,8 +19,6 @@
|
||||
|
||||
package com.arthenica.mobileffmpeg;
|
||||
|
||||
import android.os.Build;
|
||||
|
||||
/**
|
||||
* <p>This class is used to detect running ABI name using Android's <code>cpufeatures</code>
|
||||
* library.
|
||||
@@ -32,22 +30,13 @@ public class AbiDetect {
|
||||
|
||||
static {
|
||||
armV7aNeonLoaded = false;
|
||||
|
||||
/* LOAD NOT-LOADED LIBRARIES ON API < 21 */
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
System.loadLibrary("cpufeatures");
|
||||
}
|
||||
System.loadLibrary("mobileffmpeg_abidetect");
|
||||
System.loadLibrary("mobileffmpeg-abidetect");
|
||||
|
||||
/* ALL LIBRARIES LOADED AT STARTUP */
|
||||
Config.class.getName();
|
||||
FFmpeg.class.getName();
|
||||
}
|
||||
|
||||
static final String ARM_V7A = "arm-v7a";
|
||||
|
||||
static final String ARM_V7A_NEON = "arm-v7a-neon";
|
||||
|
||||
private static boolean armV7aNeonLoaded;
|
||||
|
||||
/**
|
||||
@@ -67,38 +56,24 @@ public class AbiDetect {
|
||||
*/
|
||||
public static String getAbi() {
|
||||
if (armV7aNeonLoaded) {
|
||||
return ARM_V7A_NEON;
|
||||
return "arm-v7a-neon";
|
||||
} else {
|
||||
return getNativeAbi();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns loaded ABI name.
|
||||
* <p>Returns native loaded ABI name.
|
||||
*
|
||||
* @return loaded ABI name
|
||||
* @return native loaded ABI name
|
||||
*/
|
||||
public native static String getNativeAbi();
|
||||
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();
|
||||
|
||||
/**
|
||||
* <p>Returns build configuration for <code>FFmpeg</code>.
|
||||
*
|
||||
* @return build configuration string
|
||||
*/
|
||||
native static String getNativeBuildConf();
|
||||
public native static String getCpuAbi();
|
||||
|
||||
}
|
||||
|
||||
@@ -1,72 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 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;
|
||||
|
||||
import android.content.Context;
|
||||
import android.hardware.camera2.CameraAccessException;
|
||||
import android.hardware.camera2.CameraCharacteristics;
|
||||
import android.hardware.camera2.CameraManager;
|
||||
import android.hardware.camera2.CameraMetadata;
|
||||
import android.os.Build;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.content.Context.CAMERA_SERVICE;
|
||||
import static com.arthenica.mobileffmpeg.Config.TAG;
|
||||
|
||||
class CameraSupport {
|
||||
|
||||
/**
|
||||
* <p>Compatibility method for extracting supported camera ids.
|
||||
*
|
||||
* @param context application context
|
||||
* @return returns the list of supported camera ids
|
||||
*/
|
||||
static List<String> extractSupportedCameraIds(final Context context) {
|
||||
final List<String> detectedCameraIdList = new ArrayList<>();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
try {
|
||||
final CameraManager manager = (CameraManager) context.getSystemService(CAMERA_SERVICE);
|
||||
if (manager != null) {
|
||||
final String[] cameraIdList = manager.getCameraIdList();
|
||||
|
||||
for (String cameraId : cameraIdList) {
|
||||
final CameraCharacteristics chars = manager.getCameraCharacteristics(cameraId);
|
||||
final Integer cameraSupport = chars.get(CameraCharacteristics.INFO_SUPPORTED_HARDWARE_LEVEL);
|
||||
|
||||
if (cameraSupport != null && cameraSupport == CameraMetadata.INFO_SUPPORTED_HARDWARE_LEVEL_LEGACY) {
|
||||
Log.d(TAG, "Detected camera with id " + cameraId + " has LEGACY hardware level which is not supported by Android Camera2 NDK API.");
|
||||
} else if (cameraSupport != null) {
|
||||
detectedCameraIdList.add(cameraId);
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (final CameraAccessException e) {
|
||||
Log.w(TAG, "Detecting camera ids failed.", e);
|
||||
}
|
||||
}
|
||||
|
||||
return detectedCameraIdList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -20,54 +20,50 @@
|
||||
package com.arthenica.mobileffmpeg;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.system.ErrnoException;
|
||||
import android.system.Os;
|
||||
import android.util.Log;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import static com.arthenica.mobileffmpeg.FFmpeg.getVersion;
|
||||
|
||||
/**
|
||||
* <p>This class is used to configure MobileFFmpeg library utilities/tools.
|
||||
*
|
||||
* <p>1. {@link LogCallback}: This class redirects FFmpeg/FFprobe output to Logcat by default. As
|
||||
* an alternative, it is possible not to print messages to Logcat and pass them to a
|
||||
* {@link LogCallback} function. This function can decide whether to print these logs, show them
|
||||
* inside another container or ignore them.
|
||||
* <p>1. {@link LogCallback}: By default this class redirects FFmpeg output to Logcat. As another
|
||||
* option, it is possible not to print messages to Logcat and pass them to a {@link LogCallback}
|
||||
* function. This function can decide whether to print these logs, show them inside another
|
||||
* container or ignore them.
|
||||
*
|
||||
* <p>2. {@link #setLogLevel(Level)}/{@link #getLogLevel()}: Use this methods to set/get
|
||||
* FFmpeg/FFprobe log severity.
|
||||
* <p>2. {@link #setLogLevel(Level)}/{@link #getLogLevel()}: Use this methods to see/control FFmpeg
|
||||
* log severity.
|
||||
*
|
||||
* <p>3. {@link StatisticsCallback}: It is possible to receive statistics about an ongoing
|
||||
* operation by defining a {@link StatisticsCallback} function or by calling
|
||||
* {@link #getLastReceivedStatistics()} method.
|
||||
* <p>3. {@link StatisticsCallback}: It is possible to receive statistics about ongoing operation by
|
||||
* defining a {@link StatisticsCallback} function or by calling {@link #getLastReceivedStatistics()}
|
||||
* method.
|
||||
*
|
||||
* <p>4. Font configuration: It is possible to register custom fonts with
|
||||
* {@link #setFontconfigConfigurationPath(String)} and
|
||||
* {@link #setFontDirectory(Context, String, Map)} methods.
|
||||
*
|
||||
* <p>PS: This class is introduced in v2.1 as an enhanced version of older <code>Log</code> class.
|
||||
*
|
||||
* @author Taner Sener
|
||||
* @since v2.1
|
||||
*/
|
||||
public class Config {
|
||||
|
||||
public static final int RETURN_CODE_SUCCESS = 0;
|
||||
|
||||
public static final int RETURN_CODE_CANCEL = 255;
|
||||
|
||||
private static int lastReturnCode = 0;
|
||||
|
||||
/**
|
||||
* Defines tag used for logging.
|
||||
*/
|
||||
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;
|
||||
@@ -76,54 +72,29 @@ public class Config {
|
||||
|
||||
private static Statistics lastReceivedStatistics;
|
||||
|
||||
private static int lastCreatedPipeIndex;
|
||||
private static final AtomicReference<StringBuffer> systemCommandOutputReference;
|
||||
|
||||
private static boolean runningSystemCommand;
|
||||
|
||||
static {
|
||||
|
||||
Log.i(Config.TAG, "Loading mobile-ffmpeg.");
|
||||
|
||||
/* LOAD NOT-LOADED LIBRARIES ON API < 21 */
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
|
||||
final List<String> externalLibrariesEnabled = getExternalLibraries();
|
||||
if (externalLibrariesEnabled.contains("tesseract") || externalLibrariesEnabled.contains("x265") || externalLibrariesEnabled.contains("snappy") || externalLibrariesEnabled.contains("openh264")) {
|
||||
// libc++_shared.so included only when tesseract or x265 is enabled
|
||||
System.loadLibrary("c++_shared");
|
||||
}
|
||||
System.loadLibrary("cpufeatures");
|
||||
System.loadLibrary("avutil");
|
||||
System.loadLibrary("swscale");
|
||||
System.loadLibrary("swresample");
|
||||
System.loadLibrary("avcodec");
|
||||
System.loadLibrary("avformat");
|
||||
System.loadLibrary("avfilter");
|
||||
System.loadLibrary("avdevice");
|
||||
}
|
||||
|
||||
/* ALL MOBILE-FFMPEG LIBRARIES LOADED AT STARTUP */
|
||||
Abi.class.getName();
|
||||
/* ALL LIBRARIES LOADED AT STARTUP */
|
||||
Abi cpuAbi = Abi.from(AbiDetect.getCpuAbi());
|
||||
FFmpeg.class.getName();
|
||||
FFprobe.class.getName();
|
||||
|
||||
/*
|
||||
* NEON supported arm-v7a library has a different name
|
||||
*/
|
||||
boolean nativeLibraryLoaded = false;
|
||||
if (AbiDetect.ARM_V7A.equals(AbiDetect.getNativeAbi())) {
|
||||
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 {
|
||||
if (cpuAbi == Abi.ABI_ARMV7A_NEON) {
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,16 +102,19 @@ 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-%s.", getPackageName(), AbiDetect.getAbi(), getVersion()));
|
||||
|
||||
/* NATIVE LOG LEVEL IS RECEIVED ONLY ON STARTUP */
|
||||
activeLogLevel = Level.from(getNativeLogLevel());
|
||||
|
||||
lastReceivedStatistics = new Statistics();
|
||||
|
||||
enableRedirection();
|
||||
Config.enableRedirection();
|
||||
|
||||
lastCreatedPipeIndex = 0;
|
||||
systemCommandOutputReference = new AtomicReference<>();
|
||||
systemCommandOutputReference.set(new StringBuffer());
|
||||
|
||||
runningSystemCommand = false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,15 +125,14 @@ public class Config {
|
||||
|
||||
/**
|
||||
* <p>Enables log and statistics redirection.
|
||||
* <p>When redirection is not enabled FFmpeg/FFprobe logs are printed to stderr. By enabling
|
||||
* redirection, they are routed to Logcat and can be routed further to a callback function.
|
||||
* <p>Statistics redirection behaviour is similar. Statistics are not printed at all if
|
||||
* redirection is not enabled. If it is enabled then it is possible to define a statistics
|
||||
* callback function but if you don't, they are not printed anywhere and only saved as
|
||||
* <code>lastReceivedStatistics</code> data which can be polled with
|
||||
* <p>When redirection is not enabled FFmpeg logs are printed to stderr. By enabling redirection, they are routed
|
||||
* to Logcat and can be routed further to a callback function.
|
||||
* <p>Statistics redirection behaviour is similar. Statistics are not printed at all if redirection is not enabled.
|
||||
* If it is enabled then it is possible to define a statistics callback function but if you don't, they are not
|
||||
* printed anywhere and only saved as <code>lastReceivedStatistics</code> data which can be polled with
|
||||
* {@link #getLastReceivedStatistics()}.
|
||||
* <p>Note that redirection is enabled by default. If you do not want to use its functionality
|
||||
* please use {@link #disableRedirection()} to disable it.
|
||||
* <p>Note that redirection is enabled by default. If you do not want to use its functionality please use
|
||||
* {@link #disableRedirection()} to disable it.
|
||||
*/
|
||||
public static void enableRedirection() {
|
||||
enableNativeRedirection();
|
||||
@@ -194,7 +167,7 @@ public class Config {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Sets a callback function to redirect FFmpeg/FFprobe logs.
|
||||
* <p>Sets a callback function to redirect FFmpeg logs.
|
||||
*
|
||||
* @param newLogCallback new log callback function or NULL to disable a previously defined callback
|
||||
*/
|
||||
@@ -221,18 +194,25 @@ public class Config {
|
||||
final Level level = Level.from(levelValue);
|
||||
final String text = new String(logMessage);
|
||||
|
||||
// AV_LOG_STDERR logs are always redirected
|
||||
if ((activeLogLevel == Level.AV_LOG_QUIET && levelValue != Level.AV_LOG_STDERR.getValue()) || levelValue > activeLogLevel.getValue()) {
|
||||
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) {
|
||||
try {
|
||||
logCallbackFunction.apply(new LogMessage(level, text));
|
||||
} catch (final Exception e) {
|
||||
Log.e(Config.TAG, "Exception thrown inside LogCallback block", e);
|
||||
}
|
||||
logCallbackFunction.apply(new LogMessage(level, text));
|
||||
} else {
|
||||
switch (level) {
|
||||
case AV_LOG_QUIET: {
|
||||
@@ -244,7 +224,6 @@ public class Config {
|
||||
android.util.Log.d(TAG, text);
|
||||
}
|
||||
break;
|
||||
case AV_LOG_STDERR:
|
||||
case AV_LOG_VERBOSE: {
|
||||
android.util.Log.v(TAG, text);
|
||||
}
|
||||
@@ -289,11 +268,7 @@ public class Config {
|
||||
lastReceivedStatistics.update(newStatistics);
|
||||
|
||||
if (statisticsCallbackFunction != null) {
|
||||
try {
|
||||
statisticsCallbackFunction.apply(lastReceivedStatistics);
|
||||
} catch (final Exception e) {
|
||||
Log.e(Config.TAG, "Exception thrown inside StatisticsCallback block", e);
|
||||
}
|
||||
statisticsCallbackFunction.apply(lastReceivedStatistics);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,10 +292,10 @@ public class Config {
|
||||
* <p>Sets and overrides <code>fontconfig</code> configuration directory.
|
||||
*
|
||||
* @param path directory which contains fontconfig configuration (fonts.conf)
|
||||
* @return zero on success, non-zero on error
|
||||
* @throws ErrnoException if an error occurs
|
||||
*/
|
||||
public static int setFontconfigConfigurationPath(final String path) {
|
||||
return setNativeEnvironmentVariable("FONTCONFIG_PATH", path);
|
||||
public static void setFontconfigConfigurationPath(final String path) throws ErrnoException {
|
||||
Os.setenv("FONTCONFIG_PATH", path, true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -394,7 +369,7 @@ public class Config {
|
||||
|
||||
Log.d(TAG, String.format("Font directory %s registered successfully.", fontDirectoryPath));
|
||||
|
||||
} catch (final IOException e) {
|
||||
} catch (final ErrnoException | IOException e) {
|
||||
Log.e(TAG, String.format("Failed to set font directory: %s.", fontDirectoryPath), e);
|
||||
} finally {
|
||||
if (reference.get() != null) {
|
||||
@@ -428,171 +403,57 @@ public class Config {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Creates a new named pipe to use in <code>FFmpeg</code> operations.
|
||||
* Executes system command. System command is not logged to output.
|
||||
*
|
||||
* <p>Please note that creator is responsible of closing created pipes.
|
||||
*
|
||||
* @param context application context
|
||||
* @return the full path of named pipe
|
||||
* @param arguments command arguments
|
||||
* @param commandOutputEndPatternList list of patterns which will indicate that operation has ended
|
||||
* @param timeout execution timeout
|
||||
* @return return code
|
||||
*/
|
||||
public static String registerNewFFmpegPipe(final Context context) {
|
||||
static int systemExecute(final String[] arguments, final List<String> commandOutputEndPatternList, final long timeout) {
|
||||
systemCommandOutputReference.set(new StringBuffer());
|
||||
runningSystemCommand = true;
|
||||
|
||||
// PIPES ARE CREATED UNDER THE CACHE DIRECTORY
|
||||
final File cacheDir = context.getCacheDir();
|
||||
int rc = Config.nativeExecute(arguments);
|
||||
|
||||
final String newFFmpegPipePath = cacheDir + File.separator + MOBILE_FFMPEG_PIPE_PREFIX + (++lastCreatedPipeIndex);
|
||||
long totalWaitTime = 0;
|
||||
|
||||
// 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();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the list of camera ids supported.
|
||||
*
|
||||
* @param context application context
|
||||
* @return the list of camera ids supported or an empty list if no supported camera is found
|
||||
*/
|
||||
public static List<String> getSupportedCameraIds(final Context context) {
|
||||
final List<String> detectedCameraIdList = new ArrayList<>();
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
|
||||
detectedCameraIdList.addAll(CameraSupport.extractSupportedCameraIds(context));
|
||||
}
|
||||
|
||||
return detectedCameraIdList;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns FFmpeg version bundled within the library.
|
||||
*
|
||||
* @return FFmpeg version
|
||||
*/
|
||||
public static String getFFmpegVersion() {
|
||||
return getNativeFFmpegVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns MobileFFmpeg library version.
|
||||
*
|
||||
* @return MobileFFmpeg version
|
||||
*/
|
||||
public static String getVersion() {
|
||||
if (AbiDetect.isNativeLTSBuild()) {
|
||||
return String.format("%s-lts", getNativeVersion());
|
||||
} else {
|
||||
return getNativeVersion();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <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 getNativeBuildDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* <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 single FFmpeg/FFprobe command.
|
||||
*
|
||||
* <p>This method does not support executing multiple concurrent commands. If you execute
|
||||
* multiple commands at the same time, this method will return output from all executions.
|
||||
*
|
||||
* <p>Please note that disabling redirection using {@link Config#disableRedirection()} method
|
||||
* also disables this functionality.
|
||||
*
|
||||
* @return output of the last executed command
|
||||
* @since 3.0
|
||||
*/
|
||||
public static String getLastCommandOutput() {
|
||||
String nativeLastCommandOutput = getNativeLastCommandOutput();
|
||||
if (nativeLastCommandOutput != null) {
|
||||
|
||||
// REPLACING CH(13) WITH CH(10)
|
||||
nativeLastCommandOutput = nativeLastCommandOutput.replace('\r', '\n');
|
||||
}
|
||||
return nativeLastCommandOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Prints the output of the last executed FFmpeg/FFprobe command to the Logcat at the
|
||||
* specified priority.
|
||||
*
|
||||
* <p>This method does not support executing multiple concurrent commands. If you execute
|
||||
* multiple commands at the same time, this method will print output from all executions.
|
||||
*
|
||||
* @param logPriority one of {@link Log#VERBOSE}, {@link Log#DEBUG}, {@link Log#INFO},
|
||||
* {@link Log#WARN}, {@link Log#ERROR}, {@link Log#ASSERT}
|
||||
* @since 4.3
|
||||
*/
|
||||
public static void printLastCommandOutput(int logPriority) {
|
||||
final int LOGGER_ENTRY_MAX_LEN = 4 * 1000;
|
||||
|
||||
String buffer = getLastCommandOutput();
|
||||
do {
|
||||
if (buffer.length() <= LOGGER_ENTRY_MAX_LEN) {
|
||||
Log.println(logPriority, Config.TAG, buffer);
|
||||
buffer = "";
|
||||
} else {
|
||||
final int index = buffer.substring(0, LOGGER_ENTRY_MAX_LEN).lastIndexOf('\n');
|
||||
if (index < 0) {
|
||||
Log.println(logPriority, Config.TAG, buffer.substring(0, LOGGER_ENTRY_MAX_LEN));
|
||||
buffer = buffer.substring(LOGGER_ENTRY_MAX_LEN);
|
||||
} else {
|
||||
Log.println(logPriority, Config.TAG, buffer.substring(0, index));
|
||||
buffer = buffer.substring(index);
|
||||
try {
|
||||
while (!systemCommandOutputContainsPattern(commandOutputEndPatternList) && (totalWaitTime < timeout)) {
|
||||
synchronized (systemCommandOutputReference) {
|
||||
systemCommandOutputReference.wait(20);
|
||||
}
|
||||
totalWaitTime += 20;
|
||||
}
|
||||
} while (buffer.length() > 0);
|
||||
} 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;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates return code value for the last executed command.
|
||||
* Returns output of last executed system command.
|
||||
*
|
||||
* @param newLastReturnCode new last return code value
|
||||
* @return output of last executed system command
|
||||
*/
|
||||
static void setLastReturnCode(int newLastReturnCode) {
|
||||
lastReturnCode = newLastReturnCode;
|
||||
static String getSystemCommandOutput() {
|
||||
return systemCommandOutputReference.get().toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -639,53 +500,19 @@ public class Config {
|
||||
* @param arguments FFmpeg command options/arguments as string array
|
||||
* @return zero on successful execution, 255 on user cancel and non-zero on error
|
||||
*/
|
||||
native static int nativeFFmpegExecute(final String[] arguments);
|
||||
native static int nativeExecute(final String[] arguments);
|
||||
|
||||
/**
|
||||
* <p>Cancels an ongoing FFmpeg operation natively. This function does not wait for termination
|
||||
* to complete and returns immediately.
|
||||
* <p>Cancels an ongoing operation natively. This function does not wait for termination to
|
||||
* complete and returns immediately.
|
||||
*/
|
||||
native static void nativeFFmpegCancel();
|
||||
native static void nativeCancel();
|
||||
|
||||
/**
|
||||
* <p>Synchronously executes FFprobe natively with arguments provided.
|
||||
* <p>Returns build configuration for <code>FFmpeg</code>.
|
||||
*
|
||||
* @param arguments FFprobe command options/arguments as string array
|
||||
* @return zero on successful execution, 255 on user cancel and non-zero on error
|
||||
* @return build configuration string
|
||||
*/
|
||||
native static int nativeFFprobeExecute(final String[] arguments);
|
||||
|
||||
/**
|
||||
* <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();
|
||||
|
||||
/**
|
||||
* <p>Sets an environment variable natively.
|
||||
*
|
||||
* @param variableName environment variable name
|
||||
* @param variableValue environment variable value
|
||||
* @return zero on success, non-zero on error
|
||||
*/
|
||||
public native static int setNativeEnvironmentVariable(final String variableName, final String variableValue);
|
||||
|
||||
/**
|
||||
* <p>Returns log output of the last executed single command natively.
|
||||
*
|
||||
* @return output of the last executed single command
|
||||
*/
|
||||
native static String getNativeLastCommandOutput();
|
||||
native static String getNativeBuildConf();
|
||||
|
||||
}
|
||||
|
||||
@@ -19,14 +19,15 @@
|
||||
|
||||
package com.arthenica.mobileffmpeg;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import android.util.Log;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* <p>Main class for FFmpeg operations. Provides {@link #execute(String...)} method to execute
|
||||
* FFmpeg commands.
|
||||
* <pre>
|
||||
* int rc = FFmpeg.execute("-i file1.mp4 -c:v libxvid file1.avi");
|
||||
* int rc = FFmpeg.execute("-i", "file1.mp4", "-c:v", "libxvid", "file1.avi");
|
||||
* Log.i(Config.TAG, String.format("Command execution %s.", (rc == 0?"completed successfully":"failed with rc=" + rc));
|
||||
* </pre>
|
||||
*
|
||||
@@ -35,6 +36,14 @@ import java.util.List;
|
||||
*/
|
||||
public class FFmpeg {
|
||||
|
||||
public static final int RETURN_CODE_SUCCESS = 0;
|
||||
|
||||
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();
|
||||
@@ -46,6 +55,33 @@ 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.
|
||||
*
|
||||
* @return FFmpeg version
|
||||
*/
|
||||
public static String getFFmpegVersion() {
|
||||
return Config.getNativeFFmpegVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns MobileFFmpeg library version.
|
||||
*
|
||||
* @return MobileFFmpeg version
|
||||
*/
|
||||
public static String getVersion() {
|
||||
return Config.getNativeVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Synchronously executes FFmpeg with arguments provided.
|
||||
*
|
||||
@@ -53,24 +89,21 @@ public class FFmpeg {
|
||||
* @return zero on successful execution, 255 on user cancel and non-zero on error
|
||||
*/
|
||||
public static int execute(final String[] arguments) {
|
||||
final int lastReturnCode = Config.nativeFFmpegExecute(arguments);
|
||||
lastCommandOutput = new StringBuffer();
|
||||
|
||||
Config.setLastReturnCode(lastReturnCode);
|
||||
lastReturnCode = Config.nativeExecute(arguments);
|
||||
|
||||
return lastReturnCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Synchronously executes FFmpeg command provided. Command is split into arguments using
|
||||
* provided delimiter character.
|
||||
* provided delimiter.
|
||||
*
|
||||
* @param command FFmpeg command
|
||||
* @param delimiter delimiter used to split arguments
|
||||
* @param delimiter delimiter used between arguments
|
||||
* @return zero on successful execution, 255 on user cancel and non-zero on error
|
||||
* @since 3.0
|
||||
* @deprecated argument splitting mechanism used in this method is pretty simple and prone to
|
||||
* errors. Consider using a more advanced method like {@link #execute(String)} or
|
||||
* {@link #execute(String[])}
|
||||
*/
|
||||
public static int execute(final String command, final String delimiter) {
|
||||
return execute((command == null) ? new String[]{""} : command.split((delimiter == null) ? " " : delimiter));
|
||||
@@ -78,14 +111,13 @@ public class FFmpeg {
|
||||
|
||||
/**
|
||||
* <p>Synchronously executes FFmpeg command provided. Space character is used to split command
|
||||
* into arguments. You can use single and double quote characters to specify arguments inside
|
||||
* your command.
|
||||
* into arguments.
|
||||
*
|
||||
* @param command FFmpeg command
|
||||
* @return zero on successful execution, 255 on user cancel and non-zero on error
|
||||
*/
|
||||
public static int execute(final String command) {
|
||||
return execute(parseArguments(command));
|
||||
return execute(command, " ");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,64 +125,58 @@ public class FFmpeg {
|
||||
* returns immediately.
|
||||
*/
|
||||
public static void cancel() {
|
||||
Config.nativeFFmpegCancel();
|
||||
Config.nativeCancel();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Parses the given command into arguments.
|
||||
* <p>Returns return code of last executed command.
|
||||
*
|
||||
* @param command string command
|
||||
* @return array of arguments
|
||||
* @return return code of last executed command
|
||||
* @since 3.0
|
||||
*/
|
||||
static String[] parseArguments(final String command) {
|
||||
final List<String> argumentList = new ArrayList<>();
|
||||
StringBuilder currentArgument = new StringBuilder();
|
||||
public static int getLastReturnCode() {
|
||||
return lastReturnCode;
|
||||
}
|
||||
|
||||
boolean singleQuoteStarted = false;
|
||||
boolean doubleQuoteStarted = false;
|
||||
/**
|
||||
* <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();
|
||||
}
|
||||
|
||||
for (int i = 0; i < command.length(); i++) {
|
||||
final Character previousChar;
|
||||
if (i > 0) {
|
||||
previousChar = command.charAt(i - 1);
|
||||
} else {
|
||||
previousChar = null;
|
||||
}
|
||||
final char currentChar = command.charAt(i);
|
||||
/**
|
||||
* <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);
|
||||
}
|
||||
|
||||
if (currentChar == ' ') {
|
||||
if (singleQuoteStarted || doubleQuoteStarted) {
|
||||
currentArgument.append(currentChar);
|
||||
} else if (currentArgument.length() > 0) {
|
||||
argumentList.add(currentArgument.toString());
|
||||
currentArgument = new StringBuilder();
|
||||
}
|
||||
} else if (currentChar == '\'' && (previousChar == null || previousChar != '\\')) {
|
||||
if (singleQuoteStarted) {
|
||||
singleQuoteStarted = false;
|
||||
} else if (doubleQuoteStarted) {
|
||||
currentArgument.append(currentChar);
|
||||
} else {
|
||||
singleQuoteStarted = true;
|
||||
}
|
||||
} else if (currentChar == '\"' && (previousChar == null || previousChar != '\\')) {
|
||||
if (doubleQuoteStarted) {
|
||||
doubleQuoteStarted = false;
|
||||
} else if (singleQuoteStarted) {
|
||||
currentArgument.append(currentChar);
|
||||
} else {
|
||||
doubleQuoteStarted = true;
|
||||
}
|
||||
} else {
|
||||
currentArgument.append(currentChar);
|
||||
}
|
||||
/**
|
||||
* <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;
|
||||
}
|
||||
|
||||
if (currentArgument.length() > 0) {
|
||||
argumentList.add(currentArgument.toString());
|
||||
}
|
||||
|
||||
return argumentList.toArray(new String[0]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2020 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;
|
||||
|
||||
/**
|
||||
* <p>Main class for FFprobe operations. Provides {@link #execute(String...)} method to execute
|
||||
* FFprobe commands.
|
||||
* <pre>
|
||||
* int rc = FFprobe.execute("-hide_banner -v error -show_entries format=size -of default=noprint_wrappers=1 file1.mp4");
|
||||
* Log.i(Config.TAG, String.format("Command execution %s.", (rc == 0?"completed successfully":"failed with rc=" + rc));
|
||||
* </pre>
|
||||
*
|
||||
* @author Taner Sener
|
||||
* @since v4.3.1
|
||||
*/
|
||||
public class FFprobe {
|
||||
|
||||
static {
|
||||
AbiDetect.class.getName();
|
||||
Config.class.getName();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default constructor hidden.
|
||||
*/
|
||||
private FFprobe() {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Synchronously executes FFprobe with arguments provided.
|
||||
*
|
||||
* @param arguments FFprobe command options/arguments as string array
|
||||
* @return zero on successful execution, 255 on user cancel and non-zero on error
|
||||
*/
|
||||
public static int execute(final String[] arguments) {
|
||||
final int lastReturnCode = Config.nativeFFprobeExecute(arguments);
|
||||
|
||||
Config.setLastReturnCode(lastReturnCode);
|
||||
|
||||
return lastReturnCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Synchronously executes FFprobe command provided. Space character is used to split command
|
||||
* into arguments. You can use single and double quote characters to specify arguments inside
|
||||
* your command.
|
||||
*
|
||||
* @param command FFprobe command
|
||||
* @return zero on successful execution, 255 on user cancel and non-zero on error
|
||||
*/
|
||||
public static int execute(final String command) {
|
||||
return execute(FFmpeg.parseArguments(command));
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns media information for given file.
|
||||
*
|
||||
* <p>This method does not support executing multiple concurrent operations. If you execute
|
||||
* multiple operations (execute or getMediaInformation) at the same time, the response of this
|
||||
* method is not predictable.
|
||||
*
|
||||
* @param path path or uri of media file
|
||||
* @return media information
|
||||
* @since 3.0
|
||||
*/
|
||||
public static MediaInformation getMediaInformation(final String path) {
|
||||
final int rc = execute(new String[]{"-v", "info", "-hide_banner", "-i", path});
|
||||
|
||||
if (rc == 0) {
|
||||
return MediaInformationParser.from(Config.getLastCommandOutput());
|
||||
} else {
|
||||
Log.i(Config.TAG, Config.getLastCommandOutput());
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Returns media information for given file.
|
||||
*
|
||||
* <p>This method does not support executing multiple concurrent operations. If you execute
|
||||
* multiple operations (execute or getMediaInformation) at the same time, the response of this
|
||||
* method is not predictable.
|
||||
*
|
||||
* @param path path or uri of media file
|
||||
* @param timeout complete timeout
|
||||
* @return media information
|
||||
* @since 3.0
|
||||
* @deprecated this method is deprecated since v4.3.1. You can still use this method but
|
||||
* <code>timeout</code> parameter is not effective anymore.
|
||||
*/
|
||||
public static MediaInformation getMediaInformation(final String path, final Long timeout) {
|
||||
return getMediaInformation(path);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -27,14 +27,6 @@ package com.arthenica.mobileffmpeg;
|
||||
*/
|
||||
public enum Level {
|
||||
|
||||
/**
|
||||
* This log level is defined by MobileFFmpeg. It is used to specify logs printed to stderr by
|
||||
* ffmpeg. Logs that has this level are not filtered and always redirected.
|
||||
*
|
||||
* @since 4.3.1
|
||||
*/
|
||||
AV_LOG_STDERR(-16),
|
||||
|
||||
/**
|
||||
* Print no output.
|
||||
*/
|
||||
@@ -93,9 +85,7 @@ public enum Level {
|
||||
* @return enumeration defined by value
|
||||
*/
|
||||
public static Level from(final int value) {
|
||||
if (value == AV_LOG_STDERR.getValue()) {
|
||||
return AV_LOG_STDERR;
|
||||
} else if (value == AV_LOG_QUIET.getValue()) {
|
||||
if (value == AV_LOG_QUIET.getValue()) {
|
||||
return AV_LOG_QUIET;
|
||||
} else if (value == AV_LOG_PANIC.getValue()) {
|
||||
return AV_LOG_PANIC;
|
||||
|
||||
@@ -67,14 +67,12 @@ public class MediaInformationParser {
|
||||
if (rawCommandOutput != null) {
|
||||
final String[] split = rawCommandOutput.split("\n");
|
||||
boolean metadata = false;
|
||||
boolean sidedata = false;
|
||||
StreamInformation lastCreatedStream = null;
|
||||
final StringBuilder rawInformation = new StringBuilder();
|
||||
|
||||
for (final String outputLine : split) {
|
||||
if (outputLine.startsWith("[")) {
|
||||
metadata = false;
|
||||
sidedata = false;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -82,30 +80,23 @@ public class MediaInformationParser {
|
||||
|
||||
if (trimmedLine.startsWith("Input")) {
|
||||
metadata = false;
|
||||
sidedata = false;
|
||||
lastCreatedStream = null;
|
||||
Pair<String, String> pair = parseInputBlock(trimmedLine);
|
||||
mediaInformation.setFormat(pair.getFirst());
|
||||
mediaInformation.setPath(pair.getSecond());
|
||||
} else if (trimmedLine.startsWith("Duration")) {
|
||||
metadata = false;
|
||||
sidedata = 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.toLowerCase(Locale.ENGLISH).startsWith("metadata")) {
|
||||
sidedata = false;
|
||||
} else if (trimmedLine.startsWith("Metadata")) {
|
||||
metadata = true;
|
||||
} else if (trimmedLine.toLowerCase(Locale.ENGLISH).startsWith("side data")) {
|
||||
metadata = false;
|
||||
sidedata = true;
|
||||
} else if (trimmedLine.startsWith("Stream mapping") || trimmedLine.startsWith("Press [q] to stop") || trimmedLine.startsWith("Output")) {
|
||||
break;
|
||||
} else if (trimmedLine.startsWith("Stream")) {
|
||||
metadata = false;
|
||||
sidedata = false;
|
||||
lastCreatedStream = MediaInformationParser.parseStreamBlock(trimmedLine);
|
||||
mediaInformation.addStream(lastCreatedStream);
|
||||
} else if (metadata) {
|
||||
@@ -118,14 +109,6 @@ public class MediaInformationParser {
|
||||
mediaInformation.addMetadata(pair.getFirst(), pair.getSecond());
|
||||
}
|
||||
}
|
||||
} else if (sidedata) {
|
||||
Pair<String, String> pair = parseMetadataBlock(trimmedLine);
|
||||
|
||||
if (pair.getFirst() != null && pair.getSecond() != null) {
|
||||
if (lastCreatedStream != null) {
|
||||
lastCreatedStream.addSidedata(pair.getFirst(), pair.getSecond());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rawInformation.append(outputLine);
|
||||
@@ -206,14 +189,14 @@ public class MediaInformationParser {
|
||||
pEnd = count(part2, ")");
|
||||
}
|
||||
|
||||
streamInformation.setFullFormat(part2.toLowerCase(Locale.getDefault()).trim());
|
||||
streamInformation.setFormat(part2.replaceAll("\\(.*\\)", "").toLowerCase(Locale.getDefault()).trim());
|
||||
streamInformation.setFullFormat(part2.toLowerCase().trim());
|
||||
streamInformation.setFormat(part2.replaceAll("\\(.*\\)", "").toLowerCase().trim());
|
||||
}
|
||||
|
||||
lastUsedPart++;
|
||||
String videoDimensionPart = safeGet(parts, lastUsedPart);
|
||||
if (videoDimensionPart != null) {
|
||||
String videoLayout = videoDimensionPart.toLowerCase(Locale.getDefault()).trim();
|
||||
String videoLayout = videoDimensionPart.toLowerCase().trim();
|
||||
Pair<Long, Long> dimensions = parseVideoDimensions(videoLayout);
|
||||
streamInformation.setWidth(dimensions.getFirst());
|
||||
streamInformation.setHeight(dimensions.getSecond());
|
||||
@@ -222,7 +205,7 @@ public class MediaInformationParser {
|
||||
}
|
||||
|
||||
for (int i = lastUsedPart + 1; i < parts.length; i++) {
|
||||
String part = parts[i].replaceAll("\\(.*\\)", "").toLowerCase(Locale.getDefault());
|
||||
String part = parts[i].replaceAll("\\(.*\\)", "").toLowerCase();
|
||||
|
||||
if (part.contains("kb/s")) {
|
||||
streamInformation.setBitrate(toLongObject(part.replaceAll("kb/s", "").trim()));
|
||||
@@ -236,22 +219,19 @@ public class MediaInformationParser {
|
||||
streamInformation.setCodecTimeBase(part.replaceAll("tbc", "").trim());
|
||||
}
|
||||
}
|
||||
} else if ("audio".equals(type)) {
|
||||
}
|
||||
if ("audio".equals(type)) {
|
||||
if (part2 != null) {
|
||||
streamInformation.setSampleRate(parseAudioStreamSampleRate(part2));
|
||||
}
|
||||
if (part3 != null) {
|
||||
streamInformation.setChannelLayout(part3.toLowerCase(Locale.getDefault()).trim());
|
||||
streamInformation.setChannelLayout(part3.toLowerCase().trim());
|
||||
}
|
||||
if (part4 != null) {
|
||||
streamInformation.setSampleFormat(part4.toLowerCase(Locale.getDefault()).trim());
|
||||
streamInformation.setSampleFormat(part4.toLowerCase().trim());
|
||||
}
|
||||
if (part5 != null) {
|
||||
streamInformation.setBitrate(toLongObject(part5.toLowerCase(Locale.getDefault()).replaceAll("\\(.*\\)", "").replaceAll("kb/s", "").trim()));
|
||||
}
|
||||
} else if ("data".equals(type)) {
|
||||
if (part2 != null) {
|
||||
streamInformation.setBitrate(toLongObject(part2.toLowerCase(Locale.getDefault()).replaceAll("\\(.*\\)", "").replaceAll("kb/s", "").trim()));
|
||||
streamInformation.setBitrate(toLongObject(part5.toLowerCase().replaceAll("\\(.*\\)", "").replaceAll("kb/s", "").trim()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -265,7 +245,7 @@ public class MediaInformationParser {
|
||||
Long height = null;
|
||||
|
||||
if (input != null) {
|
||||
final String[] dimensions = input.toLowerCase(Locale.getDefault()).replaceAll("\\[.*\\]", "").trim().split("x");
|
||||
final String[] dimensions = input.toLowerCase().replaceAll("\\[.*\\]", "").trim().split("x");
|
||||
width = toLongObject(safeGet(dimensions, 0));
|
||||
height = toLongObject(safeGet(dimensions, 1));
|
||||
}
|
||||
@@ -277,7 +257,7 @@ public class MediaInformationParser {
|
||||
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")) {
|
||||
if (parts[i].toLowerCase().equals("sar")) {
|
||||
return safeGet(parts, i + 1);
|
||||
}
|
||||
}
|
||||
@@ -290,7 +270,7 @@ public class MediaInformationParser {
|
||||
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")) {
|
||||
if (parts[i].toLowerCase().equals("dar")) {
|
||||
return safeGet(parts, i + 1);
|
||||
}
|
||||
}
|
||||
@@ -304,7 +284,7 @@ public class MediaInformationParser {
|
||||
boolean khz = false;
|
||||
boolean mhz = false;
|
||||
|
||||
String lowerCase = input.toLowerCase(Locale.getDefault());
|
||||
String lowerCase = input.toLowerCase();
|
||||
if (lowerCase.contains("khz")) {
|
||||
khz = true;
|
||||
}
|
||||
@@ -332,12 +312,10 @@ public class MediaInformationParser {
|
||||
|
||||
static String parseStreamType(final String input) {
|
||||
if (input != null) {
|
||||
if (input.toLowerCase(Locale.getDefault()).contains("audio:")) {
|
||||
if (input.toLowerCase().contains("audio:")) {
|
||||
return "audio";
|
||||
} else if (input.toLowerCase(Locale.getDefault()).contains("video:")) {
|
||||
} else if (input.toLowerCase().contains("video:")) {
|
||||
return "video";
|
||||
} else if (input.toLowerCase(Locale.getDefault()).contains("data:")) {
|
||||
return "data";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -346,11 +324,10 @@ public class MediaInformationParser {
|
||||
|
||||
static String parseStreamCodec(final String input) {
|
||||
if (input != null) {
|
||||
return input.toLowerCase(Locale.getDefault())
|
||||
return input.toLowerCase()
|
||||
.replaceAll("\\(.*\\)", "")
|
||||
.replaceAll("video:", "")
|
||||
.replaceAll("audio:", "")
|
||||
.replaceAll("data:", "")
|
||||
.trim();
|
||||
}
|
||||
|
||||
@@ -359,10 +336,9 @@ public class MediaInformationParser {
|
||||
|
||||
static String parseStreamFullCodec(final String input) {
|
||||
if (input != null) {
|
||||
return input.toLowerCase(Locale.getDefault())
|
||||
return input.toLowerCase()
|
||||
.replaceAll("video:", "")
|
||||
.replaceAll("audio:", "")
|
||||
.replaceAll("data:", "")
|
||||
.trim();
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ class Packages {
|
||||
|
||||
static {
|
||||
supportedExternalLibraries = new ArrayList<>();
|
||||
supportedExternalLibraries.add("chromaprint");
|
||||
supportedExternalLibraries.add("fontconfig");
|
||||
supportedExternalLibraries.add("freetype");
|
||||
supportedExternalLibraries.add("fribidi");
|
||||
@@ -52,10 +53,9 @@ class Packages {
|
||||
supportedExternalLibraries.add("libwebp");
|
||||
supportedExternalLibraries.add("libxml2");
|
||||
supportedExternalLibraries.add("opencore-amr");
|
||||
supportedExternalLibraries.add("openh264");
|
||||
supportedExternalLibraries.add("opus");
|
||||
supportedExternalLibraries.add("sdl2");
|
||||
supportedExternalLibraries.add("shine");
|
||||
supportedExternalLibraries.add("sdl");
|
||||
supportedExternalLibraries.add("snappy");
|
||||
supportedExternalLibraries.add("soxr");
|
||||
supportedExternalLibraries.add("speex");
|
||||
@@ -73,7 +73,7 @@ class Packages {
|
||||
* @return enabled external libraries
|
||||
*/
|
||||
static List<String> getExternalLibraries() {
|
||||
final String buildConfiguration = AbiDetect.getNativeBuildConf();
|
||||
final String buildConfiguration = Config.getNativeBuildConf();
|
||||
|
||||
final List<String> enabledLibraryList = new ArrayList<>();
|
||||
for (String supportedExternalLibrary : supportedExternalLibraries) {
|
||||
@@ -100,6 +100,7 @@ class Packages {
|
||||
final boolean gnutls = externalLibraryList.contains("gnutls");
|
||||
final boolean xvid = externalLibraryList.contains("xvid");
|
||||
|
||||
boolean min = false;
|
||||
boolean minGpl = false;
|
||||
boolean https = false;
|
||||
boolean httpsGpl = false;
|
||||
@@ -127,11 +128,14 @@ class Packages {
|
||||
} else {
|
||||
if (gnutls) {
|
||||
https = true;
|
||||
} else {
|
||||
min = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fullGpl) {
|
||||
if (externalLibraryList.contains("fontconfig") &&
|
||||
if (externalLibraryList.contains("chromaprint") &&
|
||||
externalLibraryList.contains("fontconfig") &&
|
||||
externalLibraryList.contains("freetype") &&
|
||||
externalLibraryList.contains("fribidi") &&
|
||||
externalLibraryList.contains("gmp") &&
|
||||
@@ -151,9 +155,11 @@ class Packages {
|
||||
externalLibraryList.contains("opencore-amr") &&
|
||||
externalLibraryList.contains("opus") &&
|
||||
externalLibraryList.contains("shine") &&
|
||||
externalLibraryList.contains("sdl") &&
|
||||
externalLibraryList.contains("snappy") &&
|
||||
externalLibraryList.contains("soxr") &&
|
||||
externalLibraryList.contains("speex") &&
|
||||
externalLibraryList.contains("tesseract") &&
|
||||
externalLibraryList.contains("twolame") &&
|
||||
externalLibraryList.contains("wavpack") &&
|
||||
externalLibraryList.contains("x264") &&
|
||||
@@ -166,7 +172,8 @@ class Packages {
|
||||
}
|
||||
|
||||
if (full) {
|
||||
if (externalLibraryList.contains("fontconfig") &&
|
||||
if (externalLibraryList.contains("chromaprint") &&
|
||||
externalLibraryList.contains("fontconfig") &&
|
||||
externalLibraryList.contains("freetype") &&
|
||||
externalLibraryList.contains("fribidi") &&
|
||||
externalLibraryList.contains("gmp") &&
|
||||
@@ -185,9 +192,11 @@ class Packages {
|
||||
externalLibraryList.contains("opencore-amr") &&
|
||||
externalLibraryList.contains("opus") &&
|
||||
externalLibraryList.contains("shine") &&
|
||||
externalLibraryList.contains("sdl") &&
|
||||
externalLibraryList.contains("snappy") &&
|
||||
externalLibraryList.contains("soxr") &&
|
||||
externalLibraryList.contains("speex") &&
|
||||
externalLibraryList.contains("tesseract") &&
|
||||
externalLibraryList.contains("twolame") &&
|
||||
externalLibraryList.contains("wavpack")) {
|
||||
return "full";
|
||||
@@ -264,11 +273,7 @@ class Packages {
|
||||
}
|
||||
}
|
||||
|
||||
if (externalLibraryList.size() == 0) {
|
||||
return "min";
|
||||
} else {
|
||||
return "custom";
|
||||
}
|
||||
return "min";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -84,14 +84,8 @@ public class StreamInformation {
|
||||
*/
|
||||
private final Map<String, String> metadata;
|
||||
|
||||
/**
|
||||
* Side data map
|
||||
*/
|
||||
private final Map<String, String> sidedata;
|
||||
|
||||
public StreamInformation() {
|
||||
this.metadata = new HashMap<>();
|
||||
this.sidedata = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -428,16 +422,6 @@ public class StreamInformation {
|
||||
this.metadata.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves metadata value associated with this key.
|
||||
*
|
||||
* @param key metadata key
|
||||
* @return metadata value associated with this key
|
||||
*/
|
||||
public String getMetadata(String key) {
|
||||
return this.metadata.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all metadata entries.
|
||||
*
|
||||
@@ -447,33 +431,4 @@ public class StreamInformation {
|
||||
return this.metadata.entrySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds side data.
|
||||
*
|
||||
* @param key side data key
|
||||
* @param value side data value
|
||||
*/
|
||||
public void addSidedata(String key, String value) {
|
||||
this.sidedata.put(key, value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves side data value associated with this key.
|
||||
*
|
||||
* @param key side data key
|
||||
* @return side data value associated with this key
|
||||
*/
|
||||
public String getSidedata(String key) {
|
||||
return this.sidedata.get(key);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all side data entries.
|
||||
*
|
||||
* @return set of site data entries
|
||||
*/
|
||||
public Set<Map.Entry<String, String>> getSidedataEntries() {
|
||||
return this.sidedata.entrySet();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,48 +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.Config;
|
||||
import com.arthenica.mobileffmpeg.FFmpeg;
|
||||
|
||||
public class AsyncSingleFFmpegExecuteTask extends AsyncTask<String, Integer, Integer> {
|
||||
private final String command;
|
||||
private final SingleExecuteCallback singleExecuteCallback;
|
||||
|
||||
public AsyncSingleFFmpegExecuteTask(final String command, final SingleExecuteCallback singleExecuteCallback) {
|
||||
this.command = command;
|
||||
this.singleExecuteCallback = singleExecuteCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(final String... arguments) {
|
||||
return FFmpeg.execute(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Integer rc) {
|
||||
if (singleExecuteCallback != null) {
|
||||
singleExecuteCallback.apply(rc, Config.getLastCommandOutput());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +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.Config;
|
||||
import com.arthenica.mobileffmpeg.FFprobe;
|
||||
|
||||
public class AsyncSingleFFprobeExecuteTask extends AsyncTask<String, Integer, Integer> {
|
||||
private final String command;
|
||||
private final SingleExecuteCallback singleExecuteCallback;
|
||||
|
||||
public AsyncSingleFFprobeExecuteTask(final String command, final SingleExecuteCallback singleExecuteCallback) {
|
||||
this.command = command;
|
||||
this.singleExecuteCallback = singleExecuteCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Integer doInBackground(final String... arguments) {
|
||||
return FFprobe.execute(command);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final Integer rc) {
|
||||
if (singleExecuteCallback != null) {
|
||||
singleExecuteCallback.apply(rc, Config.getLastCommandOutput());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +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.FFprobe;
|
||||
import com.arthenica.mobileffmpeg.MediaInformation;
|
||||
|
||||
public class AsyncSingleGetMediaInformationTask extends AsyncTask<String, MediaInformation, MediaInformation> {
|
||||
private final String path;
|
||||
private final SingleGetMediaInformationCallback singleGetMediaInformationCallback;
|
||||
|
||||
public AsyncSingleGetMediaInformationTask(final String path, final SingleGetMediaInformationCallback singleGetMediaInformationCallback) {
|
||||
this.path = path;
|
||||
this.singleGetMediaInformationCallback = singleGetMediaInformationCallback;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MediaInformation doInBackground(final String... arguments) {
|
||||
return FFprobe.getMediaInformation(path);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(final MediaInformation mediaInformation) {
|
||||
if (singleGetMediaInformationCallback != null) {
|
||||
singleGetMediaInformationCallback.apply(mediaInformation);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
* <p>Represents a callback function to receive run result.
|
||||
*
|
||||
* @author Taner Sener
|
||||
* @since v2.1
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface RunCallback {
|
||||
|
||||
void apply(final int returnCode);
|
||||
|
||||
}
|
||||
@@ -1,33 +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;
|
||||
|
||||
/**
|
||||
* <p>Represents a callback function to receive a single execution result.
|
||||
*
|
||||
* @author Taner Sener
|
||||
* @since v2.1
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface SingleExecuteCallback {
|
||||
|
||||
void apply(int returnCode, String executeOutput);
|
||||
|
||||
}
|
||||
@@ -1,34 +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;
|
||||
|
||||
import com.arthenica.mobileffmpeg.MediaInformation;
|
||||
|
||||
/**
|
||||
* <p>Represents a callback function to receive a single getMediaInformation result.
|
||||
*
|
||||
* @author Taner Sener
|
||||
*/
|
||||
@FunctionalInterface
|
||||
public interface SingleGetMediaInformationCallback {
|
||||
|
||||
void apply(MediaInformation mediaInformation);
|
||||
|
||||
}
|
||||
|
After Width: | Height: | Size: 5.9 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 3.0 KiB |
|
After Width: | Height: | Size: 3.9 KiB |
|
After Width: | Height: | Size: 7.4 KiB |
|
After Width: | Height: | Size: 10 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 19 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 26 KiB |
@@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<color name="colorPrimary">#3F51B5</color>
|
||||
<color name="colorPrimaryDark">#303F9F</color>
|
||||
<color name="colorAccent">#FF4081</color>
|
||||
</resources>
|
||||
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">MobileFFmpeg</string>
|
||||
</resources>
|
||||
@@ -0,0 +1,11 @@
|
||||
<resources>
|
||||
|
||||
<!-- Base application theme. -->
|
||||
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
|
||||
<!-- Customize your theme here. -->
|
||||
<item name="colorPrimary">@color/colorPrimary</item>
|
||||
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
|
||||
<item name="colorAccent">@color/colorAccent</item>
|
||||
</style>
|
||||
|
||||
</resources>
|
||||
|
After Width: | Height: | Size: 66 KiB |
@@ -19,7 +19,8 @@
|
||||
|
||||
package com.arthenica.mobileffmpeg;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -137,7 +138,7 @@ public class ConfigTest {
|
||||
Collections.sort(enabledList);
|
||||
|
||||
Assert.assertNotNull(enabledList);
|
||||
Assert.assertEquals(1, enabledList.size());
|
||||
Assert.assertTrue(enabledList.size() == 1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -22,9 +22,6 @@ package com.arthenica.mobileffmpeg;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* <p>Tests for {@link FFmpeg} class.
|
||||
*/
|
||||
@@ -301,40 +298,6 @@ public class FFmpegTest {
|
||||
"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";
|
||||
|
||||
private static final String MEDIA_INFORMATION_RECORDING =
|
||||
"Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/mobile/Containers/Data/Application/845A06CD-8427-4D2D-A9A8-F7738063E220/Library/Caches/video.mov':\n" +
|
||||
" Metadata:\n" +
|
||||
" major_brand : qt\n" +
|
||||
" minor_version : 0\n" +
|
||||
" compatible_brands: qt\n" +
|
||||
" creation_time : 2019-04-18T09:53:38.000000Z\n" +
|
||||
" com.apple.quicktime.location.ISO6709: +40.9761+029.0949+070.349/\n" +
|
||||
" com.apple.quicktime.make: Apple\n" +
|
||||
" com.apple.quicktime.model: iPhone 6\n" +
|
||||
" com.apple.quicktime.software: 12.2\n" +
|
||||
" com.apple.quicktime.creationdate: 2019-04-18T12:53:38+0300\n" +
|
||||
" Duration: 00:00:02.30, start: 0.000000, bitrate: 16658 kb/s\n" +
|
||||
" Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080, 16535 kb/s, 29.98 fps, 29.97 tbr, 600 tbn, 1200 tbc (default)\n" +
|
||||
" Metadata:\n" +
|
||||
" rotate : 90\n" +
|
||||
" creation_time : 2019-04-18T09:53:38.000000Z\n" +
|
||||
" handler_name : Core Media Video\n" +
|
||||
" encoder : H.264\n" +
|
||||
" Side data:\n" +
|
||||
" displaymatrix: rotation of -90.00 degrees\n" +
|
||||
" Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, mono, fltp, 96 kb/s (default)\n" +
|
||||
" Metadata:\n" +
|
||||
" creation_time : 2019-04-18T09:53:38.000000Z\n" +
|
||||
" handler_name : Core Media Audio\n" +
|
||||
" Stream #0:2(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)\n" +
|
||||
" Metadata:\n" +
|
||||
" creation_time : 2019-04-18T09:53:38.000000Z\n" +
|
||||
" handler_name : Core Media Metadata\n" +
|
||||
" Stream #0:3(und): Data: none (mebx / 0x7862656D), 0 kb/s (default)\n" +
|
||||
" Metadata:\n" +
|
||||
" creation_time : 2019-04-18T09:53:38.000000Z\n" +
|
||||
" handler_name : Core Media Metadata\n";
|
||||
|
||||
@Test
|
||||
public void mediaInformationMp3() {
|
||||
MediaInformation mediaInformation = MediaInformationParser.from(MEDIA_INFORMATION_MP3);
|
||||
@@ -342,17 +305,6 @@ public class FFmpegTest {
|
||||
Assert.assertNotNull(mediaInformation);
|
||||
assertMediaInput(mediaInformation, "mp3", "beethoven_-_symphony_no_9.mp3");
|
||||
assertMediaDuration(mediaInformation, 213240L, 0L, 320L);
|
||||
|
||||
assertMetadata(mediaInformation, "comment", "");
|
||||
assertMetadata(mediaInformation, "album", "Symphony No.9");
|
||||
assertMetadata(mediaInformation, "compilation", "0");
|
||||
assertMetadata(mediaInformation, "date", "-1");
|
||||
assertMetadata(mediaInformation, "title", "Symphony No.9");
|
||||
assertMetadata(mediaInformation, "artist", "Beethoven");
|
||||
assertMetadata(mediaInformation, "album_artist", "Beethoven");
|
||||
assertMetadata(mediaInformation, "track", "-1");
|
||||
assertMetadata(mediaInformation, "lyrics-XXX", "");
|
||||
|
||||
Assert.assertNotNull(mediaInformation.getStreams());
|
||||
Assert.assertEquals(1, mediaInformation.getStreams().size());
|
||||
assertAudioStream(mediaInformation.getStreams().get(0), 0L, "mp3", "mp3", 48000L, "stereo", "fltp", 320L);
|
||||
@@ -389,17 +341,9 @@ public class FFmpegTest {
|
||||
Assert.assertNotNull(mediaInformation);
|
||||
assertMediaInput(mediaInformation, "mov,mp4,m4a,3gp,3g2,mj2", "transition_rotate.mp4");
|
||||
assertMediaDuration(mediaInformation, 15000L, 0L, 7764L);
|
||||
|
||||
assertMetadata(mediaInformation, "major_brand", "isom");
|
||||
assertMetadata(mediaInformation, "minor_version", "512");
|
||||
assertMetadata(mediaInformation, "compatible_brands", "isomiso2avc1mp41");
|
||||
assertMetadata(mediaInformation, "encoder", "Lavf58.12.100");
|
||||
|
||||
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");
|
||||
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(0), "handler_name", "VideoHandler");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -433,31 +377,11 @@ public class FFmpegTest {
|
||||
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);
|
||||
|
||||
assertMetadata(mediaInformation, "major_brand", "isom");
|
||||
assertMetadata(mediaInformation, "minor_version", "1");
|
||||
assertMetadata(mediaInformation, "compatible_brands", "isomavc1");
|
||||
assertMetadata(mediaInformation, "creation_time", "2013-12-16T17:21:55.000000Z");
|
||||
assertMetadata(mediaInformation, "title", "Big Buck Bunny, Sunflower version");
|
||||
assertMetadata(mediaInformation, "artist", "Blender Foundation 2008, Janus Bager Kristensen 2013");
|
||||
assertMetadata(mediaInformation, "comment", "Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net");
|
||||
assertMetadata(mediaInformation, "genre", "Animation");
|
||||
assertMetadata(mediaInformation, "composer", "Sacha Goedegebure");
|
||||
|
||||
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);
|
||||
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(0), "creation_time", "2013-12-16T17:21:55.000000Z");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(0), "handler_name", "GPAC ISO Video Handler");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(1), "creation_time", "2013-12-16T17:21:58.000000Z");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(1), "handler_name", "GPAC ISO Audio Handler");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(2), "creation_time", "2013-12-16T17:21:58.000000Z");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(2), "handler_name", "GPAC ISO Audio Handler");
|
||||
|
||||
assertStreamSidedata(mediaInformation.getStreams().get(2), "audio service type", "main");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -467,31 +391,11 @@ public class FFmpegTest {
|
||||
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);
|
||||
|
||||
assertMetadata(mediaInformation, "major_brand", "isom");
|
||||
assertMetadata(mediaInformation, "minor_version", "1");
|
||||
assertMetadata(mediaInformation, "compatible_brands", "isomavc1");
|
||||
assertMetadata(mediaInformation, "creation_time", "2013-12-16T17:49:59.000000Z");
|
||||
assertMetadata(mediaInformation, "title", "Big Buck Bunny, Sunflower version");
|
||||
assertMetadata(mediaInformation, "artist", "Blender Foundation 2008, Janus Bager Kristensen 2013");
|
||||
assertMetadata(mediaInformation, "comment", "Creative Commons Attribution 3.0 - http://bbb3d.renderfarming.net");
|
||||
assertMetadata(mediaInformation, "genre", "Animation");
|
||||
assertMetadata(mediaInformation, "composer", "Sacha Goedegebure");
|
||||
|
||||
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);
|
||||
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(0), "creation_time", "2013-12-16T17:49:59.000000Z");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(0), "handler_name", "GPAC ISO Video Handler");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(1), "creation_time", "2013-12-16T17:50:04.000000Z");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(1), "handler_name", "GPAC ISO Audio Handler");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(2), "creation_time", "2013-12-16T17:50:04.000000Z");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(2), "handler_name", "GPAC ISO Audio Handler");
|
||||
|
||||
assertStreamSidedata(mediaInformation.getStreams().get(2), "audio service type", "main");
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -505,165 +409,6 @@ public class FFmpegTest {
|
||||
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);
|
||||
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(0), "ENCODER", "ffmpeg2theora 0.19");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(1), "ENCODER", "ffmpeg2theora 0.19");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void setMediaInformationRecording() {
|
||||
MediaInformation mediaInformation = MediaInformationParser.from(MEDIA_INFORMATION_RECORDING);
|
||||
|
||||
Assert.assertNotNull(mediaInformation);
|
||||
assertMediaInput(mediaInformation, "mov,mp4,m4a,3gp,3g2,mj2", "/var/mobile/Containers/Data/Application/845A06CD-8427-4D2D-A9A8-F7738063E220/Library/Caches/video.mov");
|
||||
assertMediaDuration(mediaInformation, 2300L, 0L, 16658L);
|
||||
|
||||
assertMetadata(mediaInformation, "major_brand", "qt");
|
||||
assertMetadata(mediaInformation, "minor_version", "0");
|
||||
assertMetadata(mediaInformation, "compatible_brands", "qt");
|
||||
assertMetadata(mediaInformation, "creation_time", "2019-04-18T09:53:38.000000Z");
|
||||
assertMetadata(mediaInformation, "com.apple.quicktime.location.ISO6709", "+40.9761+029.0949+070.349/");
|
||||
assertMetadata(mediaInformation, "com.apple.quicktime.make", "Apple");
|
||||
assertMetadata(mediaInformation, "com.apple.quicktime.model", "iPhone 6");
|
||||
assertMetadata(mediaInformation, "com.apple.quicktime.software", "12.2");
|
||||
assertMetadata(mediaInformation, "com.apple.quicktime.creationdate", "2019-04-18T12:53:38+0300");
|
||||
|
||||
Assert.assertNotNull(mediaInformation.getStreams());
|
||||
Assert.assertEquals(4, mediaInformation.getStreams().size());
|
||||
assertVideoStream(mediaInformation.getStreams().get(0), 0L, "h264", "h264 (avc1 / 0x31637661)", "yuv420p", "yuv420p(tv, bt709)", 1920L, 1080L, null, null, 16535L, "29.98", "29.97", "600", "1200");
|
||||
assertAudioStream(mediaInformation.getStreams().get(1), 1L, "aac", "aac (mp4a / 0x6134706d)", 44100L, "mono", "fltp", 96L);
|
||||
assertStream(mediaInformation.getStreams().get(2), 2L, "data", "none", "none (mebx / 0x7862656d)", 0L);
|
||||
assertStream(mediaInformation.getStreams().get(3), 3L, "data", "none", "none (mebx / 0x7862656d)", 0L);
|
||||
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(0), "rotate", "90");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(0), "creation_time", "2019-04-18T09:53:38.000000Z");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(0), "handler_name", "Core Media Video");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(0), "encoder", "H.264");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(1), "creation_time", "2019-04-18T09:53:38.000000Z");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(1), "handler_name", "Core Media Audio");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(2), "creation_time", "2019-04-18T09:53:38.000000Z");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(2), "handler_name", "Core Media Metadata");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(3), "creation_time", "2019-04-18T09:53:38.000000Z");
|
||||
assertStreamMetadata(mediaInformation.getStreams().get(3), "handler_name", "Core Media Metadata");
|
||||
|
||||
assertStreamSidedata(mediaInformation.getStreams().get(0), "displaymatrix", "rotation of -90.00 degrees");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseSimpleCommand() {
|
||||
final String[] argumentArray = FFmpeg.parseArguments("-hide_banner -loop 1 -i file.jpg -filter_complex [0:v]setpts=PTS-STARTPTS[video] -map [video] -vsync 2 -async 1 video.mp4");
|
||||
|
||||
Assert.assertNotNull(argumentArray);
|
||||
Assert.assertEquals(14, argumentArray.length);
|
||||
|
||||
Assert.assertEquals("-hide_banner", argumentArray[0]);
|
||||
Assert.assertEquals("-loop", argumentArray[1]);
|
||||
Assert.assertEquals("1", argumentArray[2]);
|
||||
Assert.assertEquals("-i", argumentArray[3]);
|
||||
Assert.assertEquals("file.jpg", argumentArray[4]);
|
||||
Assert.assertEquals("-filter_complex", argumentArray[5]);
|
||||
Assert.assertEquals("[0:v]setpts=PTS-STARTPTS[video]", argumentArray[6]);
|
||||
Assert.assertEquals("-map", argumentArray[7]);
|
||||
Assert.assertEquals("[video]", argumentArray[8]);
|
||||
Assert.assertEquals("-vsync", argumentArray[9]);
|
||||
Assert.assertEquals("2", argumentArray[10]);
|
||||
Assert.assertEquals("-async", argumentArray[11]);
|
||||
Assert.assertEquals("1", argumentArray[12]);
|
||||
Assert.assertEquals("video.mp4", argumentArray[13]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseSingleQuotesInCommand() {
|
||||
String[] argumentArray = FFmpeg.parseArguments("-loop 1 'file one.jpg' -filter_complex '[0:v]setpts=PTS-STARTPTS[video]' -map [video] video.mp4 ");
|
||||
|
||||
Assert.assertNotNull(argumentArray);
|
||||
Assert.assertEquals(8, argumentArray.length);
|
||||
|
||||
Assert.assertEquals("-loop", argumentArray[0]);
|
||||
Assert.assertEquals("1", argumentArray[1]);
|
||||
Assert.assertEquals("file one.jpg", argumentArray[2]);
|
||||
Assert.assertEquals("-filter_complex", argumentArray[3]);
|
||||
Assert.assertEquals("[0:v]setpts=PTS-STARTPTS[video]", argumentArray[4]);
|
||||
Assert.assertEquals("-map", argumentArray[5]);
|
||||
Assert.assertEquals("[video]", argumentArray[6]);
|
||||
Assert.assertEquals("video.mp4", argumentArray[7]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseDoubleQuotesInCommand() {
|
||||
String[] argumentArray = FFmpeg.parseArguments("-loop 1 \"file one.jpg\" -filter_complex \"[0:v]setpts=PTS-STARTPTS[video]\" -map [video] video.mp4 ");
|
||||
|
||||
Assert.assertNotNull(argumentArray);
|
||||
Assert.assertEquals(8, argumentArray.length);
|
||||
|
||||
Assert.assertEquals("-loop", argumentArray[0]);
|
||||
Assert.assertEquals("1", argumentArray[1]);
|
||||
Assert.assertEquals("file one.jpg", argumentArray[2]);
|
||||
Assert.assertEquals("-filter_complex", argumentArray[3]);
|
||||
Assert.assertEquals("[0:v]setpts=PTS-STARTPTS[video]", argumentArray[4]);
|
||||
Assert.assertEquals("-map", argumentArray[5]);
|
||||
Assert.assertEquals("[video]", argumentArray[6]);
|
||||
Assert.assertEquals("video.mp4", argumentArray[7]);
|
||||
|
||||
argumentArray = FFmpeg.parseArguments(" -i file:///tmp/input.mp4 -vcodec libx264 -vf \"scale=1024:1024,pad=width=1024:height=1024:x=0:y=0:color=black\" -acodec copy -q:v 0 -q:a 0 video.mp4");
|
||||
|
||||
Assert.assertNotNull(argumentArray);
|
||||
Assert.assertEquals(13, argumentArray.length);
|
||||
|
||||
Assert.assertEquals("-i", argumentArray[0]);
|
||||
Assert.assertEquals("file:///tmp/input.mp4", argumentArray[1]);
|
||||
Assert.assertEquals("-vcodec", argumentArray[2]);
|
||||
Assert.assertEquals("libx264", argumentArray[3]);
|
||||
Assert.assertEquals("-vf", argumentArray[4]);
|
||||
Assert.assertEquals("scale=1024:1024,pad=width=1024:height=1024:x=0:y=0:color=black", argumentArray[5]);
|
||||
Assert.assertEquals("-acodec", argumentArray[6]);
|
||||
Assert.assertEquals("copy", argumentArray[7]);
|
||||
Assert.assertEquals("-q:v", argumentArray[8]);
|
||||
Assert.assertEquals("0", argumentArray[9]);
|
||||
Assert.assertEquals("-q:a", argumentArray[10]);
|
||||
Assert.assertEquals("0", argumentArray[11]);
|
||||
Assert.assertEquals("video.mp4", argumentArray[12]);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void parseDoubleQuotesAndEscapesInCommand() {
|
||||
String[] argumentArray = FFmpeg.parseArguments(" -i file:///tmp/input.mp4 -vf \"subtitles=file:///tmp/subtitles.srt:force_style=\'FontSize=16,PrimaryColour=&HFFFFFF&\'\" -vcodec libx264 -acodec copy -q:v 0 -q:a 0 video.mp4");
|
||||
|
||||
Assert.assertNotNull(argumentArray);
|
||||
Assert.assertEquals(13, argumentArray.length);
|
||||
|
||||
Assert.assertEquals("-i", argumentArray[0]);
|
||||
Assert.assertEquals("file:///tmp/input.mp4", argumentArray[1]);
|
||||
Assert.assertEquals("-vf", argumentArray[2]);
|
||||
Assert.assertEquals("subtitles=file:///tmp/subtitles.srt:force_style='FontSize=16,PrimaryColour=&HFFFFFF&'", argumentArray[3]);
|
||||
Assert.assertEquals("-vcodec", argumentArray[4]);
|
||||
Assert.assertEquals("libx264", argumentArray[5]);
|
||||
Assert.assertEquals("-acodec", argumentArray[6]);
|
||||
Assert.assertEquals("copy", argumentArray[7]);
|
||||
Assert.assertEquals("-q:v", argumentArray[8]);
|
||||
Assert.assertEquals("0", argumentArray[9]);
|
||||
Assert.assertEquals("-q:a", argumentArray[10]);
|
||||
Assert.assertEquals("0", argumentArray[11]);
|
||||
Assert.assertEquals("video.mp4", argumentArray[12]);
|
||||
|
||||
argumentArray = FFmpeg.parseArguments(" -i file:///tmp/input.mp4 -vf \"subtitles=file:///tmp/subtitles.srt:force_style=\\\"FontSize=16,PrimaryColour=&HFFFFFF&\\\"\" -vcodec libx264 -acodec copy -q:v 0 -q:a 0 video.mp4");
|
||||
|
||||
Assert.assertNotNull(argumentArray);
|
||||
Assert.assertEquals(13, argumentArray.length);
|
||||
|
||||
Assert.assertEquals("-i", argumentArray[0]);
|
||||
Assert.assertEquals("file:///tmp/input.mp4", argumentArray[1]);
|
||||
Assert.assertEquals("-vf", argumentArray[2]);
|
||||
Assert.assertEquals("subtitles=file:///tmp/subtitles.srt:force_style=\\\"FontSize=16,PrimaryColour=&HFFFFFF&\\\"", argumentArray[3]);
|
||||
Assert.assertEquals("-vcodec", argumentArray[4]);
|
||||
Assert.assertEquals("libx264", argumentArray[5]);
|
||||
Assert.assertEquals("-acodec", argumentArray[6]);
|
||||
Assert.assertEquals("copy", argumentArray[7]);
|
||||
Assert.assertEquals("-q:v", argumentArray[8]);
|
||||
Assert.assertEquals("0", argumentArray[9]);
|
||||
Assert.assertEquals("-q:a", argumentArray[10]);
|
||||
Assert.assertEquals("0", argumentArray[11]);
|
||||
Assert.assertEquals("video.mp4", argumentArray[12]);
|
||||
}
|
||||
|
||||
private void assertMediaInput(MediaInformation mediaInformation, String format, String path) {
|
||||
@@ -677,74 +422,11 @@ public class FFmpegTest {
|
||||
Assert.assertEquals(bitrate, mediaInformation.getBitrate());
|
||||
}
|
||||
|
||||
private void assertMetadata(MediaInformation mediaInformation, String expectedKey, String expectedValue) {
|
||||
Set<Map.Entry<String, String>> metadataEntries = mediaInformation.getMetadataEntries();
|
||||
Assert.assertNotNull(metadataEntries);
|
||||
|
||||
for (Map.Entry<String, String> metadataEntry : metadataEntries) {
|
||||
String key = metadataEntry.getKey();
|
||||
String value = metadataEntry.getValue();
|
||||
|
||||
if (key.equals(expectedKey)) {
|
||||
Assert.assertEquals(expectedValue, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.fail(expectedKey + " not found");
|
||||
}
|
||||
|
||||
private void assertStreamMetadata(StreamInformation streamInformation, String expectedKey, String expectedValue) {
|
||||
Set<Map.Entry<String, String>> metadataEntries = streamInformation.getMetadataEntries();
|
||||
Assert.assertNotNull(metadataEntries);
|
||||
|
||||
for (Map.Entry<String, String> metadataEntry : metadataEntries) {
|
||||
String key = metadataEntry.getKey();
|
||||
String value = metadataEntry.getValue();
|
||||
|
||||
if (key.equals(expectedKey)) {
|
||||
Assert.assertEquals(expectedValue, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.fail(expectedKey + " not found");
|
||||
}
|
||||
|
||||
private void assertStreamSidedata(StreamInformation streamInformation, String expectedKey, String expectedValue) {
|
||||
Set<Map.Entry<String, String>> sidedataEntries = streamInformation.getSidedataEntries();
|
||||
Assert.assertNotNull(sidedataEntries);
|
||||
|
||||
for (Map.Entry<String, String> metadataEntry : sidedataEntries) {
|
||||
String key = metadataEntry.getKey();
|
||||
String value = metadataEntry.getValue();
|
||||
|
||||
if (key.equals(expectedKey)) {
|
||||
Assert.assertEquals(expectedValue, value);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Assert.fail(expectedKey + " not found");
|
||||
}
|
||||
|
||||
private void assertStream(StreamInformation streamInformation, Long index, String type, String codec, String fullCodec, Long bitrate) {
|
||||
Assert.assertEquals(index, streamInformation.getIndex());
|
||||
Assert.assertEquals(type, streamInformation.getType());
|
||||
|
||||
Assert.assertEquals(codec, streamInformation.getCodec());
|
||||
Assert.assertEquals(fullCodec, streamInformation.getFullCodec());
|
||||
|
||||
Assert.assertEquals(bitrate, streamInformation.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());
|
||||
@@ -754,7 +436,6 @@ public class FFmpegTest {
|
||||
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());
|
||||
|
||||
|
||||
@@ -22,7 +22,8 @@ package com.arthenica.mobileffmpeg;
|
||||
import com.arthenica.mobileffmpeg.util.Pair;
|
||||
import com.arthenica.mobileffmpeg.util.Trio;
|
||||
|
||||
import org.junit.Assert;
|
||||
import junit.framework.Assert;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class MediaInformationTest {
|
||||
@@ -81,16 +82,16 @@ public class MediaInformationTest {
|
||||
|
||||
@Test
|
||||
public void parseVideoStreamDisplayAspectRatio() {
|
||||
Assert.assertNull(MediaInformationParser.parseVideoStreamDisplayAspectRatio(""));
|
||||
Assert.assertNull(MediaInformationParser.parseVideoStreamDisplayAspectRatio("544x184"));
|
||||
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.assertNull(MediaInformationParser.parseVideoStreamSampleAspectRatio(""));
|
||||
Assert.assertNull(MediaInformationParser.parseVideoStreamSampleAspectRatio("544x184"));
|
||||
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]"));
|
||||
}
|
||||
|
||||
@@ -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.5.3'
|
||||
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
|
||||
|
||||
@@ -9,8 +9,6 @@
|
||||
|
||||
# Specifies the JVM arguments used for the daemon process.
|
||||
# The setting is particularly useful for tweaking memory settings.
|
||||
android.enableJetifier=true
|
||||
android.useAndroidX=true
|
||||
org.gradle.jvmargs=-Xmx1536m
|
||||
|
||||
# When configured, Gradle will run in incubating parallel mode.
|
||||
|
||||
@@ -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-6.0.1-bin.zip
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
|
||||
|
||||
@@ -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='"-Xmx64m"'
|
||||
|
||||
# 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 "$@"
|
||||
|
||||
@@ -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="-Xmx64m"
|
||||
|
||||
@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,2 +1 @@
|
||||
/Application.mk
|
||||
/Android.mk.tmp
|
||||
|
||||
@@ -2,17 +2,14 @@ LOCAL_PATH := $(call my-dir)
|
||||
$(call import-add-path, $(LOCAL_PATH))
|
||||
|
||||
MY_ARM_MODE := arm
|
||||
MY_ARM_NEON := false
|
||||
MY_PATH := ../app/src/main/cpp
|
||||
|
||||
# DEFINE ARCH FLAGS
|
||||
ifeq ($(TARGET_ARCH_ABI), armeabi-v7a)
|
||||
MY_ARCH_FLAGS := ARM_V7A
|
||||
MY_ARM_NEON := true
|
||||
endif
|
||||
ifeq ($(TARGET_ARCH_ABI), arm64-v8a)
|
||||
MY_ARCH_FLAGS := ARM64_V8A
|
||||
MY_ARM_NEON := true
|
||||
endif
|
||||
ifeq ($(TARGET_ARCH_ABI), x86)
|
||||
MY_ARCH_FLAGS := X86
|
||||
@@ -28,33 +25,42 @@ LOCAL_SRC_FILES := $(NDK_ROOT)/sources/android/cpufeatures/cpu-features.c
|
||||
LOCAL_CFLAGS := -Wall -Wextra -Werror
|
||||
LOCAL_EXPORT_C_INCLUDES := $(NDK_ROOT)/sources/android/cpufeatures
|
||||
LOCAL_EXPORT_LDLIBS := -ldl
|
||||
LOCAL_ARM_NEON := ${MY_ARM_NEON}
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_ARM_MODE := $(MY_ARM_MODE)
|
||||
LOCAL_MODULE := mobileffmpeg_abidetect
|
||||
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_LDLIBS := -llog -lz -landroid
|
||||
LOCAL_SHARED_LIBRARIES := cpufeatures
|
||||
LOCAL_ARM_NEON := ${MY_ARM_NEON}
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_ARM_MODE := $(MY_ARM_MODE)
|
||||
LOCAL_MODULE := mobileffmpeg
|
||||
ifeq ($(TARGET_PLATFORM),android-16)
|
||||
LOCAL_SRC_FILES := $(MY_PATH)/mobileffmpeg.c $(MY_PATH)/mobileffprobe.c $(MY_PATH)/android_lts_support.c $(MY_PATH)/mobileffmpeg_exception.c $(MY_PATH)/fftools_cmdutils.c $(MY_PATH)/fftools_ffmpeg.c $(MY_PATH)/fftools_ffprobe.c $(MY_PATH)/fftools_ffmpeg_opt.c $(MY_PATH)/fftools_ffmpeg_hw.c $(MY_PATH)/fftools_ffmpeg_filter.c
|
||||
else ifeq ($(TARGET_PLATFORM),android-17)
|
||||
LOCAL_SRC_FILES := $(MY_PATH)/mobileffmpeg.c $(MY_PATH)/mobileffprobe.c $(MY_PATH)/android_lts_support.c $(MY_PATH)/mobileffmpeg_exception.c $(MY_PATH)/fftools_cmdutils.c $(MY_PATH)/fftools_ffmpeg.c $(MY_PATH)/fftools_ffprobe.c $(MY_PATH)/fftools_ffmpeg_opt.c $(MY_PATH)/fftools_ffmpeg_hw.c $(MY_PATH)/fftools_ffmpeg_filter.c
|
||||
else
|
||||
LOCAL_SRC_FILES := $(MY_PATH)/mobileffmpeg.c $(MY_PATH)/mobileffprobe.c $(MY_PATH)/mobileffmpeg_exception.c $(MY_PATH)/fftools_cmdutils.c $(MY_PATH)/fftools_ffmpeg.c $(MY_PATH)/fftools_ffprobe.c $(MY_PATH)/fftools_ffmpeg_opt.c $(MY_PATH)/fftools_ffmpeg_hw.c $(MY_PATH)/fftools_ffmpeg_filter.c
|
||||
endif
|
||||
LOCAL_SRC_FILES := $(MY_PATH)/mobileffmpeg.c $(MY_PATH)/fftools_cmdutils.c $(MY_PATH)/fftools_ffmpeg.c $(MY_PATH)/fftools_ffmpeg_opt.c $(MY_PATH)/fftools_ffmpeg_hw.c $(MY_PATH)/fftools_ffmpeg_filter.c
|
||||
LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter -Wno-switch -Wno-sign-compare -I${LOCAL_PATH}/../../prebuilt/android-$(TARGET_ARCH)/ffmpeg/include
|
||||
LOCAL_LDLIBS := -llog -lz -landroid
|
||||
LOCAL_SHARED_LIBRARIES := c++_shared libavfilter libavformat libavcodec libavutil libswresample libavdevice libswscale
|
||||
LOCAL_ARM_NEON := ${MY_ARM_NEON}
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
ifeq ($(TARGET_ARCH_ABI), armeabi-v7a)
|
||||
ifeq ("$(shell test -e $(LOCAL_PATH)/../build/.neon && echo neon)","neon")
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_ARM_MODE := $(MY_ARM_MODE)
|
||||
LOCAL_MODULE := mobileffmpeg-armv7a-neon
|
||||
LOCAL_SRC_FILES := $(MY_PATH)/mobileffmpeg.c $(MY_PATH)/fftools_cmdutils.c $(MY_PATH)/fftools_ffmpeg.c $(MY_PATH)/fftools_ffmpeg_opt.c $(MY_PATH)/fftools_ffmpeg_hw.c $(MY_PATH)/fftools_ffmpeg_filter.c
|
||||
LOCAL_CFLAGS := -Wall -Werror -Wno-unused-parameter -Wno-switch -Wno-sign-compare -I${LOCAL_PATH}/../../prebuilt/android-$(TARGET_ARCH)/ffmpeg/include
|
||||
LOCAL_LDLIBS := -llog -lz -landroid
|
||||
LOCAL_SHARED_LIBRARIES := c++_shared libavcodec-neon libavfilter-neon libswscale-neon libavformat libavutil libswresample libavdevice
|
||||
LOCAL_ARM_NEON := true
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
$(call import-module, ffmpeg/neon)
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
$(call import-module, ffmpeg)
|
||||
|
||||
@@ -5,49 +5,49 @@ MY_FFMPEG_LIB := ../../../../prebuilt/android-$(TARGET_ARCH)/neon/ffmpeg/lib
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_ARM_MODE := $(MY_ARM_MODE)
|
||||
LOCAL_MODULE := libavcodec_neon
|
||||
LOCAL_MODULE := libavcodec-neon
|
||||
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)
|
||||
LOCAL_SRC_FILES := $(MY_FFMPEG_LIB)/libavcodec.so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_ARM_MODE := $(MY_ARM_MODE)
|
||||
LOCAL_MODULE := libavfilter_neon
|
||||
LOCAL_MODULE := libavfilter-neon
|
||||
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)
|
||||
LOCAL_SRC_FILES := $(MY_FFMPEG_LIB)/libavfilter.so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_ARM_MODE := $(MY_ARM_MODE)
|
||||
LOCAL_MODULE := libavdevice_neon
|
||||
LOCAL_MODULE := libavdevice-neon
|
||||
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)
|
||||
LOCAL_SRC_FILES := $(MY_FFMPEG_LIB)/libavdevice.so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_ARM_MODE := $(MY_ARM_MODE)
|
||||
LOCAL_MODULE := libavformat_neon
|
||||
LOCAL_MODULE := libavformat-neon
|
||||
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)
|
||||
LOCAL_SRC_FILES := $(MY_FFMPEG_LIB)/libavformat.so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_ARM_MODE := $(MY_ARM_MODE)
|
||||
LOCAL_MODULE := libavutil_neon
|
||||
LOCAL_MODULE := libavutil-neon
|
||||
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)
|
||||
LOCAL_SRC_FILES := $(MY_FFMPEG_LIB)/libavutil.so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_ARM_MODE := $(MY_ARM_MODE)
|
||||
LOCAL_MODULE := libswresample_neon
|
||||
LOCAL_MODULE := libswresample-neon
|
||||
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)
|
||||
LOCAL_SRC_FILES := $(MY_FFMPEG_LIB)/libswresample.so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
include $(CLEAR_VARS)
|
||||
LOCAL_ARM_MODE := $(MY_ARM_MODE)
|
||||
LOCAL_MODULE := libswscale_neon
|
||||
LOCAL_MODULE := libswscale-neon
|
||||
LOCAL_MODULE_FILENAME := $(LOCAL_MODULE)
|
||||
LOCAL_SRC_FILES := $(MY_FFMPEG_LIB)/libswscale.so
|
||||
include $(PREBUILT_SHARED_LIBRARY)
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
/build
|
||||
/.idea/
|
||||
/gradle/
|
||||
/local.properties
|
||||
@@ -1,58 +1,32 @@
|
||||
apply plugin: 'com.android.application'
|
||||
|
||||
android {
|
||||
signingConfigs {
|
||||
localConfig {
|
||||
keyAlias 'androiddebugkey'
|
||||
storeFile file(System.getProperty("user.home") + '/.android/debug.keystore')
|
||||
storePassword 'android'
|
||||
keyPassword 'android'
|
||||
}
|
||||
}
|
||||
compileSdkVersion 29
|
||||
compileSdkVersion 27
|
||||
defaultConfig {
|
||||
applicationId "com.arthenica.mobileffmpeg.test"
|
||||
minSdkVersion 24
|
||||
targetSdkVersion 29
|
||||
versionCode 240431
|
||||
versionName "4.3.1"
|
||||
minSdkVersion 21
|
||||
targetSdkVersion 27
|
||||
versionCode 30
|
||||
versionName "3.0"
|
||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
||||
}
|
||||
buildTypes {
|
||||
debug {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
release {
|
||||
minifyEnabled true
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
signingConfig signingConfigs.localConfig
|
||||
}
|
||||
}
|
||||
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 project(':app')
|
||||
implementation 'com.arthenica:mobile-ffmpeg-full:4.3.1'
|
||||
implementation 'androidx.appcompat:appcompat:1.1.0'
|
||||
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
|
||||
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||
// implementation 'com.arthenica:mobile-ffmpeg-full:3.0'
|
||||
implementation project(':app')
|
||||
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: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'
|
||||
}
|
||||
|
||||
@@ -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='"-Xmx64m"'
|
||||
|
||||
# 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" "$@"
|
||||
@@ -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="-Xmx64m"
|
||||
|
||||
@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
|
||||
@@ -4,3 +4,18 @@
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# 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
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.content.Context;
|
||||
import android.support.test.InstrumentationRegistry;
|
||||
import android.support.test.runner.AndroidJUnit4;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
* Instrumented test, which will execute on an Android device.
|
||||
*
|
||||
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
|
||||
*/
|
||||
@RunWith(AndroidJUnit4.class)
|
||||
public class ExampleInstrumentedTest {
|
||||
@Test
|
||||
public void useAppContext() throws Exception {
|
||||
// Context of the app under test.
|
||||
Context appContext = InstrumentationRegistry.getTargetContext();
|
||||
|
||||
assertEquals("com.arthenica.mobileffmpeg.test", appContext.getPackageName());
|
||||
}
|
||||
}
|
||||
@@ -12,15 +12,16 @@
|
||||
<uses-feature android:name="android.hardware.camera" android:required="true" />
|
||||
|
||||
<application
|
||||
android:allowBackup="false"
|
||||
android:allowBackup="true"
|
||||
android:icon="@mipmap/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:roundIcon="@mipmap/ic_launcher_round"
|
||||
android:supportsRtl="true"
|
||||
android:largeHeap="true"
|
||||
android:theme="@style/AppTheme"
|
||||
tools:ignore="GoogleAppIndexingWarning">
|
||||
<activity android:name="com.arthenica.mobileffmpeg.test.MainActivity">
|
||||
tools:replace="android:icon">
|
||||
<activity android:name="com.arthenica.mobileffmpeg.test.MainActivity"
|
||||
android:theme="@style/AppTheme">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
|
||||
@@ -21,81 +21,93 @@ package com.arthenica.mobileffmpeg.test;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
import android.os.Bundle;
|
||||
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;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
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.DialogUtil;
|
||||
import com.arthenica.mobileffmpeg.util.SingleExecuteCallback;
|
||||
import com.arthenica.mobileffmpeg.util.RunCallback;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import static com.arthenica.mobileffmpeg.Config.RETURN_CODE_SUCCESS;
|
||||
import static com.arthenica.mobileffmpeg.FFmpeg.RETURN_CODE_SUCCESS;
|
||||
import static com.arthenica.mobileffmpeg.test.MainActivity.TAG;
|
||||
|
||||
public class AudioTabFragment extends Fragment implements AdapterView.OnItemSelectedListener {
|
||||
|
||||
private MainActivity mainActivity;
|
||||
private AlertDialog progressDialog;
|
||||
private Button encodeButton;
|
||||
private TextView outputText;
|
||||
private String selectedCodec;
|
||||
|
||||
public AudioTabFragment() {
|
||||
super(R.layout.fragment_audio_tab);
|
||||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_audio_tab, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
Spinner audioCodecSpinner = view.findViewById(R.id.audioCodecSpinner);
|
||||
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(requireContext(),
|
||||
R.array.audio_codec, R.layout.spinner_item);
|
||||
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
||||
audioCodecSpinner.setAdapter(adapter);
|
||||
audioCodecSpinner.setOnItemSelectedListener(this);
|
||||
if (getView() != null) {
|
||||
Spinner audioCodecSpinner = getView().findViewById(R.id.audioCodecSpinner);
|
||||
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mainActivity,
|
||||
R.array.audio_codec, R.layout.spinner_item);
|
||||
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
||||
audioCodecSpinner.setAdapter(adapter);
|
||||
audioCodecSpinner.setOnItemSelectedListener(this);
|
||||
|
||||
encodeButton = view.findViewById(R.id.encodeButton);
|
||||
encodeButton.setOnClickListener(new View.OnClickListener() {
|
||||
encodeButton = getView().findViewById(R.id.encodeButton);
|
||||
encodeButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
encodeAudio();
|
||||
// encodeChromaprint();
|
||||
}
|
||||
});
|
||||
encodeButton.setEnabled(false);
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
encodeAudio();
|
||||
// encodeChromaprint();
|
||||
}
|
||||
});
|
||||
encodeButton.setEnabled(false);
|
||||
|
||||
outputText = view.findViewById(R.id.outputText);
|
||||
outputText.setMovementMethod(new ScrollingMovementMethod());
|
||||
outputText = getView().findViewById(R.id.outputText);
|
||||
outputText.setMovementMethod(new ScrollingMovementMethod());
|
||||
}
|
||||
|
||||
progressDialog = DialogUtil.createProgressDialog(requireContext(), "Encoding audio");
|
||||
progressDialog = mainActivity.createProgressDialog("Encoding audio");
|
||||
|
||||
selectedCodec = getResources().getStringArray(R.array.audio_codec)[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setActive();
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
if (isVisibleToUser) {
|
||||
setActive();
|
||||
}
|
||||
}
|
||||
|
||||
public static AudioTabFragment newInstance() {
|
||||
return new AudioTabFragment();
|
||||
public void setMainActivity(MainActivity mainActivity) {
|
||||
this.mainActivity = mainActivity;
|
||||
}
|
||||
|
||||
public static AudioTabFragment newInstance(final MainActivity mainActivity) {
|
||||
final AudioTabFragment fragment = new AudioTabFragment();
|
||||
fragment.setMainActivity(mainActivity);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public void enableLogCallback() {
|
||||
@@ -147,10 +159,10 @@ public class AudioTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
|
||||
android.util.Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", ffmpegCommand));
|
||||
|
||||
MainActivity.executeAsync(new SingleExecuteCallback() {
|
||||
MainActivity.executeAsync(new RunCallback() {
|
||||
|
||||
@Override
|
||||
public void apply(final int returnCode, final String commandOutput) {
|
||||
public void apply(final int returnCode) {
|
||||
android.util.Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode));
|
||||
|
||||
hideProgressDialog();
|
||||
@@ -160,10 +172,10 @@ public class AudioTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
@Override
|
||||
public Object call() {
|
||||
if (returnCode == RETURN_CODE_SUCCESS) {
|
||||
Popup.show(requireContext(), "Encode completed successfully.");
|
||||
Popup.show(mainActivity, "Encode completed successfully.");
|
||||
android.util.Log.d(TAG, "Encode completed successfully.");
|
||||
} else {
|
||||
Popup.show(requireContext(), "Encode failed. Please check log for the details.");
|
||||
Popup.show(mainActivity, "Encode failed. Please check log for the details.");
|
||||
android.util.Log.d(TAG, String.format("Encode failed with rc=%d", returnCode));
|
||||
}
|
||||
|
||||
@@ -206,7 +218,7 @@ public class AudioTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
android.util.Log.d(TAG, "AUDIO sample created");
|
||||
} else {
|
||||
android.util.Log.d(TAG, String.format("Creating AUDIO sample failed with rc=%d", result));
|
||||
Popup.show(requireContext(), "Creating AUDIO sample failed. Please check log for the details.");
|
||||
Popup.show(mainActivity, "Creating AUDIO sample failed. Please check log for the details.");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -248,11 +260,11 @@ public class AudioTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
}
|
||||
|
||||
final String audio = "audio." + extension;
|
||||
return new File(requireContext().getFilesDir(), audio);
|
||||
return new File(mainActivity.getFilesDir(), audio);
|
||||
}
|
||||
|
||||
public File getAudioSampleFile() {
|
||||
return new File(requireContext().getFilesDir(), "audio-sample.wav");
|
||||
return new File(mainActivity.getFilesDir(), "audio-sample.wav");
|
||||
}
|
||||
|
||||
public void setActive() {
|
||||
@@ -260,7 +272,7 @@ public class AudioTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
disableLogCallback();
|
||||
createAudioSample();
|
||||
enableLogCallback();
|
||||
Popup.show(requireContext(), Tooltip.AUDIO_TEST_TOOLTIP_TEXT);
|
||||
Popup.show(mainActivity, Tooltip.AUDIO_TEST_TOOLTIP_TEXT);
|
||||
}
|
||||
|
||||
public void appendLog(final String logMessage) {
|
||||
|
||||
@@ -20,72 +20,81 @@
|
||||
package com.arthenica.mobileffmpeg.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.method.ScrollingMovementMethod;
|
||||
import android.util.AndroidRuntimeException;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.arthenica.mobileffmpeg.Config;
|
||||
import com.arthenica.mobileffmpeg.FFmpeg;
|
||||
import com.arthenica.mobileffmpeg.FFprobe;
|
||||
import com.arthenica.mobileffmpeg.LogCallback;
|
||||
import com.arthenica.mobileffmpeg.LogMessage;
|
||||
import com.arthenica.mobileffmpeg.util.RunCallback;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class CommandTabFragment extends Fragment {
|
||||
|
||||
private MainActivity mainActivity;
|
||||
private EditText commandText;
|
||||
private TextView outputText;
|
||||
|
||||
public CommandTabFragment() {
|
||||
super(R.layout.fragment_command_tab);
|
||||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_command_tab, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
commandText = view.findViewById(R.id.commandText);
|
||||
if (getView() != null) {
|
||||
commandText = getView().findViewById(R.id.commandText);
|
||||
|
||||
View runFFmpegButton = view.findViewById(R.id.runFFmpegButton);
|
||||
runFFmpegButton.setOnClickListener(new View.OnClickListener() {
|
||||
View runButton = getView().findViewById(R.id.runButton);
|
||||
runButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
runFFmpeg();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
runFFmpeg();
|
||||
}
|
||||
});
|
||||
|
||||
View runFFprobeButton = view.findViewById(R.id.runFFprobeButton);
|
||||
runFFprobeButton.setOnClickListener(new View.OnClickListener() {
|
||||
View runAsyncButton = getView().findViewById(R.id.runAsyncButton);
|
||||
runAsyncButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
runFFprobe();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
runFFmpegAsync();
|
||||
}
|
||||
});
|
||||
|
||||
outputText = view.findViewById(R.id.outputText);
|
||||
outputText.setMovementMethod(new ScrollingMovementMethod());
|
||||
|
||||
Log.d(MainActivity.TAG, "Last command output was: " + Config.getLastCommandOutput());
|
||||
outputText = getView().findViewById(R.id.outputText);
|
||||
outputText.setMovementMethod(new ScrollingMovementMethod());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setActive();
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
if (isVisibleToUser) {
|
||||
setActive();
|
||||
}
|
||||
}
|
||||
|
||||
public static CommandTabFragment newInstance() {
|
||||
return new CommandTabFragment();
|
||||
public void setMainActivity(MainActivity mainActivity) {
|
||||
this.mainActivity = mainActivity;
|
||||
}
|
||||
|
||||
public static CommandTabFragment newInstance(final MainActivity mainActivity) {
|
||||
final CommandTabFragment fragment = new CommandTabFragment();
|
||||
fragment.setMainActivity(mainActivity);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public void enableLogCallback() {
|
||||
@@ -101,8 +110,6 @@ public class CommandTabFragment extends Fragment {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
throw new AndroidRuntimeException("I am test exception thrown by test application");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -110,43 +117,55 @@ public class CommandTabFragment extends Fragment {
|
||||
public void runFFmpeg() {
|
||||
clearLog();
|
||||
|
||||
final String ffmpegCommand = String.format("%s", commandText.getText().toString());
|
||||
final String ffmpegCommand = commandText.getText().toString();
|
||||
|
||||
android.util.Log.d(MainActivity.TAG, "Testing FFmpeg COMMAND synchronously.");
|
||||
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));
|
||||
|
||||
if (result != 0) {
|
||||
Popup.show(requireContext(), "Command failed. Please check output for the details.");
|
||||
Popup.show(mainActivity, "Command failed. Please check output for the details.");
|
||||
}
|
||||
}
|
||||
|
||||
public void runFFprobe() {
|
||||
public void runFFmpegAsync() {
|
||||
clearLog();
|
||||
|
||||
final String ffprobeCommand = String.format("%s", commandText.getText().toString());
|
||||
final String ffmpegCommand = commandText.getText().toString();
|
||||
|
||||
android.util.Log.d(MainActivity.TAG, "Testing FFprobe COMMAND synchronously.");
|
||||
android.util.Log.d(MainActivity.TAG, "Testing COMMAND asynchronously.");
|
||||
|
||||
android.util.Log.d(MainActivity.TAG, String.format("FFprobe process started with arguments\n\'%s\'", ffprobeCommand));
|
||||
android.util.Log.d(MainActivity.TAG, String.format("FFmpeg process started with arguments\n\'%s\'", ffmpegCommand));
|
||||
|
||||
int result = FFprobe.execute(ffprobeCommand);
|
||||
MainActivity.executeAsync(new RunCallback() {
|
||||
|
||||
android.util.Log.d(MainActivity.TAG, String.format("FFprobe process exited with rc %d", result));
|
||||
@Override
|
||||
public void apply(int result) {
|
||||
|
||||
if (result != 0) {
|
||||
Popup.show(requireContext(), "Command failed. Please check output for the details.");
|
||||
}
|
||||
android.util.Log.d(MainActivity.TAG, String.format("FFmpeg process exited with rc %d", result));
|
||||
|
||||
if (result != 0) {
|
||||
MainActivity.addUIAction(new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
Popup.show(mainActivity, "Command failed. Please check output for the details.");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
}, ffmpegCommand);
|
||||
}
|
||||
|
||||
private void setActive() {
|
||||
Log.i(MainActivity.TAG, "Command Tab Activated");
|
||||
public void setActive() {
|
||||
android.util.Log.i(MainActivity.TAG, "Command Tab Activated");
|
||||
enableLogCallback();
|
||||
Popup.show(requireContext(), Tooltip.COMMAND_TEST_TOOLTIP_TEXT);
|
||||
Popup.show(mainActivity, Tooltip.COMMAND_TEST_TOOLTIP_TEXT);
|
||||
}
|
||||
|
||||
public void appendLog(final String logMessage) {
|
||||
|
||||
@@ -20,65 +20,73 @@
|
||||
package com.arthenica.mobileffmpeg.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
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;
|
||||
import android.widget.EditText;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.arthenica.mobileffmpeg.Config;
|
||||
import com.arthenica.mobileffmpeg.FFprobe;
|
||||
import com.arthenica.mobileffmpeg.FFmpeg;
|
||||
import com.arthenica.mobileffmpeg.LogCallback;
|
||||
import com.arthenica.mobileffmpeg.LogMessage;
|
||||
import com.arthenica.mobileffmpeg.MediaInformation;
|
||||
import com.arthenica.mobileffmpeg.StreamInformation;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
public class HttpsTabFragment extends Fragment {
|
||||
|
||||
public static final String HTTPS_TEST_DEFAULT_URL = "https://download.blender.org/peach/trailer/trailer_1080p.ogg";
|
||||
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";
|
||||
|
||||
private MainActivity mainActivity;
|
||||
private EditText urlText;
|
||||
private TextView outputText;
|
||||
|
||||
public HttpsTabFragment() {
|
||||
super(R.layout.fragment_https_tab);
|
||||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_https_tab, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
urlText = view.findViewById(R.id.urlText);
|
||||
if (getView() != null) {
|
||||
urlText = getView().findViewById(R.id.urlText);
|
||||
|
||||
View getInfoButton = view.findViewById(R.id.getInfoButton);
|
||||
getInfoButton.setOnClickListener(new View.OnClickListener() {
|
||||
View getInfoButton = getView().findViewById(R.id.getInfoButton);
|
||||
getInfoButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getInfo();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getInfo();
|
||||
}
|
||||
});
|
||||
|
||||
outputText = view.findViewById(R.id.outputText);
|
||||
outputText.setMovementMethod(new ScrollingMovementMethod());
|
||||
outputText = getView().findViewById(R.id.outputText);
|
||||
outputText.setMovementMethod(new ScrollingMovementMethod());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setActive();
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
if (isVisibleToUser) {
|
||||
setActive();
|
||||
}
|
||||
}
|
||||
|
||||
public static HttpsTabFragment newInstance() {
|
||||
return new HttpsTabFragment();
|
||||
public void setMainActivity(MainActivity mainActivity) {
|
||||
this.mainActivity = mainActivity;
|
||||
}
|
||||
|
||||
public static HttpsTabFragment newInstance(final MainActivity mainActivity) {
|
||||
final HttpsTabFragment fragment = new HttpsTabFragment();
|
||||
fragment.setMainActivity(mainActivity);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public void enableLogCallback() {
|
||||
@@ -111,106 +119,20 @@ public class HttpsTabFragment extends Fragment {
|
||||
}
|
||||
|
||||
// HTTPS COMMAND ARGUMENTS
|
||||
MediaInformation information = FFprobe.getMediaInformation(testUrl);
|
||||
if (information == null) {
|
||||
appendLog("Get media information failed\n");
|
||||
} else {
|
||||
appendLog("Media information for " + information.getPath() + "\n");
|
||||
final String ffmpegCommand = String.format("-hide_banner -i %s -f null -", testUrl);
|
||||
|
||||
if (information.getFormat() != null) {
|
||||
appendLog("Format: " + information.getFormat() + "\n");
|
||||
}
|
||||
if (information.getBitrate() != null) {
|
||||
appendLog("Bitrate: " + information.getBitrate() + "\n");
|
||||
}
|
||||
if (information.getDuration() != null) {
|
||||
appendLog("Duration: " + information.getDuration() + "\n");
|
||||
}
|
||||
if (information.getStartTime() != null) {
|
||||
appendLog("Start time: " + information.getStartTime() + "\n");
|
||||
}
|
||||
if (information.getMetadataEntries() != null) {
|
||||
Set<Map.Entry<String, String>> entries = information.getMetadataEntries();
|
||||
for (Map.Entry<String, String> entry : entries) {
|
||||
appendLog("Metadata: " + entry.getKey() + ":" + entry.getValue() + "\n");
|
||||
}
|
||||
}
|
||||
if (information.getStreams() != null) {
|
||||
for (StreamInformation stream : information.getStreams()) {
|
||||
if (stream.getIndex() != null) {
|
||||
appendLog("Stream index: " + stream.getIndex() + "\n");
|
||||
}
|
||||
if (stream.getType() != null) {
|
||||
appendLog("Stream type: " + stream.getType() + "\n");
|
||||
}
|
||||
if (stream.getCodec() != null) {
|
||||
appendLog("Stream codec: " + stream.getCodec() + "\n");
|
||||
}
|
||||
if (stream.getFullCodec() != null) {
|
||||
appendLog("Stream full codec: " + stream.getFullCodec() + "\n");
|
||||
}
|
||||
if (stream.getFormat() != null) {
|
||||
appendLog("Stream format: " + stream.getFormat() + "\n");
|
||||
}
|
||||
if (stream.getFullFormat() != null) {
|
||||
appendLog("Stream full format: " + stream.getFullFormat() + "\n");
|
||||
}
|
||||
android.util.Log.d(MainActivity.TAG, String.format("FFmpeg process started with arguments\n'%s'", ffmpegCommand));
|
||||
|
||||
if (stream.getWidth() != null) {
|
||||
appendLog("Stream width: " + stream.getWidth() + "\n");
|
||||
}
|
||||
if (stream.getHeight() != null) {
|
||||
appendLog("Stream height: " + stream.getHeight() + "\n");
|
||||
}
|
||||
// EXECUTE
|
||||
int result = FFmpeg.execute(ffmpegCommand);
|
||||
|
||||
if (stream.getBitrate() != null) {
|
||||
appendLog("Stream bitrate: " + stream.getBitrate() + "\n");
|
||||
}
|
||||
if (stream.getSampleRate() != null) {
|
||||
appendLog("Stream sample rate: " + stream.getSampleRate() + "\n");
|
||||
}
|
||||
if (stream.getSampleFormat() != null) {
|
||||
appendLog("Stream sample format: " + stream.getSampleFormat() + "\n");
|
||||
}
|
||||
if (stream.getChannelLayout() != null) {
|
||||
appendLog("Stream channel layout: " + stream.getChannelLayout() + "\n");
|
||||
}
|
||||
|
||||
if (stream.getSampleAspectRatio() != null) {
|
||||
appendLog("Stream sample aspect ratio: " + stream.getSampleAspectRatio() + "\n");
|
||||
}
|
||||
if (stream.getDisplayAspectRatio() != null) {
|
||||
appendLog("Stream display ascpect ratio: " + stream.getDisplayAspectRatio() + "\n");
|
||||
;
|
||||
}
|
||||
if (stream.getAverageFrameRate() != null) {
|
||||
appendLog("Stream average frame rate: " + stream.getAverageFrameRate() + "\n");
|
||||
}
|
||||
if (stream.getRealFrameRate() != null) {
|
||||
appendLog("Stream real frame rate: " + stream.getRealFrameRate() + "\n");
|
||||
}
|
||||
if (stream.getTimeBase() != null) {
|
||||
appendLog("Stream time base: " + stream.getTimeBase() + "\n");
|
||||
}
|
||||
if (stream.getCodecTimeBase() != null) {
|
||||
appendLog("Stream codec time base: " + stream.getCodecTimeBase() + "\n");
|
||||
}
|
||||
|
||||
if (stream.getMetadataEntries() != null) {
|
||||
Set<Map.Entry<String, String>> entries = stream.getMetadataEntries();
|
||||
for (Map.Entry<String, String> entry : entries) {
|
||||
appendLog("Stream metadata: " + entry.getKey() + ":" + entry.getValue() + "\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
android.util.Log.d(MainActivity.TAG, String.format("FFmpeg process exited with rc %d", result));
|
||||
}
|
||||
|
||||
public void setActive() {
|
||||
Log.i(MainActivity.TAG, "Https Tab Activated");
|
||||
android.util.Log.i(MainActivity.TAG, "Https Tab Activated");
|
||||
enableLogCallback();
|
||||
Popup.show(requireContext(), Tooltip.HTTPS_TEST_TOOLTIP_TEXT);
|
||||
Popup.show(mainActivity, Tooltip.HTTPS_TEST_TOOLTIP_TEXT);
|
||||
}
|
||||
|
||||
public void appendLog(final String logMessage) {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2018-2019 Taner Sener
|
||||
* Copyright (c) 2018 Taner Sener
|
||||
*
|
||||
* This file is part of MobileFFmpeg.
|
||||
*
|
||||
@@ -20,30 +20,39 @@
|
||||
package com.arthenica.mobileffmpeg.test;
|
||||
|
||||
import android.Manifest;
|
||||
import android.app.ActionBar;
|
||||
import android.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
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;
|
||||
import android.support.v4.view.PagerTabStrip;
|
||||
import android.support.v4.view.ViewPager;
|
||||
import android.support.v7.app.AppCompatActivity;
|
||||
import android.util.Log;
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.core.app.ActivityCompat;
|
||||
import androidx.viewpager.widget.PagerTabStrip;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.arthenica.mobileffmpeg.Config;
|
||||
import com.arthenica.mobileffmpeg.util.AsyncSingleFFmpegExecuteTask;
|
||||
import com.arthenica.mobileffmpeg.util.ResourcesUtil;
|
||||
import com.arthenica.mobileffmpeg.util.SingleExecuteCallback;
|
||||
import com.arthenica.mobileffmpeg.FFmpeg;
|
||||
import com.arthenica.mobileffmpeg.util.AsynchronousTaskService;
|
||||
import com.arthenica.mobileffmpeg.util.RunCallback;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class MainActivity extends AppCompatActivity {
|
||||
|
||||
@@ -56,6 +65,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
Manifest.permission.CAMERA
|
||||
};
|
||||
|
||||
protected static final AsynchronousTaskService asynchronousTaskService = new AsynchronousTaskService();
|
||||
|
||||
protected static final Queue<Callable> actionQueue = new ConcurrentLinkedQueue<>();
|
||||
|
||||
protected static final Handler handler = new Handler();
|
||||
@@ -87,6 +98,12 @@ public class MainActivity extends AppCompatActivity {
|
||||
|
||||
setContentView(R.layout.activity_main);
|
||||
|
||||
android.support.v7.app.ActionBar supportActionBar = getSupportActionBar();
|
||||
if (supportActionBar != null) {
|
||||
supportActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
|
||||
supportActionBar.setCustomView(R.layout.action_bar);
|
||||
}
|
||||
|
||||
PagerTabStrip pagerTabStrip = findViewById(R.id.pagerTabStrip);
|
||||
if (pagerTabStrip != null) {
|
||||
pagerTabStrip.setDrawFullUnderline(false);
|
||||
@@ -95,7 +112,7 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
final ViewPager viewPager = findViewById(R.id.pager);
|
||||
viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager(), this));
|
||||
viewPager.setAdapter(new PagerAdapter(getSupportFragmentManager(), this, 6));
|
||||
|
||||
waitForUIAction();
|
||||
|
||||
@@ -125,9 +142,6 @@ public class MainActivity extends AppCompatActivity {
|
||||
} catch (final IOException e) {
|
||||
Log.e(TAG, "Font registration failed.", e);
|
||||
}
|
||||
|
||||
Log.d(TAG, "Listing supported camera ids.");
|
||||
listSupportedCameraIds();
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -138,14 +152,25 @@ public class MainActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Starts a new asynchronous FFmpeg operation with command provided.
|
||||
* <p>Starts a new asynchronous FFmpeg operation with arguments provided.
|
||||
*
|
||||
* @param singleExecuteCallback callback function to receive result of this execution
|
||||
* @param command FFmpeg command
|
||||
* @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 SingleExecuteCallback singleExecuteCallback, final String command) {
|
||||
final AsyncSingleFFmpegExecuteTask asyncCommandTask = new AsyncSingleFFmpegExecuteTask(command, singleExecuteCallback);
|
||||
asyncCommandTask.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||
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() {
|
||||
@@ -156,12 +181,84 @@ public class MainActivity extends AppCompatActivity {
|
||||
actionQueue.add(callable);
|
||||
}
|
||||
|
||||
public AlertDialog createProgressDialog(final String text) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
if (inflater != null) {
|
||||
View dialogView = inflater.inflate(R.layout.progress_dialog_layout, null);
|
||||
builder.setView(dialogView);
|
||||
|
||||
TextView textView = dialogView.findViewById(R.id.progressDialogText);
|
||||
if (textView != null) {
|
||||
textView.setText(text);
|
||||
}
|
||||
}
|
||||
builder.setCancelable(false);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
public AlertDialog createCancellableProgressDialog(final String text, final View.OnClickListener onClickListener) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(this);
|
||||
LayoutInflater inflater = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
if (inflater != null) {
|
||||
View dialogView = inflater.inflate(R.layout.cancellable_progress_dialog_layout, null);
|
||||
builder.setView(dialogView);
|
||||
|
||||
TextView textView = dialogView.findViewById(R.id.progressDialogText);
|
||||
if (textView != null) {
|
||||
textView.setText(text);
|
||||
}
|
||||
Button cancelButton = dialogView.findViewById(R.id.cancelButton);
|
||||
if (cancelButton != null) {
|
||||
cancelButton.setOnClickListener(onClickListener);
|
||||
}
|
||||
}
|
||||
builder.setCancelable(false);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
protected void resourceToFile(final int resourceId, final File file) throws IOException {
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(getResources(), resourceId);
|
||||
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
FileOutputStream outputStream = new FileOutputStream(file);
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
protected void rawResourceToFile(final int resourceId, final File file) throws IOException {
|
||||
final InputStream inputStream = getResources().openRawResource(resourceId);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
final FileOutputStream outputStream = new FileOutputStream(file);
|
||||
|
||||
try {
|
||||
final byte[] buffer = new byte[1024];
|
||||
int readSize;
|
||||
|
||||
while ((readSize = inputStream.read(buffer)) > 0) {
|
||||
outputStream.write(buffer, 0, readSize);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
Log.e(TAG, "Saving raw resource failed.", e);
|
||||
} finally {
|
||||
inputStream.close();
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
protected void registerAppFont() throws IOException {
|
||||
final File cacheDirectory = getCacheDir();
|
||||
|
||||
// SAVE FONTS
|
||||
ResourcesUtil.rawResourceToFile(getResources(), R.raw.doppioone_regular, new File(cacheDirectory, "doppioone_regular.ttf"));
|
||||
ResourcesUtil.rawResourceToFile(getResources(), R.raw.truenorg, new File(cacheDirectory, "truenorg.otf"));
|
||||
rawResourceToFile(R.raw.doppioone_regular, new File(cacheDirectory, "doppioone_regular.ttf"));
|
||||
rawResourceToFile(R.raw.truenorg, new File(cacheDirectory, "truenorg.otf"));
|
||||
|
||||
final HashMap<String, String> fontNameMapping = new HashMap<>();
|
||||
fontNameMapping.put("MyFontName", "Doppio One");
|
||||
@@ -169,15 +266,4 @@ public class MainActivity extends AppCompatActivity {
|
||||
// Config.setFontDirectory(this, cacheDirectory.getAbsolutePath(), null);
|
||||
}
|
||||
|
||||
protected void listSupportedCameraIds() {
|
||||
final List<String> supportedCameraIds = Config.getSupportedCameraIds(this);
|
||||
if (supportedCameraIds.size() == 0) {
|
||||
android.util.Log.d(MainActivity.TAG, "No supported cameras found.");
|
||||
} else {
|
||||
for (String supportedCameraId : supportedCameraIds) {
|
||||
android.util.Log.d(MainActivity.TAG, "Supported camera detected: " + supportedCameraId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,45 +19,41 @@
|
||||
|
||||
package com.arthenica.mobileffmpeg.test;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import androidx.fragment.app.Fragment;
|
||||
import androidx.fragment.app.FragmentManager;
|
||||
import androidx.fragment.app.FragmentPagerAdapter;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.app.FragmentPagerAdapter;
|
||||
|
||||
public class PagerAdapter extends FragmentPagerAdapter {
|
||||
private static final int NUMBER_OF_TABS = 7;
|
||||
private final MainActivity mainActivity;
|
||||
private int numberOfTabs;
|
||||
|
||||
private final Context context;
|
||||
PagerAdapter(final FragmentManager fragmentManager, final MainActivity mainActivity, final int numberOfTabs) {
|
||||
super(fragmentManager);
|
||||
|
||||
PagerAdapter(FragmentManager fragmentManager, Context context) {
|
||||
super(fragmentManager, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT);
|
||||
this.context = context;
|
||||
this.mainActivity = mainActivity;
|
||||
this.numberOfTabs = numberOfTabs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Fragment getItem(final int position) {
|
||||
switch (position) {
|
||||
case 0: {
|
||||
return CommandTabFragment.newInstance();
|
||||
return CommandTabFragment.newInstance(mainActivity);
|
||||
}
|
||||
case 1: {
|
||||
return VideoTabFragment.newInstance();
|
||||
return VideoTabFragment.newInstance(mainActivity);
|
||||
}
|
||||
case 2: {
|
||||
return HttpsTabFragment.newInstance();
|
||||
return HttpsTabFragment.newInstance(mainActivity);
|
||||
}
|
||||
case 3: {
|
||||
return AudioTabFragment.newInstance();
|
||||
return AudioTabFragment.newInstance(mainActivity);
|
||||
}
|
||||
case 4: {
|
||||
return SubtitleTabFragment.newInstance();
|
||||
return SubtitleTabFragment.newInstance(mainActivity);
|
||||
}
|
||||
case 5: {
|
||||
return VidStabTabFragment.newInstance();
|
||||
}
|
||||
case 6: {
|
||||
return PipeTabFragment.newInstance();
|
||||
return VidStabTabFragment.newInstance(mainActivity);
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
@@ -67,32 +63,29 @@ public class PagerAdapter extends FragmentPagerAdapter {
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return NUMBER_OF_TABS;
|
||||
return numberOfTabs;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CharSequence getPageTitle(final int position) {
|
||||
switch (position) {
|
||||
case 0: {
|
||||
return context.getString(R.string.command_tab);
|
||||
return mainActivity.getString(R.string.command_tab);
|
||||
}
|
||||
case 1: {
|
||||
return context.getString(R.string.video_tab);
|
||||
return mainActivity.getString(R.string.video_tab);
|
||||
}
|
||||
case 2: {
|
||||
return context.getString(R.string.https_tab);
|
||||
return mainActivity.getString(R.string.https_tab);
|
||||
}
|
||||
case 3: {
|
||||
return context.getString(R.string.audio_tab);
|
||||
return mainActivity.getString(R.string.audio_tab);
|
||||
}
|
||||
case 4: {
|
||||
return context.getString(R.string.subtitle_tab);
|
||||
return mainActivity.getString(R.string.subtitle_tab);
|
||||
}
|
||||
case 5: {
|
||||
return context.getString(R.string.vidstab_tab);
|
||||
}
|
||||
case 6: {
|
||||
return context.getString(R.string.pipe_tab);
|
||||
return mainActivity.getString(R.string.vidstab_tab);
|
||||
}
|
||||
default: {
|
||||
return null;
|
||||
|
||||
@@ -1,271 +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.util.Log;
|
||||
import android.view.View;
|
||||
import android.widget.MediaController;
|
||||
import android.widget.TextView;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
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.DialogUtil;
|
||||
import com.arthenica.mobileffmpeg.util.ResourcesUtil;
|
||||
import com.arthenica.mobileffmpeg.util.SingleExecuteCallback;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import static com.arthenica.mobileffmpeg.Config.RETURN_CODE_SUCCESS;
|
||||
import static com.arthenica.mobileffmpeg.test.MainActivity.TAG;
|
||||
|
||||
public class PipeTabFragment extends Fragment {
|
||||
|
||||
private VideoView videoView;
|
||||
private AlertDialog progressDialog;
|
||||
private Statistics statistics;
|
||||
|
||||
public PipeTabFragment() {
|
||||
super(R.layout.fragment_pipe_tab);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
View createButton = view.findViewById(R.id.createButton);
|
||||
if (createButton != null) {
|
||||
createButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
createVideo();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
videoView = view.findViewById(R.id.videoPlayerFrame);
|
||||
|
||||
progressDialog = DialogUtil.createProgressDialog(requireContext(), "Creating video");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setActive();
|
||||
}
|
||||
|
||||
public static PipeTabFragment newInstance() {
|
||||
return new PipeTabFragment();
|
||||
}
|
||||
|
||||
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(requireContext().getCacheDir(), "colosseum.jpg");
|
||||
final File image2File = new File(requireContext().getCacheDir(), "pyramid.jpg");
|
||||
final File image3File = new File(requireContext().getCacheDir(), "tajmahal.jpg");
|
||||
final File videoFile = getVideoFile();
|
||||
|
||||
String pipe1 = Config.registerNewFFmpegPipe(requireContext());
|
||||
String pipe2 = Config.registerNewFFmpegPipe(requireContext());
|
||||
String pipe3 = Config.registerNewFFmpegPipe(requireContext());
|
||||
|
||||
try {
|
||||
|
||||
// IF VIDEO IS PLAYING STOP PLAYBACK
|
||||
videoView.stopPlayback();
|
||||
|
||||
if (videoFile.exists()) {
|
||||
videoFile.delete();
|
||||
}
|
||||
|
||||
Log.d(TAG, "Testing PIPE with 'mpeg4' codec");
|
||||
|
||||
showProgressDialog();
|
||||
|
||||
ResourcesUtil.resourceToFile(getResources(), R.drawable.colosseum, image1File);
|
||||
ResourcesUtil.resourceToFile(getResources(), R.drawable.pyramid, image2File);
|
||||
ResourcesUtil.resourceToFile(getResources(), 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 SingleExecuteCallback() {
|
||||
|
||||
@Override
|
||||
public void apply(final int returnCode, final String commandOutput) {
|
||||
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(requireContext(), "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(requireContext(), "Create video failed");
|
||||
}
|
||||
}
|
||||
|
||||
protected void playVideo() {
|
||||
MediaController mediaController = new MediaController(requireContext());
|
||||
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(requireContext().getFilesDir(), "video.mp4");
|
||||
}
|
||||
|
||||
public void setActive() {
|
||||
Log.i(MainActivity.TAG, "Pipe Tab Activated");
|
||||
enableLogCallback();
|
||||
enableStatisticsCallback();
|
||||
Popup.show(requireContext(), 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 = DialogUtil.createProgressDialog(requireContext(), "Creating video");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,33 +23,32 @@ import android.app.AlertDialog;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
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 androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.arthenica.mobileffmpeg.Config;
|
||||
import com.arthenica.mobileffmpeg.FFmpeg;
|
||||
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.DialogUtil;
|
||||
import com.arthenica.mobileffmpeg.util.ResourcesUtil;
|
||||
import com.arthenica.mobileffmpeg.util.SingleExecuteCallback;
|
||||
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.Config.RETURN_CODE_CANCEL;
|
||||
import static com.arthenica.mobileffmpeg.Config.RETURN_CODE_SUCCESS;
|
||||
import static com.arthenica.mobileffmpeg.FFmpeg.RETURN_CODE_CANCEL;
|
||||
import static com.arthenica.mobileffmpeg.FFmpeg.RETURN_CODE_SUCCESS;
|
||||
import static com.arthenica.mobileffmpeg.test.MainActivity.TAG;
|
||||
|
||||
public class SubtitleTabFragment extends Fragment {
|
||||
@@ -60,42 +59,54 @@ public class SubtitleTabFragment extends Fragment {
|
||||
BURNING
|
||||
}
|
||||
|
||||
private MainActivity mainActivity;
|
||||
private VideoView videoView;
|
||||
private AlertDialog createProgressDialog;
|
||||
private AlertDialog burnProgressDialog;
|
||||
private Statistics statistics;
|
||||
private State state;
|
||||
|
||||
public SubtitleTabFragment() {
|
||||
super(R.layout.fragment_subtitle_tab);
|
||||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_subtitle_tab, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
View burnSubtitlesButton = view.findViewById(R.id.burnSubtitlesButton);
|
||||
burnSubtitlesButton.setOnClickListener(new View.OnClickListener() {
|
||||
if (getView() != null) {
|
||||
View burnSubtitlesButton = getView().findViewById(R.id.burnSubtitlesButton);
|
||||
burnSubtitlesButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
burnSubtitles();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
burnSubtitles();
|
||||
}
|
||||
});
|
||||
|
||||
videoView = view.findViewById(R.id.videoPlayerFrame);
|
||||
videoView = getView().findViewById(R.id.videoPlayerFrame);
|
||||
}
|
||||
|
||||
state = State.IDLE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setActive();
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
if (isVisibleToUser) {
|
||||
setActive();
|
||||
}
|
||||
}
|
||||
|
||||
public static SubtitleTabFragment newInstance() {
|
||||
return new SubtitleTabFragment();
|
||||
public void setMainActivity(MainActivity mainActivity) {
|
||||
this.mainActivity = mainActivity;
|
||||
}
|
||||
|
||||
public static SubtitleTabFragment newInstance(final MainActivity mainActivity) {
|
||||
final SubtitleTabFragment fragment = new SubtitleTabFragment();
|
||||
fragment.setMainActivity(mainActivity);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public void enableLogCallback() {
|
||||
@@ -127,9 +138,9 @@ public class SubtitleTabFragment extends Fragment {
|
||||
}
|
||||
|
||||
public void burnSubtitles() {
|
||||
final File image1File = new File(requireContext().getCacheDir(), "colosseum.jpg");
|
||||
final File image2File = new File(requireContext().getCacheDir(), "pyramid.jpg");
|
||||
final File image3File = new File(requireContext().getCacheDir(), "tajmahal.jpg");
|
||||
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();
|
||||
final File videoWithSubtitlesFile = getVideoWithSubtitlesFile();
|
||||
|
||||
@@ -150,10 +161,10 @@ public class SubtitleTabFragment extends Fragment {
|
||||
|
||||
showCreateProgressDialog();
|
||||
|
||||
ResourcesUtil.resourceToFile(getResources(), R.drawable.colosseum, image1File);
|
||||
ResourcesUtil.resourceToFile(getResources(), R.drawable.pyramid, image2File);
|
||||
ResourcesUtil.resourceToFile(getResources(), R.drawable.tajmahal, image3File);
|
||||
ResourcesUtil.rawResourceToFile(getResources(), R.raw.subtitle, getSubtitleFile());
|
||||
mainActivity.resourceToFile(R.drawable.colosseum, image1File);
|
||||
mainActivity.resourceToFile(R.drawable.pyramid, image2File);
|
||||
mainActivity.resourceToFile(R.drawable.tajmahal, image3File);
|
||||
mainActivity.rawResourceToFile(R.raw.subtitle, getSubtitleFile());
|
||||
|
||||
final String ffmpegCommand = Video.generateEncodeVideoScript(image1File.getAbsolutePath(), image2File.getAbsolutePath(), image3File.getAbsolutePath(), videoFile.getAbsolutePath(), "mpeg4", "");
|
||||
|
||||
@@ -161,12 +172,14 @@ public class SubtitleTabFragment extends Fragment {
|
||||
|
||||
state = State.CREATING;
|
||||
|
||||
MainActivity.executeAsync(new SingleExecuteCallback() {
|
||||
MainActivity.executeAsync(new RunCallback() {
|
||||
|
||||
@Override
|
||||
public void apply(final int returnCode, final String commandOutput) {
|
||||
public void apply(final int returnCode) {
|
||||
Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode));
|
||||
|
||||
state = State.IDLE;
|
||||
|
||||
hideCreateProgressDialog();
|
||||
|
||||
MainActivity.addUIAction(new Callable() {
|
||||
@@ -185,12 +198,14 @@ public class SubtitleTabFragment extends Fragment {
|
||||
|
||||
state = State.BURNING;
|
||||
|
||||
MainActivity.executeAsync(new SingleExecuteCallback() {
|
||||
MainActivity.executeAsync(new RunCallback() {
|
||||
|
||||
@Override
|
||||
public void apply(final int returnCode, final String commandOutput) {
|
||||
public void apply(final int returnCode) {
|
||||
Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode));
|
||||
|
||||
state = State.IDLE;
|
||||
|
||||
hideBurnProgressDialog();
|
||||
|
||||
MainActivity.addUIAction(new Callable() {
|
||||
@@ -201,11 +216,11 @@ public class SubtitleTabFragment extends Fragment {
|
||||
Log.d(TAG, "Burn subtitles completed successfully; playing video.");
|
||||
playVideo();
|
||||
} else if (returnCode == RETURN_CODE_CANCEL) {
|
||||
Popup.show(requireContext(), "Burn subtitles operation cancelled.");
|
||||
Log.e(TAG, "Burn subtitles operation cancelled");
|
||||
Popup.show(mainActivity, "Burn subtitles operation cancelled.");
|
||||
Log.d(TAG, "Burn subtitles operation cancelled");
|
||||
} else {
|
||||
Popup.show(requireContext(), "Burn subtitles failed. Please check log for the details.");
|
||||
Log.e(TAG, String.format("Burn subtitles failed with rc=%d", returnCode));
|
||||
Popup.show(mainActivity, "Burn subtitles failed. Please check log for the details.");
|
||||
Log.d(TAG, String.format("Burn subtitles failed with rc=%d", returnCode));
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -215,11 +230,11 @@ public class SubtitleTabFragment extends Fragment {
|
||||
}, burnSubtitlesCommand);
|
||||
|
||||
} else if (returnCode == RETURN_CODE_CANCEL) {
|
||||
Popup.show(requireContext(), "Create operation cancelled.");
|
||||
Log.e(TAG, "Create operation cancelled");
|
||||
Popup.show(mainActivity, "Create operation cancelled.");
|
||||
Log.d(TAG, "Create operation cancelled");
|
||||
} else {
|
||||
Popup.show(requireContext(), "Create video failed. Please check log for the details.");
|
||||
Log.e(TAG, String.format("Create failed with rc=%d", returnCode));
|
||||
Popup.show(mainActivity, "Create video failed. Please check log for the details.");
|
||||
Log.d(TAG, String.format("Create failed with rc=%d", returnCode));
|
||||
}
|
||||
|
||||
return null;
|
||||
@@ -230,12 +245,12 @@ public class SubtitleTabFragment extends Fragment {
|
||||
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Burn subtitles failed", e);
|
||||
Popup.show(requireContext(), "Burn subtitles failed");
|
||||
Popup.show(mainActivity, "Burn subtitles failed");
|
||||
}
|
||||
}
|
||||
|
||||
protected void playVideo() {
|
||||
MediaController mediaController = new MediaController(requireContext());
|
||||
MediaController mediaController = new MediaController(mainActivity);
|
||||
mediaController.setAnchorView(videoView);
|
||||
videoView.setVideoURI(Uri.parse("file://" + getVideoWithSubtitlesFile().getAbsolutePath()));
|
||||
videoView.setMediaController(mediaController);
|
||||
@@ -259,22 +274,22 @@ public class SubtitleTabFragment extends Fragment {
|
||||
}
|
||||
|
||||
public File getSubtitleFile() {
|
||||
return new File(requireContext().getCacheDir(), "subtitle.srt");
|
||||
return new File(mainActivity.getCacheDir(), "subtitle.srt");
|
||||
}
|
||||
|
||||
public File getVideoFile() {
|
||||
return new File(requireContext().getFilesDir(), "video.mp4");
|
||||
return new File(mainActivity.getFilesDir(), "video.mp4");
|
||||
}
|
||||
|
||||
public File getVideoWithSubtitlesFile() {
|
||||
return new File(requireContext().getFilesDir(), "video-with-subtitles.mp4");
|
||||
return new File(mainActivity.getFilesDir(), "video-with-subtitles.mp4");
|
||||
}
|
||||
|
||||
public void setActive() {
|
||||
Log.i(MainActivity.TAG, "Subtitle Tab Activated");
|
||||
android.util.Log.i(MainActivity.TAG, "Subtitle Tab Activated");
|
||||
enableLogCallback();
|
||||
enableStatisticsCallback();
|
||||
Popup.show(requireContext(), Tooltip.SUBTITLE_TEST_TOOLTIP_TEXT);
|
||||
Popup.show(mainActivity, Tooltip.SUBTITLE_TEST_TOOLTIP_TEXT);
|
||||
}
|
||||
|
||||
protected void showCreateProgressDialog() {
|
||||
@@ -283,7 +298,7 @@ public class SubtitleTabFragment extends Fragment {
|
||||
statistics = null;
|
||||
Config.resetStatistics();
|
||||
|
||||
createProgressDialog = DialogUtil.createCancellableProgressDialog(requireContext(), "Creating video", new View.OnClickListener() {
|
||||
createProgressDialog = mainActivity.createCancellableProgressDialog("Creating video", new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
@@ -327,7 +342,7 @@ public class SubtitleTabFragment extends Fragment {
|
||||
statistics = null;
|
||||
Config.resetStatistics();
|
||||
|
||||
burnProgressDialog = DialogUtil.createCancellableProgressDialog(requireContext(), "Burning subtitles", new View.OnClickListener() {
|
||||
burnProgressDialog = mainActivity.createCancellableProgressDialog("Burning subtitles", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
FFmpeg.cancel();
|
||||
|
||||
@@ -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";
|
||||
|
||||
}
|
||||
|
||||
@@ -23,68 +23,78 @@ import android.app.AlertDialog;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.MediaController;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.arthenica.mobileffmpeg.Config;
|
||||
import com.arthenica.mobileffmpeg.LogCallback;
|
||||
import com.arthenica.mobileffmpeg.LogMessage;
|
||||
import com.arthenica.mobileffmpeg.util.DialogUtil;
|
||||
import com.arthenica.mobileffmpeg.util.ResourcesUtil;
|
||||
import com.arthenica.mobileffmpeg.util.SingleExecuteCallback;
|
||||
import com.arthenica.mobileffmpeg.util.RunCallback;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import static com.arthenica.mobileffmpeg.Config.RETURN_CODE_SUCCESS;
|
||||
import static com.arthenica.mobileffmpeg.FFmpeg.RETURN_CODE_SUCCESS;
|
||||
import static com.arthenica.mobileffmpeg.test.MainActivity.TAG;
|
||||
|
||||
public class VidStabTabFragment extends Fragment {
|
||||
|
||||
private MainActivity mainActivity;
|
||||
private VideoView videoView;
|
||||
private VideoView stabilizedVideoView;
|
||||
private AlertDialog createProgressDialog;
|
||||
private AlertDialog stabilizeProgressDialog;
|
||||
|
||||
public VidStabTabFragment() {
|
||||
super(R.layout.fragment_vidstab_tab);
|
||||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater, final ViewGroup container, final Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_vidstab_tab, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
View stabilizeVideoButton = view.findViewById(R.id.stabilizeVideoButton);
|
||||
stabilizeVideoButton.setOnClickListener(new View.OnClickListener() {
|
||||
if (getView() != null) {
|
||||
View stabilizeVideoButton = getView().findViewById(R.id.stabilizeVideoButton);
|
||||
stabilizeVideoButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
stabilizeVideo();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
stabilizeVideo();
|
||||
}
|
||||
});
|
||||
|
||||
videoView = view.findViewById(R.id.videoPlayerFrame);
|
||||
stabilizedVideoView = view.findViewById(R.id.stabilizedVideoPlayerFrame);
|
||||
videoView = getView().findViewById(R.id.videoPlayerFrame);
|
||||
stabilizedVideoView = getView().findViewById(R.id.stabilizedVideoPlayerFrame);
|
||||
}
|
||||
|
||||
createProgressDialog = DialogUtil.createProgressDialog(requireContext(), "Creating video");
|
||||
stabilizeProgressDialog = DialogUtil.createProgressDialog(requireContext(), "Stabilizing video");
|
||||
createProgressDialog = mainActivity.createProgressDialog("Creating video");
|
||||
stabilizeProgressDialog = mainActivity.createProgressDialog("Stabilizing video");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setActive();
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
if (isVisibleToUser) {
|
||||
setActive();
|
||||
}
|
||||
}
|
||||
|
||||
public static VidStabTabFragment newInstance() {
|
||||
return new VidStabTabFragment();
|
||||
public void setMainActivity(MainActivity mainActivity) {
|
||||
this.mainActivity = mainActivity;
|
||||
}
|
||||
|
||||
public static VidStabTabFragment newInstance(final MainActivity mainActivity) {
|
||||
final VidStabTabFragment fragment = new VidStabTabFragment();
|
||||
fragment.setMainActivity(mainActivity);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public void enableLogCallback() {
|
||||
@@ -98,9 +108,9 @@ public class VidStabTabFragment extends Fragment {
|
||||
}
|
||||
|
||||
public void stabilizeVideo() {
|
||||
final File image1File = new File(requireContext().getCacheDir(), "colosseum.jpg");
|
||||
final File image2File = new File(requireContext().getCacheDir(), "pyramid.jpg");
|
||||
final File image3File = new File(requireContext().getCacheDir(), "tajmahal.jpg");
|
||||
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 shakeResultsFile = getShakeResultsFile();
|
||||
final File videoFile = getVideoFile();
|
||||
final File stabilizedVideoFile = getStabilizedVideoFile();
|
||||
@@ -125,18 +135,18 @@ public class VidStabTabFragment extends Fragment {
|
||||
|
||||
showCreateProgressDialog();
|
||||
|
||||
ResourcesUtil.resourceToFile(getResources(), R.drawable.colosseum, image1File);
|
||||
ResourcesUtil.resourceToFile(getResources(), R.drawable.pyramid, image2File);
|
||||
ResourcesUtil.resourceToFile(getResources(), R.drawable.tajmahal, image3File);
|
||||
mainActivity.resourceToFile(R.drawable.colosseum, image1File);
|
||||
mainActivity.resourceToFile(R.drawable.pyramid, image2File);
|
||||
mainActivity.resourceToFile(R.drawable.tajmahal, image3File);
|
||||
|
||||
final String ffmpegCommand = Video.generateShakingVideoScript(image1File.getAbsolutePath(), image2File.getAbsolutePath(), image3File.getAbsolutePath(), videoFile.getAbsolutePath());
|
||||
|
||||
android.util.Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", ffmpegCommand));
|
||||
|
||||
MainActivity.executeAsync(new SingleExecuteCallback() {
|
||||
MainActivity.executeAsync(new RunCallback() {
|
||||
|
||||
@Override
|
||||
public void apply(final int returnCode, final String commandOutput) {
|
||||
public void apply(final int returnCode) {
|
||||
android.util.Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode));
|
||||
|
||||
hideCreateProgressDialog();
|
||||
@@ -155,10 +165,10 @@ public class VidStabTabFragment extends Fragment {
|
||||
|
||||
android.util.Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", analyzeVideoCommand));
|
||||
|
||||
MainActivity.executeAsync(new SingleExecuteCallback() {
|
||||
MainActivity.executeAsync(new RunCallback() {
|
||||
|
||||
@Override
|
||||
public void apply(final int returnCode, final String commandOutput) {
|
||||
public void apply(final int returnCode) {
|
||||
android.util.Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode));
|
||||
|
||||
if (returnCode == RETURN_CODE_SUCCESS) {
|
||||
@@ -166,10 +176,10 @@ public class VidStabTabFragment extends Fragment {
|
||||
|
||||
android.util.Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", stabilizeVideoCommand));
|
||||
|
||||
MainActivity.executeAsync(new SingleExecuteCallback() {
|
||||
MainActivity.executeAsync(new RunCallback() {
|
||||
|
||||
@Override
|
||||
public void apply(final int returnCode, final String commandOutput) {
|
||||
public void apply(final int returnCode) {
|
||||
android.util.Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode));
|
||||
|
||||
hideStabilizeProgressDialog();
|
||||
@@ -183,7 +193,7 @@ public class VidStabTabFragment extends Fragment {
|
||||
playVideo();
|
||||
playStabilizedVideo();
|
||||
} else {
|
||||
Popup.show(requireContext(), "Stabilize video failed. Please check log for the details.");
|
||||
Popup.show(mainActivity, "Stabilize video failed. Please check log for the details.");
|
||||
android.util.Log.d(TAG, String.format("Stabilize video failed with rc=%d", returnCode));
|
||||
}
|
||||
|
||||
@@ -195,14 +205,14 @@ public class VidStabTabFragment extends Fragment {
|
||||
|
||||
} else {
|
||||
hideStabilizeProgressDialog();
|
||||
Popup.show(requireContext(), "Stabilize video failed. Please check log for the details.");
|
||||
Popup.show(mainActivity, "Stabilize video failed. Please check log for the details.");
|
||||
android.util.Log.d(TAG, String.format("Stabilize video failed with rc=%d", returnCode));
|
||||
}
|
||||
}
|
||||
}, analyzeVideoCommand);
|
||||
|
||||
} else {
|
||||
Popup.show(requireContext(), "Create video failed. Please check log for the details.");
|
||||
Popup.show(mainActivity, "Create video failed. Please check log for the details.");
|
||||
android.util.Log.d(TAG, String.format("Create failed with rc=%d", returnCode));
|
||||
}
|
||||
|
||||
@@ -214,12 +224,12 @@ public class VidStabTabFragment extends Fragment {
|
||||
|
||||
} catch (IOException e) {
|
||||
android.util.Log.e(TAG, "Stabilize video failed", e);
|
||||
Popup.show(requireContext(), "Stabilize video failed");
|
||||
Popup.show(mainActivity, "Stabilize video failed");
|
||||
}
|
||||
}
|
||||
|
||||
protected void playVideo() {
|
||||
MediaController mediaController = new MediaController(requireContext());
|
||||
MediaController mediaController = new MediaController(mainActivity);
|
||||
mediaController.setAnchorView(videoView);
|
||||
videoView.setVideoURI(Uri.parse("file://" + getVideoFile().getAbsolutePath()));
|
||||
videoView.setMediaController(mediaController);
|
||||
@@ -243,7 +253,7 @@ public class VidStabTabFragment extends Fragment {
|
||||
}
|
||||
|
||||
protected void playStabilizedVideo() {
|
||||
MediaController mediaController = new MediaController(requireContext());
|
||||
MediaController mediaController = new MediaController(mainActivity);
|
||||
mediaController.setAnchorView(stabilizedVideoView);
|
||||
stabilizedVideoView.setVideoURI(Uri.parse("file://" + getStabilizedVideoFile().getAbsolutePath()));
|
||||
stabilizedVideoView.setMediaController(mediaController);
|
||||
@@ -267,21 +277,21 @@ public class VidStabTabFragment extends Fragment {
|
||||
}
|
||||
|
||||
public File getShakeResultsFile() {
|
||||
return new File(requireContext().getCacheDir(), "transforms.trf");
|
||||
return new File(mainActivity.getCacheDir(), "transforms.trf");
|
||||
}
|
||||
|
||||
public File getVideoFile() {
|
||||
return new File(requireContext().getFilesDir(), "video.mp4");
|
||||
return new File(mainActivity.getFilesDir(), "video.mp4");
|
||||
}
|
||||
|
||||
public File getStabilizedVideoFile() {
|
||||
return new File(requireContext().getFilesDir(), "video-stabilized.mp4");
|
||||
return new File(mainActivity.getFilesDir(), "video-stabilized.mp4");
|
||||
}
|
||||
|
||||
public void setActive() {
|
||||
Log.i(MainActivity.TAG, "VidStab Tab Activated");
|
||||
android.util.Log.i(MainActivity.TAG, "VidStab Tab Activated");
|
||||
enableLogCallback();
|
||||
Popup.show(requireContext(), Tooltip.VIDSTAB_TEST_TOOLTIP_TEXT);
|
||||
Popup.show(mainActivity, Tooltip.VIDSTAB_TEST_TOOLTIP_TEXT);
|
||||
}
|
||||
|
||||
protected void showCreateProgressDialog() {
|
||||
|
||||
@@ -19,42 +19,19 @@
|
||||
|
||||
package com.arthenica.mobileffmpeg.test;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* <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 + "\" " +
|
||||
"-loop 1 -i '" + image2Path + "' " +
|
||||
"-loop 1 -i \"" + image3Path + "\" " +
|
||||
"-filter_complex \"" +
|
||||
"-hide_banner -y -loop 1 -i " + image1Path + " " +
|
||||
"-loop 1 -i " + image2Path + " " +
|
||||
"-loop 1 -i " + image3Path + " " +
|
||||
"-filter_complex " +
|
||||
"[0:v]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]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]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];" +
|
||||
@@ -66,17 +43,17 @@ public class Video {
|
||||
"[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 " + customOptions + "-c:v " + videoCodec.toLowerCase(Locale.ENGLISH) + " -r 30 " + videoFilePath;
|
||||
"[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 " + 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 + "\" " +
|
||||
"-loop 1 -i '" + image2Path + "' " +
|
||||
"-hide_banner -y -loop 1 -i " + image1Path + " " +
|
||||
"-loop 1 -i " + image2Path + " " +
|
||||
"-loop 1 -i " + image3Path + " " +
|
||||
"-f lavfi -i color=black:s=640x427 " +
|
||||
"-filter_complex \"" +
|
||||
"-filter_complex " +
|
||||
"[0:v]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[stream1out];" +
|
||||
"[1:v]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[stream2out];" +
|
||||
"[2:v]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[stream3out];" +
|
||||
@@ -86,7 +63,7 @@ public class Video {
|
||||
"[3:v][stream1overlaid]overlay=x=\'2*mod(n,4)\':y=\'2*mod(n,2)\',trim=duration=3[stream1shaking];" +
|
||||
"[3:v][stream2overlaid]overlay=x=\'2*mod(n,4)\':y=\'2*mod(n,2)\',trim=duration=3[stream2shaking];" +
|
||||
"[3:v][stream3overlaid]overlay=x=\'2*mod(n,4)\':y=\'2*mod(n,2)\',trim=duration=3[stream3shaking];" +
|
||||
"[stream1shaking][stream2shaking][stream3shaking]concat=n=3:v=1:a=0,scale=w=640:h=424,format=yuv420p[video]\"" +
|
||||
"[stream1shaking][stream2shaking][stream3shaking]concat=n=3:v=1:a=0,scale=w=640:h=424,format=yuv420p[video]" +
|
||||
" -map [video] -vsync 2 -async 1 -c:v mpeg4 -r 30 " + videoFilePath;
|
||||
}
|
||||
|
||||
|
||||
@@ -23,9 +23,13 @@ import android.app.AlertDialog;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
import android.util.AndroidRuntimeException;
|
||||
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.AdapterView;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.MediaController;
|
||||
@@ -33,77 +37,83 @@ import android.widget.Spinner;
|
||||
import android.widget.TextView;
|
||||
import android.widget.VideoView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.fragment.app.Fragment;
|
||||
|
||||
import com.arthenica.mobileffmpeg.Config;
|
||||
import com.arthenica.mobileffmpeg.FFmpeg;
|
||||
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.DialogUtil;
|
||||
import com.arthenica.mobileffmpeg.util.ResourcesUtil;
|
||||
import com.arthenica.mobileffmpeg.util.SingleExecuteCallback;
|
||||
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.Config.RETURN_CODE_SUCCESS;
|
||||
import static com.arthenica.mobileffmpeg.FFmpeg.RETURN_CODE_SUCCESS;
|
||||
import static com.arthenica.mobileffmpeg.test.MainActivity.TAG;
|
||||
|
||||
public class VideoTabFragment extends Fragment implements AdapterView.OnItemSelectedListener {
|
||||
|
||||
private MainActivity mainActivity;
|
||||
private VideoView videoView;
|
||||
private AlertDialog progressDialog;
|
||||
private String selectedCodec;
|
||||
private Statistics statistics;
|
||||
|
||||
public VideoTabFragment() {
|
||||
super(R.layout.fragment_video_tab);
|
||||
@Override
|
||||
public View onCreateView(@NonNull final LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
|
||||
return inflater.inflate(R.layout.fragment_video_tab, container, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
|
||||
super.onViewCreated(view, savedInstanceState);
|
||||
|
||||
Spinner videoCodecSpinner = view.findViewById(R.id.videoCodecSpinner);
|
||||
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(requireContext(),
|
||||
R.array.video_codec, R.layout.spinner_item);
|
||||
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
||||
videoCodecSpinner.setAdapter(adapter);
|
||||
videoCodecSpinner.setOnItemSelectedListener(this);
|
||||
if (getView() != null) {
|
||||
Spinner videoCodecSpinner = getView().findViewById(R.id.videoCodecSpinner);
|
||||
ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(mainActivity,
|
||||
R.array.video_codec, R.layout.spinner_item);
|
||||
adapter.setDropDownViewResource(R.layout.spinner_dropdown_item);
|
||||
videoCodecSpinner.setAdapter(adapter);
|
||||
videoCodecSpinner.setOnItemSelectedListener(this);
|
||||
|
||||
View encodeButton = view.findViewById(R.id.encodeButton);
|
||||
if (encodeButton != null) {
|
||||
encodeButton.setOnClickListener(new View.OnClickListener() {
|
||||
View encodeButton = getView().findViewById(R.id.encodeButton);
|
||||
if (encodeButton != null) {
|
||||
encodeButton.setOnClickListener(new View.OnClickListener() {
|
||||
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
encodeVideo();
|
||||
// encodeWebp();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
encodeVideo();
|
||||
// encodeWebp();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
videoView = getView().findViewById(R.id.videoPlayerFrame);
|
||||
}
|
||||
|
||||
videoView = view.findViewById(R.id.videoPlayerFrame);
|
||||
|
||||
progressDialog = DialogUtil.createProgressDialog(requireContext(), "Encoding video");
|
||||
progressDialog = mainActivity.createProgressDialog("Encoding video");
|
||||
|
||||
selectedCodec = getResources().getStringArray(R.array.video_codec)[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
setActive();
|
||||
public void setUserVisibleHint(boolean isVisibleToUser) {
|
||||
super.setUserVisibleHint(isVisibleToUser);
|
||||
if (isVisibleToUser) {
|
||||
setActive();
|
||||
}
|
||||
}
|
||||
|
||||
public static VideoTabFragment newInstance() {
|
||||
return new VideoTabFragment();
|
||||
public void setMainActivity(MainActivity mainActivity) {
|
||||
this.mainActivity = mainActivity;
|
||||
}
|
||||
|
||||
public static VideoTabFragment newInstance(final MainActivity mainActivity) {
|
||||
final VideoTabFragment fragment = new VideoTabFragment();
|
||||
fragment.setMainActivity(mainActivity);
|
||||
return fragment;
|
||||
}
|
||||
|
||||
public void enableLogCallback() {
|
||||
@@ -130,8 +140,6 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
throw new AndroidRuntimeException("I am test exception thrown by test application");
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -147,9 +155,9 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
}
|
||||
|
||||
public void encodeVideo() {
|
||||
final File image1File = new File(requireContext().getCacheDir(), "colosseum.jpg");
|
||||
final File image2File = new File(requireContext().getCacheDir(), "pyramid.jpg");
|
||||
final File image3File = new File(requireContext().getCacheDir(), "tajmahal.jpg");
|
||||
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();
|
||||
|
||||
try {
|
||||
@@ -167,24 +175,20 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
|
||||
showProgressDialog();
|
||||
|
||||
ResourcesUtil.resourceToFile(getResources(), R.drawable.colosseum, image1File);
|
||||
ResourcesUtil.resourceToFile(getResources(), R.drawable.pyramid, image2File);
|
||||
ResourcesUtil.resourceToFile(getResources(), R.drawable.tajmahal, image3File);
|
||||
mainActivity.resourceToFile(R.drawable.colosseum, image1File);
|
||||
mainActivity.resourceToFile(R.drawable.pyramid, image2File);
|
||||
mainActivity.resourceToFile(R.drawable.tajmahal, image3File);
|
||||
|
||||
final String ffmpegCommand = Video.generateEncodeVideoScript(image1File.getAbsolutePath(), image2File.getAbsolutePath(), image3File.getAbsolutePath(), videoFile.getAbsolutePath(), getSelectedVideoCodec(), getCustomOptions());
|
||||
|
||||
Log.d(TAG, String.format("FFmpeg process started with arguments\n'%s'", ffmpegCommand));
|
||||
|
||||
MainActivity.executeAsync(new SingleExecuteCallback() {
|
||||
MainActivity.executeAsync(new RunCallback() {
|
||||
|
||||
@Override
|
||||
public void apply(final int returnCode, final String commandOutput) {
|
||||
public void apply(final int returnCode) {
|
||||
Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode));
|
||||
|
||||
Log.d(TAG, "FFmpeg process output:");
|
||||
|
||||
Config.printLastCommandOutput(Log.INFO);
|
||||
|
||||
hideProgressDialog();
|
||||
|
||||
MainActivity.addUIAction(new Callable() {
|
||||
@@ -195,7 +199,7 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
Log.d(TAG, "Encode completed successfully; playing video.");
|
||||
playVideo();
|
||||
} else {
|
||||
Popup.show(requireContext(), "Encode failed. Please check log for the details.");
|
||||
Popup.show(mainActivity, "Encode failed. Please check log for the details.");
|
||||
Log.d(TAG, String.format("Encode failed with rc=%d", returnCode));
|
||||
}
|
||||
|
||||
@@ -207,16 +211,16 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Encode video failed", e);
|
||||
Popup.show(requireContext(), "Encode video failed");
|
||||
Popup.show(mainActivity, "Encode video failed");
|
||||
}
|
||||
}
|
||||
|
||||
protected void encodeWebp() {
|
||||
final File imageFile = new File(requireContext().getCacheDir(), "colosseum.jpg");
|
||||
final File outputFile = new File(requireContext().getFilesDir(), "video.webp");
|
||||
final File imageFile = new File(mainActivity.getCacheDir(), "colosseum.jpg");
|
||||
final File outputFile = new File(mainActivity.getFilesDir(), "video.webp");
|
||||
|
||||
try {
|
||||
ResourcesUtil.resourceToFile(getResources(), R.drawable.colosseum, imageFile);
|
||||
mainActivity.resourceToFile(R.drawable.colosseum, imageFile);
|
||||
|
||||
Log.d(TAG, "Testing VIDEO encoding with 'webp' codec");
|
||||
|
||||
@@ -229,12 +233,12 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
Log.d(TAG, String.format("FFmpeg process exited with rc %d", returnCode));
|
||||
} catch (IOException e) {
|
||||
Log.e(TAG, "Encode webp failed", e);
|
||||
Popup.show(requireContext(), "Encode webp failed");
|
||||
Popup.show(mainActivity, "Encode webp failed");
|
||||
}
|
||||
}
|
||||
|
||||
protected void playVideo() {
|
||||
MediaController mediaController = new MediaController(requireContext());
|
||||
MediaController mediaController = new MediaController(mainActivity);
|
||||
mediaController.setAnchorView(videoView);
|
||||
videoView.setVideoURI(Uri.parse("file://" + getVideoFile().getAbsolutePath()));
|
||||
videoView.setMediaController(mediaController);
|
||||
@@ -320,7 +324,7 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
}
|
||||
|
||||
final String video = "video." + extension;
|
||||
return new File(requireContext().getFilesDir(), video);
|
||||
return new File(mainActivity.getFilesDir(), video);
|
||||
}
|
||||
|
||||
public String getCustomOptions() {
|
||||
@@ -335,22 +339,24 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
return "-b:v 2M ";
|
||||
case "aom":
|
||||
return "-crf 30 -strict experimental ";
|
||||
case "kvazaar":
|
||||
return "-preset fast ";
|
||||
case "theora":
|
||||
return "-qscale:v 7 ";
|
||||
case "hap":
|
||||
return "-format hap_q ";
|
||||
default:
|
||||
|
||||
// kvazaar, mpeg4, x264, xvid
|
||||
// mpeg4, x264, xvid
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public void setActive() {
|
||||
Log.i(MainActivity.TAG, "Video Tab Activated");
|
||||
android.util.Log.i(MainActivity.TAG, "Video Tab Activated");
|
||||
enableLogCallback();
|
||||
enableStatisticsCallback();
|
||||
Popup.show(requireContext(), Tooltip.VIDEO_TEST_TOOLTIP_TEXT);
|
||||
Popup.show(mainActivity, Tooltip.VIDEO_TEST_TOOLTIP_TEXT);
|
||||
}
|
||||
|
||||
protected void showProgressDialog() {
|
||||
@@ -387,7 +393,7 @@ public class VideoTabFragment extends Fragment implements AdapterView.OnItemSele
|
||||
|
||||
@Override
|
||||
public Object call() {
|
||||
VideoTabFragment.this.progressDialog = DialogUtil.createProgressDialog(requireContext(), "Encoding video");
|
||||
VideoTabFragment.this.progressDialog = mainActivity.createProgressDialog("Encoding video");
|
||||
return null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Alexander Berezhnoi
|
||||
*
|
||||
* 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.app.AlertDialog;
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.arthenica.mobileffmpeg.test.R;
|
||||
|
||||
public class DialogUtil {
|
||||
|
||||
public static AlertDialog createProgressDialog(Context context, final String text) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
if (inflater != null) {
|
||||
View dialogView = inflater.inflate(R.layout.progress_dialog_layout, null);
|
||||
builder.setView(dialogView);
|
||||
|
||||
TextView textView = dialogView.findViewById(R.id.progressDialogText);
|
||||
if (textView != null) {
|
||||
textView.setText(text);
|
||||
}
|
||||
}
|
||||
builder.setCancelable(false);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
public static AlertDialog createCancellableProgressDialog(Context context, final String text, final View.OnClickListener onClickListener) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
LayoutInflater inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
|
||||
if (inflater != null) {
|
||||
View dialogView = inflater.inflate(R.layout.cancellable_progress_dialog_layout, null);
|
||||
builder.setView(dialogView);
|
||||
|
||||
TextView textView = dialogView.findViewById(R.id.progressDialogText);
|
||||
if (textView != null) {
|
||||
textView.setText(text);
|
||||
}
|
||||
Button cancelButton = dialogView.findViewById(R.id.cancelButton);
|
||||
if (cancelButton != null) {
|
||||
cancelButton.setOnClickListener(onClickListener);
|
||||
}
|
||||
}
|
||||
builder.setCancelable(false);
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,70 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Alexander Berezhnoi
|
||||
*
|
||||
* 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.content.res.Resources;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.util.Log;
|
||||
|
||||
import com.arthenica.mobileffmpeg.test.MainActivity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
public class ResourcesUtil {
|
||||
public static void resourceToFile(Resources resources, final int resourceId, final File file) throws IOException {
|
||||
Bitmap bitmap = BitmapFactory.decodeResource(resources, resourceId);
|
||||
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
|
||||
FileOutputStream outputStream = new FileOutputStream(file);
|
||||
bitmap.compress(Bitmap.CompressFormat.JPEG, 100, outputStream);
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}
|
||||
|
||||
public static void rawResourceToFile(Resources resources, final int resourceId, final File file) throws IOException {
|
||||
final InputStream inputStream = resources.openRawResource(resourceId);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
final FileOutputStream outputStream = new FileOutputStream(file);
|
||||
|
||||
try {
|
||||
final byte[] buffer = new byte[1024];
|
||||
int readSize;
|
||||
|
||||
while ((readSize = inputStream.read(buffer)) > 0) {
|
||||
outputStream.write(buffer, 0, readSize);
|
||||
}
|
||||
} catch (final IOException e) {
|
||||
Log.e(MainActivity.TAG, "Saving raw resource failed.", e);
|
||||
} finally {
|
||||
inputStream.close();
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
Before Width: | Height: | Size: 129 KiB After Width: | Height: | Size: 129 KiB |
|
Before Width: | Height: | Size: 126 KiB After Width: | Height: | Size: 126 KiB |
|
Before Width: | Height: | Size: 157 KiB After Width: | Height: | Size: 157 KiB |
@@ -0,0 +1,25 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="@color/headerColor"
|
||||
android:gravity="top"
|
||||
android:orientation="vertical">
|
||||
|
||||
<android.support.v7.widget.AppCompatTextView
|
||||
android:id="@+id/header"
|
||||
style="@style/TextAppearance.AppCompat.Widget.ActionBar.Title"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="40dp"
|
||||
android:layout_gravity="center"
|
||||
android:gravity="center"
|
||||
android:text="@string/app_name"
|
||||
android:textAlignment="center"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat"
|
||||
android:textColor="@android:color/white"
|
||||
android:textStyle="bold"
|
||||
app:fontFamily="sans-serif" />
|
||||
|
||||
</LinearLayout>
|
||||