Subtitles over VideoPlayer - Any thoughts on what to do?

I use pre rendered videos for my game which are played with the videoplayer. I’d like to add subtitles over them, but I’m unsure what the best method would be to sync them to the video? My initial thoughts are to maybe use an animation that triggers events at certain times and these events would load the next set of subtitle data?

If anyone has any other thoughts/ideas I’d love to hear them.

Thanks!

Timeline is perfect for this and made for stuff like this

Have one timeline with a VideoTrack

and then have another track for your subtitles (which is just a track affecting some text / game objects, should be simple to setup)

and hey presto, synced playable :slight_smile: Playable API is your friend for this, and timeline is built ontop of playables so for anything that needs “syncing”, consider playables api in the future :smile:

Good luck!

1 Like

I would look into making an .ass/.srt subtitle loader instead. There’s already software for convenient editing of subtitles (for example Aegisub), so why reinvent the wheel?

1 Like

I dont think that really tackles the OPs main issue which is how to sync a playing video to the subtitles. Which would either require a 3rd party asset, or developing one themself. Simply checking timestamps in SRT vs video time is not very efficient and can sometimes still have sync issues at points (although rare)

But for syncing, this is literally what timeline was made for. Timeline with 2 tracks and bang, your done :slight_smile:

OP could (And should) still load the subtitles using SRT format into a timeline track, but to ensure it is properly in sync (and more importantly, does not go out of sync during play) playables API should be used when actually playing and syncing these together (which timeline is built on top of) if you want super-precise syncing

if being super precise is not important, checking current video time vs SRT timestamp and displaying matching subtitle is enough :slight_smile:

1 Like

Subtitles have timestamps.
VideoPlayer has .time property which shows video playback time.

And that’s it.

Timeline seems like needlessly complicating thing.

Ya I’m going to go with this, cutscenes are not long enough or often enough to implement another api into the project. Thanks for the suggestion!

1 Like

Sorry to revive this but… How in the world did you manage to play a Video in the timeline? I checked the samples unity provides some video playable - it’s completely buggy and unusable.