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/
49 stars 8 forks source link

Corrupted video files (update with research) #343

Closed woodrowproctor closed 1 month ago

woodrowproctor commented 1 year ago

Unity Version 2021.3.27 Avpro Capture desktop edition 5.1.8 Windows 10 CaptureFromCamera 1600x900 capture unity audio

I posted a while ago about getting some corrupted video files but I did not have enough information to get anywhere with it. I've figured out a lot of what is going on and I think it is an avprocapture bug.

I am using the capture from camera component and I am not doing anything fancy, basically just calling -

AVProRecorder.StartCapture()
AVProRecorder.StopCapture(true);

BUG: I have about a 1/6 chance of the video I created being unplayable when stopping the capture. I can make new videos after that one and they are fine. Also, if a video is captured in the unplayable state, on destroy for the capturefromcamera component freezes forever, causing the app to stall

RESEARCH: Looks like capturebase has a list of FileWritingHandlers. The videos that never finish are never removed from the list of _pendingfilewrites, which is supposed to clean up unfinished file writes. The video will remain in the list forever because FileWritingHandlers.IsFileReady will always return false. The completion status of the file writer will forever be stuck on BusyFileWriting. This happens on all the machines I have tested. I am left with a video that won't play and an app that must be forced to quit. Length of video has not effect on my results, and about 80% of the videos I record do not have this problem

Is there a way to force a file writer to finish whatever it's doing? Running dispose on a filewriter in this state causes an infinite freeze

woodrowproctor commented 1 year ago

NativePlugin.FreeRecorder(_handle); seems to be the line that freezes forever

Chris-RH commented 12 months ago

Ahh, thank you for the info, we'll look into this further.

woodrowproctor commented 9 months ago

@Chris-RH Have there been any discoveries or changes involving this problem? We are planning on switching to a different video recording plugin because of this problem. We can only do so much when the infinite loop is inside a hidden method that we cannot debug

RichRH commented 3 months ago

Hi,

Apologies this has taken a while to look into. We think we've identified the issue and it's linked to passing the first parameter of 'StopCapture()' as 'true' when it should be 'false', as 'skipPendingFrames' forces a flush which seems to conflict with finalising the video on certain Windows/SDK versions.

We're looking into a more permanent solution but in the meantime the above workaround should hopefully address this.

Cheers,

Chris-RH commented 1 month ago

AVPro Movie Capture version 5.3.2 has been released. Please let us know if it has not fixed your issue.