SRGSSR / srgmediaplayer-apple

An advanced media player library, simple and reliable
MIT License
158 stars 33 forks source link

Support coloured subtitles #97

Open pyby opened 3 years ago

pyby commented 3 years ago

Issue type

Feature request

Description of the problem

A a deaf or hard-of-hearing, I would like to read subtitles, with the adapted colors, if available.

Environment information

Steps to reproduce

  1. Play a video stream
  2. Open alternate tracks and select a subtitles option
pyby commented 3 years ago

Interesting articles explain WebVTT specifications: https://ronallo.com/blog/html5-video-caption-cue-settings-tester/ https://www.speechpad.com/captions/webvtt

From Apple documentation, AVPlayer supports the Cue Settings in WebVTT

Here is an example.

::cue(.red){ color: red; }
::cue(.blue){ color: blue; }
::cue(.green){ color: green; }
::cue(.yellow){ color: yellow; }
::cue(.background-red){ background-color: red; }
::cue(.background-blue){ background-color: blue; }
::cue(.background-green){ background-color: green; }
::cue(.background-yellow){ background-color: yellow; }

From French TV broadcaster, France Télévision, The second channel, France 2 livestream is delivered throw HLS with an AES-128 key encryption.

The webvtt subtitles for SDH looks like:

WEBVTT
X-TIMESTAMP-MAP=MPEGTS:7351793473,LOCAL:00:00:00.000

STYLE
::cue(.white) { color: white; }
::cue(.yellow) { color: yellow; }

00:00:00.000 --> 00:00:01.680 align:middle
<c.white> Demander le double </c>
<c.white> de ton cachet. </c>

00:00:02.080 --> 00:00:04.000 align:middle
<c.white> En général, c'est radical. </c>
<c.yellow> -Charlotte. </c>

AVPlayer in Safari Mac (opened in a tab) or in iOS applications support it:

colored_subtitles_hls

For a coloured subtitles integration in SRGMediaPlayer, the stream packager service has to support Cue Settings in WebVTT.