diff --git a/src/Extension/Factory.cpp b/src/Extension/Factory.cpp index 57d67132..b332db6c 100644 --- a/src/Extension/Factory.cpp +++ b/src/Extension/Factory.cpp @@ -178,8 +178,9 @@ RtmpCodec::Ptr Factory::getRtmpDecoderByTrack(const Track::Ptr &track) { RtmpCodec::Ptr Factory::getRtmpEncoderByTrack(const Track::Ptr &track) { auto it = s_plugins.find(track->getCodecId()); if (it == s_plugins.end()) { - WarnL << "Unsupported codec: " << track->getCodecName() << ", use CommonRtmpEncoder"; - return std::make_shared(track); + auto amf = Factory::getAmfByCodecId(track->getCodecId()); + WarnL << "Unsupported codec: " << track->getCodecName() << (amf ? ", use CommonRtmpEncoder" : ""); + return amf ? std::make_shared(track) : nullptr; } return it->second->getRtmpEncoderByTrack(track); }