812674
diff -up firefox-115.0/dom/media/mp4/MP4Demuxer.cpp.1670333 firefox-115.0/dom/media/mp4/MP4Demuxer.cpp
812674
--- firefox-115.0/dom/media/mp4/MP4Demuxer.cpp.1670333	2023-06-06 23:14:43.000000000 +0200
812674
+++ firefox-115.0/dom/media/mp4/MP4Demuxer.cpp	2023-06-08 08:15:48.214109403 +0200
812674
@@ -32,6 +32,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
 
812674
 using TimeUnit = media::TimeUnit;
812674
@@ -404,6 +406,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
812674
diff -up firefox-115.0/dom/media/platforms/PDMFactory.cpp.1670333 firefox-115.0/dom/media/platforms/PDMFactory.cpp
812674
--- firefox-115.0/dom/media/platforms/PDMFactory.cpp.1670333	2023-06-06 23:14:44.000000000 +0200
812674
+++ firefox-115.0/dom/media/platforms/PDMFactory.cpp	2023-06-08 08:09:33.145289602 +0200
812674
@@ -67,6 +67,8 @@
481763
 
481763
 #include <functional>
481763
 
481763
+bool gUseKeyframeFromContainer = false;
481763
+
812674
 using DecodeSupport = mozilla::media::DecodeSupport;
812674
 using DecodeSupportSet = mozilla::media::DecodeSupportSet;
812674
 using MediaCodec = mozilla::media::MediaCodec;
812674
@@ -562,7 +564,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
   }
812674
@@ -738,9 +740,10 @@ void PDMFactory::CreateDefaultPDMs() {
481763
 
481763
   CreateAndStartupPDM<AgnosticDecoderModule>();
481763
 
481763
-  if (StaticPrefs::media_gmp_decoder_enabled() &&
481763
+  if (StaticPrefs::media_gmp_decoder_enabled() && !mFFmpegUsed &&
812674
       !StartupPDM(GMPDecoderModule::Create(),
812674
                   StaticPrefs::media_gmp_decoder_preferred())) {
481763
+    gUseKeyframeFromContainer = true;
481763
     mFailureFlags += DecoderDoctorDiagnostics::Flags::GMPPDMFailedToStartup;
481763
   }
481763
 }
812674
diff -up firefox-115.0/dom/media/platforms/PDMFactory.h.1670333 firefox-115.0/dom/media/platforms/PDMFactory.h
812674
--- firefox-115.0/dom/media/platforms/PDMFactory.h.1670333	2023-06-06 23:14:42.000000000 +0200
812674
+++ firefox-115.0/dom/media/platforms/PDMFactory.h	2023-06-08 08:09:33.145289602 +0200
812674
@@ -103,6 +103,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();