DeviLeo / DLGPlayer

A media player for iOS based on FFmpeg 4.0
GNU Lesser General Public License v3.0
169 stars 60 forks source link

Building FFmpeg with openssl: Error "openssl not found" #19

Open ggschelling opened 6 years ago

ggschelling commented 6 years ago

I'm following every step here https://github.com/DeviLeo/DLGPlayer/blob/master/How_to_build_ffmpeg_with_openssl.md Finally, running "build-ffmpeg-openssl.sh", the script will stop after a few seconds saying "Error: openssl not found"

I found out that openssl is not in the list of external libraries of ffmpeg, but I couldn't find a way to set it. Maybe you know how to do that. Setting the path with CFLAGS and LDFLAGS seems to be not enough anymore.

DeviLeo commented 6 years ago

OpenSSL-1.1.0 will cause the error "openssl not found". Please use OpenSSL-1.0.2o. You need to edit build-libssl.sh in step 2. Use x2on/OpenSSL-for-iPhone to build OpenSSL for iOS since the default version may be others.

# Change default version to 1.0.2o
DEFAULTVERSION="1.0.2o"

Please make sure your folder structure as follows.

/FFmpeg-iOS-build-script-master
 /build-ffmpeg-openssl.sh
 /ffmpeg-3.4.2
 /openssl
   /include/openssl/*.h
   /lib/*.a

And the script.

# Openssl folder
OPENSSL=`pwd`/openssl

# Make ffmpeg build with openssl
if [ "$OPENSSL" ]
then
    CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-openssl"
fi

# Openssl headers and libs path
if [ "$OPENSSL" ]
then
    CFLAGS="$CFLAGS -I$OPENSSL/include"
        LDFLAGS="$LDFLAGS -L$OPENSSL/lib"
fi
ggschelling commented 6 years ago

@DeviLeo Thanks for the quick update and help! For "arm64" the build process works fine. But with "armv7" and "armv7s" it stops with this error:

clang: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7s' [-Wignored-optimization-argument]
AS  libswresample/arm/audio_convert_neon.o
AS  libswresample/arm/resample.o
CC  libswresample/arm/resample_init.o
<stdin>:61:1: error: invalid symbol redefinition
_swri_oldapi_conv_flt_to_s16_neon:
^
<stdin>:114:1: error: invalid symbol redefinition
_swri_oldapi_conv_fltp_to_s16_2ch_neon:
^
clang: warning: optimization flag '-fomit-frame-pointer' is not supported for target 'armv7s' [-Wignored-optimization-argument]
make: *** [libswresample/arm/audio_convert_neon.o] Error 1
make: *** Waiting for unfinished jobs....

Is there any possibility to make this work?

DeviLeo commented 6 years ago

Open the file "ffmpeg-4.0/libswresample/arm/audio_convert_neon.S"

Delete _swri_oldapi_conv_flt_to_s16_neon: and _swri_oldapi_conv_fltp_to_s16_2ch_neon:. Change _swri_oldapi_conv_flt_to_s16_neon to X(swri_oldapi_conv_flt_to_s16_neon) and _swri_oldapi_conv_fltp_to_s16_2ch_neon to X(swri_oldapi_conv_fltp_to_s16_2ch_neon).

...

function swri_oldapi_conv_flt_to_s16_neon, export=1
// >> Delete Begin
// _swri_oldapi_conv_flt_to_s16_neon:
// << Delete End
        subs            r2,  r2,  #8
        vld1.32         {q0},     [r1,:128]!
        vcvt.s32.f32    q8,  q0,  #31

...

function swri_oldapi_conv_fltp_to_s16_2ch_neon, export=1
// >> Delete Begin
// _swri_oldapi_conv_fltp_to_s16_2ch_neon:
// << Delete End
        ldm             r1,  {r1, r3}
        subs            r2,  r2,  #8
        vld1.32         {q0},     [r1,:128]!

...

function swri_oldapi_conv_fltp_to_s16_nch_neon, export=1
        cmp             r3,  #2
        itt             lt
        ldrlt           r1,  [r1]
// >> Change Begin
//        blt             _swri_oldapi_conv_flt_to_s16_neon
//        beq             _swri_oldapi_conv_fltp_to_s16_2ch_neon
        blt             X(swri_oldapi_conv_flt_to_s16_neon)
        beq             X(swri_oldapi_conv_fltp_to_s16_2ch_neon)
// << Change End

        push            {r4-r8, lr}
        cmp             r3,  #4
        lsl             r12, r3,  #1
        blt             4f

...
ggschelling commented 6 years ago

@DeviLeo Wow, you're deep into that, impressive! Thanks! Now it compiles "armv7", "armv7s" and "arm64" without any errors.

Edit: When compiling the Xcode project I get a linker error. Maybe you know how to solve this too?

Undefined symbols for architecture arm64:
  "_ff_mpeg12_find_best_frame_rate", referenced from:
      _mpeg2_metadata_update_fragment in libavcodec.a(mpeg2_metadata_bsf.o)
ld: symbol(s) not found for architecture arm64
DeviLeo commented 6 years ago

By default, xcode will build active architecture only.
If you are about to build for iPhone 5s or newer devices, arm64 is the active architecture.
So you need to build ffmpeg and openssl with arm64 configured.

Check build-libssl.sh, DEFAULTARCHS="x86_64 i386 arm64 armv7s armv7". Check build-ffmpeg-openssl.sh , ARCHS="arm64 armv7 armv7s x86_64 i386".

If you don't want to build for simulator, delete x86_64 and i386. If you don't want to support iPhone 5, iPhone 5c, iPad 4 (armv7s) or older devices(armv7), keep arm64 only.

More details about device's architecture, see the following picture.

ggschelling commented 6 years ago

Thx @DeviLeo ! In my case I could solve the problem by disabling mpeg2_metadata with "--disable-bsf=mpeg2_metadata". That did the trick. Now the script is building ffmpeg and it's playing streams over https.