UnityPlugin-AVProMovieCapture icon indicating copy to clipboard operation
UnityPlugin-AVProMovieCapture copied to clipboard

[Bug] Switching Application causes frozen frame in recording. The amount of time with a frozen frame equals the amount of time of pausing

Open makakaorg opened this issue 1 year ago • 1 comments

Unity Version

2022.3.38

AVPro Movie Capture Version

5.3.0 Mobile Edition

Which platform(s) are you using?

iOS

Which OS version(s) are you using?

iOS 17.5.1

Which rendering API(s) are you using?

Metal

Hardware

iPhone 15

Which capture component are you using?

Capture From Screen

Capture mode

Realtime

Which output mode are you using?

Video file

Video codecs

H264

Audio source

Microphone

Audio codecs

AAC

Any other component configuration

No response

The issue

  1. App Switching: capturing pauses automatically.
  2. App Switching Back: capturing continues automatically.
  3. Video Saving by Button in the App.

The Resulting Video Duration equals the difference in time from Start to Stop, including Pause Time. During Pause Time, there is the last frozen frame without audio.

So, the pausing is not working.

Log output

1. 

-> applicationWillResignActive()

OnApplicationPause: pausing video capture
-> applicationDidEnterBackground()

2.

-> applicationWillEnterForeground()
-> applicationDidBecomeActive()

OnApplicationFocus: capturing video again

3. 

[AVProMovieCapture] Stopping capture 60240
RenderHeads.Media.AVProMovieCapture.CaptureBase:StopCapture(Boolean, Boolean, Boolean)

🔹 Stopping capture...
🟩 Video capture finished.
🟩 Audio capture finished.
🔹 Stopped, writing file...
🔹 Successfully added captured video to photos
🟩 Asset added to photo library with URL: file:///var/mobile/Media/DCIM/120APPLE/IMG_0971.MP4
🔹 Finished writing
🟩 deallocating instance <MCVideoRecorder: 0x105f5f3d0>

CompletedFileWritingAction - updating LastFileSaved to file:///var/mobile/Media/DCIM/120APPLE/IMG_0971.MP4
RenderHeads.Media.AVProMovieCapture.<>c:<StopCapture>b__361_0(FileWritingHandler)
RenderHeads.Media.AVProMovieCapture.FileWritingHandler:Dispose()
RenderHeads.Media.AVProMovieCapture.FileWritingHandler:IsFileReady()
RenderHeads.Media.AVProMovieCapture.FileWritingHandler:Cleanup(List`1)
ARMasksCameraModesControl:Update()

Video Recording — all pending file writes completed
🟩 deallocating instance <MCVideoCaptureMetal: 0x300626ae0>
🟩 deallocating instance <MCAssetWriterInputPixelBufferAdaptorVideoCaptureOutput: 0x30092ad00>

makakaorg avatar Jul 23 '24 20:07 makakaorg

There is also random experience when video is not saved at 3rd step

makakaorg avatar Jul 23 '24 20:07 makakaorg

This has been fixed and will make it into the next release.

MorrisRH avatar Aug 29 '24 10:08 MorrisRH

There is also random experience when video is not saved at 3rd step

Not sure what you mean by this but hopefully the fix for the capture not being paused will cover it.

MorrisRH avatar Aug 29 '24 10:08 MorrisRH

This has been fixed in AVPro Movie Capture version 5.3.1. Please let us know if your issue is not resolved.

Chris-RH avatar Sep 03 '24 07:09 Chris-RH

I have this new flag set this way: iOSSaveCaptureWhenAppLosesFocus: 1

iOS 18.5, Unity 2022.3.62, iPhone 15, AVPro Movie Capture Mobile 5.3.3

When loosing focus, the video is saved, but the app behaves this way when trying to return to it:

  • is restarted without Xcode debugging
  • is frozen with Xcode debugging

Log after loosing focus with Xcode debugging:

💬️ (MCVideoRecorder.m:1212) Stopping capture... 💬️ (MCVideoRecorder.m:1269) Stopped, writing file... Touch was already deallocated Unsupported fetch for asset collections with type 1 and subtype 202 💬️ (MCVideoRecorder.m:1109) Created asset collection with name: AR Masker 💬️ (MCVideoRecorder.m:1166) Successfully added captured video to photos 💬️ (MCVideoRecorder.m:1302) Finished writing Error: domain: Plugin, code: CaptureStoppedDueToAppSuspension, message: Capture was stopped due to app suspension RenderHeads.Media.AVProMovieCapture.CaptureBase:ActualErrorHandler(MCErrorDomain, MCPluginError, String) RenderHeads.Media.AVProMovieCapture.CaptureBase:ErrorHandler(Int32, Int32, Int32, String)

[AVProMovieCapture] Stopping capture 7712 RenderHeads.Media.AVProMovieCapture.CaptureBase:StopCapture(Boolean, Boolean, Boolean) RenderHeads.Media.AVProMovieCapture.CaptureBase:ActualErrorHandler(MCErrorDomain, MCPluginError, String) RenderHeads.Media.AVProMovieCapture.CaptureBase:ErrorHandler(Int32, Int32, Int32, String)

Video — File Path: avpmc-photolibrary:///AR Masker/AR_Masker_2025-05-25_21-04-24_1180x2556.mp4 — with status: Completed ARMasksCameraModesControl:OnCompleteVideoSaving(FileWritingHandler) RenderHeads.Media.AVProMovieCapture.FileWritingHandler:Dispose() RenderHeads.Media.AVProMovieCapture.CaptureBase:StopCapture(Boolean, Boolean, Boolean) RenderHeads.Media.AVProMovieCapture.CaptureBase:ActualErrorHandler(MCErrorDomain, MCPluginError, String) RenderHeads.Media.AVProMovieCapture.CaptureBase:ErrorHandler(Int32, Int32, Int32, String)

libc++abi: terminating due to uncaught exception of type Il2CppExceptionWrapper terminating due to uncaught exception of type Il2CppExceptionWrapper Can't show file for stack frame : <DBGLLDBStackFrame: 0x360b84d50> - stackNumber:9 - name:il2cpp::vm::Exception::Raise. The file path does not exist on the file system: /Users/bokken/build/output/unity/unity/External/il2cpp/builds/libil2cpp/vm/Exception.cpp

makakaorg avatar May 25 '25 18:05 makakaorg

A fix for this will make it into the next release (version 5.3.4).

For now, you can work around it by changing line 2979 in CaptureBase.cs from this:

bool canFreeRecorder = (ignorePendingFileWrites || NativePlugin.IsFileWritingComplete(_handle));

to this:

bool canFreeRecorder = false;

MorrisRH avatar May 30 '25 16:05 MorrisRH

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

Chris-RH avatar Jun 07 '25 11:06 Chris-RH