Skip to content

I try to enable srt in ffmpeg but i cannot compile ffmpeg #109

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ciccio14 opened this issue Apr 1, 2025 · 4 comments
Open

I try to enable srt in ffmpeg but i cannot compile ffmpeg #109

ciccio14 opened this issue Apr 1, 2025 · 4 comments

Comments

@ciccio14
Copy link

ciccio14 commented Apr 1, 2025

I tried to enable libsrt for ffmpeg using the istructions:

i added this line:

  --enable-libsrt | -srt)
    EXTERNAL_LIBRARIES+=("libsrt")
    ;;

to parse-arguments.sh

i created libsrt directory under scripts
i create download.sh like this:

#!/usr/bin/env bash

# Script to download SRT's source code
# Relies on SRT_SOURCE_TYPE and SRT_SOURCE_VALUE variables
# to choose the valid origin and version

# Exports SOURCES_DIR_srt - path where actual sources are stored

# Getting sources of a particular SRT release.
# Same argument (SRT version) produces the same source set.
function ensureSourcesTar() {
  source ${SCRIPTS_DIR}/common-functions.sh

  downloadTarArchive \
    "srt" \
    "https://github.com/Haivision/srt/archive/refs/tags/${SRT_SOURCE_VALUE}.tar.gz"
}

# Getting sources of a particular branch or a tag of SRT's git repository.
# Same branch name may produce different source sets,
# as the branch in the origin repository may be updated in the future.
# Git tags lead to stable states of the source code.
function ensureSourcesGit() {
  NAME_TO_CHECKOUT=${SRT_SOURCE_VALUE}
  GIT_DIRECTORY=srt-git
  SRT_SOURCES=$(pwd)/${GIT_DIRECTORY}

  if [[ ! -d "$SRT_SOURCES" ]]; then
    git clone https://github.com/Haivision/srt.git ${GIT_DIRECTORY}
  fi

  cd ${GIT_DIRECTORY}
  git reset --hard

  git checkout $NAME_TO_CHECKOUT
  if [ ${SRT_SOURCE_TYPE} = "GIT_BRANCH" ]; then
    # Forcing the update of a branch
    git pull origin $NAME_TO_CHECKOUT
  fi

  # Additional logging to keep track of the exact commit to build
  echo "Commit to build:"
  git rev-parse HEAD

  export SOURCES_DIR_srt=${SRT_SOURCES}
}

# Actual code
case ${SRT_SOURCE_TYPE} in
  GIT_TAG)
    echo "Using SRT git tag: ${SRT_SOURCE_VALUE}"
    ensureSourcesGit
    ;;
  GIT_BRANCH)
    echo "Using SRT git repository and its branch: ${SRT_SOURCE_VALUE}"
    ensureSourcesGit
    ;;
  TAR)
    echo "Using SRT source archive: ${SRT_SOURCE_VALUE}"
    ensureSourcesTar
    ;;
esac

then i created the build.sh script:

#!/usr/bin/env bash

cmake -DENABLE_SHARED=1 -DCMAKE_INSTALL_PREFIX=/home/tommaso/lavoro/mine/progetti/ffmpeg-android/ffmpeg-android-maker/scripts/libsrt

${MAKE_EXECUTABLE} clean
${MAKE_EXECUTABLE} -j${HOST_NPROC}
${MAKE_EXECUTABLE} install

but when i try to compile the compiler seems to ignore my configuration.
i also already installed libsrt in my ubuntu machine but if i try to add --enable-libsrt \ to build.sh of ffmpeg, the compile fails

Building the component: ffmpeg
ERROR: srt >= 1.3.0 not found using pkg-config

even if pkgconf finds the library installed:

pkgconf --modversion srt
1.5.4
@Javernaut
Copy link
Owner

Javernaut commented Apr 2, 2025

I see you missed quite a lot of stuff that happens in other scripts of this project:

  • you don't use android toolchain for cmake. Here you can see an example of how this is done. Basically you build srt for you host environment and not for android. Please, adjust your script.
  • Please use the env variables like the script above. Yeah, I know their discoverability is not ideal, but they ensure you work in a proper directory for individual ABI. This matters, as cmake creates separate build directories for each ABI.
  • your local pkgconf has nothing to do with ffmpeg building process. And the message "ERROR: srt >= 1.3.0 not found using pkg-config" is actually misleading. It can mean many things like 'the headers are not in available' or 'there was a linking error', or anything else while checking the particular library.

