If unimportant stream analysis failed then playback could be without video or audio (or both)
Some checks failed
continuous-integration/drone/push Build is failing
Some checks failed
continuous-integration/drone/push Build is failing
This commit is contained in:
@@ -138,6 +138,31 @@ sealed class CinemaMediaAnalyzer
|
||||
break;
|
||||
}
|
||||
|
||||
// Add unrecognized bogus streams so stream Index values are continous and sorted in the
|
||||
// ascending order as implementation of EncodingHelper.FindIndex is extremely stupid.
|
||||
Dictionary<int, MediaStream> indicies = new Dictionary<int, MediaStream>();
|
||||
int minI = int.MaxValue, maxI = -1;
|
||||
foreach (MediaStream i in result.MediaStreams)
|
||||
{
|
||||
indicies.Add(i.Index, i);
|
||||
if (minI > i.Index)
|
||||
minI = i.Index;
|
||||
if (maxI < i.Index)
|
||||
maxI = i.Index;
|
||||
}
|
||||
if (minI != 0 || maxI + 1 != indicies.Count || !indicies.ContainsKey(0))
|
||||
{
|
||||
List<MediaStream> streams = new List<MediaStream>();
|
||||
for (int i = 0; i < maxI; i++)
|
||||
if (indicies.TryGetValue(i, out MediaStream? a))
|
||||
// Regular stream
|
||||
streams.Add(a);
|
||||
else
|
||||
// Bogus stream to fill index position
|
||||
streams.Add(new MediaStream() { Type = MediaStreamType.Data, Index = i });
|
||||
result.MediaStreams = streams;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user