支持Hi-Res无损音频格式

croire 2 years ago
parent 74a0f7b96d
commit a35d8a0334

@ -25,6 +25,7 @@ namespace DownKyi.Core.BiliApi.BiliUtils
new Quality { Name = "132K", Id = 30232 }, new Quality { Name = "132K", Id = 30232 },
new Quality { Name = "192K", Id = 30280 }, new Quality { Name = "192K", Id = 30280 },
new Quality { Name = "Dolby Atmos", Id = 30250 }, new Quality { Name = "Dolby Atmos", Id = 30250 },
new Quality { Name = "Hi-Res无损", Id = 30251 },
}; };
/// <summary> /// <summary>

@ -18,5 +18,7 @@ namespace DownKyi.Core.BiliApi.VideoStream.Models
public List<PlayUrlDashVideo> Audio { get; set; } public List<PlayUrlDashVideo> Audio { get; set; }
[JsonProperty("dolby")] [JsonProperty("dolby")]
public PlayUrlDashDolby Dolby { get; set; } public PlayUrlDashDolby Dolby { get; set; }
[JsonProperty("flac")]
public PlayUrlDashFlac Flac { get; set; }
} }
} }

@ -0,0 +1,12 @@
using DownKyi.Core.BiliApi.Models;
using Newtonsoft.Json;
namespace DownKyi.Core.BiliApi.VideoStream.Models
{
public class PlayUrlDashFlac : BaseModel
{
[JsonProperty("audio")]
public PlayUrlDashVideo Audio { get; set; }
//bool display { get; set; }
}
}

@ -249,6 +249,7 @@
<Compile Include="BiliApi\VideoStream\Models\PlayUrl.cs" /> <Compile Include="BiliApi\VideoStream\Models\PlayUrl.cs" />
<Compile Include="BiliApi\VideoStream\Models\PlayUrlDash.cs" /> <Compile Include="BiliApi\VideoStream\Models\PlayUrlDash.cs" />
<Compile Include="BiliApi\VideoStream\Models\PlayUrlDashDolby.cs" /> <Compile Include="BiliApi\VideoStream\Models\PlayUrlDashDolby.cs" />
<Compile Include="BiliApi\VideoStream\Models\PlayUrlDashFlac.cs" />
<Compile Include="BiliApi\VideoStream\Models\PlayUrlDashVideo.cs" /> <Compile Include="BiliApi\VideoStream\Models\PlayUrlDashVideo.cs" />
<Compile Include="BiliApi\VideoStream\Models\PlayUrlDurl.cs" /> <Compile Include="BiliApi\VideoStream\Models\PlayUrlDurl.cs" />
<Compile Include="BiliApi\VideoStream\Models\PlayUrlSupportFormat.cs" /> <Compile Include="BiliApi\VideoStream\Models\PlayUrlSupportFormat.cs" />

@ -34,15 +34,19 @@ namespace DownKyi.Core.FFmpeg
/// <param name="destVideo"></param> /// <param name="destVideo"></param>
public static bool MergeVideo(string video1, string video2, string destVideo) public static bool MergeVideo(string video1, string video2, string destVideo)
{ {
string param = $"-y -i \"{video1}\" -i \"{video2}\" -acodec copy -vcodec copy -f mp4 \"{destVideo}\""; string param = $"-y -i \"{video1}\" -i \"{video2}\" -strict -2 -acodec copy -vcodec copy -f mp4 \"{destVideo}\"";
if (video1 == null || !File.Exists(video1)) if (video1 == null || !File.Exists(video1))
{ {
param = $"-y -i \"{video2}\" -acodec copy -vcodec copy -f mp4 \"{destVideo}\""; param = $"-y -i \"{video2}\" -strict -2 -acodec copy -vcodec copy -f mp4 \"{destVideo}\"";
} }
if (video2 == null || !File.Exists(video2)) if (video2 == null || !File.Exists(video2))
{ {
param = $"-y -i \"{video1}\" -acodec copy \"{destVideo}\""; param = $"-y -i \"{video1}\" -strict -2 -acodec copy \"{destVideo}\"";
} }
// 支持flac格式音频
//param += " -strict -2";
if (!File.Exists(video1) && !File.Exists(video2)) { return false; } if (!File.Exists(video1) && !File.Exists(video2)) { return false; }
// 如果存在 // 如果存在

@ -82,6 +82,11 @@ namespace DownKyi.Services.Download
{ {
downloadAudio = downloading.PlayUrl.Dash.Dolby.Audio[0]; downloadAudio = downloading.PlayUrl.Dash.Dolby.Audio[0];
} }
// Hi-Res无损
if (downloading.AudioCodec.Id == 30251)
{
downloadAudio = downloading.PlayUrl.Dash.Flac.Audio;
}
} }
catch (Exception) { } catch (Exception) { }

