Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
110 changes: 42 additions & 68 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,101 +1,75 @@
# VlcMedia

Unreal Engine 4 Media Framework plug-in using the Video LAN Codec (libvlc).

Unreal Engine Media Framework plugin using VideoLAN libvlc.

## About

This plug-in is still under development and likely has a lot of remaining issues
to be fixed. Use in production is not yet recommended.

Make sure to pull the *Tag* that matches your Unreal Engine version. If you sync
to *Master* the code may not compile, because it may depend on Engine changes
that are not yet available in the UE4 Master branch.
This repository is based on the original `ue4plugins/VlcMedia` project and has
been updated to run on Unreal Engine 5.6.

The plugin is still community maintained. Test carefully before production use.

## Supported Platforms
## Engine and Platform Status

This plug-in was last built against **Unreal Engine 4.19** and tested
against the following platforms:
- Engine target: **Unreal Engine 5.6** (`VlcMedia.uplugin`)
- Confirmed working path in this branch: **Win64**
- Linux and Mac modules are still present, but may require platform-specific
validation and packaging updates.

- Linux (Ubuntu 16.04)
- ~~Mac~~
- Windows
## Licensing and Distribution Notes

**IMPORTANT**: Please note that this repository contains pre-compiled binaries
for libvlc and its plug-ins, which are licensed under LGPL. This means that you
cannot create monolithic builds of your game without violating LGPL, the UE4
EULA or both. The libvlc libraries must remain dynamic libraries that are bound
at run-time - static linking is not allowed - and the licensing related files in
*/ThirdParty/vlc* must be retained.
This repository includes precompiled libvlc binaries and plugins licensed under
LGPL.

This also means that this plug-in cannot work on platforms that do not support
dynamically linked libraries (i.e. iOS, HTML5) or do not currently implement
support for it (i.e. Android, XboxOne).
Important requirements:

Epic is in the process of adding plug-in support to monolithic builds, but there
is no ETA yet. Once this is supported, you will be able to distribute monolithic
game and server builds with VlcMedia, provided that the libvlc libraries and
plug-ins remain as separate DLLs.
- Keep libvlc as dynamically loaded libraries (DLL/dylib/so)
- Do not statically link libvlc into game binaries
- Keep licensing and notice files in `ThirdParty/vlc`

Because of these constraints, platforms without practical dynamic library plugin
support are not expected to work.

## Prerequisites

A relatively recent version of libvlc is required. The latest stable release
(currently 2.2.1) is not sufficient.

For Mac and Windows, the following nightly builds are currently included:
* macOS: vlc-4.0.0-20180319-0303-dev
* Win32: vlc-4.0.0-20180319-0303-dev-win32
* Win64: vlc-4.0.0-20180319-1331-dev-win64

Nightly builds can be downloaded from the VideoLAN web site (see below).

For debugging on Win32 and Win64, you can download debug builds and replace the
corresponding files and folders in the *VlcMedia/ThirdParty/vlc/* directory.
- Unreal Engine 5.6
- Visual Studio toolchain for C++ builds on Windows
- A C++ project (or full source engine build) to compile plugin modules

### Linux (Ubuntu 16.04)
## Included Runtime Binaries

A suitable version of **libvlc** must be installed or compiled from source. If
you ship your game on Linux, you will likely want to include libvlc with it, so
that users don't have to install it themselves. We will eventually include those
binaries in this repository, although it is not clear what distros should be
supported and where the builds are coming from. A better workflow needs to be
established for this (https://github.com/ue4plugins/VlcMedia/issues/17).
`ThirdParty/vlc` contains bundled VLC runtime files used by the plugin.

To clean up, clone, make and install VLC (including libvlc) into your project,
run the *VlcMedia/Build/Vlc4LinuxCloneMakeInstall.sh* script from within your
project's root folder. If you later need to make and re-install VLC from the
existing VLC code, run the *Vlc4LinuxMakeInstall.sh* script instead.
- Win64 binaries and plugins are refreshed in this branch
- Linux helper scripts are available in `Build/` for local libvlc setup

### Mac, Windows
If you need to swap libvlc builds, replace the corresponding files under
`ThirdParty/vlc/<Platform>` and re-test playback.

All required libraries and plug-ins are included in the *ThirdParty* directory
and work out of the box.
## Installation

### As Project Plugin (recommended)

## Dependencies
1. Copy or clone this repository into your project at `Plugins/VlcMedia`
2. Regenerate project files if needed
3. Build the project from Visual Studio (or via Unreal Build Tool)

This plug-in requires Visual Studio and either a C++ code project or the full
Unreal Engine 4 source code from GitHub. If you are new to programming in UE4,
please see the official [Programming Guide](https://docs.unrealengine.com/latest/INT/Programming/index.html)!
### As Engine Plugin

1. Place repository under `Engine/Plugins/Media/VlcMedia`
2. Rebuild engine/project modules

## Usage
## RTSP Notes

You can use this plug-in as a project plug-in, or an Engine plug-in.
RTSP-specific setup notes are available in `RTSP_SETUP.md`.

If you use it as a project plug-in, clone this repository into your project's
*/Plugins* directory and compile your game in Visual Studio. A C++ code project
is required for this to work.
### UE5.6 RTSP Preview

If you use it as an Engine plug-in, clone this repository into the
*/Engine/Plugins/Media* directory and compile your game. Full Unreal Engine 4
source code from GitHub is required for this.
The screenshot below shows RTSP playback running in UE 5.6 with this plugin setup.

![UE5.6 RTSP CCTV preview](Resources/images/ue56-rtsp-cctv-preview.png)

