Overlay Subtitles (VTT) with cue settings

I’m trying to use vtt subtitles from a file and overlay them on a video stream. I’m looking to use the per-cue settings to position them. I’m not sure if this is a bug or just unsupported but I cannot get them settings data to apply (the subtitle always show at bottom center).

Steps to reproduce:

  • Create test video of black 1080p frames, 10 seconds: ffmpeg -f lavfi -i color=c=black:s=1920x1080:r=30:d=10 test.mp4
  • Create simple vtt subtitles file (subs.vtt):
WEBVTT

00:00:02,000 --> 00:00:08,000 T:50% A:center
Cue Settings Test
  • Run gstreamer pipeline:
gst-launch-1.0 \
    subtitleoverlay name=ov ! x264enc ! mp4mux ! filesink location=output.mp4 \
    filesrc location=test.mp4 ! decodebin ! videoconvert ! ov.video_sink \
    filesrc location=subs.vtt ! subparse ! ov.subtitle_sink

I’ve tried textoverlay and textrender elements in place of subtitleoverlay but they don’t seem to handle cue settings either.

Another thing I noticed was that the code from subparse: subprojects/gst-plugins-base/gst/subparse/gstsubparse.c · 1.28 · GStreamer / gstreamer · GitLab looks like it uses different attribute/setting tags than the official spec?

Is there any way with gstreamer to overlay text with positioning and styling on a specific “time-range” basis. Even if I need to use the api instead of cli, that’s fine.

GStreamer Version: 1.28.0

Maybe try this MR? webvtt: support CSS styling (!9679) · Merge requests · GStreamer / gstreamer · GitLab

Another thing I noticed was that the code from subparse: subprojects/gst-plugins-base/gst/subparse/gstsubparse.c · 1.28 · GStreamer / gstreamer · GitLab looks like it uses different attribute/setting tags than the official spec?

Yes the current parser we have for WebVTT in GStreamer was written for an early version of the spec. It would need to be updated.

1 Like