Skip to content

Commit 7461b45

Browse files
authored
Merge pull request #288 from wseemann/284
Support 16KB page sizes
2 parents 4fdde1b + bd00013 commit 7461b45

File tree

570 files changed

+37468
-21236
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

570 files changed

+37468
-21236
lines changed

FMMRDemo.apk

6.4 MB
Binary file not shown.

README.md

Lines changed: 35 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
FFmpegMediaMetadataRetriever
2-
============================
1+
# FFmpegMediaMetadataRetriever
32

43
View the project page <a href=http://wseemann.github.io/FFmpegMediaMetadataRetriever/>here</a>.
54

6-
Donations
7-
------------
5+
## Donations
86

97
Donations can be made via PayPal:
108

@@ -14,82 +12,62 @@ Donations can be made via PayPal:
1412

1513
- [**Choose what you want to donate**](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=2BDTFVEW9LFZY), all donations are awesome!
1614

17-
Overview
18-
--------
15+
## Overview
1916

2017
FFmpegMediaMetadataRetriever is a reimplementation of Android's MediaMetadataRetriever class. The FFmpegMediaMetadataRetriever class provides a unified interface for retrieving frame and meta data from an input media file and uses FFmpeg as its backend.
2118

22-
This project uses FFmpeg version 4.2.2.
23-
2419
Key Features:
25-
* ARMv7, x86, x86_64 and ARM_64 support (Note: ARM and MIPS aren't supported as of version 1.0.14)
26-
* Support for API 16+
27-
* URL support (Unlike MediaMetadataRetriever, see: http://code.google.com/p/android/issues/detail?id=35794)
20+
21+
- Built using FFmpeg version 7.1.1
22+
- ARMv7, x86, x86_64 and ARM_64 support (Note: ARM and MIPS aren't supported as of version 1.0.14)
23+
- Support for API 21+ and 16 KB page sizes
24+
- URL support (Unlike MediaMetadataRetriever, see: http://code.google.com/p/android/issues/detail?id=35794)
2825

2926
Supported protocols:
30-
* file, http, https, mms, mmsh and rtmp
27+
28+
- file, http, https, mms, mmsh and rtmp
3129

3230
Supported formats (audio and video):
33-
* aac, acc+, avi, flac, mp2, mp3, mp4, ogg, 3gp and more!
3431

35-
Additional support for:
36-
* ICY Metadata (SHOUTcast metadata)
32+
- aac, acc+, avi, flac, mp2, mp3, mp4, ogg, 3gp and more!
3733

38-
Demo Application
39-
------------
34+
Additional support for:
4035

41-
If you would like to try FFmpegMediaMetadataRetriever you can do so using the [Demo Application](https://github.com/wseemann/FFmpegMediaMetadataRetriever/blob/master/FMMRDemo.apk)
36+
- ICY Metadata (SHOUTcast metadata)
4237

43-
Using FMMR in your application (Android Studio)
44-
------------
38+
## Using FMMR in your application (Android Studio)
4539

4640
Add the following maven dependency to your project's `build.gradle` file:
4741

4842
dependencies {
49-
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-core:1.0.19'
50-
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-native:1.0.19'
43+
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-core:1.0.20'
44+
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-native:1.0.20'
5145
}
5246

5347
Optionally, to support individual ABIs:
5448

5549
dependencies {
56-
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-core:1.0.19'
57-
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-native-armeabi-v7a:1.0.19'
58-
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-native-x86:1.0.19'
59-
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-native-x86_64:1.0.19'
60-
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-native-arm64-v8a:1.0.19'
50+
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-core:1.0.20'
51+
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-native-armeabi-v7a:1.0.20'
52+
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-native-x86:1.0.20'
53+
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-native-x86_64:1.0.20'
54+
implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever-native-arm64-v8a:1.0.20'
6155
}
6256

6357
or, if your application supports individual architectures extract the appropriate AAR file into you projects "libs" folder:
6458

6559
[Prebuilt AARs](https://github.com/wseemann/FFmpegMediaMetadataRetriever/releases/download/v1.0.19/prebuilt-aars.zip)
6660

67-
Demo Application
68-
------------
61+
## Demo Application
6962

7063
A sample application that makes use of FFmpegMediaMetadataRetriever can be downloaded [here](https://github.com/wseemann/FFmpegMediaMetadataRetriever/blob/master/FMMRDemo.apk?raw=true). Note: The sample application is compiled with support for ALL available formats. This results in a larger library and APK. FFmpeg can be recompiled with a subset of codecs enabled for those wanting a smaller size.
7164

72-
Installation
73-
------------
65+
## Requirements
7466

75-
FFmpegMediaMetadataRetriever relies on FFmpeg and native code. The build process
76-
is complex and may be confusing for those unfamiliar the Android NDK. For this
77-
reason I've precompiled AARs created by the build process and checked them
78-
in [here](https://github.com/wseemann/FFmpegMediaMetadataRetriever/releases/download/v1.0.19/prebuilt-aars.zip).
79-
The modules are also included with the library. If you don't want to build the modules
80-
you can simple unzip the prebuilt ones and copy them to your projects "libs" folder. (Note:
81-
copy them to YOUR projects "libs" folder, NOT the "libs" folder located in
82-
FFmpegMediaMetadataRetriever/fmmr-library. Once this step is complete you can use the
83-
library (See: Installation in Eclipse (Kepler)). If you want to compile the modules yourself
84-
follow the Ant instructions listed below before attempting to use the library.
67+
- [Android Studio](http://developer.android.com/sdk/index.html) Meerkat 2024.3.2 Patch 1 or higher
68+
- [Android NDK](http://developer.android.com/tools/sdk/ndk/index.html) r27 or higher
8569

86-
Download and install the [Android SDK](http://developer.android.com/sdk/index.html).
87-
Download the [Android NDK](http://developer.android.com/tools/sdk/ndk/index.html).
88-
Clone/Download/Fork the repo through GitHub or via (read-only)
89-
90-
git clone https://github.com/wseemann/FFmpegMediaMetadataRetriever.git
91-
92-
### Android Studio (Gradle)
70+
## Android Studio (Gradle)
9371

9472
Note: The build instructions and scripts assume you are running Unix or Linux. Building
9573
on other operating systems is currently not supported.
@@ -109,12 +87,11 @@ where <path to SDK> is the path to your Android SDK, for example:
10987

11088
where <path to NDK> is the path to your Android NDK, for example:
11189

112-
ndk.dir=/home/wseemann/Android/android-ndk-r20
90+
ndk.dir=/Users/wseemann/Library/Android/sdk/ndk/27.1.12297006
11391

11492
To compile the library in Android Studio, highlight `core` in the project explorer and run Build->Make Module 'core'. This will also build the native FFmpeg binaries.
11593

116-
Usage
117-
------------
94+
## Usage
11895

11996
Sample code:
12097

@@ -124,21 +101,20 @@ Sample code:
124101
mmr.extractMetadata(FFmpegMediaMetadataRetriever.METADATA_KEY_ARTIST);
125102
Bitmap b = mmr.getFrameAtTime(2000000, FFmpegMediaMetadataRetriever.OPTION_CLOSEST); // frame at 2 seconds
126103
byte [] artwork = mmr.getEmbeddedPicture();
127-
104+
128105
mmr.release();
129106

130-
FFmpeg
131-
-----------
107+
## FFmpeg
108+
132109
This software uses code of <a href=http://ffmpeg.org>FFmpeg</a> licensed under the <a href=http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>LGPLv2.1</a> and its source can be downloaded <a href=https://www.ffmpeg.org/developer.html>here</a>.
133110

134-
License
135-
------------
111+
## License
136112

137113
```
138-
FFmpegMediaMetadataRetriever: A unified interface for retrieving frame
114+
FFmpegMediaMetadataRetriever: A unified interface for retrieving frame
139115
and meta data from an input media file.
140116
141-
Copyright 2022 William Seemann
117+
Copyright 2025 William Seemann
142118
143119
Licensed under the Apache License, Version 2.0 (the "License");
144120
you may not use this file except in compliance with the License.
@@ -151,3 +127,4 @@ distributed under the License is distributed on an "AS IS" BASIS,
151127
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
152128
See the License for the specific language governing permissions and
153129
limitations under the License.
130+
```

build.gradle

Lines changed: 0 additions & 27 deletions
This file was deleted.

build.gradle.kts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// Top-level build file where you can add configuration options common to all sub-projects/modules.
2+
plugins {
3+
alias(libs.plugins.android.application) apply false
4+
alias(libs.plugins.kotlin.android) apply false
5+
alias(libs.plugins.kotlin.compose) apply false
6+
}

check_elf_alignment.sh

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
#!/bin/bash
2+
progname="${0##*/}"
3+
progname="${progname%.sh}"
4+
5+
# usage: check_elf_alignment.sh [path to *.so files|path to *.apk]
6+
7+
cleanup_trap() {
8+
if [ -n "${tmp}" -a -d "${tmp}" ]; then
9+
rm -rf ${tmp}
10+
fi
11+
exit $1
12+
}
13+
14+
usage() {
15+
echo "Host side script to check the ELF alignment of shared libraries."
16+
echo "Shared libraries are reported ALIGNED when their ELF regions are"
17+
echo "16 KB or 64 KB aligned. Otherwise they are reported as UNALIGNED."
18+
echo
19+
echo "Usage: ${progname} [input-path|input-APK|input-APEX]"
20+
}
21+
22+
if [ ${#} -ne 1 ]; then
23+
usage
24+
exit
25+
fi
26+
27+
case ${1} in
28+
--help | -h | -\?)
29+
usage
30+
exit
31+
;;
32+
33+
*)
34+
dir="${1}"
35+
;;
36+
esac
37+
38+
if ! [ -f "${dir}" -o -d "${dir}" ]; then
39+
echo "Invalid file: ${dir}" >&2
40+
exit 1
41+
fi
42+
43+
if [[ "${dir}" == *.apk ]]; then
44+
trap 'cleanup_trap' EXIT
45+
46+
echo
47+
echo "Recursively analyzing $dir"
48+
echo
49+
50+
if { zipalign --help 2>&1 | grep -q "\-P <pagesize_kb>"; }; then
51+
echo "=== APK zip-alignment ==="
52+
zipalign -v -c -P 16 4 "${dir}" | egrep 'lib/arm64-v8a|lib/x86_64|Verification'
53+
echo "========================="
54+
else
55+
echo "NOTICE: Zip alignment check requires build-tools version 35.0.0-rc3 or higher."
56+
echo " You can install the latest build-tools by running the below command"
57+
echo " and updating your \$PATH:"
58+
echo
59+
echo " sdkmanager \"build-tools;35.0.0-rc3\""
60+
fi
61+
62+
dir_filename=$(basename "${dir}")
63+
tmp=$(mktemp -d -t "${dir_filename%.apk}_out_XXXXX")
64+
unzip "${dir}" lib/* -d "${tmp}" >/dev/null 2>&1
65+
dir="${tmp}"
66+
fi
67+
68+
if [[ "${dir}" == *.apex ]]; then
69+
trap 'cleanup_trap' EXIT
70+
71+
echo
72+
echo "Recursively analyzing $dir"
73+
echo
74+
75+
dir_filename=$(basename "${dir}")
76+
tmp=$(mktemp -d -t "${dir_filename%.apex}_out_XXXXX")
77+
deapexer extract "${dir}" "${tmp}" || { echo "Failed to deapex." && exit 1; }
78+
dir="${tmp}"
79+
fi
80+
81+
RED="\e[31m"
82+
GREEN="\e[32m"
83+
ENDCOLOR="\e[0m"
84+
85+
unaligned_libs=()
86+
87+
echo
88+
echo "=== ELF alignment ==="
89+
90+
matches="$(find "${dir}" -type f)"
91+
IFS=$'\n'
92+
for match in $matches; do
93+
# We could recursively call this script or rewrite it to though.
94+
[[ "${match}" == *".apk" ]] && echo "WARNING: doesn't recursively inspect .apk file: ${match}"
95+
[[ "${match}" == *".apex" ]] && echo "WARNING: doesn't recursively inspect .apex file: ${match}"
96+
97+
[[ $(file "${match}") == *"ELF"* ]] || continue
98+
99+
res="$(objdump -p "${match}" | grep LOAD | awk '{ print $NF }' | head -1)"
100+
if [[ $res =~ 2\*\*(1[4-9]|[2-9][0-9]|[1-9][0-9]{2,}) ]]; then
101+
echo -e "${match}: ${GREEN}ALIGNED${ENDCOLOR} ($res)"
102+
else
103+
echo -e "${match}: ${RED}UNALIGNED${ENDCOLOR} ($res)"
104+
unaligned_libs+=("${match}")
105+
fi
106+
done
107+
108+
if [ ${#unaligned_libs[@]} -gt 0 ]; then
109+
echo -e "${RED}Found ${#unaligned_libs[@]} unaligned libs (only arm64-v8a/x86_64 libs need to be aligned).${ENDCOLOR}"
110+
elif [ -n "${dir_filename}" ]; then
111+
echo -e "ELF Verification Successful"
112+
fi
113+
echo "====================="

core/build.gradle

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@ apply plugin: 'com.android.library'
22
apply from: "$rootProject.projectDir/publishing.gradle"
33

44
android {
5-
compileSdk versions.get("compileSdkVersion")
5+
namespace 'wseemann.media'
6+
7+
compileSdk Integer.parseInt(libs.versions.compileSdk.get())
68

79
defaultConfig {
8-
minSdkVersion versions.get("minSdkVersion")
9-
targetSdkVersion versions.get("targetSdkVersion")
10-
versionCode versions.get("versionCode")
11-
versionName versions.get("versionName")
10+
minSdkVersion Integer.parseInt(libs.versions.minSdk.get())
11+
targetSdkVersion Integer.parseInt(libs.versions.targetSdk.get())
12+
ndkVersion libs.versions.ndk.get()
1213

1314
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1415

@@ -23,6 +24,17 @@ android {
2324
publishing {
2425
singleVariant('release')
2526
}
27+
28+
compileOptions {
29+
sourceCompatibility JavaVersion.VERSION_17
30+
targetCompatibility JavaVersion.VERSION_17
31+
}
32+
33+
java {
34+
toolchain {
35+
languageVersion = JavaLanguageVersion.of(17)
36+
}
37+
}
2638
}
2739

2840
afterEvaluate {
@@ -33,7 +45,7 @@ afterEvaluate {
3345

3446
groupId = 'com.github.wseemann'
3547
artifactId = 'FFmpegMediaMetadataRetriever-core'
36-
version = "$project.android.defaultConfig.versionName"
48+
version = libs.versions.versionName.get()
3749

3850
pom {
3951
name = 'FFmpegMediaMetadataRetriever-core'
@@ -65,8 +77,8 @@ afterEvaluate {
6577
}
6678

6779
dependencies {
68-
implementation 'androidx.appcompat:appcompat:1.5.1'
69-
testImplementation 'junit:junit:4.13.2'
70-
androidTestImplementation 'androidx.test:runner:1.4.0'
71-
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
80+
implementation(libs.androidx.appcompat)
81+
testImplementation(libs.junit)
82+
androidTestImplementation(libs.androidx.runner)
83+
androidTestImplementation(libs.androidx.espresso.core)
7284
}

core/src/main/AndroidManifest.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
2-
package="wseemann.media">
1+
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
32

43
<uses-permission android:name="android.permission.INTERNET" />
54

core/src/main/java/wseemann/media/FFmpegMediaMetadataRetriever.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* FFmpegMediaMetadataRetriever: A unified interface for retrieving frame
33
* and meta data from an input media file.
44
*
5-
* Copyright 2022 William Seemann
5+
* Copyright 2025 William Seemann
66
*
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.

0 commit comments

Comments
 (0)