## References

* [VideoLAN Homepage](http://videolan.org)
* [VideoLAN Nightly Builds](http://nightlies.videolan.org/)
* [Introduction to UE4 Plugins](https://wiki.unrealengine.com/An_Introduction_to_UE4_Plugins)
- [VideoLAN](https://www.videolan.org/)
- [VlcMedia upstream repository](https://github.com/ue4plugins/VlcMedia)
103 changes: 103 additions & 0 deletions RTSP_SETUP.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# RTSP 재생 설정 (UE 5.6, VlcMedia)

이 문서는 본 프로젝트에서 RTSP 스트림이 정상 재생되도록 구성한 내용을 정리한 것입니다.

## 원본 플러그인 저장소

- VlcMedia 원본: `https://github.com/ue4plugins/VlcMedia`
- 본 프로젝트에는 위 플러그인을 프로젝트 플러그인 형태로 포함해 커스터마이징했습니다.

## 환경

- 프로젝트 경로(예시): `<YourProject>/Plugins/VlcMedia`
- 엔진: Unreal Engine 5.6.x
- RTSP 예시: `rtsp://210.99.70.120:1935/live/cctv001.stream`
- 테스트 주소 출처: [충청남도 천안시_교통정보 CCTV](https://www.data.go.kr/data/15063717/fileData.do)

## 필요한 것 (사전 설치/준비)

- Unreal Engine 5.6.x
- C++ 빌드를 위한 Visual Studio (MSVC 툴체인)
- 별도의 VLC 설치는 필요 없음
- LibVLC 바이너리를 플러그인 폴더에 포함해서 사용합니다.

## LibVLC 구성

- LibVLC 위치:
- `Plugins/VlcMedia-master/ThirdParty/vlc/Win64`
- 사용 버전:
- LibVLC 3.0.20 (Win64 zip 기반)
- vmem 출력 강제 및 HW 디코더 비활성화 상태로 동작

## 액터 구성 (CCTVStreamActor)

### 에디터에서 만든 MediaPlayer/MediaTexture 사용 (권장)

런타임 생성 대신 에디터에서 만든 에셋을 연결하면 일관성이 좋아집니다.

1) **Media Player** 에셋 생성
2) 생성 시 **Video Output Media Texture** 체크 → Media Texture 자동 생성
3) 액터에 다음 에셋을 지정
- `MediaPlayerAsset`
- `MediaTextureAsset`
4) `BaseMaterial`에는 `Texture` 파라미터가 있는 머티리얼을 지정

### 주요 프로퍼티

- `RtspUrl`: 재생할 RTSP URL
- `OverridePlayerName`: 기본값 `VlcMedia`
- `bUseTCP`: true이면 `?transport=tcp`를 붙여 TCP 강제

## 성능 최적화

- **복수 스트림**: 최대 8개 동시 재생 권장 (메모리 제한)
- **해상도**: 1080p 내에서 조정 (4K는 메모리 과다 사용)
- **재생 관리**: 사용하지 않는 스트림은 Pause 상태로 전환
- **프레임 버퍼**: 필요시 30fps로 제한하여 부하 감소

## 보안 고려사항

- **인증 URL**: `rtsp://<user>:<password>@<host>:<port>/<path>` (실계정/실비밀번호 직접 노출 금지)
- **네트워크**: 방화벽에서 554(RTSP), 1935(RTMP) 포트 허용
- **TLS**: 프로덕션에서는 `rtsps://` 사용 고려

## 디버깅 명령어

### UE5 콘솔 변수
```bash
vt.VlcMedia.LogLevel 4
vt.VlcMedia.ShowStats 1
Media.LogLevel Verbose
Media.Player.ShowTime 1
```

### 스트림 상태 확인
```cpp
// CCTVStreamActor에서
bool IsStreamHealthy() const;
float GetCurrentBitrate() const;
```

## 배포 테스트 케이스

| 시나리오 | 검증 항목 | 통과 기준 |
| --- | --- | --- |
| 단일 스트림 24시간 | 안정성 | 크래시 없음 |
| 다중 스트림 (4개) | 성능 | 메모리 < 2GB |
| 네트워크 장애 | 복구력 | 5초 내 재연결 |

## 에러 코드별 대응표

| 증상 | 원인 | 해결책 |
| --- | --- | --- |
| 검은 화면 | vmem 실패 | `--avcodec-hw=none` |
| 연결 타임아웃 | 방화벽 | `?transport=tcp` |
| 소리만 나옴 | 비디오 출력 | vmem 설정 확인 |

## 트러블슈팅

### 미디어 플레이어는 재생되는데 머티리얼이 검정일 때

1) `MediaTexture`가 올바른 `MediaPlayer`에 연결되어 있는지 확인
2) 머티리얼 파라미터 이름이 `Texture`인지 확인
3) 로그에서 `StaticVideoDisplayCallback` 호출 여부 확인
Binary file added Resources/images/ue56-rtsp-cctv-preview.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions Source/VlcMedia/Private/Player/VlcMediaAudioSample.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include "CoreTypes.h"
#include "IMediaAudioSample.h"
#include "IMediaTimeSource.h"
#include "MediaObjectPool.h"
#include "Misc/Timespan.h"
#include "Templates/SharedPointer.h"
Expand Down Expand Up @@ -118,9 +119,9 @@ class FVlcMediaAudioSample
return SampleRate;
}

virtual FTimespan GetTime() const override
virtual FMediaTimeStamp GetTime() const override
{
return Time;
return FMediaTimeStamp(Time);
}

protected:
Expand Down
Loading