481763
diff -up firefox-99.0/dom/media/mp4/MP4Demuxer.cpp.1670333 firefox-99.0/dom/media/mp4/MP4Demuxer.cpp
481763
--- firefox-99.0/dom/media/mp4/MP4Demuxer.cpp.1670333	2022-03-31 01:24:44.000000000 +0200
481763
+++ firefox-99.0/dom/media/mp4/MP4Demuxer.cpp	2022-04-04 09:58:35.606351546 +0200
481763
@@ -31,6 +31,8 @@ mozilla::LogModule* GetDemuxerLog() { re
481763
   DDMOZ_LOG(gMediaDemuxerLog, mozilla::LogLevel::Debug, "::%s: " arg, \
481763
             __func__, ##__VA_ARGS__)
481763
 
481763
+extern bool gUseKeyframeFromContainer;
481763
+
481763
 namespace mozilla {
481763
 
481763
 DDLoggedTypeDeclNameAndBase(MP4TrackDemuxer, MediaTrackDemuxer);
481763
@@ -394,6 +396,12 @@ already_AddRefed<MediaRawData> MP4TrackD
481763
           [[fallthrough]];
481763
         case H264::FrameType::OTHER: {
481763
           bool keyframe = type == H264::FrameType::I_FRAME;
481763
+          if (gUseKeyframeFromContainer) {
481763
+            if (sample->mKeyframe && sample->mKeyframe != keyframe) {
481763
+              sample->mKeyframe = keyframe;
481763
+            }
481763
+            break;
481763
+          }
481763
           if (sample->mKeyframe != keyframe) {
481763
             NS_WARNING(nsPrintfCString("Frame incorrectly marked as %skeyframe "
481763
                                        "@ pts:%" PRId64 " dur:%" PRId64
481763
diff -up firefox-99.0/dom/media/platforms/PDMFactory.cpp.1670333 firefox-99.0/dom/media/platforms/PDMFactory.cpp
481763
--- firefox-99.0/dom/media/platforms/PDMFactory.cpp.1670333	2022-03-31 01:24:44.000000000 +0200
481763
+++ firefox-99.0/dom/media/platforms/PDMFactory.cpp	2022-04-04 10:09:57.383419125 +0200
481763
@@ -58,6 +58,8 @@
481763
 
481763
 #include <functional>
481763
 
481763
+bool gUseKeyframeFromContainer = false;
481763
+
481763
 namespace mozilla {
481763
 
481763
 #define PDM_INIT_LOG(msg, ...) \
481763
@@ -495,7 +497,7 @@ void PDMFactory::CreateRddPDMs() {
481763
 #ifdef MOZ_FFMPEG
481763
   if (StaticPrefs::media_ffmpeg_enabled() &&
481763
       StaticPrefs::media_rdd_ffmpeg_enabled() &&
481763
-      !CreateAndStartupPDM<FFmpegRuntimeLinker>()) {
481763
+      !(mFFmpegUsed = CreateAndStartupPDM<FFmpegRuntimeLinker>())) {
481763
     mFailureFlags += GetFailureFlagBasedOnFFmpegStatus(
481763
         FFmpegRuntimeLinker::LinkStatusCode());
481763
   }
481763
@@ -602,8 +604,9 @@ void PDMFactory::CreateDefaultPDMs() {
481763
 
481763
   CreateAndStartupPDM<AgnosticDecoderModule>();
481763
 
481763
-  if (StaticPrefs::media_gmp_decoder_enabled() &&
481763
+  if (StaticPrefs::media_gmp_decoder_enabled() && !mFFmpegUsed &&
481763
       !CreateAndStartupPDM<GMPDecoderModule>()) {
481763
+    gUseKeyframeFromContainer = true;
481763
     mFailureFlags += DecoderDoctorDiagnostics::Flags::GMPPDMFailedToStartup;
481763
   }
481763
 }
481763
diff -up firefox-99.0/dom/media/platforms/PDMFactory.h.1670333 firefox-99.0/dom/media/platforms/PDMFactory.h
481763
--- firefox-99.0/dom/media/platforms/PDMFactory.h.1670333	2022-03-31 01:24:44.000000000 +0200
481763
+++ firefox-99.0/dom/media/platforms/PDMFactory.h	2022-04-04 09:58:35.606351546 +0200
481763
@@ -121,6 +121,7 @@ class PDMFactory final {
481763
   RefPtr<PlatformDecoderModule> mNullPDM;
481763
 
481763
   DecoderDoctorDiagnostics::FlagsSet mFailureFlags;
481763
+  bool mFFmpegUsed = false;
481763
 
481763
   friend class RemoteVideoDecoderParent;
481763
   static void EnsureInit();