2

I have these files, (test.mp4 test.srt test-fr.srt ) I want to convert the video test.mp4 to m3u8 with multiple subtitles

This is the kind of m3u8 file, that am trying to generate(this example is from hls-js site)

as you can see, the subtitles and audio chunks are included to the main m3u8 file.

#EXTM3U
#EXT-X-VERSION:3

#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="Chinese",FORCED=NO,AUTOSELECT=YES,URI="media/chinese/ed.m3u8",LANGUAGE="zh"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs",NAME="French",FORCED=NO,AUTOSELECT=YES,URI="media/french/ed.m3u8",LANGUAGE="fr"

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,URI="media/b160000-english.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",LANGUAGE="sp",NAME="Spanish",DEFAULT=NO,AUTOSELECT=YES,URI="media/b160000-spanish.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac",LANGUAGE="en",NAME="Commentary (eng)",DEFAULT=NO,AUTOSELECT=NO,URI="media/b160000-commentary.m3u8"

#EXT-X-STREAM-INF:BANDWIDTH=2962000,NAME="Main",CODECS="avc1.66.30",RESOLUTION=1280x720,AUDIO="aac",SUBTITLES="subs"
media/b2962000-video.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1427000,NAME="Main",CODECS="avc1.66.30",RESOLUTION=768x432,AUDIO="aac",SUBTITLES="subs"
media/b1427000-video.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=688000,NAME="Main",CODECS="avc1.66.30",RESOLUTION=448x252,AUDIO="aac",SUBTITLES="subs"
media/b688000-video.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=331000,NAME="Main",CODECS="avc1.66.30",RESOLUTION=284x160,AUDIO="aac",SUBTITLES="subs"
media/b331000-video.m3u8

#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs_b",NAME="Chinese",FORCED=NO,AUTOSELECT=YES,URI="media_b/chinese/ed.m3u8",LANGUAGE="zh"
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subs_b",NAME="French",FORCED=NO,AUTOSELECT=YES,URI="media_b/french/ed.m3u8",LANGUAGE="fr"

#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_b",LANGUAGE="en",NAME="English",DEFAULT=YES,AUTOSELECT=YES,URI="media_b/b160000-english.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_b",LANGUAGE="sp",NAME="Spanish",DEFAULT=NO,AUTOSELECT=YES,URI="media_b/b160000-spanish.m3u8"
#EXT-X-MEDIA:TYPE=AUDIO,GROUP-ID="aac_b",LANGUAGE="en",NAME="Commentary (eng)",DEFAULT=NO,AUTOSELECT=NO,URI="media_b/b160000-commentary.m3u8"

#EXT-X-STREAM-INF:BANDWIDTH=2962000,NAME="Main",CODECS="avc1.66.30",RESOLUTION=1280x720,AUDIO="aac_b",SUBTITLES="subs_b"
media_b/b2962000-video.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1427000,NAME="Main",CODECS="avc1.66.30",RESOLUTION=768x432,AUDIO="aac_b",SUBTITLES="subs_b"
media_b/b1427000-video.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=688000,NAME="Main",CODECS="avc1.66.30",RESOLUTION=448x252,AUDIO="aac_b",SUBTITLES="subs_b"
media_b/b688000-video.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=331000,NAME="Main",CODECS="avc1.66.30",RESOLUTION=284x160,AUDIO="aac_b",SUBTITLES="subs_b"
media_b/b331000-video.m3u8

I tried this command

ffmpeg -i test.mp4 -vf "subtitles=test.srt" -y test.m3u8

but it actually burned the subtitle inside the video. What is the right command that creates the m3u8 with all subtitles included inside m3u8 like in the example above? thank you.

PS:new to ffmpeg:)

UPDATE: my main goal here is to make different video players recognise the captions enter image description here

PS: am developing a website for video streaming

2
  • 1
    an m3u8 is a playlist, not a video container, so I'm not 100% sure what you want to achieve Oct 7, 2022 at 8:34
  • 1
    @MarcusMüller what am trying to do is to convert mp4 to hls chunks for video streaming. Output file is (m3u8) and it's working. But now i want to add a soft subtitle to that video, to make subtitle switchable in the UI. and whats makes it swtchable is this line of code in m3u8 #EXT-X-MEDIA:TYPE=SUBTITLES,GROUP.... Now i want to generate the same kind of file with fmpeg Oct 7, 2022 at 8:55

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.