mirror of
https://github.com/arcodange-org/mediabunny.git
synced 2026-10-09 08:43:49 +02:00
Add subtitle tracks and implement subtitle tracks for Matroska muxer
This commit is contained in:
+13
-2
@@ -78,12 +78,23 @@
|
||||
codec: 'opus',
|
||||
bitrate: 128e3,
|
||||
});
|
||||
let subtitleSource = new Metamuxer.TextSubtitleSource('webvtt');
|
||||
|
||||
output.addTrack(videoSource);
|
||||
output.addTrack(audioSource);
|
||||
output.addVideoTrack(videoSource);
|
||||
output.addAudioTrack(audioSource);
|
||||
output.addSubtitleTrack(subtitleSource);
|
||||
|
||||
output.start();
|
||||
|
||||
let simpleWebvttFile =
|
||||
`WEBVTT
|
||||
|
||||
00:00:00.000 --> 00:00:10.000
|
||||
Example entry 1: Hello <b>world</b>.
|
||||
`;
|
||||
subtitleSource.digest(simpleWebvttFile);
|
||||
subtitleSource.close();
|
||||
|
||||
for (let i = 0; i < 100; i++) {
|
||||
context.fillStyle = ['red', 'green', 'blue', 'yellow'][i % 4];
|
||||
context.fillRect(canvas.width * Math.random(), canvas.height * Math.random(), canvas.width * Math.random(), canvas.height * Math.random());
|
||||
|
||||
Reference in New Issue
Block a user