Use FFmpeg shared libraries & Update build instructions

This commit is contained in:
Matéo Duparc 2021-10-15 10:02:48 +02:00
parent 497c22edc1
commit a377b61240
Signed by: hardcoresushi
GPG Key ID: 007F84120107191E
4 changed files with 41 additions and 18 deletions

View File

@ -75,7 +75,10 @@ DroidFS need some permissions to work properly. Here is why:
Required to encrypt/decrypt password hashes using a fingerprint protected key.
</li>
<li><h4>Camera:</h4>
Needed to take photos directly from DroidFS to import them securely. You can deny this permission if you don't want to use it.
Needed to take photos & videos directly encrypted inside DroidFS. You can deny this permission if you don't want to use it.
</li>
<li><h4>Record audio:</h4>
Required if you want sound on video recorded with DroidFS.
</li>
</ul>
@ -114,6 +117,11 @@ Continue **ONLY** if the signature is **VALID**.
```
$ tar -xvzf openssl-1.1.1l.tar.gz
```
DroidFS also need [FFmpeg](https://ffmpeg.org) to record encrypted video:
```
$ cd app/ffmpeg
$ git clone --depth=1 https://git.ffmpeg.org/ffmpeg.git
```
#### Build
First, we need to install some dependencies:
@ -129,6 +137,11 @@ Then, retrieve your Android NDK installation path, usually someting like "/home/
$ cd DroidFS/app/libgocryptfs
$ env ANDROID_NDK_HOME="<your ndk path>" OPENSSL_PATH="./openssl-1.1.1l" ./build.sh
```
And also FFmpeg:
```
$ cd app/ffmpeg
$ env ANDROID_NDK_HOME="<your ndk path>" ./build.sh ffmpeg
```
Then, open the DroidFS project with Android Studio. \
If a device (virtual or physical) is connected, just click on "Run". \
If you want to generate a signed APK, you can follow this [post](https://stackoverflow.com/a/28938286).

View File

@ -25,38 +25,38 @@ target_link_libraries(
add_library(
avformat
STATIC
SHARED
IMPORTED
)
set_target_properties(
avformat
PROPERTIES IMPORTED_LOCATION
${PROJECT_SOURCE_DIR}/ffmpeg/build/${ANDROID_ABI}/libavformat/libavformat.a
${PROJECT_SOURCE_DIR}/ffmpeg/build/${ANDROID_ABI}/libavformat/libavformat.so
)
add_library(
avcodec
STATIC
SHARED
IMPORTED
)
set_target_properties(
avcodec
PROPERTIES IMPORTED_LOCATION
${PROJECT_SOURCE_DIR}/ffmpeg/build/${ANDROID_ABI}/libavcodec/libavcodec.a
${PROJECT_SOURCE_DIR}/ffmpeg/build/${ANDROID_ABI}/libavcodec/libavcodec.so
)
add_library(
avutil
STATIC
SHARED
IMPORTED
)
set_target_properties(
avutil
PROPERTIES IMPORTED_LOCATION
${PROJECT_SOURCE_DIR}/ffmpeg/build/${ANDROID_ABI}/libavutil/libavutil.a
${PROJECT_SOURCE_DIR}/ffmpeg/build/${ANDROID_ABI}/libavutil/libavutil.so
)
add_library(

View File

@ -4,7 +4,7 @@ apply plugin: 'kotlin-android'
android {
compileSdkVersion 31
buildToolsVersion "31"
ndkVersion "21.4.7075529"
ndkVersion "23.0.7599858"
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8

View File

@ -2,8 +2,12 @@
if [ -z ${ANDROID_NDK_HOME+x} ]; then
echo "Error: \$ANDROID_NDK_HOME is not defined."
elif [ $# -lt 1 ]; then
echo "Usage: $0 <FFmpeg source directory> [<ABI>]"
else
FFMPEG_DIR=$1
compile_for_arch() {
echo "Compiling for $1..."
case $1 in
"x86_64")
CFN="x86_64-linux-android21-clang"
@ -12,6 +16,7 @@ else
"x86")
CFN="i686-linux-android21-clang"
ARCH="i686"
EXTRA_FLAGS="--disable-asm"
;;
"arm64-v8a")
CFN="aarch64-linux-android21-clang"
@ -22,19 +27,26 @@ else
ARCH="arm"
;;
esac
cd ffmpeg && make clean &&
(cd $FFMPEG_DIR && make clean;
./configure \
--cc="$CFN" \
--cxx="$CFN++" \
--arch="$ARCH" \
$EXTRA_FLAGS \
--target-os=android \
--enable-cross-compile \
--enable-version3 \
--disable-programs \
--disable-static \
--enable-shared \
--disable-bsfs \
--disable-parsers \
--disable-demuxers \
--disable-muxers \
--enable-muxer="mp4" \
--disable-decoders \
--disable-encoders \
--enable-encoder="aac" \
--disable-avdevice \
--disable-swresample \
--disable-swscale \
@ -60,21 +72,19 @@ else
--disable-alsa \
--disable-debug \
>/dev/null &&
make -j 8 >/dev/null &&
mkdir -p ../build/$1/libavformat ../build/$1/libavcodec ../build/$1/libavutil &&
cp libavformat/*.h libavformat/libavformat.a ../build/$1/libavformat &&
cp libavcodec/*.h libavcodec/libavcodec.a ../build/$1/libavcodec &&
cp libavutil/*.h libavutil/libavutil.a ../build/$1/libavutil &&
cd ..
make -j $(nproc --all) >/dev/null) &&
mkdir -p build/$1/libavformat build/$1/libavcodec build/$1/libavutil &&
cp $FFMPEG_DIR/libavformat/*.h $FFMPEG_DIR/libavformat/libavformat.so build/$1/libavformat &&
cp $FFMPEG_DIR/libavcodec/*.h $FFMPEG_DIR/libavcodec/libavcodec.so build/$1/libavcodec &&
cp $FFMPEG_DIR/libavutil/*.h $FFMPEG_DIR/libavutil/libavutil.so build/$1/libavutil
}
export PATH=$ANDROID_NDK_HOME/toolchains/llvm/prebuilt/linux-x86_64/bin:$PATH
if [ "$#" -eq 1 ]; then
compile_for_arch $1
if [ $# -eq 2 ]; then
compile_for_arch $2
else
declare -a ABIs=("x86_64" "x86" "arm64-v8a" "armeabi-v7a")
for abi in ${ABIs[@]}; do
echo "Compiling for $abi..."
compile_for_arch $abi
done
fi