Description
The FinishAsync
method is used to complete the video creation process in the VideoWriter
class. This asynchronous method ensures that the video encoder is properly flushed and the video file is finalized. It is essential to call this method after adding all frames to ensure the video is correctly saved and closed.
Usage
To use the FinishAsync
method, ensure that you have added all the necessary frames to the VideoWriter
instance using the AddFrame
method. Once all frames are added, call FinishAsync
to finalize the video. This method returns a Task
, so it should be awaited to ensure the operation completes before proceeding.
Example
// Example of using FinishAsync in a video creation process
// Create an instance of VideoWriter
var videoWriter = new VideoWriter();
// Add frames to the video
videoWriter.AddFrame(frameData1, timestamp1);
videoWriter.AddFrame(frameData2, timestamp2);
// ... add more frames as needed
// Finalize the video
await videoWriter.FinishAsync();
// Dispose of the VideoWriter when done
videoWriter.Dispose();