GIFRecorder.CommitFrame

public void CommitFrame (T[] pixelBuffer, long timestamp);

Description

Commit a video frame for encoding.

Note that WebGL is an immediate-encode platform, meaning that frames are encoded immediately they are committed. As a result, timestamps on video frames and audio sample buffers are wholly ignored.


public class RecordWebCam : MonoBehaviour {

    WebCamTexture cameraTexture;
    IMediaRecorder mediaRecorder;
    IClock clock;
       
    IEnumerator Start () {
        // Start camera preview
        cameraTexture = new WebCamTexture();
        cameraTexture.Play();
        // Start recording
        clock = new RealtimeClock();
        mediaRecorder = new ... // Create a recorder
        // Wait a while
        yield return new WaitForSeconds(10f);
        // Stop recording
        mediaRecorder.Dispose();
        mediaRecorder = null;
    }
    
    void Update () {
        if (mediaRecorder != null && cameraTexture.didUpdateThisFrame) {
            // Commit the frame for encoding
            mediaRecorder.CommitFrame(cameraTexture.GetPixels32(), clock.Timestamp);
        }
    }

}



Copyright (c) Yusuf Olokoba 2016