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