Video Playback Features
Learn about the advanced video playback capabilities of Vulkan Media Player and how to use them effectively in your Unreal Engine projects.
Supported Video Formats
Video Codecs
Vulkan Media Player currently supports:
| Codec | Status | Notes |
|---|---|---|
| H.264 (AVC) | ✅ Fully Supported | Hardware-accelerated via Vulkan Video |
H.265 and Other Codecs
Support for additional codecs (H.265/HEVC, VP9, AV1) is planned for future releases. Currently, only H.264 is supported.
Container Formats
| Format | Extension | Support |
|---|---|---|
| MP4 | .mp4 | ✅ Recommended |
| MKV | .mkv | ✅ Supported |
| WebM | .webm | ⚠️ Limited |
Best Practices
For optimal playback with Vulkan Media Player:
- Codec: H.264 (AVC) - the only supported codec
- Container: MP4 (recommended) or MKV
- Resolution: 1920x1080 or lower
- Bitrate: 5-10 Mbps for high quality
- Profile: High Profile, Level 4.1
Playback Control
Basic Playback Operations
Opening Media
// C++ Example
UMediaPlayer* MediaPlayer = GetMediaPlayer();
UFileMediaSource* MediaSource = NewObject<UFileMediaSource>();
MediaSource->FilePath = TEXT("Content/Movies/MyVideo.mp4");
MediaPlayer->OpenSource(MediaSource);Blueprint Equivalent:
- Use Open Source node with your Media Player and File Media Source
Play/Pause
// Play
MediaPlayer->Play();
// Pause
MediaPlayer->Pause();
// Toggle
if (MediaPlayer->IsPlaying())
{
MediaPlayer->Pause();
}
else
{
MediaPlayer->Play();
}Stop and Close
// Stop playback (can resume with Play())
MediaPlayer->Close();
// Completely release media resources
MediaPlayer->Close();Advanced Playback Control
Seeking
// Seek to specific time (in seconds)
FTimespan SeekTime = FTimespan::FromSeconds(30.0);
MediaPlayer->Seek(SeekTime);
// Seek to percentage
float Percentage = 0.5f; // 50%
FTimespan Duration = MediaPlayer->GetDuration();
FTimespan SeekTime = Duration * Percentage;
MediaPlayer->Seek(SeekTime);Playback Rate
// Normal speed
MediaPlayer->SetRate(1.0f);
// Slow motion (50%)
MediaPlayer->SetRate(0.5f);
// Fast forward (2x)
MediaPlayer->SetRate(2.0f);
// Reverse playback (if supported)
MediaPlayer->SetRate(-1.0f);Rate Limitations
Not all video codecs and GPUs support variable playback rates. Test thoroughly on target hardware.
Looping
// Enable looping
MediaPlayer->SetLooping(true);
// Disable looping
MediaPlayer->SetLooping(false);Blueprint:
- Enable Loop checkbox in Media Player asset properties
Playback States
Monitoring Playback State
// Check if media is currently playing
bool bIsPlaying = MediaPlayer->IsPlaying();
// Check if media is paused
bool bIsPaused = MediaPlayer->IsPaused();
// Check if media is buffering
bool bIsBuffering = MediaPlayer->IsBuffering();
// Check if media is ready to play
bool bIsReady = MediaPlayer->IsReady();
// Get current playback time
FTimespan CurrentTime = MediaPlayer->GetTime();
// Get total duration
FTimespan Duration = MediaPlayer->GetDuration();Playback Events
Subscribe to media player events:
// On media opened successfully
MediaPlayer->OnMediaOpened.AddDynamic(this, &AMyActor::OnMediaOpened);
// On media playback started
MediaPlayer->OnPlaybackStarted.AddDynamic(this, &AMyActor::OnPlaybackStarted);
// On media reached end
MediaPlayer->OnEndReached.AddDynamic(this, &AMyActor::OnEndReached);
// On playback error
MediaPlayer->OnMediaOpenFailed.AddDynamic(this, &AMyActor::OnMediaOpenFailed);Blueprint:
- Use the Event Graph to bind to media player events
Display Options
Texture Output
Creating Media Texture
Media textures are automatically created when you create a Media Player asset, or you can create them manually:
- Right-click in Content Browser
- Select Media → Media Texture
- Set the Media Player property to your Media Player asset
Material Setup
Basic Material:
MediaTexture → Emissive ColorWith Aspect Ratio Correction:
MediaTexture → TextureSample
↓
Multiply (RGB) → Emissive ColorVideo Dimensions
// Get video dimensions
FIntPoint Dimensions = MediaPlayer->GetVideoTrackDimensions(INDEX_NONE, INDEX_NONE);
int32 Width = Dimensions.X;
int32 Height = Dimensions.Y;
// Get aspect ratio
float AspectRatio = (float)Width / (float)Height;Performance Optimization
Hardware Acceleration
Vulkan Media Player automatically uses hardware acceleration when available. To verify:
// Check if hardware acceleration is active
// (Implementation-specific - check Output Log)Best Practices
Resolution
- Use 1920x1080 or lower for best performance
- Higher resolutions require more GPU memory and bandwidth
Bitrate
- Balance quality and file size
- Recommended: 5-10 Mbps for 1080p
Codec Selection
- Use H.264 (only supported codec)
- Ensure videos are properly encoded with H.264
Texture Format
- Default settings usually work best
- Avoid manual texture format changes unless necessary
Streaming Video
Local File Streaming
// Open large video file for streaming
UFileMediaSource* MediaSource = NewObject<UFileMediaSource>();
MediaSource->FilePath = TEXT("Content/Movies/LargeVideo.mp4");
MediaPlayer->OpenSource(MediaSource);The plugin automatically handles buffering for smooth playback.
Network Streaming
Experimental
Network streaming support is experimental. Test thoroughly for your use case.
Troubleshooting
Video Plays But Performance is Poor
Possible Causes:
- Hardware acceleration not working
- Video resolution too high
- Codec not hardware-supported
Solutions:
- Check
vulkaninfooutput for codec support - Reduce video resolution
- Update GPU drivers
- Verify Vulkan RHI is enabled
Seeking is Slow or Inaccurate
Cause: Video file doesn't have proper keyframe intervals
Solution: Re-encode video with regular keyframes:
ffmpeg -i input.mp4 -c:v libx264 -g 30 -keyint_min 30 output.mp4Video Freezes or Stutters
Possible Causes:
- File I/O bottleneck
- Insufficient GPU memory
- Driver issues
Solutions:
- Move video file to SSD
- Reduce video resolution
- Update GPU drivers
- Close other GPU-intensive applications
Next Steps
- Learn about Audio Support
- Optimize Performance for your specific use case
- Join our Discord community for tips and tricks
Need help? Join our Discord community for support!
