The library reads basic information about video and audio files.
For video streams:
- Video codec name
- Bit rate
- Frame size
- 4 equidistant frames can be read (incubating feature)
For audio streams:
- Audio codec name
- Bit rate
- Number of channels
- Channel layout
- Sample rate and format
For subtitle streams: title and language from stream’s metadata.
Supported ABIs are: armeabi-v7a, arm64-v8a, x86 and x86_64.
The main purpose is to show how to use the output of ffmpeg-android-maker.
Extensive description can be found in this article, though the article was written at the time this library wasn't extracted as a separate repository.
The codebase has a native part that glues FFmpeg libs to JVM part.
FFmpeg accepts 2 types of input: File paths and File Descriptors. File paths are better and allow the FFmpeg to use all the functionality it has. File Descriptors can be passed to FFmpeg via pipe protocol, but it has certain problems like inability to seek backward. That is why the number of frames loaded is limited to 4 only. Though the File protocol doesn't have this problem.
Library tries to recreate a raw file path from a Uri and pass it to FFmpeg. If it doesn't succeed, it falls back to File Descriptor way.
The library is available via Maven Central, so you are able to use it as a dependency:
dependencies {
implementation 'io.github.javernaut:mediafile:x.y.z'
}
repositories {
// ...
mavenCentral()
}
In order to compile the library yourself, you have to get ffmpeg-android-maker source code and compile it. It is already added as a submodule. So the first thing to do is to load it:
git submodule update --init
Then you need to setup and execute the ffmpeg-android-maker's script. The command used to generate the artifacts for Maven Central looks like this:
./ffmpeg-android-maker.sh -dav1d
More details about how to setup your environment for FFmpeg compilation can be found in ffmpeg-android-maker repository.
MediaFile library's source code is available under the MIT license. See the LICENSE.txt file for more details.