浏览代码

UI: Support PCM in MP4

derrod 2 年之前
父节点
当前提交
ef3a67708e
共有 2 个文件被更改,包括 17 次插入7 次删除
  1. 5 4
      UI/window-basic-main.cpp
  2. 12 3
      UI/window-basic-settings.cpp

+ 5 - 4
UI/window-basic-main.cpp

@@ -7510,16 +7510,17 @@ void OBSBasic::AutoRemux(QString input, bool no_show)
 	const char *format = config_get_string(
 		config, isSimpleMode ? "SimpleOutput" : "AdvOut", "RecFormat2");
 
-	/* AV1+PCM cannot be remuxed into any supported format (until FFmpeg 6.1) */
-	if (strcmp(vCodecName, "av1") == 0 &&
-	    strncmp(aCodecName, "pcm", 3) == 0)
+	bool audio_is_pcm = strncmp(aCodecName, "pcm", 3) == 0;
+	/* FFmpeg <= 6.0 cannot remux AV1+PCM into any supported format. */
+	if (audio_is_pcm && !ff_supports_pcm_in_mp4() &&
+	    strcmp(vCodecName, "av1") == 0)
 		return;
 
 	/* Retain original container for fMP4/fMOV */
 	if (strncmp(format, "fragmented", 10) == 0) {
 		output += "remuxed." + suffix;
 	} else if (strcmp(vCodecName, "prores") == 0 ||
-		   strncmp(aCodecName, "pcm", 3) == 0) {
+		   (audio_is_pcm && !ff_supports_pcm_in_mp4())) {
 		output += "mov";
 	} else {
 		output += "mp4";

+ 12 - 3
UI/window-basic-settings.cpp

@@ -4996,15 +4996,18 @@ static const unordered_map<string, unordered_set<string>> codec_compat = {
 	{"mpegts", {"h264", "hevc", "aac", "opus"}},
 	{"hls",
 	 {"h264", "hevc", "aac"}}, // Also using MPEG-TS, but no Opus support
+	{"mp4",
+	 {"h264", "hevc", "av1", "aac", "opus", "alac", "flac", "pcm_s16le",
+	  "pcm_s24le", "pcm_f32le"}},
+	{"fragmented_mp4",
+	 {"h264", "hevc", "av1", "aac", "opus", "alac", "flac", "pcm_s16le",
+	  "pcm_s24le", "pcm_f32le"}},
 	{"mov",
 	 {"h264", "hevc", "prores", "aac", "alac", "pcm_s16le", "pcm_s24le",
 	  "pcm_f32le"}},
-	{"mp4", {"h264", "hevc", "av1", "aac", "opus", "alac", "flac"}},
 	{"fragmented_mov",
 	 {"h264", "hevc", "prores", "aac", "alac", "pcm_s16le", "pcm_s24le",
 	  "pcm_f32le"}},
-	{"fragmented_mp4",
-	 {"h264", "hevc", "av1", "aac", "opus", "alac", "flac"}},
 	// MKV supports everything
 	{"mkv", {}},
 };
@@ -5019,6 +5022,12 @@ static bool ContainerSupportsCodec(const string &container, const string &codec)
 	// Assume everything is supported
 	if (codecs.empty())
 		return true;
+
+	// PCM in MP4 is only supported in FFmpeg > 6.0
+	if ((container == "mp4" || container == "fragmented_mp4") &&
+	    !ff_supports_pcm_in_mp4() && codec.find("pcm_") != string::npos)
+		return false;
+
 	return codecs.count(codec) > 0;
 }