ffmpeghttp-live-streamingwebvtthls.jsvtt

Ffmpeg burnt in subtitles out of sync when converting to hls


I have a file that has subtitles burn into it and they are perfectly in sync.

Here is the file. https://983yqbz442.s3.amazonaws.com/little-mermaid-captions.mp4

I run this command to convert to hls and it creates the .ts files and the .vtt files.

ffmpeg -i little-mermaid-captions.mp4 -profile:v baseline -level 3.0 -s 640x360 -start_number 0 -hls_time 10 -hls_list_size 0 -f hls index.m3u8

I also then create a master.m3u8 file in the same folder with the following.

#EXTM3U
#EXT-X-VERSION:3
#EXT-X-INDEPENDENT-SEGMENTS
#EXT-X-STREAM-INF:BANDWIDTH=800000,RESOLUTION=640x360,SUBTITLES="subtitles"
index.m3u8
#EXT-X-MEDIA:TYPE=SUBTITLES,GROUP-ID="subtitles",NAME="English",DEFAULT=YES,AUTOSELECT=YES,FORCED=NO,LANGUAGE="ENG",URI="index_vtt.m3u8"

Now if I play the master.m3u8 file the subtitles are now out of sync and are about 1 sec to quick. I understand this is probably a setting I am missing through FFmpeg but really stuck on this and would appreciate any insight.

Thanks

More info.

Here is a link to the direct .m3u8 this can be opened in Safari.

https://983yqbz442.s3.amazonaws.com/hlstests/master.m3u8

The generated vtt file is here.

https://983yqbz442.s3.amazonaws.com/hlstests/subs-0.vtt

If you look at the start of the .vtt file you will see this.

WEBVTT

00:06.840 --> 00:10.320
once long ago in the deep blue below

It should start at 00:06.840 but when playing the .m3u8 file in Safari you should see it starts at around 5 seconds not 6 about a second too early.


Solution

  • For some reason FFMPEG adds about 1.4 seconds to the presentation time of the MPEG-2 Transport Stream when writing. So your video and audio are late. If you add -muxdelay 0 to your FFMPEG command line the sync issue should be resolved.