Skip to content

Commit

Permalink
Fix failures when text track has both VTT and CMFT.
Browse files Browse the repository at this point in the history
Use VTT over CMFT since shaka supports CMFT.
  • Loading branch information
duggaraju committed Aug 22, 2023
1 parent 3836b82 commit 2891aa5
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 19 deletions.
34 changes: 16 additions & 18 deletions transform/BasePackager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,21 @@ abstract class BasePackager : IPackager

public IDictionary<string, IList<Track>> FileToTrackMap => _fileToTrackMap;

public static bool IsTextTrackSupported(Track track, Manifest manifest)
{
return !track.IsMultiFile && (track.Source.EndsWith(VTT_FILE) || track.Parameters.Any(t => t.Name == TRANSCRIPT_SOURCE));
}

public static bool IsLiveTextTrackSupported(Track track, ClientManifest clientManifest)
{
return track.IsMultiFile &&
// Choose the text track with a list of fragblobs for close captions.
clientManifest!.Streams.Any(
stream => (stream.Type == StreamType.Text &&
stream.SubType == "SUBT") &&
stream.Name == track.TrackName);
}

public BasePackager(AssetDetails assetDetails, TransMuxer transMuxer, ILogger logger)
{
_assetDetails = assetDetails;
Expand All @@ -65,24 +80,7 @@ public BasePackager(AssetDetails assetDetails, TransMuxer transMuxer, ILogger lo
SelectedTracks = manifest.Tracks.Where(t =>
{
if (t is TextTrack)
{
bool pickThisTextTrack = !t.IsMultiFile && (t.Source.EndsWith(VTT_FILE) || t.Parameters.Any(t => t.Name == TRANSCRIPT_SOURCE));
if (manifest.IsLiveArchive)
{
pickThisTextTrack = false;
if (t.IsMultiFile)
{
// Choose the text track with a list of fragblobs for close captions.
pickThisTextTrack = assetDetails.ClientManifest!.Streams.Any(
stream => (stream.Type == StreamType.Text &&
stream.SubType == "SUBT") &&
stream.Name == t.TrackName);
}
}
return pickThisTextTrack;
}
return manifest.IsLiveArchive && IsLiveTextTrackSupported(t, assetDetails.ClientManifest!) || IsTextTrackSupported(t, manifest);
return true;
}).ToList();

Expand Down
3 changes: 2 additions & 1 deletion transform/ShakaPackager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,9 @@ private IEnumerable<string> GetArguments(IList<string> inputs, IList<string> out

List<string> arguments = new(SelectedTracks.Select((t, i) =>
{
var source = t.Parameters.SingleOrDefault(p => p.Name == TRANSCRIPT_SOURCE)?.Value ?? t.Source;
var ext = t.IsMultiFile ? (t is TextTrack ? VTT_FILE : MEDIA_FILE) : string.Empty;
var file = $"{t.Source}{ext}";
var file = $"{source}{ext}";
var index = Inputs.IndexOf(file);
var multiTrack = TransmuxedSmooth && FileToTrackMap[file].Count > 1;
var inputFile = multiTrack ?
Expand Down

0 comments on commit 2891aa5

Please sign in to comment.