From c1776cbc156a47e3c94c8d210c8ccdec8c71ead2 Mon Sep 17 00:00:00 2001 From: nilaoda Date: Sat, 22 Jun 2024 23:52:53 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E6=8C=81=E6=9D=9C=E6=AF=94=E8=A7=86?= =?UTF-8?q?=E7=95=8CISM=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 目前没有实现Box写入, 解密后需要手动提取ES后再封装为对应Profile的mp4. --- .gitignore | 3 +++ .../Mp4/MSSMoovProcessor.cs | 27 ++++++++++++++++--- src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs | 2 +- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 707da68..35a2a08 100644 --- a/.gitignore +++ b/.gitignore @@ -363,3 +363,6 @@ MigrationBackup/ # Fody - auto-generated XML schema FodyWeavers.xsd + +# macOS shit +.DS_Store diff --git a/src/N_m3u8DL-RE.Parser/Mp4/MSSMoovProcessor.cs b/src/N_m3u8DL-RE.Parser/Mp4/MSSMoovProcessor.cs index 26b9a00..82f6428 100644 --- a/src/N_m3u8DL-RE.Parser/Mp4/MSSMoovProcessor.cs +++ b/src/N_m3u8DL-RE.Parser/Mp4/MSSMoovProcessor.cs @@ -62,7 +62,7 @@ namespace N_m3u8DL_RE.Parser.Mp4 private static byte SELF_CONTAINED = 0x1; private static List SupportedFourCC = new List() { - "HVC1","HEV1","AACL","AACH","EC-3","H264","AVC1","DAVC","AVC1","TTML" + "HVC1","HEV1","AACL","AACH","EC-3","H264","AVC1","DAVC","AVC1","TTML","DVHE","DVH1" }; public MSSMoovProcessor(StreamSpec streamSpec) @@ -546,6 +546,27 @@ namespace N_m3u8DL_RE.Parser.Mp4 return Box("hvc1", stream.ToArray()); //HEVC Simple Entry } } + // 杜比视界也按照hevc处理 + else if (FourCC == "DVHE" || FourCC == "DVH1") + { + var arr = CodecPrivateData.Split(new[] { StartCode }, StringSplitOptions.RemoveEmptyEntries); + var vps = HexUtil.HexToBytes(arr.Where(x => (HexUtil.HexToBytes(x[0..2])[0] >> 1) == 0x20).First()); + var sps = HexUtil.HexToBytes(arr.Where(x => (HexUtil.HexToBytes(x[0..2])[0] >> 1) == 0x21).First()); + var pps = HexUtil.HexToBytes(arr.Where(x => (HexUtil.HexToBytes(x[0..2])[0] >> 1) == 0x22).First()); + //make hvcC + var hvcC = GetHvcC(sps, pps, vps, "dvh1"); + writer.Write(hvcC); + if (IsProtection) + { + var sinfBox = GenSinf("dvh1"); + writer.Write(sinfBox); + return Box("encv", stream.ToArray()); //Encrypted Video + } + else + { + return Box("dvh1", stream.ToArray()); //HEVC Simple Entry + } + } else { throw new NotSupportedException(); @@ -591,7 +612,7 @@ namespace N_m3u8DL_RE.Parser.Mp4 return Box("avcC", stream.ToArray()); //AVC Decoder Configuration Record } - private byte[] GetHvcC(byte[] sps, byte[] pps, byte[] vps) + private byte[] GetHvcC(byte[] sps, byte[] pps, byte[] vps, string code = "hvc1") { var oriSps = new List(sps); //https://www.itu.int/rec/dologin.asp?lang=f&id=T-REC-H.265-201504-S!!PDF-E&type=items @@ -652,7 +673,7 @@ namespace N_m3u8DL_RE.Parser.Mp4 }*/ //生成编码信息 - var codecs = $"hvc1" + + var codecs = code + $".{HEVC_GENERAL_PROFILE_SPACE_STRINGS[generalProfileSpace]}{generalProfileIdc}" + $".{Convert.ToString(generalProfileCompatibilityFlags, 16)}" + $".{(generalTierFlag == 1 ? 'H' : 'L')}{generalLevelIdc}" + diff --git a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs index 2237d02..8654576 100644 --- a/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs +++ b/src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs @@ -18,7 +18,7 @@ namespace N_m3u8DL_RE.CommandLine { internal partial class CommandInvoker { - public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20231113"; + public const string VERSION_INFO = "N_m3u8DL-RE (Beta version) 20240622"; [GeneratedRegex("((best|worst)\\d*|all)")] private static partial Regex ForStrRegex();