Created
June 20, 2019 22:06
-
-
Save olokobayusuf/ba09d39c8b0e2bde4780ad11f69d73d7 to your computer and use it in GitHub Desktop.
An example illustrating transcoding a video in Unity using NatExtractor and NatCorder.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using NatCorder; | |
using NatExtractor; | |
public class TranscodeDemo : MonoBehaviour { | |
public string videoPath; // Path to video to be transcoded | |
void Start () { | |
// Create a frame extractor | |
var extractor = new FrameExtractor(videoPath); | |
// Create an MP4 recorder | |
var recorder = new MP4Recorder( | |
extractor.resolution.width, | |
extractor.resolution.height, | |
extractor.resolution.refreshRate, | |
0, | |
0, | |
OnTranscode | |
); | |
// Transcode | |
extractor.Extract( | |
(pixelBuffer, timestamp) => recorder.CommitFrame(pixelBuffer, timestamp), | |
() => recorder.Dispose() | |
); | |
} | |
void OnTranscode (string path) { | |
// Use transcoded video | |
... | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment