Skip to content

Commit

Permalink
Merge pull request #407 from nilaoda/feat/dolby_ism
Browse files Browse the repository at this point in the history
支持杜比视界ISM解析
  • Loading branch information
nilaoda authored Jun 22, 2024
2 parents 54a9eda + c1776cb commit 5f131f1
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -363,3 +363,6 @@ MigrationBackup/

# Fody - auto-generated XML schema
FodyWeavers.xsd

# macOS shit
.DS_Store
27 changes: 24 additions & 3 deletions src/N_m3u8DL-RE.Parser/Mp4/MSSMoovProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ private byte[] UnityMatrix
private static byte SELF_CONTAINED = 0x1;
private static List<string> SupportedFourCC = new List<string>()
{
"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)
Expand Down Expand Up @@ -546,6 +546,27 @@ private byte[] GetSampleEntryBox()
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();
Expand Down Expand Up @@ -591,7 +612,7 @@ private byte[] GetAvcC(byte[] sps, byte[] pps)
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<byte>(sps);
//https://www.itu.int/rec/dologin.asp?lang=f&id=T-REC-H.265-201504-S!!PDF-E&type=items
Expand Down Expand Up @@ -652,7 +673,7 @@ private byte[] GetHvcC(byte[] sps, byte[] pps, byte[] vps)
}*/

//生成编码信息
var codecs = $"hvc1" +
var codecs = code +
$".{HEVC_GENERAL_PROFILE_SPACE_STRINGS[generalProfileSpace]}{generalProfileIdc}" +
$".{Convert.ToString(generalProfileCompatibilityFlags, 16)}" +
$".{(generalTierFlag == 1 ? 'H' : 'L')}{generalLevelIdc}" +
Expand Down
2 changes: 1 addition & 1 deletion src/N_m3u8DL-RE/CommandLine/CommandInvoker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 5f131f1

Please sign in to comment.