I have noticed that when I use Command Line Tool 14.3, Xcode 14.3, and FFmpeg 4.4, Xcode executes the wrong branch of the if code, even though the expression in the if statement is "false." However, when I use Xcode 13.4 and Command Line Tools 13.4, everything works fine. Moreover, this issue only occurs in the release build, not in the debug build.
I compiled FFmpeg 4.4 using the following script: ios-ffmpeg-build.sh
The reproduction path is to play a video in mpegts format and there will be a crash during the seek operation when video status is playing, staying at ff_ Seek_ Frame_ In binary. Even if you do st ->index_ Whether entries are null and the result is false. The content of the if branch was still executed
the video link is : https://sdk-release.qnsdk.com/animal_ts.ts
the ios-ffmpeg-build.sh content is :
#!/bin/sh
SHELL_PATH=pwd
#FFpmeg文件/文件夹名称
SRC_NAME="qplayer-ffmpeg"
SRC_PATH="$SHELL_PATH/$SRC_NAME"
#编译的平台
ARCHS="arm64 x86_64"
ARCHS="arm64"
#输出路径 PREFIX="$SHELL_PATH/libs/ios/qplayer-ffmpeg" SRC_BUILD="$SRC_PATH/ios-build"
#需要编译的平台 BUILD_ARCH="all" #最低触发的版本 DEPLOYMENT_TARGET="11.0" #需要编译的第三方库 BUILD_THIRD_LIB="all"
CONFIGURE_FLAGS="--enable-static
--disable-shared
--enable-small
--disable-everything
--disable-ffplay
--disable-ffmpeg
--disable-ffprobe
--disable-avfilter
--disable-avdevice
--disable-nonfree
--enable-swscale
--disable-avfilter
--disable-encoders \
--enable-protocol=crypto
--enable-protocol=http
--enable-protocol=https
--enable-protocol=rtmp
--enable-protocol=tcp
--enable-protocol=file \
--enable-decoder=h264
--enable-decoder=hevc
--enable-decoder=mpeg4
--enable-decoder=aac
--enable-decoder=mp3
--enable-decoder=flac
--enable-decoder=pcm_s24le \
--enable-demuxer=h264
--enable-demuxer=hevc
--enable-demuxer=mov
--enable-demuxer=mp3
--enable-demuxer=mp4
--enable-demuxer=mpegts
--enable-demuxer=hls
--enable-demuxer=flv
--enable-demuxer=aac
--enable-demuxer=mpegvideo
--enable-demuxer=wav
--enable-demuxer=pcm_s24le
--enable-demuxer=flac \
--enable-parser=aac
--enable-parser=aac_latm
--enable-parser=mpegaudio
--enable-parser=flac
--enable-parser=hevc
--enable-parser=h264 \
--enable-bsfs
--disable-bsf=chomp
--disable-bsf=dca_core
--disable-bsf=dump_extradata
--disable-bsf=hevc_mp4toannexb
--disable-bsf=imx_dump_header
--disable-bsf=mjpeg2jpeg
--disable-bsf=mjpega_dump_header
--disable-bsf=mov2textsub
--disable-bsf=mp3_header_decompress
--disable-bsf=mpeg4_unpack_bframes
--disable-bsf=noise
--disable-bsf=remove_extradata
--disable-bsf=text2movsub
--disable-bsf=vp9_superframe \
--disable-asm
--disable-stripping
--disable-optimizations
--enable-cross-compile
--disable-debug \
--enable-hwaccel=h264_videotoolbox
--enable-hwaccel=hevc_videotoolbox"
if [ ! "$BUILD_ARCH" ] then BUILD_ARCH="all" fi
if [ ! "$DEPLOYMENT_TARGET" ] then DEPLOYMENT_TARGET="10.0" fi
if [ ! "$BUILD_THIRD_LIB" ] then BUILD_THIRD_LIB="all" fi
#依赖openssl OPENSSL=$SHELL_PATH/libs/ios/qplayer-openssl CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-openssl"
#是否依赖srt if [ "$BUILD_THIRD_LIB" = "srt" ] || [ "$BUILD_THIRD_LIB" = "all" ] then SRTPATH=$SHELL_PATH/libs/ios/qplayer-srt CONFIGURE_FLAGS="$CONFIGURE_FLAGS --enable-libsrt --enable-protocol=libsrt" fi
#检测并安装yasm
if [ ! which yasm
]
then
echo 'Yasm not found'
if [ ! which brew
]
then
echo 'Homebrew not found. Trying to install...'
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
|| exit 1
fi
echo 'Trying to install Yasm...'
brew install yasm || exit 1
fi
#检测并安装gas-preprocessor.pl
if [ ! which gas-preprocessor.pl
]
then
echo 'gas-preprocessor.pl not found. Trying to install...'
(curl -L https://github.com/libav/gas-preprocessor/raw/master/gas-preprocessor.pl
-o /usr/local/bin/gas-preprocessor.pl
&& chmod +x /usr/local/bin/gas-preprocessor.pl)
|| exit 1
fi
rm -rf "$PREFIX" "$SRC_BUILD"
#开始编译 for ARCH in $ARCHS do if [ "$BUILD_ARCH" = "all" -o "$BUILD_ARCH" = "$ARCH" ] then echo "building $ARCH..." mkdir -p "$SRC_BUILD/$ARCH" cd "$SRC_BUILD/$ARCH"
CFLAGS="-arch $ARCH"
if [ "$ARCH" = "i386" -o "$ARCH" = "x86_64" ]
then
PLATFORM="iPhoneSimulator"
CFLAGS="$CFLAGS -mios-simulator-version-min=$DEPLOYMENT_TARGET"
else
PLATFORM="iPhoneOS"
CFLAGS="$CFLAGS -mios-version-min=$DEPLOYMENT_TARGET -fembed-bitcode"
if [ "$ARCH" = "arm64" ]
then
EXPORT="GASPP_FIX_XCODE5=1"
fi
fi
XCRUN_SDK=`echo $PLATFORM | tr '[:upper:]' '[:lower:]'`
CC="xcrun -sdk $XCRUN_SDK clang"
if [ "$ARCH" = "arm64" ]
then
AS="gas-preprocessor.pl -arch aarch64 -- $CC"
else
AS="gas-preprocessor.pl -- $CC"
fi
LDFLAGS="$CFLAGS"
CXXFLAGS="$CFLAGS"
if [ "$OPENSSL" ]
then
CFLAGS="$CFLAGS -I$OPENSSL/include"
LDFLAGS="$LDFLAGS -L$OPENSSL/lib"
fi
if [ "$SRTPATH" ]
then
CFLAGS="$CFLAGS -I$SRTPATH/include"
LDFLAGS="$LDFLAGS -L$SRTPATH/lib"
fi
echo CC=$CC
echo CFLAGS="$CFLAGS"
echo LDFLAGS="$LDFLAGS"
TMPDIR=${TMPDIR/%\/} $SRC_PATH/configure \
--target-os=darwin \
--arch=$ARCH \
--cc="$CC" \
$CONFIGURE_FLAGS \
--extra-cflags="$CFLAGS" \
--extra-cxxflags="$CFLAGS" \
--extra-ldflags="$LDFLAGS" \
--prefix="$SRC_BUILD/$ARCH" \
|| exit 1
make -j3 install $EXPORT || exit 1
if [ "$ARCH" = "arm64" ]
then
cp -f libavcodec/bsf_list.c libavcodec/codec_list.c libavcodec/parser_list.c ../../libavcodec/
cp -f libavformat/demuxer_list.c libavformat/muxer_list.c libavformat/protocol_list.c ../../libavformat/
cp -f libavutil/avconfig.h libavutil/ffversion.h ../../libavutil/
fi
make distclean
fi
done
echo "building lipo ffmpeg lib binaries..."
mkdir -p $PREFIX/lib
set - $ARCHS
cd $SRC_BUILD/$1/lib
for LIB in *.a
do
cd $SHELL_PATH
lipo -create find $SRC_BUILD -name $LIB
-output $PREFIX/lib/$LIB || exit 1
done
chmod -R ug+w $PREFIX
cd $SHELL_PATH cp -rf $SRC_BUILD/$1/include $PREFIX rm -rf $SRC_BUILD echo "building lipo ffmpeg lib binaries successed"