支持JPEG伪装的TS

This commit is contained in:
nilaoda 2022-11-17 22:32:01 +08:00
parent 616da62f74
commit ce2bc766e4
1 changed files with 19 additions and 1 deletions

View File

@ -21,6 +21,9 @@ namespace N_m3u8DL_RE.Util
//BMP HEADER检测
else if (size > 10 && 0x42 == bArr[0] && 0x4D == bArr[1] && 0x00 == bArr[5] && 0x00 == bArr[6] && 0x00 == bArr[7] && 0x00 == bArr[8])
return true;
//JPEG HEADER检测
else if (size > 3 && 0xFF == bArr[0] && 0xD8 == bArr[1] && 0xFF == bArr[2])
return true;
return false;
}
@ -41,7 +44,7 @@ namespace N_m3u8DL_RE.Util
sourceData = sourceData[771..];
else
{
//确定是PNG但是需要手动查询结尾标记 0x47 出现两次
//手动查询结尾标记 0x47 出现两次
int skip = 0;
for (int i = 4; i < sourceData.Length - 188 * 2 - 4; i++)
{
@ -64,6 +67,21 @@ namespace N_m3u8DL_RE.Util
{
sourceData = sourceData[0x3E..];
}
//JPEG HEADER检测
else if (0xFF == sourceData[0] && 0xD8 == sourceData[1] && 0xFF == sourceData[2])
{
//手动查询结尾标记 0x47 出现两次
int skip = 0;
for (int i = 4; i < sourceData.Length - 188 * 2 - 4; i++)
{
if (sourceData[i] == 0x47 && sourceData[i + 188] == 0x47 && sourceData[i + 188 + 188] == 0x47)
{
skip = i;
break;
}
}
sourceData = sourceData[skip..];
}
await File.WriteAllBytesAsync(sourcePath, sourceData);
}