[MacOS] AVPixelFormat crash
Describe the bug I noticed a few crashes on MacOS related to AVPixelFormat. All MacOS versions are impacted and I'm using fvp 0.28.0 and mdk 0.3.0 with Flutter 3.24.3
Expected behavior The app should not crash
Log I can't reproduce on my Mac so I can share with you the Crashlytics stacktrace:
Crash : mdk.vdec0@0x700004c26000
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000000
Crashed: mdk.vdec0@0x700004c26000
0 mdk 0xb3712 mdk::abi::ffmpeg::to(mdk::abi::VideoFormat&, AVPixelFormat) + 1724 (__hash_table:1724)
1 mdk 0xb65a1 mdk::abi::ffmpeg::to(mdk::abi::VideoFrame&, AVFrame const*, AVRational const&) + 173 (VideoFrameGlue.cpp:173)
2 mdk 0xc3486 mdk::abi::VideoDecoderFFmpegBase::from(AVFrame*) + 167 (VideoDecoderFFmpegBase.cpp:167)
3 mdk 0xc3c59 mdk::abi::VideoDecoderAVCodec::from(AVFrame*) + 379 (VideoDecoderAVCodec.cpp:379)
4 mdk 0xc3549 std::__1::__function::__func<mdk::abi::VideoDecoderFFmpegBase::decode(mdk::abi::Packet const&)::$_3, std::__1::allocator<mdk::abi::VideoDecoderFFmpegBase::decode(mdk::abi::Packet const&)::$_3>, double (AVFrame*)>::operator()(AVFrame*&&) + 60 (VideoFrame.h:60)
5 mdk 0xbf70c mdk::abi::AVCoderBase::decodePacket(AVCodecContext*, mdk::abi::Packet const&, std::__1::function<double (AVFrame*)>&&) + 139 (AVCoderBase.cpp:139)
6 mdk 0xc340e mdk::abi::VideoDecoderFFmpegBase::decode(mdk::abi::Packet const&) + 138 (VideoDecoderFFmpegBase.cpp:138)
7 mdk 0x22cdd bool mdk::abi::FrameReaderImpl::decodeLoop<(mdk::abi::MediaType)0>(int, int) + 2500 (FrameReader.cpp:2500)
8 mdk 0x1dfd2 void* std::__1::__thread_proxy[abi:nn180100]<std::__1::tuple<std::__1::unique_ptr<std::__1::__thread_struct, std::__1::default_delete<std::__1::__thread_struct>>, mdk::abi::FrameReaderImpl::startDecodeThread(mdk::abi::FrameReaderImpl::DecLoopState&, mdk::abi::MediaType, int)::$_0>>(void*) + 2732 (FrameReader.cpp:2732)
9 libsystem_pthread.dylib 0x64e1 _pthread_start + 125
10 libsystem_pthread.dylib 0x1f6b thread_start + 15
when does it crash? what decoders do you set? a log will be helpful
Unfortunately, I have no idea when it's happening as I didn't add enough tracking information. I will add more in the future! I'm not setting any decoder so it's probably using the default ones. Also, I'm using the Backend Player API.
if you are using backend api, then software decoder is used, less efficient. you have to set via player videoDecoders, see video_player_mdk.dart
Ah ok good to know, I'll make the changes. Actually, the only reason why I'm using the backend API is because in the past it was not possible to control tracks. I'll check if thanks to your latest additions I can move to VideoPlayerPlatform implementation.
now you can use videoplayercintroller with extensions, see controller.dart