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