Skip to content

Commit

Permalink
nilaoda#420 metadata添加作者
Browse files Browse the repository at this point in the history
  • Loading branch information
nilaoda committed Sep 13, 2022
1 parent a30e127 commit b5b297d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 5 additions & 3 deletions BBDown/BBDownMuxer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private static string EscapeString(string str)
return string.IsNullOrEmpty(str) ? str : str.Replace("\"", "'");
}

public static int MuxByMp4box(string videoPath, string audioPath, string outPath, string desc, string title, string episodeId, string pic, string lang, List<Subtitle>? subs, bool audioOnly, bool videoOnly, List<ViewPoint>? points)
public static int MuxByMp4box(string videoPath, string audioPath, string outPath, string desc, string title, string author, string episodeId, string pic, string lang, List<Subtitle>? subs, bool audioOnly, bool videoOnly, List<ViewPoint>? points)
{
StringBuilder inputArg = new();
StringBuilder metaArg = new();
Expand Down Expand Up @@ -72,6 +72,7 @@ public static int MuxByMp4box(string videoPath, string audioPath, string outPath
else
metaArg.Append($":title=\"{title}\"");
metaArg.Append($":comment=\"{desc}\"");
metaArg.Append($":artist=\"{author}\"");

if (subs != null)
{
Expand All @@ -92,7 +93,7 @@ public static int MuxByMp4box(string videoPath, string audioPath, string outPath
return RunExe(MP4BOX, arguments, MP4BOX != "mp4box");
}

public static int MuxAV(bool useMp4box, string videoPath, string audioPath, string outPath, string desc = "", string title = "", string episodeId = "", string pic = "", string lang = "", List<Subtitle>? subs = null, bool audioOnly = false, bool videoOnly = false, List<ViewPoint>? points = null)
public static int MuxAV(bool useMp4box, string videoPath, string audioPath, string outPath, string desc = "", string title = "", string author = "", string episodeId = "", string pic = "", string lang = "", List<Subtitle>? subs = null, bool audioOnly = false, bool videoOnly = false, List<ViewPoint>? points = null)
{
if (audioOnly && audioPath != "")
videoPath = "";
Expand All @@ -104,7 +105,7 @@ public static int MuxAV(bool useMp4box, string videoPath, string audioPath, stri

if (useMp4box)
{
return MuxByMp4box(videoPath, audioPath, outPath, desc, title, episodeId, pic, lang, subs, audioOnly, videoOnly, points);
return MuxByMp4box(videoPath, audioPath, outPath, desc, title, author, episodeId, pic, lang, subs, audioOnly, videoOnly, points);
}

if (outPath.Contains('/') && ! Directory.Exists(Path.GetDirectoryName(outPath)))
Expand Down Expand Up @@ -152,6 +153,7 @@ public static int MuxAV(bool useMp4box, string videoPath, string audioPath, stri
inputArg.ToString() + metaArg.ToString() + $" -metadata title=\"" + (episodeId == "" ? title : episodeId) + "\" " +
(lang == "" ? "" : $"-metadata:s:a:0 language={lang} ") +
$"-metadata description=\"{desc}\" " +
$"-metadata artist=\"{author}\" " +
(episodeId == "" ? "" : $"-metadata album=\"{title}\" ") +
$"-c copy " + (audioOnly && audioPath == "" ? " -vn " : "") +
(subs != null ? " -c:s mov_text " : "") +
Expand Down
2 changes: 2 additions & 0 deletions BBDown/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -714,6 +714,7 @@ private static async Task DoWorkAsync(MyOption myOption)
int code = MuxAV(useMp4box, videoPath, audioPath, savePath,
desc,
title,
p.ownerName ?? "",
(pagesCount > 1 || (bangumi && !vInfo.IsBangumiEnd)) ? p.title : "",
File.Exists(coverPath) ? coverPath : "",
lang,
Expand Down Expand Up @@ -823,6 +824,7 @@ private static async Task DoWorkAsync(MyOption myOption)
int code = MuxAV(false, videoPath, "", savePath,
desc,
title,
p.ownerName ?? "",
(pagesCount > 1 || (bangumi && !vInfo.IsBangumiEnd)) ? p.title : "",
File.Exists(coverPath) ? coverPath : "",
lang,
Expand Down

0 comments on commit b5b297d

Please sign in to comment.