From 43547c60233dabb340167403ab5b6be9439bc3a4 Mon Sep 17 00:00:00 2001 From: nilaoda Date: Sun, 24 Nov 2024 18:30:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=85=83=E6=95=B0=E6=8D=AE=E5=86=99=E5=85=A5?= =?UTF-8?q?=E8=A7=86=E9=A2=91URL?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- BBDown/BBDownMuxer.cs | 13 ++++++++----- BBDown/Program.cs | 11 ++++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/BBDown/BBDownMuxer.cs b/BBDown/BBDownMuxer.cs index 01ab89a4d..256607a6b 100644 --- a/BBDown/BBDownMuxer.cs +++ b/BBDown/BBDownMuxer.cs @@ -44,7 +44,7 @@ private static string EscapeString(string str) return string.IsNullOrEmpty(str) ? str : str.Replace("\"", "'").Replace("\\", "\\\\"); } - private static int MuxByMp4box(string videoPath, string audioPath, string outPath, string desc, string title, string author, string episodeId, string pic, string lang, List? subs, bool audioOnly, bool videoOnly, List? points) + private static int MuxByMp4box(string url, string videoPath, string audioPath, string outPath, string desc, string title, string author, string episodeId, string pic, string lang, List? subs, bool audioOnly, bool videoOnly, List? points) { StringBuilder inputArg = new(); StringBuilder metaArg = new(); @@ -73,7 +73,8 @@ private static int MuxByMp4box(string videoPath, string audioPath, string outPat metaArg.Append($":album=\"{title}\":title=\"{episodeId}\""); else metaArg.Append($":title=\"{title}\""); - metaArg.Append($":comment=\"{desc}\""); + metaArg.Append($":sdesc=\"{desc}\""); + metaArg.Append($":comment=\"{url}\""); metaArg.Append($":artist=\"{author}\""); if (subs != null) @@ -90,12 +91,12 @@ private static int MuxByMp4box(string videoPath, string audioPath, string outPat } //----分析完毕 - var arguments = (Config.DEBUG_LOG ? " -v " : "") + inputArg + (metaArg.ToString() == "" ? "" : " -itags tool=" + metaArg.ToString()) + $" -new -- \"{outPath}\""; + var arguments = (Config.DEBUG_LOG ? " -v " : "") + inputArg + (metaArg.ToString() == "" ? "" : " -itags tool=" + metaArg) + $" -new -- \"{outPath}\""; LogDebug("mp4box命令: {0}", arguments); return RunExe(MP4BOX, arguments, MP4BOX != "mp4box"); } - public static int MuxAV(bool useMp4box, string videoPath, string audioPath, List audioMaterial, string outPath, string desc = "", string title = "", string author = "", string episodeId = "", string pic = "", string lang = "", List? subs = null, bool audioOnly = false, bool videoOnly = false, List? points = null, long pubTime = 0, bool simplyMux = false) + public static int MuxAV(bool useMp4box, string bvid, string videoPath, string audioPath, List audioMaterial, string outPath, string desc = "", string title = "", string author = "", string episodeId = "", string pic = "", string lang = "", List? subs = null, bool audioOnly = false, bool videoOnly = false, List? points = null, long pubTime = 0, bool simplyMux = false) { if (audioOnly && audioPath != "") videoPath = ""; @@ -104,10 +105,11 @@ public static int MuxAV(bool useMp4box, string videoPath, string audioPath, List desc = EscapeString(desc); title = EscapeString(title); episodeId = EscapeString(episodeId); + var url = $"https://www.bilibili.com/video/{bvid}/"; if (useMp4box) { - return MuxByMp4box(videoPath, audioPath, outPath, desc, title, author, episodeId, pic, lang, subs, audioOnly, videoOnly, points); + return MuxByMp4box(url, videoPath, audioPath, outPath, desc, title, author, episodeId, pic, lang, subs, audioOnly, videoOnly, points); } if (outPath.Contains('/') && ! Directory.Exists(Path.GetDirectoryName(outPath))) @@ -179,6 +181,7 @@ public static int MuxAV(bool useMp4box, string videoPath, string audioPath, List argsBuilder.Append(metaArg); if (!simplyMux) { argsBuilder.Append($"-metadata title=\"{(episodeId == "" ? title : episodeId)}\" "); + argsBuilder.Append($"-metadata comment=\"{url}\" "); if (lang != "") argsBuilder.Append($"-metadata:s:a:0 language={lang} "); if (!string.IsNullOrWhiteSpace(desc)) argsBuilder.Append($"-metadata description=\"{desc}\" "); if (!string.IsNullOrEmpty(author)) argsBuilder.Append($"-metadata artist=\"{author}\" "); diff --git a/BBDown/Program.cs b/BBDown/Program.cs index 9036d7137..e5771b289 100644 --- a/BBDown/Program.cs +++ b/BBDown/Program.cs @@ -244,7 +244,7 @@ public static (Dictionary encodingPriority, Dictionary encodingPriority, Dictionary !string.IsNullOrEmpty(p.ownerMid))?.ownerMid; if (!string.IsNullOrEmpty(mid)) { @@ -664,7 +669,7 @@ private static async Task DownloadPageAsync(Page p, MyOption myOption, VInfo vIn Log($"开始合并音视频{(subtitleInfo.Any() ? "和字幕" : "")}..."); if (myOption.AudioOnly) savePath = savePath[..^4] + ".m4a"; - int code = BBDownMuxer.MuxAV(myOption.UseMP4box, videoPath, audioPath, audioMaterial, savePath, + int code = BBDownMuxer.MuxAV(myOption.UseMP4box, p.bvid, videoPath, audioPath, audioMaterial, savePath, desc, title, p.ownerName ?? "", @@ -753,7 +758,7 @@ private static async Task DownloadPageAsync(Page p, MyOption myOption, VInfo vIn Log($"开始混流视频{(subtitleInfo.Any() ? "和字幕" : "")}..."); if (myOption.AudioOnly) savePath = savePath[..^4] + ".m4a"; - int code = BBDownMuxer.MuxAV(false, videoPath, "", audioMaterial, savePath, + int code = BBDownMuxer.MuxAV(false, p.bvid, videoPath, "", audioMaterial, savePath, desc, title, p.ownerName ?? "",