无法在 Xamarin.Forms 项目中同时使用 Mobile FFmpeg 和 LibVLCSharp

Cannot use Mobile FFmpeg and LibVLCSharp together in Xamarin.Forms project

我正在向 Xamarin Forms 项目添加视频流捕获功能。我正在尝试使用 VLC 的 LibVLCSharp.Forms (https://github.com/videolan/libvlcsharp) package and the Mobile ffmpeg Xamarin wrapper package, Laerdal.Xamarin.FFmpeg.* (https://github.com/Laerdal/Laerdal.Xamarin.FFmpeg.iOS)。但是,VLC 的内部 ffmpeg 库与 ffmpeg 包装器冲突,并且使用不同的标志构建,这些标志排除了我需要的功能。

对于本机开发,您似乎可以在 Pods-<Your App>.debug.xcconfig 文件中使用 OTHER_LDFLAGS 标志配置首选库,但我看不到在哪里可以使用 Xamarin.Forms . 资料来源:https://github.com/tanersener/mobile-ffmpeg/wiki/Using-Multiple-FFmpeg-Implementations-In-The-Same-iOS-Application

如何配置 Xamarin iOS 构建以优先使用移动 ffmpeg 库而不是 VLC ffmpeg 库?如果我能够使用移动 ffmpeg 库,它会导致 VLC 出现问题吗?

这是我尝试使用 ffmpeg 运行 命令时的日志消息。如您所见,ffmpeg 的内部库路径引用 "vlc":

FFmpegExecute: Command: -vsync 1 -i 'rtsp://wowzaec2demo.streamlock.net/vod/mp4:bigbuckbunny_115k.mov' -force_key_frames "expr: gte(t, n_forced * 2)" -strict experimental -f segment -segment_time 00:00:02 -segment_start_number 0 -reset_timestamps 1 -c:v copy -c:a copy '[path to temp]/tmp/VideoStream/%01d-record-temp.mp4'
Loaded mobile-ffmpeg-full-gpl-x86_64-4.4-lts-20200725
INFO: ffmpeg version v4.4-dev-416
INFO:  Copyright (c) 2000-2020 the FFmpeg developers
INFO:
INFO:   built with Apple LLVM version 7.3.0 (clang-703.0.31)
INFO:   configuration: --sysroot=/Applications/Xcode-v7.3.1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk --prefix=/Users/taner/Projects/mobile-ffmpeg/prebuilt/ios-x86_64/ffmpeg --enable-version3 --arch=x86_64 --cpu=x86_64 --target-os=darwin --ar=/Applications/Xcode-v7.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar --cc=clang --cxx=clang++ --as='clang -arch x86_64 -target x86_64-ios-darwin -march=x86-64 -msse4.2 -mpopcnt -m64 -mtune=intel -DMOBILE_FFMPEG_X86_64 -Wno-unused-function -Wno-deprecated-declarations -fstrict-aliasing -DIOS -DMOBILE_FFMPEG_LTS -DMOBILE_FFMPEG_BUILD_DATE=20200725 -isysroot /Applications/Xcode-v7.3.1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk -O2 -mios-simulator-version-min=9.3 -I/Applications/Xcode-v7.3.1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.3.sdk/usr/include' --ranlib=/Applications/Xcode-v7.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib --strip=/Applications/Xcode-v7.3.1.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/strip --disable-neon --enable-cross-compile --enable-pic --disable-asm --enable-inline-asm --enable-optimizations --enable-swscale --enable-static --disable-shared --enable-small --disable-v4l2-m2m --disable-outdev=v4l2 --disable-outdev=fbdev --disable-outdev=audiotoolbox --disable-indev=v4l2 --disable-indev=fbdev --disable-openssl --disable-xmm-clobber-test --disable-debug --disable-neon-clobber-test --disable-programs --disable-postproc --disable-doc --disable-htmlpages --disable-manpages --disable-podpages --disable-txtpages --disable-sndio --disable-schannel --disable-securetransport --disable-xlib --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --disable-appkit --disable-alsa --disable-cuda --disable-cuvid --disable-nvenc --disable-vaapi --disable-vdpau --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libwavpack --enable-libkvazaar --enable-libx264 --enable-gpl --enable-libxvid --enable-gpl --enable-libx265 --enable-gpl --enable-libvidstab --enable-gpl --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libaom --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-zlib --enable-audiotoolbox --enable-bzlib --enable-videotoolbox --disable-avfoundation --enable-iconv --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libwavpack --enable-libkvazaar --enable-libx264 --enable-gpl --enable-libxvid --enable-gpl --enable-libx265 --enable-gpl --enable-libvidstab --enable-gpl --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libaom --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-zlib --enable-audiotoolbox --enable-bzlib --enable-videotoolbox --disable-avfoundation --enable-iconv --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libwavpack --enable-libkvazaar --enable-libx264 --enable-gpl --enable-libxvid --enable-gpl --enable-libx265 --enable-gpl --enable-libvidstab --enable-gpl --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libaom --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-zlib --enable-audiotoolbox --enable-bzlib --enable-videotoolbox --disable-avfoundation --enable-iconv --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-gmp --enable-gnutls --enable-libmp3lame --enable-libass --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxml2 --enable-libopencore-amrnb --enable-libshine --enable-libspeex --enable-libwavpack --enable-libkvazaar --enable-libx264 --enable-gpl --enable-libxvid --enable-gpl --enable-libx265 --enable-gpl --enable-libvidstab --enable-gpl --enable-libilbc --enable-libopus --enable-libsnappy --enable-libsoxr --enable-libaom --enable-libtwolame --disable-sdl2 --enable-libvo-amrwbenc --enable-zlib --enable-audiotoolbox --enable-bzlib --enable-videotoolbox --disable-avfoundation --enable-iconv
INFO:   WARNING: library configuration mismatch
INFO:   avutil      configuration: --extra-ldflags='-arch x86_64 -v -Wl,-ios_simulator_version_min,8.4 -L/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64/lib -Wl,-ios_simulator_version_min,8.4' --cc=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --pkg-config=pkg-config --disable-doc --disable-encoder=vorbis --disable-decoder=opus --enable-libgsm --disable-decoder=mlp --disable-demuxer=mlp --disable-parser=mlp --disable-debug --disable-avdevice --disable-devices --disable-avfilter --disable-filters --disable-protocol=concat --disable-bsfs --disable-bzlib --disable-libvpx --disable-avresample --enable-bsf=vp9_superframe --disable-swresample --disable-iconv --disable-avisynth --disable-nvenc --disable-linux-perf --disable-securetransport --enable-libopenjpeg --enable-libmp3lame --enable-cross-compile --disable-programs --arch=x86_64 --target-os=darwin --disable-lzma --cpu=core2 --enable-pic --extra-ldflags='-arch x86_64 -miphoneos-version-min=8.4 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk -arch x86_64 -O3 -g -miphoneos-version-min=8.4 -arch x86_64 -miphoneos-version-min=8.4 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk -arch x86_64 -O3 -g -miphoneos-version-min=8.4 -I/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64/include -g -O2 -I/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64/include' --enable-pthreads --nm= --ar=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar --prefix=/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64 --enable-static --disable-shared
INFO:   avcodec     configuration: --extra-ldflags='-arch x86_64 -v -Wl,-ios_simulator_version_min,8.4 -L/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64/lib -Wl,-ios_simulator_version_min,8.4' --cc=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --pkg-config=pkg-config --disable-doc --disable-encoder=vorbis --disable-decoder=opus --enable-libgsm --disable-decoder=mlp --disable-demuxer=mlp --disable-parser=mlp --disable-debug --disable-avdevice --disable-devices --disable-avfilter --disable-filters --disable-protocol=concat --disable-bsfs --disable-bzlib --disable-libvpx --disable-avresample --enable-bsf=vp9_superframe --disable-swresample --disable-iconv --disable-avisynth --disable-nvenc --disable-linux-perf --disable-securetransport --enable-libopenjpeg --enable-libmp3lame --enable-cross-compile --disable-programs --arch=x86_64 --target-os=darwin --disable-lzma --cpu=core2 --enable-pic --extra-ldflags='-arch x86_64 -miphoneos-version-min=8.4 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk -arch x86_64 -O3 -g -miphoneos-version-min=8.4 -arch x86_64 -miphoneos-version-min=8.4 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk -arch x86_64 -O3 -g -miphoneos-version-min=8.4 -I/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64/include -g -O2 -I/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64/include' --enable-pthreads --nm= --ar=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar --prefix=/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64 --enable-static --disable-shared
INFO:   avformat    configuration: --extra-ldflags='-arch x86_64 -v -Wl,-ios_simulator_version_min,8.4 -L/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64/lib -Wl,-ios_simulator_version_min,8.4' --cc=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --pkg-config=pkg-config --disable-doc --disable-encoder=vorbis --disable-decoder=opus --enable-libgsm --disable-decoder=mlp --disable-demuxer=mlp --disable-parser=mlp --disable-debug --disable-avdevice --disable-devices --disable-avfilter --disable-filters --disable-protocol=concat --disable-bsfs --disable-bzlib --disable-libvpx --disable-avresample --enable-bsf=vp9_superframe --disable-swresample --disable-iconv --disable-avisynth --disable-nvenc --disable-linux-perf --disable-securetransport --enable-libopenjpeg --enable-libmp3lame --enable-cross-compile --disable-programs --arch=x86_64 --target-os=darwin --disable-lzma --cpu=core2 --enable-pic --extra-ldflags='-arch x86_64 -miphoneos-version-min=8.4 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk -arch x86_64 -O3 -g -miphoneos-version-min=8.4 -arch x86_64 -miphoneos-version-min=8.4 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk -arch x86_64 -O3 -g -miphoneos-version-min=8.4 -I/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64/include -g -O2 -I/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64/include' --enable-pthreads --nm= --ar=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar --prefix=/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64 --enable-static --disable-shared
INFO:   swscale     configuration: --extra-ldflags='-arch x86_64 -v -Wl,-ios_simulator_version_min,8.4 -L/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64/lib -Wl,-ios_simulator_version_min,8.4' --cc=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang --pkg-config=pkg-config --disable-doc --disable-encoder=vorbis --disable-decoder=opus --enable-libgsm --disable-decoder=mlp --disable-demuxer=mlp --disable-parser=mlp --disable-debug --disable-avdevice --disable-devices --disable-avfilter --disable-filters --disable-protocol=concat --disable-bsfs --disable-bzlib --disable-libvpx --disable-avresample --enable-bsf=vp9_superframe --disable-swresample --disable-iconv --disable-avisynth --disable-nvenc --disable-linux-perf --disable-securetransport --enable-libopenjpeg --enable-libmp3lame --enable-cross-compile --disable-programs --arch=x86_64 --target-os=darwin --disable-lzma --cpu=core2 --enable-pic --extra-ldflags='-arch x86_64 -miphoneos-version-min=8.4 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk -arch x86_64 -O3 -g -miphoneos-version-min=8.4 -arch x86_64 -miphoneos-version-min=8.4 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator13.2.sdk -arch x86_64 -O3 -g -miphoneos-version-min=8.4 -I/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64/include -g -O2 -I/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64/include' --enable-pthreads --nm= --ar=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ar --prefix=/Users/Martz/Projects/vlckit/libvlc/vlc/contrib/iPhone-x86_64-apple-darwin14-x86_64 --enable-static --disable-shared
INFO:   libavutil      56. 55.100 / 56.  5.100
INFO:   libavcodec     58. 96.100 / 58.  6.103
INFO:   libavformat    58. 48.100 / 58.  3.100
INFO:   libavdevice    58. 11.101 / 58. 11.101
INFO:   libavfilter     7. 87.100 /  7. 87.100
INFO:   libswscale      5.  8.100 /  5.  0.101
INFO:   libswresample   3.  8.100 /  3.  8.100
ERROR: Unrecognized option 'segment_time'.
FATAL: Error splitting the argument list:
FATAL: Option not found

解决方案在您分享的 link 之一中

For native development, it looks like you can configure a preferred library with the OTHER_LDFLAGS flag in the Pods-.debug.xcconfig file but I don't see where to do that with Xamarin.Forms. Source: https://github.com/tanersener/mobile-ffmpeg/wiki/Using-Multiple-FFmpeg-Implementations-In-The-Same-iOS-Application

Xamarin.Forms 仍然是 原生开发,因此您可以像 Swift iOS 开发人员那样做。

  • 您需要在 XCode(不是共享项目)中打开本机 iOS 应用程序项目。
  • 创建一个 xcconfig 文件。 This guide 看起来不错,屏幕截图可以帮助您导航 XCode。
  • xcconfig 看起来像 this。您想将 mobile-ffmpeg 框架放在 mobilevlckit 框架之前。
  • Xamarin.iOS 可能也需要一些框架,所以在这之前我会在详细诊断模式下构建您的应用程序以查看当前 OTHER_LDFLAGS 值是什么。