Inserting SEI into H.264 (AVC) Streams | v0.18.0.0+
OvenMediaEngine can insert SEI (Supplemental Enhancement Information) into live streams to deliver custom data with video content at frame-level precision.
Overview
You can insert SEI dynamically through OvenMediaEngine's Send Event API or continuously through XML configuration.
When inserting SEI, you can add custom data, and the inserted SEI automatically includes UUID and Timestamp.
The inserted SEI is generated in OvenMediaEngine-specific format containing UUID, Timestamp, and custom data.
OvenPlayer can receive SEI inserted by OvenMediaEngine and provides functionality to automatically parse the SEI specification defined by OvenMediaEngine.
Inserting SEI via Send Event API
API Interface
You can use OvenMediaEngine's SendEvent REST API to dynamically trigger events that insert SEI into streams.
Request
eventFormat
Y
Specifies the event format (use sei
format)
eventType
N
Specifies the event type (use video
format)
events
Y
Contains event data values
event.seiType
N
Specifies SEI type (use UserDataUnregistered
format)
event.data
Y
Enter the actual data to be transmitted
Response
Inserting SEI through XML Configuration
For scenarios requiring continuous SEI insertion, you can configure this behavior through XML configuration. Create an XML file defining SEI insertion events and enable EventGenerator
in Server.xml
.
Configuration Example
Server.xml: You can enable the EventGenerator functionality for SEI insertion by adding <Application><EventGenerator>
.
<Enable>
Y
Set activation status with true or false
<Path>
Y
Set the path to the XML file defining SEI insertion details. If a relative path is specified, the directory containing the Server.xml file is used as the base
XML Defining SEI Insertion Events: Create an XML file defining SEI insertion events at the path specified in Server.xml
. In this example, it's send_event_info.xml
.
<Enable>
Y
Set activation status with true or false
<SourceStreamName>
Y
Specify target stream name. Supports wildcards (*) for pattern matching
<Interval>
Y
Set event occurrence interval in milliseconds (ms)
<EventFormat>
Y
Specify event format (use sei
format)
<EventType>
N
Set to video
<Values><SeiType>
N
Specify SEI type (use UserDataUnregistered
format)
<Values><Data>
Y
Specify custom data to be inserted into SEI
Changes made to the event definition XML file are immediately applied without needing to restart OvenMediaEngine.
OvenMediaEngine-Specific SEI Payload Format
The payload of SEI generated by OvenMediaEngine always includes UUID and Timestamp values in the following structure:
UUID
128
Indicates that the SEI Payload follows OvenMediaEngine's specification. Always set to 464d4c47-5241-494e-434f-4c4f554201
Timestamp
64
Epoch time in milliseconds
Data
Varies depending on custom data
custom data
Receiving SEI Data
OvenPlayer can parse SEI inserted by OvenMediaEngine and pass the included UUID, Timestamp, and custom data to the application.
Code Example
Player Initialization:
Call
OvenPlayer.create()
function to create a player in the specified div.Specify the stream type and URL in the
sources
array. SEI is only supported in WebRTC streams.Enable H.264 NAL (Network Abstraction Layer) parsing through
parseStream.enabled: true
setting. This is required for SEI metadata processing.
SEI Data Processing:
Register a
player.on('metaData', callback)
event listener to process SEI whenever it is received.You can obtain the UUID, Timestamp, and custom data inserted by OvenMediaEngine from the event callback parameter.
metaData Event Callback Parameters
type
Always set to sei
, indicating this is SEI metadata
nalu
Uint8Array containing raw NALU (Network Abstraction Layer Unit) data of the SEI
sei
SEI parsing result containing the following sub-fields:
- type
: SEI type
- size
: Payload size
- payload
: Raw SEI payload data (Uint8Array)
registered
Indicates whether the SEI was generated in the format defined by OvenMediaEngine. If true, the following additional fields are included
uuid
(when registered=true) Unique identifier inserted by OvenMediaEngine into the SEI
timecode
(when registered=true) Timestamp (milliseconds) when the SEI was inserted
userdata
(when registered=true) Uint8Array containing custom data. This data should be parsed according to the application's requirements
Appendix: Installing OvenPlayer
OvenPlayer version 0.10.39 and later can receive SEI data included in video during WebRTC stream playback.
OvenPlayer can be downloaded from the GitHub releases page.
After extracting the downloaded file, copy all files in the
dist
directory to your project's library folder:
Key files to copy:
ovenplayer.js
: OvenPlayer core libraryRTCTransformWorker.worker.worker.js
: Worker script for WebRTC processing
Due to Web Worker CORS policy, ovenplayer.js
must be self-hosted, and the RTCTransformWorker.worker.worker.js
file must exist in the same path as ovenplayer.js
.
Last updated