Skip to content

Commit ed04317

Browse files
committed
feat: support non-English and multiple audio streams.
Silly Americans thinking we're the only ones on the planet...
1 parent c01593f commit ed04317

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

Jellyfin.Plugin.DoViRemux/RemuxLibraryTask.cs

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,15 @@ private async Task ProcessOneItem(Video item, CancellationToken cancellationToke
117117
// truehd isn't supported by many consumer MP4 decoders even though ffmpeg can do it.
118118
// it's found on a lot of DoVi media (cough particularly hybrid remuxes cough),
119119
// but media like Bluray is required to have an AAC/AC3/whatever fallback stream for compatibility
120-
var audioStream = streams.FirstOrDefault(s => s.Type == MediaBrowser.Model.Entities.MediaStreamType.Audio
121-
&& s.Codec != "truehd"
122-
&& s.Language == "eng")
120+
var audioStreams = streams.Where(s => s.Type == MediaBrowser.Model.Entities.MediaStreamType.Audio
121+
&& s.Codec != "truehd")
122+
.Select((audioStream, i) => new { audioStream.Index, OutputIndex = i, audioStream.Language})
123+
.ToList();
124+
if (audioStreams.Count == 0)
125+
{
123126
// TODO: transcode it instead
124-
?? throw new Exception("Couldn't find an appropriate audio stream to copy");
127+
throw new Exception("Couldn't find an appropriate audio stream to copy");
128+
}
125129

126130
// PGS subtitles aren't supported by mp4. Technically we can use the copy codec
127131
// and most decoders will know how to use subrip subtitles, but mov_text is standard
@@ -148,13 +152,14 @@ private async Task ProcessOneItem(Video item, CancellationToken cancellationToke
148152

149153
string cli = "-analyzeduration 200M -probesize 1G -fflags +genpts ";
150154
cli += $"-i \"{inputPath}\" ";
151-
cli += $"-map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 -map 0:{audioStream.Index} ";
155+
cli += $"-map_metadata -1 -map_chapters -1 -threads 0 -map 0:0 ";
156+
cli += string.Concat(audioStreams.Select(a => $"-map 0:{a.Index} "));
152157
cli += string.Concat(subtitles.Select(s => $"-map 0:{s.Index} "));
153158
cli += "-codec:v:0 copy -tag:v:0 dvh1 -strict experimental -bsf:v hevc_mp4toannexb -start_at_zero ";
159+
cli += string.Concat(audioStreams.Select(a => $"-codec:a:{a.OutputIndex} copy "));
154160
cli += string.Concat(subtitles.Select(s => $"-codec:s:{s.OutputIndex} {s.Codec} "));
155-
cli += "-codec:a:0 copy ";
161+
cli += string.Concat(audioStreams.Select(a => $"-metadata:s:a:{a.OutputIndex} language=\"{a.Language}\" "));
156162
cli += string.Concat(subtitles.Select(s => $"-metadata:s:s:{s.OutputIndex} language=\"{s.Lang}\" "));
157-
cli += $"-metadata:s:a:0 language=\"eng\" ";
158163
cli += "-copyts -avoid_negative_ts disabled -max_muxing_queue_size 2048 ";
159164
cli += $"\"{outputPath}\"";
160165

meta.yaml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,4 @@ category: "General"
1212
artifacts:
1313
- "Jellyfin.Plugin.DoViRemux.dll"
1414
changelog: |-
15-
- Removed the default task trigger
16-
- Removed the post-scan task which merges remuxed versions
15+
- Added support for multiple and non-English audio streams

0 commit comments

Comments
 (0)