Skip to content

Commit

Permalink
优化混流问题 Fix #198
Browse files Browse the repository at this point in the history
  • Loading branch information
nilaoda committed Jun 18, 2023
1 parent 8743a06 commit c05dbab
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions src/N_m3u8DL-RE/Util/MergeUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,22 +188,15 @@ public static bool MuxInputsByFFmpeg(string binary, OutputFile[] files, string o
//MAP
for (int i = 0; i < files.Length; i++)
{
if (files[i].MediaType != Common.Enum.MediaType.AUDIO && files[i].MediaType != Common.Enum.MediaType.SUBTITLES && files[i].Mediainfos.Any(x => x.Type == "Video"))
{
var x = files[i].Mediainfos.FindIndex(x => x.Type == "Video");
//视频流只取视频 防止CC字幕导致的混流失败
command.Append($" -map {i}:{x} ");
//同时需要修正 Mediainfos 数量 只保留视频
files[i].Mediainfos = new List<Mediainfo>() { files[i].Mediainfos[x] };
}
else
command.Append($" -map {i} ");
command.Append($" -map {i} ");
}

var srt = files.Any(x => x.FilePath.EndsWith(".srt"));

if (mp4)
command.Append($" -strict unofficial -c:a copy -c:v copy -c:s mov_text "); //mp4不支持vtt/srt字幕,必须转换格式
else
command.Append($" -strict unofficial -c copy ");
command.Append($" -strict unofficial -c copy -c:s {(srt ? "srt" : "webvtt")} ");

//CLEAN
command.Append(" -map_metadata -1 ");
Expand Down

0 comments on commit c05dbab

Please sign in to comment.