Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

NatCorder - Video Recording API

Discussion in 'Assets and Asset Store' started by Lanre, Nov 18, 2017.

  1. Menion-Leah

    Menion-Leah

    Joined:
    Nov 5, 2014
    Posts:
    189
    It depends on how you implemented your frame commit section.

    For instance, if you used to have something like this:

    Code (CSharp):
    1. AsyncGPUReadback.Request(framebuffer, 0, request => {
    2.                  
    3.                         NativeArray<byte> frameData = request.GetData<byte>();
    4.                         unsafe
    5.                         {
    6.                             IntPtr ptr = (IntPtr)Unity.Collections.LowLevel.Unsafe.NativeArrayUnsafeUtility.GetUnsafePtr(frameData);
    7.                             _natCorder.CommitFrame(ptr, timestamp);
    8.                         }
    9.                     }
    10.                 });
    a simple workaround would be something like this:

    Code (CSharp):
    1. NativeArray<byte> nativeArray = new NativeArray<byte>(framebuffer.width * framebuffer.height * 4, Allocator.TempJob);
    2.                 AsyncGPUReadback.RequestIntoNativeArray(ref nativeArray, framebuffer, 0, request =>
    3.                 {
    4.                     try
    5.                     {
    6.                         if (_natCorder != null)
    7.                         {
    8.                             byte[] frameData = new byte[nativeArray.Length];
    9.                             nativeArray.CopyTo(frameData);
    10.                             _natCorder.CommitFrame(frameData, timestamp);
    11.                         }
    12.                     }
    13.                     finally
    14.                     {
    15.                         nativeArray.Dispose();
    16.                     }
    17.                 });
     
  2. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    Or better yet:
    Code (CSharp):
    1. using Unity.Collections.LowLevel.Unsafe; // somewhere above
    2.  
    3. var nativeArray = new NativeArray<byte>(recorder.frameSize.width * recorder.frameSize.height * 4, Allocator.TempJob);
    4. AsyncGPUReadback.RequestIntoNativeArray(ref nativeArray, framebuffer, 0, request => {
    5.     using (nativeArray)
    6.         if (recorder != null)
    7.             unsafe {
    8.                 var nativeBuffer = (IntPtr)NativeArrayUnsafeUtility.GetUnsafePtr(nativeArray);
    9.                 recorder.CommitFrame(nativeBuffer, timestamp);
    10.             }
    11. });
    You could also create the `nativeArray` as a persistent one, hence removing the need for repeated re- and de-allocations. If you're using an unsafe context, you can avoid reading the pixel data into managed memory, then transferring it back to native memory (this roundtrip is pure overhead).
     
  3. GJBooij

    GJBooij

    Joined:
    Jun 18, 2013
    Posts:
    10
    Ok thanks! Although I'm not able to add this code as you can't use unsafe in an iterator?

    We are using 2019.4 and I read about the iOS issue with this
    AsyncGPUReadback.Request
    in the CameraInput.cs. So now I'm trying to replace the code there with the
    AsyncGPUReadback.RequestIntoNativeArray
    one.
    Not much luck yet. I tried the code from Menion-Leah, but the Unity Editor crashes when stopping recording.
     
  4. Menion-Leah

    Menion-Leah

    Joined:
    Nov 5, 2014
    Posts:
    189
    Good to know, thanks!
    I must have done something wrong, because when I tried to use an approach similar to the one you suggested I ran into issues with NativeArray being either disposed/inaccessibile/unreleased (also tried Persistent/Temp).

    The solution with the round trip prevented those issues.
     
  5. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    Ah if you're trying to add this to CameraInput then yes you'll run into that error, since `OnFrame` is a coroutine. Can you share the crash logs?
     
  6. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    Sounds like a Unity bug to me. In any case your code is fine.
     
  7. Palaui

    Palaui

    Joined:
    Nov 4, 2015
    Posts:
    2
    Hello,

    My company bought NatDevice and NatCorder two days ago with the purpose of taking videos mp4 using the phone cameras, but after all the weekend trying, no sound was able to be captured, I tried different Unity versions with no luck, the examples are not working, and not a single test was successful(Tried on WIndows editor and Android).
    The examples in a clean project are not working either, is there something I should try?
     
  8. IGOODI_IT

    IGOODI_IT

    Joined:
    Feb 11, 2020
    Posts:
    8
    Hi again!
    It seems that some Android phones (so far about 30% of tested devices) have trouble with MP4 recording. Specifically, as soon as the recording starts, the whole app crashes.
    IOs phones and Editor environments work fine.
    The problem seems to be here:
    Code (CSharp):
    1. 07-06 15:59:25.539  9765  9812 E CRASH   : managed backtrace:
    2. 07-06 15:59:25.539  9765  9812 E CRASH   :       #00 (wrapper managed-to-native) NatSuite.Recorders.Internal.Bridge:FrameSize (intptr,int&,int&)
    3. 07-06 15:59:25.539  9765  9812 E CRASH   :       #01 NatSuite.Recorders.Internal.NativeRecorder:get_frameSize () <C:\Users\RiccardoVailati\Desktop\IGOODI MOBILE UNITY\IgoodiUnityMobileApp\Assets\External Components\NatSuite\Plugins\Managed\Recorders\Internal\NativeRecorder.cs:19>
    4. 07-06 15:59:25.539  9765  9812 E CRASH   :       #02 NatSuite.Recorders.MP4Recorder:get_frameSize () <C:\Users\RiccardoVailati\Desktop\IGOODI MOBILE UNITY\IgoodiUnityMobileApp\Assets\External Components\NatSuite\Plugins\Managed\Recorders\MP4Recorder.cs:21>
    5. 07-06 15:59:25.539  9765  9812 E CRASH   :       #03 NatSuite.Recorders.Inputs.CameraInput:.ctor (NatSuite.Recorders.IMediaRecorder,NatSuite.Recorders.Clocks.IClock,UnityEngine.Camera[]) <C:\Users\RiccardoVailati\Desktop\IGOODI MOBILE UNITY\IgoodiUnityMobileApp\Assets\External Components\NatSuite\Plugins\Managed\Recorders\Inputs\CameraInput.cs:43>
    6. 07-06 15:59:25.539  9765  9812 E CRASH   :       #04 ScreenshotCameraController:startRecording () <C:\Users\RiccardoVailati\Desktop\IGOODI MOBILE UNITY\IgoodiUnityMobileApp\Assets\Scenes\HomeScreen\ScreenshotCamera\ScreenshotCameraController.cs:61>
    7. 07-06 15:59:25.539  9765  9812 E CRASH   :       #05 ScreenshotButtonScript:Update () <C:\Users\RiccardoVailati\Desktop\IGOODI MOBILE UNITY\IgoodiUnityMobileApp\Assets\Scenes\HomeScreen\ScreenshotCamera\ScreenshotButtonScript.cs:32>
    8. 07-06 15:59:25.539  9765  9812 E CRASH   :       #06 (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
    The attached file contains the whole log, if that helps, and this is the code that fails:
    Code (CSharp):
    1.  
    2.         recorder = new MP4Recorder(Screen.width, Screen.height, 24);
    3.         RealtimeClock clock = new RealtimeClock();
    4.         cameraInput = new CameraInput(recorder, clock, Camera.main);
    Any idea on how to fix this?
     

    Attached Files:

  9. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    Can you share runtime logs from any of your devices? And can you share your code? I'll need more information to be helpful.
     
  10. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    Don't record at screen resolution. Use a fixed resolution like 1280x720.
     
    IGOODI_IT likes this.
  11. shreee

    shreee

    Joined:
    Aug 31, 2016
    Posts:
    19
    exactly, lanare

    may be your device resolution smaller then the recording code..like you device resolution is 840x400 and in recording code resolution have 1920x1080.
     
  12. GJBooij

    GJBooij

    Joined:
    Jun 18, 2013
    Posts:
    10
    This is the crash log I'm getting:
    Code (CSharp):
    1. 2020-07-07 13:47:32.002 16471-16519/? A/.voedselsterre: runtime.cc:571] "UnityMain" prio=5 tid=12 Runnable
    2. 2020-07-07 13:47:32.002 16471-16519/? A/.voedselsterre: runtime.cc:571]   at com.unity3d.player.UnityPlayer.nativeRender(Native method)
    3. 2020-07-07 13:47:32.002 16471-16519/? A/.voedselsterre: runtime.cc:571]   at com.unity3d.player.UnityPlayer.access$300(unavailable:-1)
    4. 2020-07-07 13:47:32.002 16471-16519/? A/.voedselsterre: runtime.cc:571]   at com.unity3d.player.UnityPlayer$e$1.handleMessage(unavailable:-1)
    5. 2020-07-07 13:47:32.002 16471-16519/? A/.voedselsterre: runtime.cc:571]   at com.unity3d.player.UnityPlayer$e.run(unavailable:-1)
    6. 2020-07-07 13:47:32.005 16471-16519/? A/.voedselsterre: runtime.cc:571] "UnityChoreographer" prio=5 tid=14 Native
    7. 2020-07-07 13:47:32.009 16471-16519/? A/.voedselsterre: runtime.cc:571]   at com.unity3d.player.UnityPlayer.nativeRender(Native method)
    8. 2020-07-07 13:47:32.028 16471-16519/? E/CRASH: pid: 16471, tid: 16519, name: UnityMain  >>> com.samhoud.voedselsterren <<<
    9. 2020-07-07 13:47:32.029 16471-16519/? E/CRASH:       #04 NatSuite.Recorders.Inputs.CameraInput/<>c__DisplayClass11_1:<OnFrame>b__0 (UnityEngine.Rendering.AsyncGPUReadbackRequest) <0xd7>
    10. 2020-07-07 13:47:32.674 16471-16519/? E/AndroidRuntime: FATAL EXCEPTION: UnityMain
    11.     Process: com.company.newproject, PID: 16471
    12.     java.lang.Error: *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
    13.     Version '2019.4.0f1 (0af376155913)', Build type 'Release', Scripting Backend 'mono', CPU 'armeabi-v7a'
    14.     Build fingerprint: 'samsung/starltexx/starlte:9/PPR1.180610.011/G960FXXU7CSK1:user/release-keys'
    15.     Revision: '26'
    16.     ABI: 'arm'
    17.     Timestamp: 2020-07-07 13:47:32+0200
    18.     pid: 16471, tid: 16519, name: UnityMain  >>> com.company.newproject <<<
    19.     uid: 10085
    20.     signal 6 (SIGABRT), code -6 (SI_TKILL), fault addr --------
    21.         r0  00000000  r1  00004087  r2  00000006  r3  00000008
    22.         r4  00004057  r5  00004087  r6  c76be534  r7  0000010c
    23.         r8  0000000b  r9  0000005b  r10 e5570384  r11 e5571eb4
    24.         ip  c76be4d0  sp  c76be520  lr  e59eeeb1  pc  e59e5eae
    25.  
    26.     backtrace:
    27.           #00 pc 0001ceae  /system/lib/libc.so (abort+58) (BuildId: 231517bb8a85e40761bcb94d2bb2d7a1)
    28.           #01 pc 00350fa7  /system/lib/libart.so (art::Runtime::Abort(char const*)+910) (BuildId: 889153dd67b992f69359e6923b98ce10)
    29.           #02 pc 000071b3  /system/lib/libbase.so (android::base::LogMessage::~LogMessage()+494) (BuildId: 134fd9b8cd8f2f4ea7304be5857cf27b)
    30.           #03 pc 001b952d  /system/lib/libart.so (art::IndirectReferenceTable::AbortIfNoCheckJNI(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)+172) (BuildId: 889153dd67b992f69359e6923b98ce10)
    31.           #04 pc 0023a2f3  /system/lib/libart.so (art::IndirectReferenceTable::GetChecked(void*) const+270) (BuildId: 889153dd67b992f69359e6923b98ce10)
    32.           #05 pc 0023668f  /system/lib/libart.so (art::JavaVMExt::DecodeGlobal(void*)+10) (BuildId: 889153dd67b992f69359e6923b98ce10)
    33.           #06 pc 00376b65  /system/lib/libart.so (art::Thread::DecodeJObject(_jobject*) const+168) (BuildId: 889153dd67b992f69359e6923b98ce10)
    34.           #07 pc 0026b783  /system/lib/libart.so (art::JNI::GetObjectClass(_JNIEnv*, _jobject*)+402) (BuildId: 889153dd67b992f69359e6923b98ce10)
    35.           #08 pc 00000da7  /data/app/com.company.newproject-g2f9Wewv3G6KRGfLIPZ9bA==/lib/arm/libNatCorder.so (NCFrameSize+30) (BuildId: 2567ae6a57fad542c249dc2cc296d227ffcfe4c3)
    36.           #09 pc 00000e7f  /data/app/com.company.newproject-g2f9Wewv3G6KRGfLIPZ9bA==/lib/arm/libNatCorder.so (NCCommitFrame+50) (BuildId: 2567ae6a57fad542c249dc2cc296d227ffcfe4c3)
    37.           #10 pc 0000aa0e  <anonymous:e18c3000>
    38.  
    39.     managed backtrace:
    40.           #00 (wrapper managed-to-native) NatSuite.Recorders.Internal.Bridge:CommitFrame (intptr,intptr,long)
    41.           #01 NatSuite.Recorders.Internal.NativeRecorder:CommitFrame (intptr,long) <0x2f>
    42.           #02 NatSuite.Recorders.Internal.NativeRecorder:CommitFrame<byte> (byte[],long) <0x4b>
    43.           #03 NatSuite.Recorders.MP4Recorder:CommitFrame<byte> (byte[],long) <0x43>
    44.           #04 NatSuite.Recorders.Inputs.CameraInput/<>c__DisplayClass11_1:<OnFrame>b__0 (UnityEngine.Rendering.AsyncGPUReadbackRequest) <0xd7>
    45.           #05 (wrapper runtime-invoke) <Module>:runtime_invoke_void__this___AsyncGPUReadbackRequest (object,intptr,intptr,intptr)
    46.  
    47.         at libc.abort(abort:58)
    48.         at libart.art::Runtime::Abort(char const*)(Abort:910)
    49.         at libbase.android::base::LogMessage::~LogMessage()(~LogMessage:494)
    50.         at libart.art::IndirectReferenceTable::AbortIfNoCheckJNI(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&)(AbortIfNoCheckJNI:172)
    51.         at libart.art::IndirectReferenceTable::GetChecked(void*) const(GetChecked:270)
    52.         at libart.art::JavaVMExt::DecodeGlobal(void*)(DecodeGlobal:10)
    53.         at libart.art::Thread::DecodeJObject(_jobject*) const(DecodeJObject:168)
    54.         at libart.art::JNI::GetObjectClass(_JNIEnv*, _jobject*)(GetObjectClass:402)
    55.         at libNatCorder.NCFrameSize(NCFrameSize:30)
    56.         at libNatCorder.NCCommitFrame(NCCommitFrame:50)
    57.         at NatSuite.Recorders.Internal.Bridge.CommitFrame (intptr,intptr,long)(Native Method)
    58.         at NatSuite.Recorders.Internal.NativeRecorder.CommitFrame (intptr,long)(0x2f:47)
    59.         at NatSuite.Recorders.Internal.NativeRecorder.CommitFrame<byte> (byte[],long)(0x4b:75)
    60. 2020-07-07 13:47:32.674 16471-16519/? E/AndroidRuntime:     at NatSuite.Recorders.MP4Recorder.CommitFrame<byte> (byte[],long)(0x43:67)
    61.         at NatSuite.Recorders.Inputs.CameraInput.<>c__DisplayClass11_1.<OnFrame>b__0 (UnityEngine.Rendering.AsyncGPUReadbackRequest)(0xd7:215)
    62.         at <Module>.runtime_invoke_void__this___AsyncGPUReadbackRequest (object,intptr,intptr,intptr)(Native Method)
    And this is the code that I changed from (commented) to what Menion-Leah said
    Code (CSharp):
    1.  
    2. if (SystemInfo.supportsAsyncGPUReadback)
    3.                 {
    4.                     //AsyncGPUReadback.Request(frameBuffer, 0, request => {
    5.                     //    if (pixelBuffer != null) {
    6.                     //        request.GetData<byte>().CopyTo(pixelBuffer);
    7.                     //        recorder.CommitFrame(pixelBuffer, timestamp);
    8.                     //    }
    9.                     //});
    10.                  
    11.                      NativeArray<byte> nativeArray = new NativeArray<byte>(frameBuffer.width * frameBuffer.height * 4, Allocator.TempJob);
    12.                      AsyncGPUReadback.RequestIntoNativeArray(ref nativeArray, frameBuffer, 0, request =>
    13.                      {
    14.                          try
    15.                          {
    16.                              if (recorder != null)
    17.                              {
    18.                                  pixelBuffer = new byte[nativeArray.Length];
    19.                                  nativeArray.CopyTo(pixelBuffer);
    20.                                  recorder.CommitFrame(pixelBuffer, timestamp);
    21.                              }
    22.                          }
    23.                          finally
    24.                          {
    25.                              nativeArray.Dispose();
    26.                          }
    27.                      });
    28.                 }
    29.  
     
  13. shreee

    shreee

    Joined:
    Aug 31, 2016
    Posts:
    19

    hii , GJBooij

    above crash happending because of not sufficient memory in device...suggestion is stop corountine after your requirment is complete..may execute your corountine that cause crash happening
     
  14. GJBooij

    GJBooij

    Joined:
    Jun 18, 2013
    Posts:
    10
    The crash immediately happens when I stop recording, which I implemented as the documentation told me to do. (When releasing the record button) So, I'm not sure how I'm influencing this...
     
  15. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    The `recorder` will never be `null`; it is a readonly field. So when recording stops and the recorder is invalidated, your readback code will still try to commit a frame, leading to an inevitable crash. See how the original `CameraInput` code handles stopping recording.
     
  16. daphne-mage

    daphne-mage

    Joined:
    Feb 13, 2020
    Posts:
    5
    Hello,

    I implemented NatCorder as a replacement for FFmpeg to export videos in my multiplatform project (Windows, iOS, OSX, Android), of which I am very satisfied. It works well in the editor (2019.4.2) but it crashes on the Windows standalone.

    I have this crash report:

    Code (CSharp):
    1. NatCorder.dll caused an Access Violation (0xc0000005)
    2.   in module NatCorder.dll at 0033:c67f2cd0
    3.  
    4. Stack Trace of Crashed Thread 1852:
    5. 0x00007FFBC67F2CD0 (NatCorder) NCFinishWriting
    6. 0x00007FFBC67F1100 (NatCorder) NCCreateMP4Recorder
    7. 0x0000021C8E517ACE (Assembly-CSharp) NatSuite.Recorders.Internal.Bridge.CreateMP4Recorder()
    8. 0x0000021C6AEBD7B3 (Assembly-CSharp) <>c__DisplayClass2_0.<.ctor>b__0()
    9. 0x0000021C6AEB8F98 (Assembly-CSharp) NatSuite.Recorders.Internal.NativeRecorder..ctor()
    10. 0x0000021C6AEB8E0B (Assembly-CSharp) NatSuite.Recorders.MP4Recorder..ctor()
    11. 0x0000021C6AEB8BFB (Assembly-CSharp) NatCorderTest.Start()
    12. 0x0000021C6AEB6FF0 (mscorlib) System.Object.runtime_invoke_void__this__()
    13. 0x00007FFB4911D660 (mono-2.0-bdwgc) mono_get_runtime_build_info
    14. 0x00007FFB490A28E2 (mono-2.0-bdwgc) mono_perfcounters_init
    15. 0x00007FFB490AB93F (mono-2.0-bdwgc) mono_runtime_invoke
    16. 0x00007FFB4C56E21D (UnityPlayer) UnityMain
    17. 0x00007FFB4C56B603 (UnityPlayer) UnityMain
    18. 0x00007FFB4C556EA9 (UnityPlayer) UnityMain
    19. 0x00007FFB4C556F3E (UnityPlayer) UnityMain
    20. 0x00007FFB4C554EB9 (UnityPlayer) UnityMain
    21. 0x00007FFB4C2EAD7D (UnityPlayer) UnityMain
    22. 0x00007FFB4C430567 (UnityPlayer) UnityMain
    23. 0x00007FFB4C430603 (UnityPlayer) UnityMain
    24. 0x00007FFB4C432A03 (UnityPlayer) UnityMain
    25. ERROR: SymGetSymFromAddr64, GetLastError: 'Tentative d’accès à une adresse non valide.' (Address: 00007FFB4C1EB61E)
    26. 0x00007FFB4C1EB61E (UnityPlayer) (function-name not available)
    27. ERROR: SymGetSymFromAddr64, GetLastError: 'Tentative d’accès à une adresse non valide.' (Address: 00007FFB4C1EA37A)
    28. 0x00007FFB4C1EA37A (UnityPlayer) (function-name not available)
    29. ERROR: SymGetSymFromAddr64, GetLastError: 'Tentative d’accès à une adresse non valide.' (Address: 00007FFB4C1EE2EC)
    30. 0x00007FFB4C1EE2EC (UnityPlayer) (function-name not available)
    31. 0x00007FFB4C1F1DDB (UnityPlayer) UnityMain
    32. ERROR: SymGetSymFromAddr64, GetLastError: 'Tentative d’accès à une adresse non valide.' (Address: 00007FF795CB11F2)
    33. 0x00007FF795CB11F2 (BDNF) (function-name not available)
    34. 0x00007FFBCBB07BD4 (KERNEL32) BaseThreadInitThunk
    35. 0x00007FFBCCFCCE51 (ntdll) RtlUserThreadStart
    Is there any settings that I don't know about? Thank you for your time.
     
  17. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    Hi there. Can you share your recording code?
     
  18. daphne-mage

    daphne-mage

    Joined:
    Feb 13, 2020
    Posts:
    5
    I created this very simple test class for the editor attached to the main Camera in my scene. Once built, only the recorder and clock are supposed to be instanciated, and the code in Update() is never reached due to record and isRecording both being false.

    Code (CSharp):
    1. public class NatCorderTest : MonoBehaviour
    2. {
    3.     private MP4Recorder recorder;
    4.     private CameraInput cameraInput;
    5.     private FixedIntervalClock clock;
    6.  
    7.     public bool record = false;
    8.  
    9.     private bool isRecording = false;
    10.  
    11.     public string path;
    12.  
    13.     private void Start()
    14.     {
    15.         recorder = new MP4Recorder(1920, 1080, 60);
    16.         clock = new FixedIntervalClock(60, true);
    17.     }
    18.  
    19.     private void Update()
    20.     {
    21.         if (record && !isRecording)
    22.         {
    23.             Debug.Log("Start Recording");
    24.             cameraInput = new CameraInput(recorder, clock, Camera.main);
    25.             isRecording = true;
    26.         }
    27.         else if (!record && isRecording)
    28.         {
    29.             Debug.Log("Stop Recording");
    30.             isRecording = false;
    31.             cameraInput.Dispose();
    32.             GetVideoPath();
    33.         }
    34.     }
    35.  
    36.     private async void GetVideoPath()
    37.     {
    38.         Debug.Log("Start Awaiting");
    39.         path = await recorder.FinishWriting();
    40.         Debug.Log("Stop Awaiting");
    41.         Debug.Log(path);
    42.     }
    43. }
    Thank you for your help!
     
  19. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    Your code's state management is confusing, as you have a `record` and `isRecording` variable. I recommend rewriting this code to have simpler state management (don't start and stop recording in Update). Follow the included examples for guidance.
     
  20. daphne-mage

    daphne-mage

    Joined:
    Feb 13, 2020
    Posts:
    5
    Sorry for this bad bunch of code, I made it quicly just to figure out why my real project was crashing. I hope this new code snippet is less confusing:

    Code (CSharp):
    1. public class NatCorderTest : MonoBehaviour
    2. {
    3.     private MP4Recorder recorder;
    4.     private CameraInput cameraInput;
    5.     private FixedIntervalClock clock;
    6.  
    7.     string path;
    8.  
    9.     private void Start()
    10.     {
    11.         recorder = new MP4Recorder(1920, 1080, 60);
    12.         clock = new FixedIntervalClock(60, true);
    13.         StartRecording();
    14.     }
    15.  
    16.     void StartRecording()
    17.     {
    18.         Debug.Log("Start Recording");
    19.         cameraInput = new CameraInput(recorder, clock, Camera.main);
    20.         Invoke("StopRecording", 4f);
    21.     }
    22.  
    23.     void StopRecording()
    24.     {
    25.         Debug.Log("Stop Recording");
    26.         cameraInput.Dispose();
    27.         GetVideoPath();
    28.     }
    29.  
    30.     private async void GetVideoPath()
    31.     {
    32.         Debug.Log("Start Awaiting");
    33.         path = await recorder.FinishWriting();
    34.         Debug.Log("Stop Awaiting");
    35.         Debug.Log(path);
    36.     }
    37. }
    It also crashes just after launch. The line causing the crash is
    Code (CSharp):
    1.  recorder = new MP4Recorder(1920, 1080, 60);
    and I think the problem is caused by this part in the MP4Recorder constructor:

    Code (CSharp):
    1. new NativeRecorder((callback, context) => Bridge.CreateMP4Recorder(width, height, framerate, bitrate, keyframeInterval, sampleRate, channelCount, Utility.GetPath(@".mp4"), callback, context))
    If I look at the stacktrace, I also find suspicious that the last function called is NCFinishWriting.

    When I run my code with only the Start function, it also crashes and I get the same stack trace.
     
    awu_unity312 likes this.
  21. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    Are you able to run the ReplayCam example? If ReplayCam crashes, post the stack trace. Nothing should be calling `FinishWriting` in the constructor.
     
  22. daphne-mage

    daphne-mage

    Joined:
    Feb 13, 2020
    Posts:
    5
    I can run ReplayCam and it works fine in the editor, but when I build it and run the example, it crashes just like my own test and I get the same stack error:

    Code (CSharp):
    1. NatCorder.dll caused an Access Violation (0xc0000005)
    2.   in module NatCorder.dll at 0033:bf672cd0.
    3.  
    4. Stack Trace of Crashed Thread 26492:
    5. 0x00007FFBBF672CD0 (NatCorder) NCFinishWriting
    6. 0x00007FFBBF671100 (NatCorder) NCCreateMP4Recorder
    7. 0x0000011A4BD75F0E (Assembly-CSharp) NatSuite.Recorders.Internal.Bridge.CreateMP4Recorder()
    8. 0x0000011A4BD5D173 (Assembly-CSharp) <>c__DisplayClass2_0.<.ctor>b__0()
    9. 0x0000011A4BD5BE18 (Assembly-CSharp) NatSuite.Recorders.Internal.NativeRecorder..ctor()
    10. 0x0000011A4BD5BC8B (Assembly-CSharp) NatSuite.Recorders.MP4Recorder..ctor()
    11. 0x0000011A4BD5B7BB (Assembly-CSharp) NatSuite.Examples.ReplayCam.StartRecording()
    12. 0x0000011A4BD5B559 (UnityEngine.CoreModule) UnityEngine.Events.InvokableCall.Invoke()
    13. 0x0000011A4BD56A2B (UnityEngine.CoreModule) UnityEngine.Events.UnityEvent.Invoke()
    14. 0x0000011A4BC2BE93 (Assembly-CSharp) <Countdown>d__10.MoveNext()
    15. 0x0000011A4BC2ACEC (UnityEngine.CoreModule) UnityEngine.SetupCoroutine.InvokeMoveNext()
    16. 0x0000011A4BC2AE17 (UnityEngine.CoreModule) <Module>.runtime_invoke_void_object_intptr()
    17. 0x00007FFB4E35D660 (mono-2.0-bdwgc) mono_get_runtime_build_info
    18. 0x00007FFB4E2E28E2 (mono-2.0-bdwgc) mono_perfcounters_init
    19. 0x00007FFB4E2EB93F (mono-2.0-bdwgc) mono_runtime_invoke
    20. 0x00007FFB3FCBE21D (UnityPlayer) UnityMain
    21. 0x00007FFB3FCBB603 (UnityPlayer) UnityMain
    22. 0x00007FFB3FCA1BC0 (UnityPlayer) UnityMain
    23. 0x00007FFB3FA3AD7D (UnityPlayer) UnityMain
    24. 0x00007FFB3FB80567 (UnityPlayer) UnityMain
    25. 0x00007FFB3FB80603 (UnityPlayer) UnityMain
    26. 0x00007FFB3FB82A03 (UnityPlayer) UnityMain
    27. ERROR: SymGetSymFromAddr64, GetLastError: 'Tentative d’accès à une adresse non valide.' (Address: 00007FFB3F93B61E)
    28. 0x00007FFB3F93B61E (UnityPlayer) (function-name not available)
    29. ERROR: SymGetSymFromAddr64, GetLastError: 'Tentative d’accès à une adresse non valide.' (Address: 00007FFB3F93A37A)
    30. 0x00007FFB3F93A37A (UnityPlayer) (function-name not available)
    31. ERROR: SymGetSymFromAddr64, GetLastError: 'Tentative d’accès à une adresse non valide.' (Address: 00007FFB3F93E2EC)
    32. 0x00007FFB3F93E2EC (UnityPlayer) (function-name not available)
    33. 0x00007FFB3F941DDB (UnityPlayer) UnityMain
    34. ERROR: SymGetSymFromAddr64, GetLastError: 'Tentative d’accès à une adresse non valide.' (Address: 00007FF73EAB11F2)
    35. 0x00007FF73EAB11F2 (BDNF) (function-name not available)
    36. 0x00007FFBCBB07BD4 (KERNEL32) BaseThreadInitThunk
    37. 0x00007FFBCCFCCE51 (ntdll) RtlUserThreadStart
    Also, I tried to build for Mac and it worked well.
     
    Ahren_Li likes this.
  23. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    Okay I'll try to reproduce it on my end and go from there. Thanks for bringing this to my attention.
     
    Ahren_Li likes this.
  24. daphne-mage

    daphne-mage

    Joined:
    Feb 13, 2020
    Posts:
    5
    Thank you for looking into it.
     
    Lanre likes this.
  25. Archi_16

    Archi_16

    Joined:
    Apr 7, 2017
    Posts:
    87
    Hello. @Lanre i need some help.

    App crashing sometimes with Fatal Exception.

    Fatal Exception: java.lang.Error
    FATAL EXCEPTION [MP4Recorder Audio Thread]
    (it is not always on the same line of code, every time on different line)

    I still have no clue why is this happening. Have you(or others) idea, what can be wrong to get this exception?
    Thanks.
     
  26. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    Can you share your recording code and the full logs? Not sure what's going on here, and I haven't encountered an error like this in a long while.
     
  27. i4mtheone

    i4mtheone

    Joined:
    May 16, 2018
    Posts:
    11
    Hello @Lanre

    I want to display camera preview in a rect with rounded corners (UI Mask component). I'm using RawImage to display the camera texture, but since the CameraPreview shader doesn't support UI Masking I've added the code for it to work:

    Code (CSharp):
    1.           // required for UI.Mask
    2.          _StencilComp ("Stencil Comparison", Float) = 8
    3.          _Stencil ("Stencil ID", Float) = 0
    4.          _StencilOp ("Stencil Operation", Float) = 0
    5.          _StencilWriteMask ("Stencil Write Mask", Float) = 255
    6.          _StencilReadMask ("Stencil Read Mask", Float) = 255
    7.          _ColorMask ("Color Mask", Float) = 15
    Code (CSharp):
    1.         // required for UI.Mask
    2.          Stencil
    3.          {
    4.              Ref [_Stencil]
    5.              Comp [_StencilComp]
    6.              Pass [_StencilOp]
    7.              ReadMask [_StencilReadMask]
    8.              WriteMask [_StencilWriteMask]
    9.          }
    10.           ColorMask [_ColorMask]
    However, as soon as I added those snippets, the Rotation and Scale properties stopped working on the shader, resulting in wrongly rotated or flipped displayed camera texture. Could you guide me how to fix this?
     
  28. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    I'm not sure why this would happen. I recommend creating a thread in the shaders sub-forum to see if anyone more knowledgeable on Unity shaders can help; this is not my area of specialty, and the shader included with the example is purely for demonstration purposes. It isn't built to support more advanced UI effects.
     
  29. shreee

    shreee

    Joined:
    Aug 31, 2016
    Posts:
    19
    Hyy Lanre,

    what i m telling you actuly this hair difference is show when plying mp4 recorded video...
    help me
     
  30. shreee

    shreee

    Joined:
    Aug 31, 2016
    Posts:
    19
    Hii , Lanre

    recording sometime black mp4 ...nothing into vision..only black screen..
    so any solutin.??
     
  31. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    I don't know the inner workings of your hair shader, so I don't know why it renders differently when rendering to texture vs. rendering to the screen.
    Can you share more information on this? Can you post your recording code, logs, and anything else that might be useful? Are you able to reproduce this behaviour in the ReplayCam example?
     
  32. shreee

    shreee

    Joined:
    Aug 31, 2016
    Posts:
    19
    its happening with sometime in 4GB RAM device only..
     
  33. sabanmete

    sabanmete

    Joined:
    Mar 20, 2020
    Posts:
    19
    Hi, i am using arcore and natCorder. I am trying to get better fps when i recording. It seems like my fps dropping when i hit record. I am using match frame rate unchecked on ar session and i set recording fps on 60. This is a screenshoot from my profiler when i start to record. What can i do to get better, fixed 60 fps ? (my fps looks normal while not recording)
     

    Attached Files:

    • FPS2.png
      FPS2.png
      File size:
      113.2 KB
      Views:
      340
  34. Archi_16

    Archi_16

    Joined:
    Apr 7, 2017
    Posts:
    87
    I cant share code, im sorry for that. but i can provide more information.

    Crash caoused by
    java.lang.IllegalStateException
    writeSampleData returned an error

    com.olokobayusuf.natcorder.MP4Recorder$11.run (MP4Recorder.java:333)
     
  35. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    It looks like all the time is being spent reading back the pixel data from the GPU. This is currently a limitation when using ARCore because it does not support Vulkan. Vulkan does not have this problem because it supports asynchronous readbacks from the GPU. You can read more on it here.
     
  36. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    You are using an outdated version of NatCorder. Upgrade to 1.7.2 on the Asset Store.
     
  37. PlasticApps

    PlasticApps

    Joined:
    Mar 4, 2017
    Posts:
    13
    Hi, have some problem with Android 8.1 Phones. Trying to record video in my app but its Crashes after 1-2 seconds What can i do to fix it?
    Here is the log
    07-15 22:56:52.697 29626 29670 V NatSuite: NatCorder: Prepared MP4Recorder video encoder with format: {width=1280, height=720, bitrate=5909760, mime=video/avc, frame-rate=30.0, i-frame-interval=3, color-format=2130708361}
    07-15 22:56:52.700 545 545 I MediaPlayerService: MediaPlayerService::getOMX
    07-15 22:56:52.701 29626 29914 I OMXClient: MuxOMX ctor
    07-15 22:56:52.703 542 4020 I OMXMaster: makeComponentInstance(OMX.google.aac.encoder) in mediacodec process
    07-15 22:56:52.716 29626 29670 V NatSuite: NatCorder: Prepared MP4Recorder audio encoder with format: {mime=audio/mp4a-latm, aac-profile=2, channel-count=2, channel-mask=12, max-input-size=16384, bitrate=64000, sample-rate=48000}
    07-15 22:56:52.719 542 26821 D GraphicBufferSource: setting dataspace: 0x104
    07-15 22:56:52.720 542 3413 E OMXNodeInstance: getParameter(21e0a88:qcom.encoder.avc, ParamConsumerUsageBits(0x6f800004)) ERROR: UnsupportedIndex(0x8000101a)
    07-15 22:56:52.720 542 29317 D GraphicBufferSource: requesting color aspects (R:2(Limited), P:1(BT709_5), M:1(BT709_5), T:3(SMPTE170M))
    07-15 22:56:53.022 542 4020 D GraphicBufferSource: got buffer with new dataSpace #104
    07-15 22:56:53.023 542 29911 I OMX-VENC: open Color conv for RGBA888 W: 1280, H: 720
    07-15 22:56:53.023 29626 29905 D ACodec : dataspace changed to 0x10c10000 (R:2(Limited), P:1(BT709_5), M:1(BT709_5), T:3(SMPTE170M)) (R:2(Limited), S:1(BT709), T:3(SMPTE_170M))
    07-15 22:56:53.078 29626 29920 I MPEG4Writer: limits: 4294967295/0 bytes/us, bit rate: -1 bps and the estimated moov size 3195 bytes
    07-15 22:56:53.080 29626 29925 I MPEG4Writer: setStartTimestampUs: 0
    07-15 22:56:53.080 29626 29925 I MPEG4Writer: Earliest track starting time: 0
    07-15 22:56:53.080 29626 29924 I MPEG4Writer: setStartTimestampUs: 0
    07-15 22:56:53.092 29626 29924 W MPEG4Writer: 0-duration samples found: 1
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] JNI ERROR (app bug): local reference table overflow (max=512)
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] local reference table dump:
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] Last 10 entries (of 512):
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] 511: 0x132ed670 java.lang.Class<api.natsuite.natcorder.MP4Recorder>
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] 510: 0x1357d000 float[] (512 elements)
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] 509: 0x132ed670 java.lang.Class<api.natsuite.natcorder.MP4Recorder>
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] 508: 0x1357c000 float[] (512 elements)
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] 507: 0x132ed670 java.lang.Class<api.natsuite.natcorder.MP4Recorder>
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] 506: 0x13577000 float[] (512 elements)
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] 505: 0x132ed670 java.lang.Class<api.natsuite.natcorder.MP4Recorder>
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] 504: 0x13576000 float[] (512 elements)
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] 503: 0x132ed670 java.lang.Class<api.natsuite.natcorder.MP4Recorder>
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] 502: 0x13574000 float[] (512 elements)
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] Summary:
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] 256 of java.lang.Class (1 unique instances)
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132] 256 of float[] (512 elements) (256 unique instances)
    07-15 22:56:54.192 29626 29702 F art : art/runtime/indirect_reference_table.cc:132]
    07-15 22:56:54.678 29626 29702 F art : art/runtime/runtime.cc:422] Runtime aborting...
    07-15 22:56:54.678 29626 29702 F art : art/runtime/runtime.cc:422] Aborting thread:
    07-15 22:56:54.678 29626 29702 F art : art/runtime/runtime.cc:422] "Thread-14" prio=10 tid=64 Runnable
    07-15 22:56:54.678 29626 29702 F art : art/runtime/runtime.cc:422] | group="" sCount=0 dsCount=0 obj=0x12e37dc0 self=0x71abdba000
    07-15 22:56:54.678 29626 29702 F art : art/runtime/runtime.cc:422] | sysTid=29702 nice=-19 cgrp=default sched=0/0 handle=0x71c0605450
    07-15 22:56:54.678 29626 29702 F art : art/runtime/runtime.cc:422] | state=R schedstat=( 2348798664 469459003 20061 ) utm=189 stm=44 core=3 HZ=100
    07-15 22:56:54.678 29626 29702 F art : art/runtime/runtime.cc:422] | stack=0x71c04ff000-0x71c0501000 stackSize=1053KB
    07-15 22:56:54.678 29626 29702 F art : art/runtime/runtime.cc:422] | held mutexes= "abort lock" "mutator lock"(shared held)
    07-15 22:56:54.678 29626 29702 F art : art/runtime/runtime.cc:422] native: #00 pc 000000000047ef3c /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+220)
    07-15 22:56:54.678 29626 29702 F art : art/runtime/runtime.cc:422] native: #01 pc 000000000047ef38 /system/lib64/libart.so (_ZN3art15DumpNativeStackERNSt3__113basic_ostreamIcNS0_11char_traitsIcEEEEiP12BacktraceMapPKcPNS_9ArtMethodEPv+216)
     
  38. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    Are you using NatCorder 1.7.2? If not, make sure to upgrade. This should have been fixed recently.
     
    PlasticApps likes this.
  39. UniBitDeveloper

    UniBitDeveloper

    Joined:
    Jul 17, 2017
    Posts:
    19
    @Lanre
    Hi i use Wikitude AR plugin, and i need to record video with AR object and real world(background)
    For this i have AR camera which draw AR model in depth camera mode, also i create one more camera to draw real world at plane.This is my AR camera http://prntscr.com/tj6s3z
    This is camera which draw real world -> http://prntscr.com/tj6rn0
    and when i record video, i use both camera.

    Code (CSharp):
    1.  
    2. _clock = new RealtimeClock();
    3. _videoRecorder = new MP4Recorder(
    4.             1080,
    5.             1920,
    6.             30,
    7.             AudioSettings.outputSampleRate,
    8.             2
    9.         );
    10. _cameraInput = new CameraInput(_videoRecorder,_clock,Camera.allCameras);
    11. _audioInput = new AudioInput(_videoRecorder,_clock,Camera.main.GetComponent<AudioListener>());
    12.  
    my video at android(perfect) ->

    my video at ios(problems, the video seems to be cropped) ->

    How to fix it, please help
    i use latest natcorder, unity 2019.3.15 and wkitude 9.2
     
  40. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    You'll have to reach out to Wikitude's support for this one. CameraInput is simply rendering the camera view to a texture. It is likely the case that Wikitude is overriding how the camera renders, which is why it is offset (cropped). This would have nothing to do with NatCorder, and you can verify this by looking at the CameraInput sources; all it is doing is re-rendering the camera to a RenderTexture by calling `camera.Render`. The camera is expected to render normally, as it did when rendering to the screen.
     
  41. Archi_16

    Archi_16

    Joined:
    Apr 7, 2017
    Posts:
    87
    my project is on Unity 2018.4.23. Natcorder v1.7.2 is for 2019.3.11 or newer.
    will it be big problem? i cant update app. there is a lot of plugins which is conflicting somehow.
     
  42. dri_richard

    dri_richard

    Joined:
    Mar 10, 2017
    Posts:
    153
    Our application mixes game audio with microphone input, and because of device-specific mic latency we mix in memory and commit all the audio samples at the end of the recording, calling CommitSamples() with a timestamp of 0.

    This works great in Natcorder 1.5.1 but we're trying to upgrade to 1.7.2 so we can use AsyncGPUReadback, and we find that CommitFrame() starts to take more than 1 second to return if we don't commit audio samples regularly.

    I was always surprised that our technique worked, but it was useful. Has there been a specification change?
     
  43. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    NatCorder will work on Unity 2018.3+. You can use Unity 2019 to download the package, then copy it to your 2018 project.
     
    Archi_16 likes this.
  44. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    Are you on Windows? I have no clue why, but on Windows if you don't commit audio frames in step with video frames, then it starts to lag terribly. I have absolutely no clue why this happens.
     
  45. JonathanFri

    JonathanFri

    Joined:
    Jul 3, 2019
    Posts:
    13
    Hey,
    we are using Unity 2018.4.24f, NatCorder 1.7.0 and are recording WebCamTextureInput.

    When the user puts the app in background or the app loses focus, we are pausing the recording.

    Thats pretty much how we are doing it:

    Code (CSharp):
    1. protected override void OnApplicationPause(bool pauseStatus)
    2.         {
    3.             if (_recording)
    4.             {
    5.                 if (pauseStatus)
    6.                 {
    7.                     DisposeInputs();
    8.                 }
    9.                 else
    10.                 {
    11.                     StartInputs();
    12.                 }
    13.             }
    14.         }
    15.  
    16.         protected override void OnApplicationFocus(bool hasFocus)
    17.         {
    18.             if (_recording)
    19.             {
    20.                 if (hasFocus)
    21.                 {
    22.                     StartInputs();
    23.                 }
    24.                 else
    25.                 {
    26.                     DisposeInputs();
    27.                 }
    28.             }
    29.         }
    30.  
    31. private void StartInputs()
    32. {
    33.    _recordingClock.Paused = false;
    34.    _webCamTextureInput = new WebCamTextureInput(_videoRecorder, _recordingClock, _activeCameraTexture);
    35.    _audioInput = new AudioInput(_videoRecorder, _recordingClock, microphoneSource, true);
    36. }
    37.  
    38. private void DisposeInputs()
    39. {
    40.    _audioInput.Dispose();
    41.    _webCamTextureInput.Dispose();
    42.    _recordingClock.Paused = true;
    43. }
    44.  
    45.  
    46.  
    That works on Android, but not on iOs.

    When leaving the app on iOs and reopneing the app from the background, we are getting spammed with this:

    Code (CSharp):
    1. -> applicationWillResignActive()
    2. -> applicationDidEnterBackground()
    3. 2020-07-20 16:38:22.819321+0200 app[5112:1324024] [Snapshotting] Snapshotting a view (0x10d0a5800, UIKeyboardImpl) that has not been rendered at least once requires afterScreenUpdates:YES.
    4. -> applicationWillEnterForeground()
    5. 2020-07-20 16:38:27.352353+0200 app[5112:1325830] [] nw_read_request_report [C9] Receive failed with error "Software caused connection abort"
    6. 2020-07-20 16:38:27.353032+0200 app[5112:1325830] [] nw_read_request_report [C9] Receive failed with error "Software caused connection abort"
    7. -> applicationDidBecomeActive()
    8. 2020-07-20 16:38:27.645525+0200 app[5112:1324024] NatCorder Error: MP4Recorder failed to record video frame for time 2619768600 due to invalid recorder state: 3
    9. 2020-07-20 16:38:27.782399+0200 app[5112:1324024] NatCorder Error: MP4Recorder failed to record video frame for time 2756612200 due to invalid recorder state: 3
    10. 2020-07-20 16:38:27.813959+0200 app[5112:1324024] NatCorder Error: MP4Recorder failed to record video frame for time 2788182700 due to invalid recorder state: 3
    11. 2020-07-20 16:38:27.848963+0200 app[5112:1324024] NatCorder Error: MP4Recorder failed to record video frame for time 2823182900 due to invalid recorder state: 3
    12. 2020-07-20 16:38:27.880851+0200 app[5112:1324024] NatCorder Error: MP4Recorder failed to record video frame for time 2855077900 due to invalid recorder state: 3
    13. 2020-07-20 16:38:27.915029+0200 app[5112:1324024] NatCorder Error: MP4Recorder failed to record video frame for time 2889262900 due to invalid recorder state: 3
    14. 2020-07-20 16:38:28.014888+0200 app[5112:1324024] NatCorder Error: MP4Recorder failed to record video frame for time 2989118800 due to invalid recorder state: 3
    15. 2020-07-20 16:38:28.048782+0200 app[5112:1324024] NatCorder Error: MP4Recorder failed to record video frame for time 3023013500 due to invalid recorder state: 3
    16. 2020-07-20 16:38:28.079793+0200 app[5112:1324024] NatCorder Error: MP4Recorder failed to record video frame for time 3054017900 due to invalid recorder state: 3
    17. 2020-07-20 16:38:28.115865+0200 app[5112:1324024] NatCorder Error: MP4Recorder failed to record video frame for time 3090077500 due to invalid recorder state: 3
    18. 2020-07-20 16:38:28.146360+0200 app[5112:1324024] NatCorder Error: MP4Recorder failed to record video frame for time 3120600100 due to invalid recorder state: 3
    19. 2020-07-20 16:38:28.180375+0200 app[5112:1324024] NatCorder Error: MP4Recorder failed to record video frame for time 3154616900 due to invalid recorder state: 3
    I mean I know what the error is telling me, however we are doing everything we can do to prevent that.
     
    Last edited: Jul 21, 2020
  46. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    If the app loses focus, the native encoder will stop. This is an OS restriction on both iOS and Android. As such, you cannot pause recording then suspend the app--recording will fail.
     
    JonathanFri likes this.
  47. dri_richard

    dri_richard

    Joined:
    Mar 10, 2017
    Posts:
    153
    Yes this is on Windows. But I'm puzzled why it only happens after upgrading from 1.5.1, if the native encoder is presumably the same?
     
  48. dri_richard

    dri_richard

    Joined:
    Mar 10, 2017
    Posts:
    153
    Do you know if this has an issue number in Unity's Issue Tracker? This is another problem we face in upgrading from 1.5.1 to 1.7.2
     
  49. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    I remember this behaviour going all the way back. Nothing has changed in the native Windows implementation since 1.5.1.
     
  50. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,974
    No I don't think this was posted on Issue Tracker.