@ -132,15 +132,16 @@ namespace DownKyi.Services
private static ObservableCollection<string> GetAudioQualityFormatList(PlayUrl playUrl, int defaultAudioQuality) private static ObservableCollection<string> GetAudioQualityFormatList(PlayUrl playUrl, int defaultAudioQuality)
{ {
List<string> audioQualityFormatList = new List<string>(); List<string> audioQualityFormatList = new List<string>();
List<Quality> audioQualities = Constant.GetAudioQualities();
if (playUrl.Dash.Audio != null && playUrl.Dash.Audio.Count > 0) if (playUrl.Dash.Audio != null && playUrl.Dash.Audio.Count > 0)
{ {
foreach (PlayUrlDashVideo audio in playUrl.Dash.Audio) foreach (PlayUrlDashVideo audio in playUrl.Dash.Audio)
{ {
// 音质id大于设置质时,跳过 // 音质id大于设置质时,跳过
if (audio.Id > defaultAudioQuality) { continue; } if (audio.Id > defaultAudioQuality) { continue; }
Quality audioQuality = Constant.GetAudioQualities().FirstOrDefault(t => { return t.Id == audio.Id; }); Quality audioQuality = audioQualities.FirstOrDefault(t => { return t.Id == audio.Id; });
if (audioQuality != null) if (audioQuality != null)
{ {
ListHelper.AddUnique(audioQualityFormatList, audioQuality.Name); ListHelper.AddUnique(audioQualityFormatList, audioQuality.Name);
@ -148,9 +149,20 @@ namespace DownKyi.Services
} }
} }
if (playUrl.Dash.Dolby.Audio != null && playUrl.Dash.Dolby.Audio.Count > 0) if (audioQualities[3].Id <= defaultAudioQuality - 1000 && playUrl.Dash.Dolby != null)
{ {
ListHelper.AddUnique(audioQualityFormatList, Constant.GetAudioQualities().Last().Name); if (playUrl.Dash.Dolby.Audio != null && playUrl.Dash.Dolby.Audio.Count > 0)
{
ListHelper.AddUnique(audioQualityFormatList, audioQualities[3].Name);
}
}
if (audioQualities[4].Id <= defaultAudioQuality - 1000 && playUrl.Dash.Flac != null)
{
if (playUrl.Dash.Flac.Audio != null)
{
ListHelper.AddUnique(audioQualityFormatList, audioQualities[4].Name);
}
} }
audioQualityFormatList.Sort(new StringLogicalComparer<string>()); audioQualityFormatList.Sort(new StringLogicalComparer<string>());

@ -197,7 +197,9 @@ namespace DownKyi.ViewModels.Settings
// 优先下载音质 // 优先下载音质
AudioQualityList = Constant.GetAudioQualities(); AudioQualityList = Constant.GetAudioQualities();
AudioQualityList.RemoveAt(3); //AudioQualityList.RemoveAt(3);
AudioQualityList[3].Id = AudioQualityList[3].Id + 1000;
AudioQualityList[4].Id = AudioQualityList[4].Id + 1000;
// 文件命名格式 // 文件命名格式
SelectedFileName = new ObservableCollection<DisplayFileNamePart>(); SelectedFileName = new ObservableCollection<DisplayFileNamePart>();

Loading…
Cancel
Save