xamarin.formsffmpegxamarin.ioslibvlcsharpmobile-ffmpeg

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


I am adding video stream capture functionality to a Xamarin Forms project. I am trying to use VLC's 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). However, the internal ffmpeg library from VLC is conflicting with the ffmpeg wrapper and is built with different flags which exclude functionality that I need.

For native development, it looks like you can configure a preferred library with the OTHER_LDFLAGS flag in the Pods-<Your App>.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

How can I configure Xamarin iOS builds to prefer the mobile ffmpeg library over the VLC ffmpeg library? If I am able to use the mobile ffmpeg library, will it cause issues with VLC?

Here is a log message when I try to run commands with ffmpeg. As you can see, ffmpeg's internal library paths reference "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

Solution

  • The solution is in one of the link you shared

    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 is still native development, so you can do this the same way a Swift iOS developer would.