Video files generally work on vtt files So I want it to convert the file to vtt first, then put it dynamic into video I have two different files One of them converts VTT files to video but not able to receive srt file It can accept both files at the same time, via the input file The second converts the srt file to vtt but does not convert it to video
first, my code appended vtt file to the video I went to convert srt to vtt after that append it to the video.
<lablel>Subtitles: <input id="subtitlet" type="file"></lablel>
<video id="video" src="123.mp4" controls>
<track id="subtitles" kind="subtitles" label="English captions" srclang="en" default>
</video>
<script>
const $ = document.querySelector.bind(document);
$('#subtitlet').addEventListener('change', () => {
// approach 1
$('#subtitles').src = URL.createObjectURL($('#subtitlet').files[0]);
// approach 2
let track = document.createElement('track');
track.src = URL.createObjectURL($('#subtitlet').files[0]);
$('#video').appendChild(track);
});
</script>
second convert srt to vtt but not append to video I went append to video in this link
convert srt to vtt after appending to video HTML