NatReader is a lightweight video decoding API designed for transcoding applications. It currently supports decoding frames from local video files (*.mp4
).
NatReader can be installed using the Unity Package Manager. In your manifest.json
file, add the following dependency:
{
"dependencies": {
"com.natsuite.natreader": "git+https://github.com/natsuite/NatReader"
}
}
First, create a frame reader for your media file. Currently, NatReader only supports MP4 video files:
var videoPath = "...";
var reader = new MP4Reader(videoPath);
With the reader, you can decode frames using the Read
method:
foreach (var (pixelBuffer, timestamp) in reader.Read()) {
// Use pixel buffer // This is always a `byte[]` in RGBA32 layout
...
}
Finally, when you are done reading frames, make sure to dispose the reader:
reader.Dispose();
- Unity 2019.2+
- Android API Level 24+
- iOS 11+
- macOS 10.13+