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. Required to encrypt/decrypt password hashes using a fingerprint protected key.
</li> </li>
<li><h4>Camera:</h4> <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> </li>
</ul> </ul>
@ -114,6 +117,11 @@ Continue **ONLY** if the signature is **VALID**.
``` ```
$ tar -xvzf openssl-1.1.1l.tar.gz $ 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 #### Build
First, we need to install some dependencies: 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 $ cd DroidFS/app/libgocryptfs
$ env ANDROID_NDK_HOME="<your ndk path>" OPENSSL_PATH="./openssl-1.1.1l" ./build.sh $ 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. \ Then, open the DroidFS project with Android Studio. \
If a device (virtual or physical) is connected, just click on "Run". \ 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). 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( add_library(
avformat avformat
STATIC SHARED
IMPORTED IMPORTED
) )
set_target_properties( set_target_properties(
avformat avformat
PROPERTIES IMPORTED_LOCATION 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( add_library(
avcodec avcodec
STATIC SHARED
IMPORTED IMPORTED
) )
set_target_properties( set_target_properties(
avcodec avcodec
PROPERTIES IMPORTED_LOCATION 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( add_library(
avutil avutil
STATIC SHARED
IMPORTED IMPORTED
) )
set_target_properties( set_target_properties(
avutil avutil
PROPERTIES IMPORTED_LOCATION 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( add_library(

View File

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

View File

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