How to add subtitles do Media Player?

Does anyone know how can I add subtitles to a video playing in Media Player? I already have the Media Player and Media Player Texture objects set up and working.

I cannot find for the love of my life any documentation regarding this. I already read most of this documentation ( Media Framework in Unreal Engine | Unreal Engine Documentation ) but can’t find anything about it. Google/UE forums/UE Answers doesn’t have anything about this either.

I realized some stuff:

  1. Looking at some screenshots of the documentation, an option appears in the Add New > Media: Localized Overlays.
  2. I created one object of this type and saw it had a map element Culture:BasicOverlay.
  3. Created a BasicOverlay and saw that it had a element that received a srt file (BLISS)
  4. Associated two srt files for two basic overlays, one for English and one for Portuguese.

Now what should I do? I have this setup ready (look at the image), but can’t see in the Media Player objects where to add these overlays.

For reference, I put the setup of my overlays object in a image attachment:

PS: I already seen this question, but it doesn’t have any answer neither covers localization: How to add subtitle/caption tracks to media player? - Programming & Scripting - Unreal Engine Forums

1 Like

There is no out of the box support for subtitles yet. The assets you found are not fully functional yet and have actually been removed in 4.19. UE4 Media Framework has support for subtitle tracks, but it’s only implemented on PS4 right now. Windows Media Foundation (WMF) in particular has no support for embedded subtitles, and some other platforms don’t either. Some more involved solution is needed to make this work on all platforms (possibly involving separate subtitle assets), and we haven’t figured that out yet.

You could possibly whip up something with the audio asset subtitles supports in UE4, but I have no example I can point you to.

We will address this feature at some point, but it hasn’t become high priority yet.

Hey, has there been any progress on subtitle support since this was posted?

Andy

Since this was the first search result I found for creating movie subtitles I thought I’d share my workaround even though this thread is rather old.

Using UE4.26.1 I’ve read through a lot of engine code trying to figure this out, the Subtitle Manager already has a function named SetMovieSubtitle callable via FSubtitleManager::GetSubtitleManager()->SetMovieSubtitle(…) which seems to be not properly implemented yet (at least afaik presently it doesn’t work maybe this will change in future versions).

I created a function in a Blueprint Library to be able to display subtitles to my needs.

332977-subtitlenode.png

This solution requires the Engine dependency

#include "AudioDevice.h"
#include "Kismet/KismetSystemLibrary.h"

void UToolFunctionLibrary::DisplaySubtitle(UObject* WorldContextObj, const FText& SubtitleText, const float Duration)
{
	//Create a SoundSourceBus to be able to use the Engines Audio Subtitle system
	USoundSourceBus* SoundSourceBus = NewObject<USoundSourceBus>(USoundSourceBus::StaticClass());
	FSubtitleCue Subtitle;
	Subtitle.Text = SubtitleText;
	SoundSourceBus->Subtitles.Add(Subtitle);
	SoundSourceBus->Duration = Duration;
	SoundSourceBus->SubtitlePriority = 10000;

	//Active Sound struct required by AddNewActiveSound
	FActiveSound NewActiveSound;
	NewActiveSound.SetSound(SoundSourceBus);
	NewActiveSound.SetWorld(WorldContextObj->GetWorld());

	NewActiveSound.Priority = SoundSourceBus->Priority;
	NewActiveSound.SubtitlePriority = SoundSourceBus->GetSubtitlePriority();
	
	NewActiveSound.SetOwner(WorldContextObj->GetWorld()->GetFirstPlayerController());
	
	WorldContextObj->GetWorld()->GetAudioDevice()->AddNewActiveSound(NewActiveSound);

	//Should destroy the sound source bus after the subtitle was displayed
	SoundSourceBus->MarkPendingKill();
}

To use this function I created a Widget that contains an image with the brush being set to a UI Material that has a Media Texture as a parameter.
The subtitles are stored in an array which’s type is a custom struct consisting of just a FText for the Subtitle and Float for the duration. These subtitles also work with the unreal localization features.

For pauses between subtitles, I just leave the Text empty.

332978-subtitlearray.png

When start playing the movie I then call the following event which iterates through the subtitles.
If you need to be able to pause your media player or use other functionalities, you would need to bind the media player events to this blueprint section.

332980-workingsubtitle.png