RenderHeads / UnityPlugin-AVProMovieCapture

AVPro Movie Capture is a Unity Plugin for advanced video capture to AVI/MP4/MOV files
https://renderheads.com/products/avpro-movie-capture/
48 stars 8 forks source link

Make StopCapture() async #71

Closed AndrewRH closed 3 years ago

AndrewRH commented 4 years ago

Some captures can take quite a while to stop, and currently this blocks the calling thread. There should be an async version of StopCapture()

leavittx commented 4 years ago

Hi. Would be also quite useful to be notified when the (future) async StopCapture will finish its work. Looking forward to it!

AndrewRH commented 4 years ago

@leavittx I've put up a preview package here with support for non-blocking StopCapture()

https://github.com/RenderHeads/UnityPlugin-AVProMovieCapture/releases/tag/4.4.2

You can simply use it as is and it should work, but if you need to know when the file writing is complete then you can register for notification (see ScreenCaptureDemo.cs for an implementation):

void Start()
{
    _capture.BeginFinalFileWritingAction += OnBeginFinalFileWriting;
}

void OnBeginFinalFileWriting(FileWritingHandler handler)
{
    _fileWritingHandler = handler;
}

void Update()
{
    if (_fileWritingHandler != null)
    {
        if (_fileWritingHandler.IsFileReady())
        {
            Debug.Log("File is ready " + _fileWritingHandler.Path);
            _fileWritingHandler = null;
        }
    }
}

Let me know if that works for you and then we can get it into a proper release.

Thanks,

AndrewRH commented 3 years ago

I'm closing this issue as the feature request has been implemented in 4.4.2 and we are about to release 4.4.3