shaka-project / shaka-packager

A media packaging and development framework for VOD and Live DASH and HLS applications, supporting Common Encryption for Widevine and other DRM Systems.
https://shaka-project.github.io/shaka-packager/
Other
1.95k stars 504 forks source link

Missing codec information in HLS for VTT-in-MP4 subs #645

Closed joeyparrish closed 4 months ago

joeyparrish commented 5 years ago

System info

Operating System: gLinux Shaka Packager Version: v2.3.0

Issue and steps to reproduce the problem

Packager Command:

wget https://storage.googleapis.com/shaka-streamer-assets/sample-inputs/Sintel.2010.720p.mkv
wget https://storage.googleapis.com/shaka-streamer-assets/sample-inputs/Sintel.2010.English.vtt
ffmpeg -i Sintel.2010.720p.mkv -t 5 -c:v copy -c:a copy Sintel.clip.mp4

packager \
  in=Sintel.clip.mp4,stream=video,output=video_output.mp4, \
  in=Sintel.2010.English.vtt,stream=text,language=en,output=text_output.mp4, \
  --segment_duration 10 \
  --hls_master_playlist_output master_playlist.m3u8 \
  --hls_playlist_type VOD

What is the expected result?

The master playlist should have codec information on the VTT-in-MP4 subtitles so that Shaka Player can differentiate between VTT-in-MP4 and TTML-in-MP4.

What happens instead?

The HLS master playlist has no codec info for the text stream:

#EXTM3U
## Generated with https://github.com/google/shaka-packager version v2.3.0-5bf8ad5-release

#EXT-X-MEDIA:TYPE=SUBTITLES,URI="stream_0.m3u8",GROUP-ID="default-text-group",LANGUAGE="en",NAME="stream_0",AUTOSELECT=YES

#EXT-X-STREAM-INF:BANDWIDTH=3295469,AVERAGE-BANDWIDTH=3295469,CODECS="avc1.640029",RESOLUTION=1280x544,SUBTITLES="default-text-group"
stream_1.m3u8
kqyang commented 5 years ago

Apple requires WebVTT subtitles in text files, see HLS Authoring Specification for Apple Devices

5.3. WebVTT subtitles MUST be in text files, with an X-TIMESTAMP-MAP according to the HLS specification.

We removed the codecs attribute for WebVTT intentionally for legacy device compatibility as old Apple devices do not recognize "wvtt" in codecs, see #402 for details.

Another section of the specification says

5.10. The kind of subtitles SHOULD be specified in the CODECS attribute of the associated EXT-X-STREAM-INF tags. You SHOULD use “stpp.ttml.im1t” to identify IMSC1 subtitles. You MAY use “wvtt" to identify WebVTT subtitles.

So codec information for WebVTT is optional and codec information for TTML is recommended.

@joeyparrish Would it work in the player to assume webvtt subtitles if the relevant codec information is missing? (since codec information for TTML should be present)

We can also introduce a flag in packager to let users decide whether to write the codec information for WebVTT in the playlist.