Search Unity

NatCorder - Video Recording API

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

  1. vcasas

    vcasas

    Joined:
    Oct 6, 2017
    Posts:
    7
    Please turn up the volume on your speaker, there is a weird sound, no matter how much I talk and make various sounds, none of them are recorded, it just sounds that weird sound.
     
  2. unity_AB5C36A3F38FC7A871DD

    unity_AB5C36A3F38FC7A871DD

    Joined:
    Apr 5, 2022
    Posts:
    1
    Hello my natcorder crashes on my android mobile when i press record it works fine in the editor but the problem is only on my android phone
     
  3. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Not at all. You simply need to record the ARSessionOrigin game camera.
     
  4. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    I see, it sounds like static over some spaced-out intervals. How are you recording the mic audio? Using the `Microphone` API, like in ReplayCam?
     
  5. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Hey there, can you share the crash logs from logcat in a .txt attachment?
     
  6. vcasas

    vcasas

    Joined:
    Oct 6, 2017
    Posts:
    7
    I used the script "ReplayCam.cs" with the option "Record Microphone" activated

     
  7. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    I see. In this case, I recommend seeing if different values of "DSP Buffer Size" in Audio Settings (Project Settings) improves the audio quality. We recommend using NatDevice if you want to record with microphone audio in production apps. We developed our own microphone streaming solution because Unity's Microphone API produces glitchy audio.
     
  8. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    374
    Hello.

    I have various doubts. Let's see if you can help me clarify them before proceeding with the purchase.

    I have used other systems that are in the Unity store. None has convinced me because they have bugs and problems that the authors do not solve.

    My game is car racing. Therefore, there are several cameras located at many points along the route. I also have a replay system of my own. Through replay, I would like my game to be able to record scenes and shots that the user wants without using tools like Camtasia, Bandicam, etc.

    1- I have had problems with other systems as it does not record the vegetation that is rendered through Vegetation Studio Pro.

    2- The quality of the recording, despite having a very powerful computer, is not good. There are a lot of pixels in the screen recording, while in the camera recordings the "lag" is tremendous. Impossible, actually. In addition to what is indicated in point 1.

    3- The same happens with the Enviro climate in times of rain or snow. It doesn't record them.

    4- Is there a trial version?

    In summary, and given that it is a product that has a price to consider, I have my doubts about whether the recordings will have the quality that I need. My outlay on other tools is quite high and they are of no use to me. Even some of them have disappeared or have not been maintained for years.

    Thanks
     
  9. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Hey there, thanks for reaching out with your question. I have inline responses below:
    I can't answer this because I'm unfamiliar with Vegetation Studio Pro. But you can do a simple test without NatCorder: render your game camera to a RenderTexture, readback the RenderTexture to a normal Texture2D, and then encode it to a JPEG or PNG. If the vegetation shows up in the final image, then it will show up in NatCorder. When recording video frames from Unity, NatCorder is completely transparent: it renders one or more game cameras to an offscreen RenderTexture, then reads back the pixel buffer from the GPU into memory, and finally sends that pixel buffer to the native recorder.
    This depends entirely on the rendering complexity of your app. The way to increase "quality" is to increase the recording resolution, but just as you've said, it comes with a corresponding performance cost. This is because you effectively have to re-render the entire game into the offscreen RenderTexture for recording, effectively doubling your draw calls. There are ways to potentially not have to re-render everything, but this is highly app-specific, so you have to build it out yourself.
    See my answer to your first question.
    No there isn't. NatCorder is all code, so it isn't easy for us to offer a trial. I recommend reading through the online docs. Let me know if you have other questions.
     
    Barritico likes this.
  10. Barritico

    Barritico

    Joined:
    Jun 9, 2017
    Posts:
    374

    Ok, Thanks!!
     
    Lanre likes this.
  11. DannyWoo

    DannyWoo

    Joined:
    Oct 25, 2012
    Posts:
    24
    natcoder is working well in the unity editor or stand alone exe in my computer
    but when i copy all to other computer i got this error at Player.log

    =============================================
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/NatCorder
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/NatCorder.dll
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/NatCorder.dll
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/NatCorder
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/libNatCorder
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/libNatCorder.dll
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/libNatCorder.dll
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/libNatCorder
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/NatCorder
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/NatCorder.dll
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/NatCorder.dll
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/NatCorder
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/libNatCorder
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/libNatCorder.dll
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/libNatCorder.dll
    Fallback handler could not load library C:/Artractive/GiniCasting_Data/MonoBleedingEdge/libNatCorder
    DllNotFoundException: NatCorder assembly:<unknown assembly> type:<unknown type> member:(null)
    at (wrapper managed-to-native) NatSuite.Recorders.Internal.NatCorder.CreateMP4Recorder(string,int,int,single,int,int,int,int,int,intptr&)
    at NatSuite.Recorders.MP4Recorder.Create (System.String path, System.Int32 width, System.Int32 height, System.Single frameRate, System.Int32 sampleRate, System.Int32 channelCount, System.Int32 videoBitRate, System.Int32 keyframeInterval, System.Int32 audioBitRate) [0x0002a] in <d4fb697bdbdc43f7a8485183487261fc>:0
    at NatSuite.Recorders.MP4Recorder..ctor (System.String path, System.Int32 width, System.Int32 height, System.Single frameRate, System.Int32 sampleRate, System.Int32 channelCount, System.Int32 videoBitRate, System.Int32 keyframeInterval, System.Int32 audioBitRate) [0x00000] in <d4fb697bdbdc43f7a8485183487261fc>:0
    at NatRecorder.StartRecording () [0x00035] in <500ed3684e03491bb3f1931bcde7ed41>:0
    at ProgressUpdate.ProgressStart () [0x00057] in <500ed3684e03491bb3f1931bcde7ed41>:0
     
  12. TheVirtualMunk

    TheVirtualMunk

    Joined:
    Sep 6, 2019
    Posts:
    150
    Hi there, we were experiencing the same issue, and I was hoping you could shine some light on the "All sorts of issues" part. Since we can record a specific aspect ratio with any screen resolution, I'm guessing the main issue is the resolution and aspect ratio of the camera doesn't match the recording format, and an additional camera is needed?
    This could be solved by changing the renderscale of the device to something that fits either the width or the height of the set recording resolution, and then black bars the experience to fit that aspect ratio (not sure how to do that tho).
     
  13. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Hey there, what OS is the other computer running? And is it 32- or 64-bit?
     
  14. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    The next NatCorder update will provide a way to help with this. We're adding a `ScreenInput` recording input that uses Unity's `CaptureScreenshot` function to copy the entire screen into a RenderTexture. This way, you can avoid the double-draw call (but lose things like selectively rendering items on screen).
     
    TheVirtualMunk likes this.
  15. DannyWoo

    DannyWoo

    Joined:
    Oct 25, 2012
    Posts:
    24
    Hi i.ve tested with two other computer and i got same error with them. the OS is Windowes 10 and 64bit
     
  16. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    In that case, make sure that you install the latest Microsoft Visual C++ Redistributable on the other computers. Let me know if the issue persists.
     
  17. DannyWoo

    DannyWoo

    Joined:
    Oct 25, 2012
    Posts:
    24
    YES you are right! the problem has solved. Thanks
     
  18. TheVirtualMunk

    TheVirtualMunk

    Joined:
    Sep 6, 2019
    Posts:
    150
    Any ETA for this update?
    Also, why not render a specific camera to the render texture instead of everything using 'CaptureScreenshot' - then we can still have our overlay camera (rendering the UI recording controlls etc.) when recording but not in the recording itself. This way we can avoid double drawing as well, no?
     
  19. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Great!
     
  20. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Sometime this week.
    The `CameraInput` script already does this.
    Rendering to a RenderTexture (or more accurately, calling `camera.Render`) will double the draw calls from said camera. There's no way around this.
     
  21. TheVirtualMunk

    TheVirtualMunk

    Joined:
    Sep 6, 2019
    Posts:
    150
    That sounds like a weird behavior on Unity's part. You have already drawn the whole scene, why would you need it again? I guess you could hook into the opaque texture of the render pipeline (with a similar outcome to your capture screenshot method), or change the SRP/create a Renderer Feature to capture certain layers only.
     
  22. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    It's actually the correct behaviour. Imagine rendering to a `RenderTexture` with a different resolution or aspect ratio than that of the screen (this is what happens when you create a recorder with a different res than the screen); in this case, Unity has to calculate a new projection matrix based on the new 'screen' size, then render with this new projection. So the double-render is unavoidable.
     
    TheVirtualMunk likes this.
  23. keyounghyu

    keyounghyu

    Joined:
    Sep 3, 2020
    Posts:
    5
    i got some crash. andorid version 7.0 or 7.1.1.
    device crashed when FinishWriting timing.
     

    Attached Files:

  24. keyounghyu

    keyounghyu

    Joined:
    Sep 3, 2020
    Posts:
    5
    same device other log. plz check in
     

    Attached Files:

  25. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Hey there, this crash is coming from Android itself:
    Code (CSharp):
    1. #05 pc 000000000013f680 /system/lib64/libstagefright.so (android::MPEG4Writer::Track::writeMp4aEsdsBox()+904)
    It's not a NatCorder bug. I recommend upgrading your device's version of Android if possible, and making sure it is running the official Android release.
     
  26. keyounghyu

    keyounghyu

    Joined:
    Sep 3, 2020
    Posts:
    5
    natcorder guide says 'requirements Android API level 24+ (Android Nougat or newer)'
    but API Level 24 device not work. is it correct?
     
  27. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Android API level 24 will work. But your specific device seems to be crashing. The library mentioned in the stack trace, `libstagefright.so`, is a core component of the Android operating system.
     
    keyounghyu likes this.
  28. pjaimin

    pjaimin

    Joined:
    Nov 3, 2018
    Posts:
    13
    Hey @Lanre Is there any API to pause and resume recording ???
     
  29. Yode_group

    Yode_group

    Joined:
    Apr 5, 2016
    Posts:
    14
    Hey @Lanre! The problem of recording a microphone along with karaoke music still haunts many. Next Gen Recorder tried to fix this problem, but the author switched to another project and didn't develop it for Android. Is there any hope that this problem will be solved in Natcorder,
    how did MixerDevice give this opportunity before, or do you still have to break Unity in order to achieve this?
     
  30. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Hey there, check out the docs on this. Note that you cannot pause recording then suspend the app. If the app loses focus, then recording will always fail.
     
  31. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Hey there! This issue happens to be on our internal roadmap now. I don't yet have an ETA because we're still surveying different approaches and potential solutions, but we'll make a public announcement sometime soon on Discord.
     
  32. Yode_group

    Yode_group

    Joined:
    Apr 5, 2016
    Posts:
    14
    Thanks for the reply! We'll be looking forward to it!
     
    Lanre likes this.
  33. Bambivalent

    Bambivalent

    Joined:
    Jan 25, 2017
    Posts:
    16
    Hello, I still don't understand how to save to camera roll on Android, or save at downloads folder where I can access the MP4 file. Camera roll-related posts are several years old, and SavePayload() seems depreacted in NatShare. The link to the NatShare API on the doc's social share page is broken.
    Thank you very much in advance, Max
     
    Last edited: May 21, 2022
  34. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Hey there, NatShare is still the way to go. Thanks for catching the broken link! We renamed out GitHub organization, so some links were invalidated. I've fixed it.
     
  35. danielesuppo

    danielesuppo

    Joined:
    Oct 20, 2015
    Posts:
    331
    Hello, I would have a couple of questions:
    - how can I change the name of the recorded video file?
    - how can I specify the recording path on Windows?

    I've read the documentation but I didn't find these informations
    Many thanks!
     
    Last edited: May 26, 2022
  36. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Hey there, you can use the File.Move method for both of these. NatCorder doesn't allow for specifying the video path/name.
     
  37. Furvio

    Furvio

    Joined:
    Oct 13, 2017
    Posts:
    3
    hey @Lanre I am facing a weird behaviour on some android devices using the MP4Recorder with a custom resolution, recording the video at 473x1024 don't work, i get an error when creating the MP4Recorder, while if I use the screen width and height resolution to record it works just fine.
    I also tried to change only the video resolution to 473x1024 in the ReplyCam example scene and I get the same behaviour. do you have any ideas on what could cause this issue?

    I am using Unity 2020.3.18 and natcorder 1.8.1
     
  38. Furvio

    Furvio

    Joined:
    Oct 13, 2017
    Posts:
    3
    so from further testing it seems that the problem could be the odd resolutions (in the sense that the resolution values should be even).
    I also tried with a resolution of 591x1280 and I still get the error and it doesn't work, but with a resolution of 590x1280 it works fine. also 472x1024 no problems o_O
     
  39. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Yup, the resolution width and height have to be divisible by two.
     
  40. siisee11

    siisee11

    Joined:
    Sep 4, 2021
    Posts:
    3
    I tried to record two audios, one from natdevice microphone and one from audiosource generated by AVPro. I got a result with delayed, sometimes with choppy sound. I used the same realtime clock. Is there a way to record both sounds? I don't know what value should be used as sampleRate and channelCound. From NatDevice or AudioSettings?

    Can you give example code of mixing audioSource and natdevice input?

    Thank you
     
    Last edited: Jun 1, 2022
  41. Furvio

    Furvio

    Joined:
    Oct 13, 2017
    Posts:
    3
    Lanre likes this.
  42. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    To record multiple audio sources into one, you'll need to mix the audio manually. Trying to commit audio from two different sources simultaneously will result in choppy audio. We don't have an example for mixing audio; it's a feature on our roadmap.
     
  43. zxyin4

    zxyin4

    Joined:
    Feb 24, 2017
    Posts:
    3
    why natcorder works fine in debug version on my android phone, but will crash when create MP4Recorder in release version?
     
  44. zxyin4

    zxyin4

    Joined:
    Feb 24, 2017
    Posts:
    3
    Android Studio Logcat logged : "Didn't find class "api.natsuite.natcorder.MediaRecorder" on path: DexPathList ..."
     
  45. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    This is likely due to Proguard. Make sure to add the following keep rule:
    Code (CSharp):
    1. - keep class api.natsuite.*
     
  46. zxyin4

    zxyin4

    Joined:
    Feb 24, 2017
    Posts:
    3
    it works, thank you very much!
     
    Lanre likes this.
  47. garamanx

    garamanx

    Joined:
    Apr 3, 2019
    Posts:
    11
    Thank you so much for your help so far, Lanre!

    I want to make a simple Camera Device App for Samsung S20 only. I had frame drops in the videos before. Now I started a fresh project, used your webcam example scene, now I have frame drops in the webcam view, not in the videos. Using Vulkan made it even worse. I use the Android API for Android 11 with Unity 2021.3.4. Any ideas what could be wrong?
    Thanks in advance, Max
     
  48. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    Hey there, have you tried profiling your app in the Unity profiler? That is the best way to pinpoint the cause. If the issue stems from the camera preview, then I recommend trying out NatDevice.
     
  49. Bambivalent

    Bambivalent

    Joined:
    Jan 25, 2017
    Posts:
    16
    Thank you. I tried out NatDevice. I made a fresh project with Unity 2020.3.11 and just added one line to you MiniCam script, and built it:
    cameraDevice.previewResolution = (3840, 2160);

    You can see the LogCat output below. This means that the app doesn't even handle the 4K preview. Do you think there are any more options to get this running?

    Best regards, Max

    Code (csharp):
    1. 2022.06.13 22:23:47.271 17814 20400 Info Unity Started camera preview with resolution 2160x3840
    2. 2022.06.13 22:23:47.271 17814 20400 Info Unity
    3. 2022.06.13 22:23:47.744 17814 20754 Error SwappyVk Failed to wait for fence 2
    4. 2022.06.13 22:23:48.146 17814 20754 Error SwappyVk Failed to wait for fence 2
    5. 2022.06.13 22:23:48.859 17814 20754 Error SwappyVk Failed to wait for fence 2
    6. 2022.06.13 22:23:48.909 17814 20754 Error SwappyVk Failed to wait for fence 2
    7. 2022.06.13 22:23:49.437 17814 20754 Error SwappyVk Failed to wait for fence 2
    8. 2022.06.13 22:23:49.909 17814 20754 Error SwappyVk Failed to wait for fence 2
    9. 2022.06.13 22:23:50.770 17814 20754 Error SwappyVk Failed to wait for fence 2
    10. 2022.06.13 22:23:51.584 17814 20400 Error Unity Could not allocate memory: System out of memory!
    11. 2022.06.13 22:23:51.584 17814 20400 Error Unity Trying to allocate: 33177604B with 16 alignment. MemoryLabel: Texture
    12. 2022.06.13 22:23:51.584 17814 20400 Error Unity Allocation happened at: Line:70 in
    13. 2022.06.13 22:23:51.584 17814 20400 Error Unity Memory overview
    14. 2022.06.13 22:23:51.584 17814 20400 Error Unity
    15. 2022.06.13 22:23:51.584 17814 20400 Error Unity [ ALLOC_TEMP_THREAD ] used: 32768B | peak: 0B | reserved: 5963776B
    16. 2022.06.13 22:23:51.584 17814 20400 Error Unity [ ALLOC_TEMP_JOB_1_FRAME ] used: 0B | peak: 0B | reserved: 1048576B
    17. 2022.06.13 22:23:51.584 17814 20400 Error Unity [ ALLOC_TEMP_JOB_2_FRAMES ] used: 0B | peak: 0B | reserved: 1048576B
    18. 2022.06.13 22:23:51.584 17814 20400 Error Unity [ ALLOC_TEMP_JOB_4_FRAMES ] used: 0B | peak: 0B | reserved: 2097152B
    19. 2022.06.13 22:23:51.584 17814 20400 Error Unity [ ALLOC_TEMP_JOB_ASYNC ] used: 0B | peak: 0B | reserved: 5242880B
    20. 2022.06.13 22:23:51.584 17814 20400 Error Unity [ ALLOC_DEFAULT ] used: 98791612B | peak: 0B | reserved: 116699136B
    21. 2022.06.13 22:23:51.584 17814 20400 Error Unity [ ALLOC_GFX ] used: 33234404B | peak: 0B | reserved: 99917824B
    22. 2022.06.13 22:23:51.584 17814 20400 Error Unity [ ALLOC_CACHEOBJECTS ] used: 725984B | peak: 0B | reserved: 10485760B
    23. 2022.06.13 22:23:51.584 17814 20400 Error Unity [ ALLOC_TYPETREE ] used: 5280B | peak: 0B | reserved: 17825792B
    24. 2022.06.13 22:23:51.584 17814 20400 Error Unity
    25. 0001.01.01 00:00:00.000 -1 -1 Info  --------- beginning of crash
    26. 2022.06.13 22:23:51.585 17814 20400 Fatal libc Fatal signal 5 (SIGTRAP), code -6 (SI_TKILL) in tid 20400 (UnityMain), pid 17814 (ecorderOnly2020)
    27.  
     
  50. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,973
    It's not the app. The device itself is out of memory:
    Code (CSharp):
    1. Error Unity Could not allocate memory: System out of memory!
    Why do you need to run a preview at such a high resolution?