@ciccio14
Copy link
Author

ciccio14 commented Apr 2, 2025

Hi Javernaut,

Thank you for taking the time to respond to my question. I apologize for the mistakes in my previous script and for not following the necessary steps correctly to build SRT for Android.

I have updated my script based on your suggestions and am now testing the new configuration.

`#!/usr/bin/env bash
CMAKE_BUILD_DIR=libsrt_build_${ANDROID_ABI}
cd srt
rm -rf ${CMAKE_BUILD_DIR}
mkdir ${CMAKE_BUILD_DIR}
cd ${CMAKE_BUILD_DIR}
${CMAKE_EXECUTABLE} ..
-DCMAKE_SYSTEM_NAME=Android
-DANDROID_PLATFORM=${ANDROID_PLATFORM}
-DANDROID_ABI=${ANDROID_ABI}
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK_HOME}/build/cmake/android.toolchain.cmake
-DCMAKE_INSTALL_PREFIX=${INSTALL_DIR}
-DENABLE_SHARED=1
-DSRT_STATIC=0
-DENABLE_TESTING=0

${MAKE_EXECUTABLE} clean
${MAKE_EXECUTABLE} -j${HOST_NPROC}
${MAKE_EXECUTABLE} install
export EXTRA_BUILD_CONFIGURATION_FLAGS="$EXTRA_BUILD_CONFIGURATION_FLAGS --enable-libsrt"`

However, during compilation, I encounter the following error:
[ 68%] Building C object CMakeFiles/srt_virtual.dir/haicrypt/cryspr-openssl-evp.c.o
In file included from /home/tommaso/lavoro/mine/progetti/ffmpeg-android/ffmpeg-android-maker/scripts/libsrt/srt/haicrypt/cryspr.c:24:
In file included from /home/tommaso/lavoro/mine/progetti/ffmpeg-android/ffmpeg-android-maker/scripts/libsrt/srt/haicrypt/hcrypt.h:48:
In file included from /home/tommaso/lavoro/mine/progetti/ffmpeg-android/ffmpeg-android-maker/scripts/libsrt/srt/haicrypt/cryspr.h:39:
In file included from /home/tommaso/lavoro/mine/progetti/ffmpeg-android/ffmpeg-android-maker/scripts/libsrt/srt/haicrypt/cryspr-config.h:13:
/home/tommaso/lavoro/mine/progetti/ffmpeg-android/ffmpeg-android-maker/scripts/libsrt/srt/haicrypt/cryspr-openssl-evp.h:22:10: fatal error: 'openssl/evp.h' file not found
22 | #include <openssl/evp.h> /* PKCS5_xxx() */

It seems that the build process cannot find the OpenSSL libraries. I have checked my build environment and tried specifying the library paths, but the error persists.

If you have any suggestions on how to resolve this issue, I would greatly appreciate it.

Thanks again for your help!

Best regards

@ciccio14
Copy link
Author

ciccio14 commented Apr 3, 2025

going into more detail I found this internal script of srt
https://github.com/Haivision/srt/blob/master/docs/build/build-android.md
made specifically to build the application for android. is it possible to integrate it into the ffmpeg build process?

@Javernaut
Copy link
Owner

Hey there,
I'm really out of capacity to dive super deep into the thing. Yet I can provide a couple of advices.

  1. Do you really need the openssl? I don't know for what exactly you are goint to use srt, but you could use flags that eliminate the dependency on openssl.
  2. Another thing, as I understand when building srt you can supply the mbedtls instead of opessl. You could try doing the thing this way. The mbedtls is already built by ffmpeg-andorid-maker, but you probably need to tweek these scripts to use mbedtls by srt, and not by ffmpeg itself.
    Sadly, I never came with a proper solution for dependencies and shared libraries building instead of static libs. I even consider rewriting the whole thing in Python once I really have time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants