There are plenty of online tutorials on how to package IJKPlayer, and they almost work. However, there is still little information on how to upgrade ffMPEG kernel and HTTPS, so I will share how to upgrade FFMPEG and summarize a complete package process. Packing reference: juejin.cn/post/684490… Ijkplayer github github.com/bilibili/ij…
Get the code
# Cut to the desktop first
cd Desktop/
# clone ijkPlayer code
git clone https://github.com/Bilibili/ijkplayer.git
cd ijkplayer
# Cut to the latest version k0.8.8Git Checkout -b latest k0.8.8Copy the code
Configure decoder
- Module-default. sh More codecs/formats
- Module-lite-hevc. sh Fewer codecs/formats (including heVC)
- Module-lite.sh Fewer codecs/formats (default)
cd config
Delete the default decoder
rm module.sh
# create a soft link pointing to module-lite-hevc.sh
ln -s module-lite-hevc.sh module.sh
cd.cd ios
sh compile-ffmpeg.sh clean
Copy the code
Configure the FFMPEG kernel version
Edit the init-ios.sh file
cd. vi init-ios.shCopy the code
#! /usr/bin/env bash
#
# Copyright (C) 2013-2015 Bilibili
# Copyright (C) 2013-2015 Zhang Rui <[email protected]>
#
Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# IJK_FFMPEG_UPSTREAM=git://git.videolan.org/ffmpeg.gitIJK_FFMPEG_UPSTREAM=https://github.com/Bilibili/FFmpeg.git IJK_FFMPEG_FORK=https://github.com/Bilibili/FFmpeg.git IJK_FFMPEG_COMMIT= FF3.4 -- IJK0.8.7 --20180103--001 IJK_FFMPEG_LOCAL_REPO=extra/ FFmPEG..Copy the code
Note that IJK_FFMPEG_COMMIT is where the FFMPEG version is configured. If not modified, ff3.4– IJK0.8.7 –20180103–001 is used by default. Check out bilibili Fork’s ffmpeg library for the supported version github.com/bilibili/FF…
IJK_FFMPEG_COMMIT = ff4.0 - ijk0.8.25-20200221-001Copy the code
Change the corresponding place to the version of your choice.
Obtain ffMPEG related files
[root@localhost] [root@localhost] [root@localhost] [root@localhost
./init-ios.sh
Copy the code
Configuring HTTPS
Skip this step if you don’t need HTTPS. Also edit the init-ios-openssl.sh file to configure the HTTPS version.
vi init-ios-openssl.s
Copy the code
As with upgrading FFMPEG, find the IJK_OPENSSL_COMMIT entry
IJK_OPENSSL_COMMIT=OpenSSL_1_0_2n
Copy the code
You can see that the default version is OpenSSL_1_0_2n, also github.com/bilibili/op… Select the version to be replaced. In this case, select the latest OpenSSL_1_0_2u version.
IJK_OPENSSL_COMMIT=OpenSSL_1_0_2u
Copy the code
Obtain HTTPS related files
# Be patient
./init-ios-openssl.sh
Copy the code
Edit the module.sh file
vi config/module.sh
Copy the code
Add at the end
# support HTTPS
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-openssl"
# ffmpeg4.0 need
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-bsf=eac3_core"
Copy the code
And comment out the following two items
#export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-ffserver"
#export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-vda"
Copy the code
Reference github.com/bilibili/ij…
Change the lowest supported version
Because ffMPEG 4.0 uses parts of the API that are iOS8.0 or higher, it is necessary to change the lowest supported version or compile FFMPEG with similar errors
libavcodec/videotoolbox.c:862:9: error: 'VTDecompressionSessionInvalidate'Newer [-werror, -wunguarded -availability] is only available on iOS 8.0 or newer [-wunguarded -availability] VTDecompressionSessionInvalidate(videotoolbox->session);Copy the code
Edit ios/tools/do – the compile – ffmpeg. Sh
vi ios/tools/do-compile-ffmpeg.sh
Copy the code
If version-min < 8.0, change to 8.0
if [ "$FF_ARCH" = "i386" ]; then
FF_BUILD_NAME="ffmpeg-i386"
FF_BUILD_NAME_OPENSSL=openssl-i386
FF_XCRUN_PLATFORM="iPhoneSimulator"
FF_XCRUN_OSVERSION="- the mios - simulator - version - min = 8.0"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_SIMULATOR"
elif [ "$FF_ARCH" = "x86_64" ]; then
FF_BUILD_NAME="ffmpeg-x86_64"
FF_BUILD_NAME_OPENSSL=openssl-x86_64
FF_XCRUN_PLATFORM="iPhoneSimulator"
FF_XCRUN_OSVERSION="- the mios - simulator - version - min = 8.0"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_SIMULATOR"
elif [ "$FF_ARCH" = "armv7" ]; then
FF_BUILD_NAME="ffmpeg-armv7"
FF_BUILD_NAME_OPENSSL=openssl-armv7
FF_XCRUN_OSVERSION="- miphoneos - version - min = 8.0"
FF_XCODE_BITCODE="-fembed-bitcode"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_ARM"
# FFMPEG_CFG_CPU="--cpu=cortex-a8"
elif [ "$FF_ARCH" = "armv7s" ]; then
FF_BUILD_NAME="ffmpeg-armv7s"
FF_BUILD_NAME_OPENSSL=openssl-armv7s
FFMPEG_CFG_CPU="--cpu=swift"
FF_XCRUN_OSVERSION="- miphoneos - version - min = 8.0"
FF_XCODE_BITCODE="-fembed-bitcode"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_ARM"
elif [ "$FF_ARCH" = "arm64" ]; then
FF_BUILD_NAME="ffmpeg-arm64"
FF_BUILD_NAME_OPENSSL=openssl-arm64
FF_XCRUN_OSVERSION="- miphoneos - version - min = 8.0"
FF_XCODE_BITCODE="-fembed-bitcode"
FFMPEG_CFG_FLAGS="$FFMPEG_CFG_FLAGS $FFMPEG_CFG_FLAGS_ARM"
FF_GASPP_EXPORT="GASPP_FIX_XCODE5=1"
else
echo "unknown architecture $FF_ARCH";
exit 1
fi
Copy the code
Do the same for the ios/tools/do-compile-openssl.sh file
vi ios/tools/do-compile-openssl.sh
Copy the code
if [ "$FF_ARCH" = "i386" ]; then
FF_BUILD_NAME="openssl-i386"
FF_XCRUN_PLATFORM="iPhoneSimulator"
FF_XCRUN_OSVERSION="- the mios - simulator - version - min = 8.0"
OPENSSL_CFG_FLAGS="darwin-i386-cc $OPENSSL_CFG_FLAGS"
elif [ "$FF_ARCH" = "x86_64" ]; then
FF_BUILD_NAME="openssl-x86_64"
FF_XCRUN_PLATFORM="iPhoneSimulator"
FF_XCRUN_OSVERSION="- the mios - simulator - version - min = 8.0"
OPENSSL_CFG_FLAGS="darwin64-x86_64-cc $OPENSSL_CFG_FLAGS"
elif [ "$FF_ARCH" = "armv7" ]; then
FF_BUILD_NAME="openssl-armv7"
FF_XCRUN_OSVERSION="- miphoneos - version - min = 8.0"
FF_XCODE_BITCODE="-fembed-bitcode"
OPENSSL_CFG_FLAGS="$OPENSSL_CFG_FLAGS_ARM $OPENSSL_CFG_FLAGS"
# OPENSSL_CFG_CPU="--cpu=cortex-a8"
elif [ "$FF_ARCH" = "armv7s" ]; then
FF_BUILD_NAME="openssl-armv7s"
OPENSSL_CFG_CPU="--cpu=swift"
FF_XCRUN_OSVERSION="- miphoneos - version - min = 8.0"
FF_XCODE_BITCODE="-fembed-bitcode"
OPENSSL_CFG_FLAGS="$OPENSSL_CFG_FLAGS_ARM $OPENSSL_CFG_FLAGS"
elif [ "$FF_ARCH" = "arm64" ]; then
FF_BUILD_NAME="openssl-arm64"
FF_XCRUN_OSVERSION="- miphoneos - version - min = 8.0"
FF_XCODE_BITCODE="-fembed-bitcode"
OPENSSL_CFG_FLAGS="$OPENSSL_CFG_FLAGS_ARM $OPENSSL_CFG_FLAGS"
FF_GASPP_EXPORT="GASPP_FIX_XCODE5=1"
else
echo "unknown architecture $FF_ARCH";
exit 1
fi
Copy the code
Remove armv7
The use of Xcode11.4 packaging has weakened 32-bit support, so armv7 needs to be removed. If you want to support ARMV7, use the lower version Xcode package. Edit the ios/compile-ffmpeg.sh file
vi ios/compile-ffmpeg.sh
Copy the code
Find FF_ALL_ARCHS_IOS8_SDK=”armv7 arm64 i386 x86_64″ and change it to FF_ALL_ARCHS_IOS8_SDK=”arm64 i386 x86_64″. Otherwise, an error may occur.
./libavutil/arm/asm.S:50:9: error: unknown directive
.arch armv7-a
^
make: *** [libavcodec/arm/aacpsdsp_neon.o] Error 1
Copy the code
libswresample/arm/audio_convert_neon.S:25:1: error: invalid symbol redefinition
_swri_oldapi_conv_flt_to_s16_neon:
^
libswresample/arm/audio_convert_neon.S:70:1: error: invalid symbol redefinition
_swri_oldapi_conv_fltp_to_s16_2ch_neon:
^
make: *** [libswresample/arm/audio_convert_neon.o] Error 1
make: *** Waiting for unfinished jobs....
Copy the code
compile
cd ios
Build OpenSSL first, skip if you don't need to support HTTPS
./compile-openssl.sh all
# compiler ffmpeg
./compile-ffmpeg.sh all
Copy the code
packaging
Open the IJKMediaPlayer xcodeproj
open IJKMediaPlayer/IJKMediaPlayer.xcodeproj
Copy the code
Add the openssl
Skip this step if you do not need to support HTTPS.
Configuring the packaged Version
Since we have previously set the compiled version to 8.0 support minimum, it is best to set the packaged version to 8.0 support minimum as well.
Real machine package
Edit scheme
Simulator package
Choose any emulator version
Press Command + B on the keyboard to pack.
merge
In fact, the combined package can be used on either a real machine or an emulator, but it will be twice the size. This is self-selecting.
cd /Users/LSW/Library/Developer/Xcode/DerivedData/IJKMediaPlayer-hdieucicuskakgftfkjtnzhnbsme/Build/Products
Copy the code
Merge by command
lipo -create Release-iphoneos/IJKMediaFramework.framework/IJKMediaFramework Release-iphonesimulator/IJKMediaFramework.framework/IJKMediaFramework -output IJKMediaFramework
Copy the code
conclusion
The above is the complete process of packaging before me, as for how to import in this will not mention, there are many articles on the Internet. I hope I can help the students who need to pack, please point out any questions directly.