Search Unity

  1. Unity 2019.2 is now released.
    Dismiss Notice

NatCorder - Video Recording API

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

  1. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616

    Get NatCorder on the Asset Store.

    Hello all! Today, I am very excited to introduce an API that you will most definitely want to get your hands on. The NatCorder API is a lightweight, easy-to-use, full-feature video recording API for iOS and Android. With NatCorder, you can record anything*. You can record the screen, a part of the screen, a specific camera, a texture, and so on. NatCorder also provides the ability to record game audio along with video.

    NatCorder is an excellent alternative to the Everyplay API. Unlike Everyplay, it is lightweight (less overhead), allows you to record at custom resolutions, allows you to access the saved video on device storage, and supports recording within the Editor so that you don't need to build on your device to test.

    NatCorder Features Include:
    - Record anything that can be rendered into a texture.
    - Control recording quality and file size with bitrate and keyframe interval.
    - Record at any resolution. You get to specify what resolution recording you want.
    - Record to animated GIF images or to MP4 videos.
    - Get path to recorded video in device storage.
    - Record game audio with video.
    - Use native sharing UI to share recorded videos.
    - Get thumbnail for recorded video (at custom times too).
    - Support for recording on macOS Editor and Player.
    - Support for recording on Windows Editor and Player.

    With Unity deprecating Everyplay, NatCorder is your best choice for video recording in Unity Engine.

    ___

    * You can record anything that can be rendered into a texture.

    Check out our written tutorials:
    1. Unity Recording Made Easy
    2. Audio Workflows
     
    Last edited: Oct 5, 2019
  2. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    Hi guys. We've started beta testing. Simply post your interest in testing the API here and I'll send it to you for free!
     
    enustes and Prathmeshtekale like this.
  3. JoMaHo

    JoMaHo

    Joined:
    Apr 2, 2017
    Posts:
    94
    Can it record mic audio?
     
  4. jilt

    jilt

    Joined:
    Nov 7, 2014
    Posts:
    49
    interested in testing, already using your NatCam Pro asset.
     
  5. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    Indirectly, yes. It allows you to record from an AudioListener, so if you play the microphone audio into your scene, you're all set. Now that you have brought this up, we will add support for AudioSources too.
     
  6. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    PM me with your email address (or post it here if you're comfortable) and I'll email you the package.
     
  7. david-arcus

    david-arcus

    Joined:
    Jul 17, 2017
    Posts:
    9
    Hi Lanre, this sounds fantastic and is just what I’m looking for! Would love to try the beta.

    Cheers
     
    Lanre likes this.
  8. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    I've shared the beta with you. Thank you!
     
  9. david-arcus

    david-arcus

    Joined:
    Jul 17, 2017
    Posts:
    9
    Hi Lanre - I modified your example app to include a NatCamPreview texture with video, and recorded the video and some UI elements.

    I tested the app on an iPhone 6S, iPhone X, Samsung S4, Samsung Note4, Samsung S6 and Samsung S8 and can happily say all recorded with very high performance, with only a small amount of lag on the Note 4. I used the default settings (960x540).

    It's really great! Let me know if there's anything you'd like me to test.
     
    Lanre likes this.
  10. polytropoi

    polytropoi

    Joined:
    Aug 16, 2006
    Posts:
    677
    Can you confirm that it works with ARKit and ARCore?
     
  11. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    That's absolutely great! Please keep on testing and let me know any feedback you have (especially feature requests).
     
  12. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    I haven't tested on ARKit or ARCore, but it should work perfectly. I can send you the beta if you are interested in testing it (PM me your email address).
     
  13. victorkin11

    victorkin11

    Joined:
    Apr 20, 2013
    Posts:
    97
    I would like To join the beta testing program, I have tested other plugin, here is MyApp. Thank you!
     
  14. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    PM me your email address and I will share it with you.
     
  15. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    Make sure to check out the full release article on Medium!
     
  16. Archviz3d

    Archviz3d

    Joined:
    Apr 4, 2016
    Posts:
    92
    Hi!!!
    This seems awesome!! Congrats!! I was really hoping for some other solution beside everyplay to come out!!
    I have a 2 questions - can we decide for example:

    1 - To record the screen without all the ui?
    2 - To record the screen with some of the ui elements and dont record other ui elements?

    Thanks
     
  17. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    This is totally possible. You can create a game camera that is set to render only the gameobjects you want rendered (using layers), and then record from that camera. If you'd like to test the API, PM me your email address and I will send the package to you.
     
    Archviz3d likes this.
  18. DVDGuy

    DVDGuy

    Joined:
    Nov 7, 2014
    Posts:
    1
    Hi Lanre,

    This looks like exactly what I've been looking for! I'd be happy to give it a go.
     
    Last edited: Dec 5, 2017
    Lanre likes this.
  19. vdKa

    vdKa

    Joined:
    Jan 22, 2014
    Posts:
    11
    Hi Lanre,

    First of all you did a great job :D
    I would be happy to join the beta testing program too.
     
    Lanre likes this.
  20. magicofspade

    magicofspade

    Joined:
    Aug 26, 2017
    Posts:
    1
    Hi Lanre,

    Thank you, these are the feature I was requesting. I'm very much interested in trying the beta version.
    :)
     
    Lanre likes this.
  21. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    Great! PM me your email address.
     
  22. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    I'll add you in; simply PM me your email address.
     
  23. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    That's great. PM me your email address!
     
  24. vdKa

    vdKa

    Joined:
    Jan 22, 2014
    Posts:
    11
    Hi,
    First of all after natcorder is finished it will be perfect package. You did a great job :D
    Im writing down my impressions.
    I tested the package on "Samsung Note 2".

    1- At my first attempt I recorded the video then when I stopped recording it replayed it. And my video is recorded into my folders root. (/storage/emulated0/videoname). I tested it couple of times it was same and fine. But sometimes app crashes with error (timeout while trying to pause unity engine) when I stop recording. The video is still recorded with the name but with a broken video file. See the attached file. This maybe related with some memory issues. This bring us to my second impression :D

    2- After 10-15 seconds it throws error "Not enough memory left to execute command".
    I think the algorithm behind this package is , it captures each frame into a texture then combine them to a video. Simply like a gif generator. If it is like this it may cause some problems on long videos. When this issue happens some glitches occures. For example the cube is rotating glitchy.
     

    Attached Files:

    Lanre likes this.
  25. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    Can you email me the full logs from logcat? The Note 2 is a very low-end device, so I'm not too worried. I will look into better optimizing the API for such devices.
     
  26. caglarenes

    caglarenes

    Joined:
    Jul 9, 2015
    Posts:
    31
    Hello, I just buy NatCam Pro and I want to to try your new recording asset in my project. Can you send me beta version?
     
    rsdabb and Lanre like this.
  27. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    Great! PM me your email address and I'll share the beta with you.
     
  28. upressplay

    upressplay

    Joined:
    Aug 8, 2017
    Posts:
    24
    I am trying to record a RenderTexture without the performance hit from ReadPixels. This sounds like a great solution, on top of the NatCam Pro camera apis that has already solved the Android Exposure issues we encountered on Google Pixels and LG phones.
     
    Lanre likes this.
  29. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    Sounds great. I've shared the beta with you.
     
  30. upressplay

    upressplay

    Joined:
    Aug 8, 2017
    Posts:
    24
    Followed the read me about including ffmpeg for use in the editor, on Mac and on PC. Getting the following errors. I noticed that it’s putting the mp4 in the main directory, maybe it’s the wrong callback location?

    Mac OS
    Win32Exception: ApplicationName='/Users/matt.jones/Documents/projects/truetv/TruTV-ImpracticalJokersApp/Assets/StreamingAssets/NatCorder/darwin/ffmpeg', CommandLine='-y -f rawvideo -vcodec rawvideo -pixel_format rgb24
    -video_size 357x200 -framerate 20 -loglevel warning
    -i - -vcodec libx264 -pix_fmt yuv420p
    -preset ultrafast recording_2017_12_12_10_22_26_515.mp4', CurrentDirectory=''
    System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process)
    System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process)
    System.Diagnostics.Process.Start ()
    (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
    NatCorderU.Core.Platforms.NatCorderStandalone.StartRecording (Configuration configuration, NatCorderU.Core.SaveCallback saveCallback, IAudioSource audioSource) (at Assets/NatCorder/Plugins/Managed/Platforms/NatCorderStandalone.cs:82)
    NatCorderU.Core.NatCorder.StartRecording (Configuration configuration, NatCorderU.Core.SaveCallback saveCallback) (at Assets/NatCorder/Plugins/Managed/NatCorder.cs:47)
    TRU.Photobooth.MPCamRender.StartRecording () (at Assets/TRU/Photobooth/Scripts/MPCamRender.cs:175)
    TRU.Photobooth.MPCamRender.OnRecButtonClick (System.String recordMode) (at Assets/TRU/Photobooth/Scripts/MPCamRender.cs:247)
    TRU.Photobooth.Photobooth.Record () (at Assets/TRU/Photobooth/Scripts/Photobooth.cs:120)
    UnityEngine.Events.InvokableCall.Invoke () (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEvent.cs:165)
    UnityEngine.Events.UnityEvent.Invoke () (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:58)
    UnityEngine.UI.Button.Press () (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:36)
    UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:45)
    UnityEngine.EventSystems.ExecuteEvents.Execute (IPointerClickHandler handler, UnityEngine.EventSystems.BaseEventData eventData) (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:50)
    UnityEngine.EventSystems.ExecuteEvents.Execute[IPointerClickHandler] (UnityEngine.GameObject target, UnityEngine.EventSystems.BaseEventData eventData, UnityEngine.EventSystems.EventFunction`1 functor) (at /Users/builduser/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/EventSystem/ExecuteEvents.cs:261)
    UnityEngine.EventSystems.EventSystem:Update()


    Windows
    Win32Exception: ApplicationName='C:/MYFILE/Unity Projects/TruTV-ImpracticalJokersApp/Assets/StreamingAssets/NatCorder/win/ffmpeg.exe', CommandLine='-y -f rawvideo -vcodec rawvideo -pixel_format rgb24
    -video_size 285x160 -framerate 20 -loglevel warning
    -i - -vcodec libx264 -pix_fmt yuv420p
    -preset ultrafast recording_2017_12_12_10_24_49_431.mp4', CurrentDirectory=''
    System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process)
    System.Diagnostics.Process.Start_common (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process)
    System.Diagnostics.Process.Start ()
    (wrapper remoting-invoke-with-check) System.Diagnostics.Process:Start ()
    NatCorderU.Core.Platforms.NatCorderStandalone.StartRecording (Configuration configuration, NatCorderU.Core.SaveCallback saveCallback, IAudioSource audioSource) (at Assets/NatCorder/Plugins/Managed/Platforms/NatCorderStandalone.cs:82)
    NatCorderU.Core.NatCorder.StartRecording (Configuration configuration, NatCorderU.Core.SaveCallback saveCallback) (at Assets/NatCorder/Plugins/Managed/NatCorder.cs:47)
    TRU.Photobooth.MPCamRender.StartRecording () (at Assets/TRU/Photobooth/Scripts/MPCamRender.cs:176)
    TRU.Photobooth.MPCamRender.OnRecButtonClick (System.String recordMode) (at Assets/TRU/Photobooth/Scripts/MPCamRender.cs:250)
    TRU.Photobooth.Photobooth.Record () (at Assets/TRU/Photobooth/Scripts/Photobooth.cs:120)
    UnityEngine.Events.InvokableCall.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent.cs:165)
    UnityEngine.Events.UnityEvent.Invoke () (at C:/buildslave/unity/build/Runtime/Export/UnityEvent_0.cs:58)
    UnityEngine.UI.Button.Press () (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:36)
    UnityEngine.UI.Button.OnPointerClick (UnityEngine.EventSystems.PointerEventData eventData) (at C:/buildslave/unity/build/Extensions/guisystem/UnityEngine.UI/UI/Core/Button.cs:45)

    NatCorderStandalone.cs
    Line 44
    return Application.streamingAssetsPath + "/NatCorder/darwin/ffmpeg";

    Read Me says to put them in here after you download from: https://github.com/KeatsPeeks/ffmpeg-static
    - `Assets/StreamingAssets/NatCorder/darwin` if you are running on macOS.
    - `Assets/StreamingAssets/NatCorder/win` if you are running on Windows.

    This is the file path when I followed the read me. Not sure if the x64 directory is igonored.
    Assets/StreamingAssets/NatCorder/darwin/x64/ffmpeg
     
  31. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    Do not place it in x64. Put the executable for your architecture in win/darwin/linux directly.
     
    upressplay likes this.
  32. upressplay

    upressplay

    Joined:
    Aug 8, 2017
    Posts:
    24
    Got the recording in the Editor working. Next issue, I'm recording a RenderTexture that is capturing the Screen.width and Screen.height. We don't want the recording to include the background. The NatCam feed is 100% width, height is dictated by the device camera. Is there a way to define a top value for recording? And then define the height to be the size of the camera feed in relation to the width of the device? Attached is a screen grab of the result to illustrate the issue.
     

    Attached Files:

  33. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    This has to be handled on your end (when blitting your maskRT). NatCorder simply expects that you blit to an encoding render texture, which it provides. You might want to set the resolution of your recording to the width and height you want, rather than the width and height of the screen.
     
  34. upressplay

    upressplay

    Joined:
    Aug 8, 2017
    Posts:
    24
    In the Editor, the mp4 is being rendered to the root folder, not Streaming Assets or Resources. What is the ideal placement of this file? For desktop editor, Android and IOS. I would like to make this consistent for testing purposes. Streaming Assets seems to be the preferred location.

    Also, our app will have two render phases. 1. For the OpenCV facemask and props recording. 2. We pass the recording to a sticker scene, so the user can apply stickers. We plan on using ffmpegs watermark functionality for this, to avoid 2 passes of video compression.

    So, we have a temporary recording that we want to keep inside of the app, then save the final file to user's assets. I did notice that when we did this...

    Once you have gotten the executable in place, open NatCorderStandalone.cs (in NatCorder>Plugins>Managed>Platforms) and uncomment the `FFMPEG_API` definition at the top of the file. You should now be all set.

    ... on Android it no longer saved the mp4 in the Videos folder, but at the root of App Storage, found in "My Files."

    Is there a setting we are not seeing? Or is this a file path refinement that needs to be made on the beta?
     
  35. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    There isn't necessarily an ideal placement. We can't save videos to StreamingAssets because on some platforms, it is read-only. As a result, we let NatCorder save to a convenient location (at its discretion) and return the path to the client (you). If you want to save the video to a specific location, then you can simply move the video file to such a location immediately you receive the path in the save callback.
     
  36. mbrzechwa

    mbrzechwa

    Joined:
    Jun 3, 2017
    Posts:
    5
    Hey @Lanre , I'm working with @upressplay on this issue. It appears there is a bug in the callback response for StartRecording and that "path" is only returning the filename and not the folder path. So we are unable via code to locate where the output file was saved.

    Question: You say you are "letting NatCorder save to a convenient location" that seems to be arbitrary based on platform and folder permissions. Since this is a Unity plugin would it not be simpler to use Application.persistentDataPath or Application.temporaryCachePath to get the safe sandboxed location from Unity at least for iOS and Android?
     
  37. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    I presume that this is occurring in the editor. I'll open an issue for it.
    It's not arbitrary; on Android and iOS, it uses file paths provided by the platform API's. We will look into making NatCorder Android save in the application's sandbox, but iOS and Standalone (FFMPEG) already do this.
     
  38. mbrzechwa

    mbrzechwa

    Joined:
    Jun 3, 2017
    Posts:
    5
    @Lanre thank you. I've looked into it further and it is in fact returning path on Android and I'm able to find and move the file. It looks like in the editor it's just returning a relative path instead of absolute as it's saving to the project root. thanks for looking into it.
     
    Lanre likes this.
  39. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    Beta testing is going very well; so far, NatCorder is stable. Please let me know if you would like to test the second beta. We have added the Sharing API which allows you to get thumbnails of videos (and allows for getting thumbnails from custom times), and to share videos using the native sharing UI.

    One last thing: please post any feature requests you have for NatCorder 1.0. Thank you!
     
  40. WilliamGMacie

    WilliamGMacie

    Joined:
    May 8, 2017
    Posts:
    6
    How to use NatCam Core API Unitypackage? I don't know well. I wanna set active camera(not device camera) and recording during the play game.
     
  41. WilliamGMacie

    WilliamGMacie

    Joined:
    May 8, 2017
    Posts:
    6
    "1 - To record the screen without all the ui?
    2 - To record the screen with some of the ui elements and dont record other ui elements?

    This is totally possible. You can create a game camera that is set to render only the gameobjects you want rendered (using layers), and then record from that camera. If you'd like to test the API, PM me your email address and I will send the package to you."

    This is previous post. I want to know how to do it.
     
    Last edited: Dec 21, 2017
    nikosurfing likes this.
  42. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    You have to create a secondary camera, make sure that it doesn't clear the framebuffer (so that anything rendered by the main camera doesn't vanish), then make sure that it renders only objects within a specific layer or layers. This way, some objects are rendered from the secondary camera, the remaining are rendered from the main camera, and you record from the camera that sees only the objects you want to record.
     
    Last edited: Dec 21, 2017
  43. matiasjaure

    matiasjaure

    Joined:
    May 27, 2011
    Posts:
    39
    Hi! I'd like to join it, I'm looking for exactly this now.
     
  44. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    Great! PM me your email address and I'll share the API with you.
     
  45. WilliamGMacie

    WilliamGMacie

    Joined:
    May 8, 2017
    Posts:
    6
    Hello, Lanre
    I am using NatCam core API, how can I do it? How can render only Main Camera?
     
  46. WilliamGMacie

    WilliamGMacie

    Joined:
    May 8, 2017
    Posts:
    6
    Where is the code?

    Replay.StartRecording(Camera.main, Configuration.Default, );
     
    Last edited: Dec 22, 2017
  47. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    This is not part of NatCam.
     
  48. Archviz3d

    Archviz3d

    Joined:
    Apr 4, 2016
    Posts:
    92
    Finally, I got some time to test it!

    I used your example scene with unity 2017.2.0f3, and build it to ios 11.2.1, ãnd im testing it in an iphone 6.
    If you add antialiasing msaa 2x or more, when you record you'll have a lot of strange behaviour, you have to record for 20 seconds or so!! At the begginning all is ok but then it starts to flash old positions of the cube (this doesnt happen when msaa is off)
    Im also using 2 cameras one for rendering the cube , and another with depth for redering just the ui.

    I also want to test how it goes with post processing effects v1 from unity...
     
  49. Archviz3d

    Archviz3d

    Joined:
    Apr 4, 2016
    Posts:
    92
    To be more clear, its not when you record when you have the strange behaviour, is after you record, and play the video you will see it start flashing old position like stuttering...
     
  50. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    2,616
    Thanks for mentioning this; I haven't experienced it myself. When you mention antialiasing, are you referring to antialiasing for the entire app (in Quality Settings)? Or are you setting antialiasing on the encoder render texture that NatCorder provides? I would also like to see your code (email it to me).
    Let me know how this goes!