Implement code feedback

- Rewrite AudioResolver
- Use async & await instead of .Result
- Add support for audio containers with multiple audio streams (e.g.
  mka)
- Fix bug when using external subtitle and external audio streams at the
  same time
This commit is contained in:
Jonas Resch
2021-11-27 12:10:57 +01:00
parent 5e91f50c43
commit a68e58556c
4 changed files with 118 additions and 214 deletions

View File

@@ -678,12 +678,6 @@ namespace MediaBrowser.Controller.MediaEncoding
arg.Append("-i ")
.Append(GetInputPathArgument(state));
if (state.AudioStream.IsExternal)
{
arg.Append(" -i ")
.Append(string.Format(CultureInfo.InvariantCulture, "file:\"{0}\"", state.AudioStream.Path));
}
if (state.SubtitleStream != null
&& state.SubtitleDeliveryMethod == SubtitleDeliveryMethod.Encode
&& state.SubtitleStream.IsExternal && !state.SubtitleStream.IsTextSubtitleStream)
@@ -702,6 +696,12 @@ namespace MediaBrowser.Controller.MediaEncoding
arg.Append(" -i \"").Append(subtitlePath).Append('\"');
}
if (state.AudioStream != null && state.AudioStream.IsExternal)
{
arg.Append(" -i ")
.Append(string.Format(CultureInfo.InvariantCulture, "file:\"{0}\"", state.AudioStream.Path));
}
return arg.ToString();
}
@@ -2007,7 +2007,14 @@ namespace MediaBrowser.Controller.MediaEncoding
{
if (state.AudioStream.IsExternal)
{
args += " -map 1:a";
int externalAudioMapIndex = state.SubtitleStream != null && state.SubtitleStream.IsExternal ? 2 : 1;
int externalAudioStream = state.MediaSource.MediaStreams.Where(i => i.Path == state.AudioStream.Path).ToList().IndexOf(state.AudioStream);
args += string.Format(
CultureInfo.InvariantCulture,
" -map {0}:{1}",
externalAudioMapIndex,
externalAudioStream);
}
else
{