Skip to content

Commit

Permalink
update build for android, and build instructions
Browse files Browse the repository at this point in the history
  • Loading branch information
maxnut committed Oct 15, 2024
1 parent 4819418 commit da51e60
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 5 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ if (WIN32)
${CMAKE_SOURCE_DIR}/lib/swscale.lib
${CMAKE_SOURCE_DIR}/lib/libx264.lib
${CMAKE_SOURCE_DIR}/lib/x265-static.lib
${CMAKE_SOURCE_DIR}/lib/aom.lib
${CMAKE_SOURCE_DIR}/lib/vpx.lib
${CMAKE_SOURCE_DIR}/lib/openh264.lib
${CMAKE_SOURCE_DIR}/lib/ws2_32.lib
${CMAKE_SOURCE_DIR}/lib/mfplat.lib
${CMAKE_SOURCE_DIR}/lib/mf.lib
Expand All @@ -59,14 +62,24 @@ elseif (ANDROID)
${CMAKE_SOURCE_DIR}/lib/arm64-v8a/libavutil.a
${CMAKE_SOURCE_DIR}/lib/arm64-v8a/libswresample.a
${CMAKE_SOURCE_DIR}/lib/arm64-v8a/libswscale.a
${CMAKE_SOURCE_DIR}/lib/arm64-v8a/libaom.a
${CMAKE_SOURCE_DIR}/lib/arm64-v8a/libvpx.a
${CMAKE_SOURCE_DIR}/lib/arm64-v8a/libx264.a
${CMAKE_SOURCE_DIR}/lib/arm64-v8a/libx265.a
) # android
elseif(ANDROID_ABI STREQUAL "armeabi-v7a")
add_definitions(-D__USE_FILE_OFFSET64)
add_definitions(-DANDROID_PLATFORM=24)
set(STATIC_LIBS
${CMAKE_SOURCE_DIR}/lib/armeabi-v7a/libavcodec.a
${CMAKE_SOURCE_DIR}/lib/armeabi-v7a/libavformat.a
${CMAKE_SOURCE_DIR}/lib/armeabi-v7a/libavutil.a
${CMAKE_SOURCE_DIR}/lib/armeabi-v7a/libswresample.a
${CMAKE_SOURCE_DIR}/lib/armeabi-v7a/libswscale.a
${CMAKE_SOURCE_DIR}/lib/armeabi-v7a/libaom.a
${CMAKE_SOURCE_DIR}/lib/armeabi-v7a/libvpx.a
${CMAKE_SOURCE_DIR}/lib/armeabi-v7a/libx264.a
${CMAKE_SOURCE_DIR}/lib/armeabi-v7a/libx265.a
) # android
endif()
else ()
Expand Down
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,20 @@ void audioRaw() {
### Windows
To get the needed libraries on Windows, you can use vcpkg:
```sh
vcpkg install ffmpeg[core,avcodec,avformat,avutil,swscale,swresample,amf,x264,x265,nvcodec]:x64-windows-static --recurse
vcpkg install ffmpeg[core,avcodec,avformat,avutil,swscale,swresample,amf,x264,x265,nvcodec,openh264,aom,vpx]:x64-windows-static --recurse
```
the other libraries are part of the Windows SDK

## Android
To get the needed libraries on Android, you can use [this](https://github.com/EclipseMenu/ffmpeg-android-maker/) script. Read the README in the repository for further instructions.
To get the needed libraries on Android, you can use [this](https://github.com/EclipseMenu/ffmpeg-android-maker/) script, make sure you have pkg-config installed before running it. Read the README in the repository for further instructions.
```sh
git clone https://github.com/EclipseMenu/ffmpeg-android-maker/
cd ffmpeg-android-maker
./ffmpeg-android-maker.sh
./ffmpeg-android-maker.sh --enable-libaom --enable-libvpx --enable-libx264 --enable-libx265 --android-api-level=24
```
You can either run it natively on Linux or using WSL on Windows.

When building for android32 you need to set android version 24, you can do so by adding this arg to your geode build command
```sh
geode build --platform android32 --config Release -- -DANDROID_PLATFORM=24
```
2 changes: 1 addition & 1 deletion mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
},
"id": "eclipse.ffmpeg-api",
"name": "FFmpeg API",
"version": "v1.0.2",
"version": "v1.0.3",
"developers": ["Eclipse Team", "maxnu"],
"description": "Interaction with FFmpeg made easy",
"tags": ["utility", "offline"],
Expand Down
4 changes: 3 additions & 1 deletion src/recorder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ std::vector<std::string> Recorder::getAvailableCodecs() {
const AVCodec * codec;

while ((codec = av_codec_iterate(&iter))) {
if(codec->type == AVMEDIA_TYPE_VIDEO && avcodec_find_encoder_by_name(codec->name) != nullptr)
if(codec->type == AVMEDIA_TYPE_VIDEO &&
(codec->id == AV_CODEC_ID_H264 || codec->id == AV_CODEC_ID_HEVC || codec->id == AV_CODEC_ID_VP8 || codec->id == AV_CODEC_ID_VP9 || codec->id == AV_CODEC_ID_AV1 || codec->id == AV_CODEC_ID_MPEG4) &&
avcodec_find_encoder_by_name(codec->name) != nullptr && codec->pix_fmts && std::find(vec.begin(), vec.end(), std::string(codec->name)) == vec.end())
vec.push_back(codec->name);
}

Expand Down

0 comments on commit da51e60

Please sign in to comment.