diff --git a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs index 00e2175..a85f0eb 100644 --- a/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs +++ b/src/N_m3u8DL-RE/DownloadManager/SimpleDownloadManager.cs @@ -115,6 +115,7 @@ namespace N_m3u8DL_RE.DownloadManager { speedContainer.ResetVars(); bool useAACFilter = false; //ffmpeg合并flag + List mediaInfos = new(); ConcurrentDictionary FileDic = new(); var segments = streamSpec.Playlist?.MediaParts.SelectMany(m => m.MediaSegments); @@ -203,9 +204,9 @@ namespace N_m3u8DL_RE.DownloadManager if (!readInfo) { Logger.WarnMarkUp(ResString.readingInfo); - var mediainfos = await MediainfoUtil.ReadInfoAsync(DownloaderConfig.MyOptions.FFmpegBinaryPath!, result.ActualFilePath); - mediainfos.ForEach(info => Logger.InfoMarkUp(info.ToStringMarkUp())); - ChangeSpecInfo(streamSpec, mediainfos, ref useAACFilter); + mediaInfos = await MediainfoUtil.ReadInfoAsync(DownloaderConfig.MyOptions.FFmpegBinaryPath!, result.ActualFilePath); + mediaInfos.ForEach(info => Logger.InfoMarkUp(info.ToStringMarkUp())); + ChangeSpecInfo(streamSpec, mediaInfos, ref useAACFilter); readInfo = true; } } @@ -246,9 +247,9 @@ namespace N_m3u8DL_RE.DownloadManager } //ffmpeg读取信息 Logger.WarnMarkUp(ResString.readingInfo); - var mediainfos = await MediainfoUtil.ReadInfoAsync(DownloaderConfig.MyOptions.FFmpegBinaryPath!, result!.ActualFilePath); - mediainfos.ForEach(info => Logger.InfoMarkUp(info.ToStringMarkUp())); - ChangeSpecInfo(streamSpec, mediainfos, ref useAACFilter); + mediaInfos = await MediainfoUtil.ReadInfoAsync(DownloaderConfig.MyOptions.FFmpegBinaryPath!, result!.ActualFilePath); + mediaInfos.ForEach(info => Logger.InfoMarkUp(info.ToStringMarkUp())); + ChangeSpecInfo(streamSpec, mediaInfos, ref useAACFilter); readInfo = true; } @@ -543,7 +544,14 @@ namespace N_m3u8DL_RE.DownloadManager //记录所有文件信息 if (File.Exists(output)) - OutputFiles.Add(new OutputFile() { Index = task.Id, FilePath = output, LangCode = streamSpec.Language, Description = streamSpec.Name }); + OutputFiles.Add(new OutputFile() + { + Index = task.Id, + FilePath = output, + LangCode = streamSpec.Language, + Description = streamSpec.Name, + Mediainfos = mediaInfos + }); return true; } diff --git a/src/N_m3u8DL-RE/Downloader/SimpleDownloader.cs b/src/N_m3u8DL-RE/Downloader/SimpleDownloader.cs index 772d886..9895e4a 100644 --- a/src/N_m3u8DL-RE/Downloader/SimpleDownloader.cs +++ b/src/N_m3u8DL-RE/Downloader/SimpleDownloader.cs @@ -76,7 +76,7 @@ namespace N_m3u8DL_RE.Downloader } catch (Exception ex) { - Logger.WarnMarkUp($"{ex.Message} retryCount: {retryCount}"); + Logger.WarnMarkUp($"[grey]{ex.Message.EscapeMarkup()} retryCount: {retryCount}[/]"); Logger.Debug(ex.ToString()); if (retryCount-- > 0) { diff --git a/src/N_m3u8DL-RE/Entity/OutputFile.cs b/src/N_m3u8DL-RE/Entity/OutputFile.cs index cbf8b1e..66f3cb2 100644 --- a/src/N_m3u8DL-RE/Entity/OutputFile.cs +++ b/src/N_m3u8DL-RE/Entity/OutputFile.cs @@ -12,5 +12,6 @@ namespace N_m3u8DL_RE.Entity public required string FilePath { get; set; } public string? LangCode { get; set; } public string? Description { get; set; } + public List Mediainfos { get; set; } = new(); } } diff --git a/src/N_m3u8DL-RE/Util/MergeUtil.cs b/src/N_m3u8DL-RE/Util/MergeUtil.cs index deb8ece..b57ed78 100644 --- a/src/N_m3u8DL-RE/Util/MergeUtil.cs +++ b/src/N_m3u8DL-RE/Util/MergeUtil.cs @@ -158,7 +158,7 @@ namespace N_m3u8DL_RE.Util //MAP for (int i = 0; i < files.Length; i++) { - command.Append($" -map {i}:0 "); + command.Append($" -map {i} "); } if (mp4) @@ -170,15 +170,25 @@ namespace N_m3u8DL_RE.Util command.Append(" -map_metadata -1 "); //LANG and NAME + var streamIndex = 0; for (int i = 0; i < files.Length; i++) { //转换语言代码 ConvertLangCodeAndDisplayName(files[i]); - command.Append($" -metadata:s:{i} language=\"{files[i].LangCode ?? "und"}\" "); + command.Append($" -metadata:s:{streamIndex} language=\"{files[i].LangCode ?? "und"}\" "); if (!string.IsNullOrEmpty(files[i].Description)) { - command.Append($" -metadata:s:{i} title=\"{files[i].Description}\" "); + command.Append($" -metadata:s:{streamIndex} title=\"{files[i].Description}\" "); } + /** + * -metadata:s:xx标记的是 输出的第xx个流的metadata, + * 若输入文件存在不止一个流时,这里单纯使用files的index + * 就有可能出现metadata错位的情况,所以加了如下逻辑 + */ + if (files[i].Mediainfos.Count > 0) + streamIndex += files[i].Mediainfos.Count; + else + streamIndex++; } command.Append($" -metadata date=\"{dateString}\" -ignore_unknown -copy_unknown ");