Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

NatCorder - Video Recording API

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

  1. ToniFuturefly

    ToniFuturefly

    Joined:
    Mar 8, 2017
    Posts:
    5
    Hi Lanre! Awesome!

    Building a simple test app of my own, i get the following linker errors in iOS:

    Undefined symbols for architecture arm64:

    "_OBJC_CLASS_$_PHAssetChangeRequest", referenced from:

    objc-class-ref in libSharing.a(Sharing.o)

    "_OBJC_CLASS_$_PHPhotoLibrary", referenced from:

    objc-class-ref in libSharing.a(Sharing.o)

    "_vImageVerticalReflect_ARGB8888", referenced from:

    _NCGetThumbnail in libSharing.a(Sharing.o)

    ld: symbol(s) not found for architecture arm64
     
  2. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    You need to add the Accelerate.framework and Photos.framework frameworks to your Xcode project. NatCorder should do this automatically though. I'll check it out.
     
  3. alejobrainz

    alejobrainz

    Joined:
    Sep 10, 2005
    Posts:
    250
    This worked fine, but in the console I get the following error when sharing:

    Failed to determine whether URL /var/mobile/Containers/Data/Application/FBAC4607-B4DE-4785-8DF9-058B802B33BB/Documents/animoji.mp4 (n) is managed by a file provider

    Share still works, but I'm not sure if it affects the recipient apps in any way.
     
    i9mobile likes this.
  4. jbvobling

    jbvobling

    Joined:
    Sep 26, 2017
    Posts:
    27
    Why is it that when sharing the file using NatCorderU.Extensions.Sharing.Share(path), the audio of the shared video is earlier? (using Android)

    The actual video file is sync in Android Device. It just, when shared, the shared video result audio is not in sync with the video, the audio is earlier like 0.5sec.

    Tested Social Site:
    Facebook Post - No Problem
    Facebook Messenger - Problem Occur
    Slack - Problem Occur
    Twitter Post - No Problem
     
    Last edited: Mar 1, 2018
  5. ToniFuturefly

    ToniFuturefly

    Joined:
    Mar 8, 2017
    Posts:
    5
    Thanks, Lanre.

    Regarding the audio "too early" anomaly, I was working on similar native functionality on iOS myself earlier, and noticed that (counterintuitively) the presentationtime of audio buffers in AVAssetWriter seemed to be required to be set at the end of the buffer rather than the beginning. This caused a similar issue in my own implementation. Just in case you made the same mistake :)
     
  6. jbvobling

    jbvobling

    Joined:
    Sep 26, 2017
    Posts:
    27
    [Solved]
    Another Issue, I can't seem to make it work in our iOS Device.
    -Our device version 11.3
    -xCode 9.3 Beta

    This is the log when i try to press the Recording Button.

    16:52:49.514861+0800 natcam[994:352074] [DYMTLInitPlatform] platform initialization successful 2018-03-01 16:52:49.550549+0800 natcam[994:351934] -> registered mono modules 0x10515e190 -> applicationDidFinishLaunching() 2018-03-01 16:52:50.341627+0800 natcam[994:351934] Metal GPU Frame Capture Enabled 2018-03-01 16:52:50.344397+0800 natcam[994:351934] Metal API Validation Disabled -> applicationDidBecomeActive() Renderer: Apple A10X GPU Vendor: Apple Inc. Version: OpenGL ES 2.0 Metal - 52.3.2 GLES: 2 GL_OES_depth_texture GL_OES_depth_texture_cube_map GL_OES_depth24 GL_OES_element_index_uint GL_OES_fbo_render_mipmap GL_OES_mapbuffer GL_OES_packed_depth_stencil GL_OES_rgb8_rgba8 GL_OES_standard_derivatives GL_OES_texture_float GL_OES_texture_half_float GL_OES_texture_half_float_linear GL_OES_vertex_array_object GL_EXT_blend_minmax GL_EXT_color_buffer_half_float GL_EXT_debug_label GL_EXT_debug_marker GL_EXT_discard_framebuffer GL_EXT_draw_instanced GL_EXT_instanced_arrays GL_EXT_map_buffer_range GL_EXT_occlusion_query_boolean GL_EXT_pvrtc_sRGB GL_EXT_read_format_bgra GL_EXT_separate_shader_objects GL_EXT_shader_framebuffer_fetch GL_EXT_shader_texture_lod GL_EXT_shadow_samplers GL_EXT_sRGB GL_EXT_texture_filter_anisotropic GL_EXT_texture_rg GL_EXT_texture_storage GL_APPLE_clip_distance GL_APPLE_color_buffer_packed_float GL_APPLE_copy_texture_levels GL_APPLE_framebuffer_multisample GL_APPLE_rgb_422 GL_APPLE_sync GL_APPLE_texture_format_BGRA8888 GL_APPLE_texture_max_level GL_APPLE_texture_packed_float GL_IMG_r ead_format GL_IMG_texture_compression_pvrtc OPENGL LOG: Creating OpenGL ES 2.0 graphics device ; Context level <OpenGL ES 2.0> ; Context handle -939359872 Initialize engine version: 2017.3.1f1 (fc1d3344e6ea) WARNING: 0:4: extension 'GL_EXT_frag_depth' is not supported ERROR: 0:38: Use of undeclared identifier 'gl_FragDepthEXT' Note: Creation of internal variant of shader 'Hidden/Internal-MotionVectors' failed. WARNING: Shader Unsupported: 'Hidden/Internal-MotionVectors' - Pass '' has no vertex shader WARNING: Shader Unsupported: 'Hidden/Internal-MotionVectors' - Setting to default shader. WARNING: Shader Unsupported: 'Hidden/BlitToDepth' - Pass '' has no vertex shader WARNING: Shader Unsupported: 'Hidden/BlitToDepth' - Setting to default shader. WARNING: Shader Unsupported: 'Hidden/BlitToDepth_MSAA' - Pass '' has no vertex shader WARNING: Shader Unsupported: 'Hidden/BlitToDepth_MSAA' - Setting to default shader. WARNING: 0:4: extension 'GL_EXT_frag_depth' is not supported ERROR: 0:14: Use of undeclared identifier 'gl_FragDepthEXT' Note: Creation of internal variant of shader 'Hidden/BlitCopyWithDepth' failed. WARNING: Shader Unsupported: 'Hidden/BlitCopyWithDepth' - Pass '' has no vertex shader WARNING: Shader Unsupported: 'Hidden/BlitCopyWithDepth' - Setting to default shader. Setting up 1 worker threads for Enlighten. Thread -> id: 16c997000 -> priority: 1 UnloadTime: 1.165250 ms NatCorder: Initialized NatCorder 1.0 iOS backend 2018-03-01 16:52:54.107475+0800 natcam[994:351934] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles 2018-03-01 16:52:54.107731+0800 natcam[994:351934] [MC] Reading from public effective user settings. NatCam Dispatch: Initialized main dispatch NatCorderU.Core.Platforms.NatCorderiOS:StartRecording(Configuration, VideoCallback, IAudioSource) NatCorderU.Core.NatCorder:StartRecording(Configuration, VideoCallback, IAudioSource) NatCorderU.Core.Replay:StartRecording(Camera, Configuration, VideoCallback, AudioSource, Boolean) ReplayCam:StartRecording() UnityEngine.Events.UnityEvent:Invoke() NatCamU.Examples.<Countdown>c__Iterator0:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr) (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/DebugBindings.gen.cpp Line: 51)

    To solve this, use 'Auto graphics API', uncheck Metal.
     
    Last edited: Mar 2, 2018
  7. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    This looks like an innocuous warning. You should be fine.
     
  8. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    What device did you use to test? What version of Android is it running? Can you check that the video itself has audio in sync? (you can play the video using Handheld.PlayFullScreenMovie). Let me know.
     
  9. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    Thanks Toni. I'll test this out and see if it helps.
     
  10. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    These logs look normal. Is the app crashing? If so, can you email me a screenshot of the stack trace (on the left pane in Xcode).
     
  11. jbvobling

    jbvobling

    Joined:
    Sep 26, 2017
    Posts:
    27
    Device used: Samsung S7 Edge
    Android Version: 7.0
    The video using Handheld.PlayFullScreenMovie, is sync. The only problem is when shared, the video result is not sync in specific social site:

    Tested Social Site:
    Facebook Post - No Problem
    Facebook Messenger - Problem Occur
    Slack - Problem Occur
    Twitter Post - No Problem
     
  12. jbvobling

    jbvobling

    Joined:
    Sep 26, 2017
    Posts:
    27
    Yeah, the app is crashing, like its hanged.

    Ok.
     
  13. Deleted User

    Deleted User

    Guest

    Thanks, Lanre.
    My team is actively reviewing this awesome plugin.
    Can you send me sample app via my email?
    usj1111@outlook.com
     
    Last edited by a moderator: Mar 2, 2018
  14. jbvobling

    jbvobling

    Joined:
    Sep 26, 2017
    Posts:
    27

    For iOS, when recording, the video replay is delayed.
     
  15. ToniFuturefly

    ToniFuturefly

    Joined:
    Mar 8, 2017
    Posts:
    5
    After some testing I integrated NarCorder in another project, but got an unexpected result. Recording from a camera + an audio source, it seems that the recording looks like it started, but at StopRecording nothing has been recorded:

    Here's the iOS log:

    NatCorder: Initialized NatCorder 1.0 iOS backend
    NatCam Dispatch: Initialized main dispatch
    NatCorderU.Core.Platforms.NatCorderiOS:StartRecording(Configuration, VideoCallback, IAudioSource)
    NatCorderU.Core.NatCorder:StartRecording(Configuration, VideoCallback, IAudioSource)
    NatCorderU.Core.Replay:StartRecording(Camera, Configuration, VideoCallback)
    OurWorld.Combat.NatCorderController:StartRecord()

    .....

    NatCorder Error: Cannot stop recording because NatCorder is not recording
    NatCorderU.Extensions.Utilities:LogError(String)


    Here's my code (the base class calls aren't doing anything special):


    public override void StartRecord()
    {
    base.StartRecord();
    Debug.LogFormat("Starting recording from {0} & {1} with config {2}", _camera, _audioListener, _recordConfiguration);
    Replay.StartRecording(_camera, _recordConfiguration, OnReplay, _audioListener);
    }

    public override void StopRecord()
    {
    base.StopRecord();
    Replay.StopRecording();
    }


    Any methods of getting more details on the error?

    Thanks,
    Toni
     
  16. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    I'm looking into this issue right now. Thanks for letting me know.
     
  17. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    This issue has been fixed. I will let you know when an update has been pushed to the Asset Store. In the mean time, make sure to enable 'Auto Graphics API' in Player Settings as a workaround to this issue.
     
  18. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    I have shared an APK with you on Dropbox.
     
  19. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    Hi Toni. Can you email me the logs from your run? If NatCorder doesn't think that it is currently recording, then chances are that StartRecording failed at some point. What's interesting is that NatCam.AcquireFrame and NatCam.CommitFrame should fail, warning that you cannot acquire/commit when not recording.
     
  20. Mr-Oliv

    Mr-Oliv

    Joined:
    Sep 14, 2012
    Posts:
    26
    Hi!
    I'm getting errors on all the Dispatch scripts: "The type or namespace name `Core' could not be found". Also, they can't find "CoreDoc".
    I'm on 2017.3.0f3, Android platform.
    Thanks
     
  21. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    Hi there. Go to Player Settings and scroll down to Scripting Define Symbols. Then remove 'NATCAM_CORE' from the list.
     
  22. Mr-Oliv

    Mr-Oliv

    Joined:
    Sep 14, 2012
    Posts:
    26
    Nevermind... I figured it out. An old NatCam installation messed it up
     
    Lanre likes this.
  23. jbvobling

    jbvobling

    Joined:
    Sep 26, 2017
    Posts:
    27
    Also, when we record using iPadPro, there is a noise audio and an audio delay when the video is replaying. This is using Handheld.PlayFullScreenMovie(path).
     
  24. mrmdesign

    mrmdesign

    Joined:
    Apr 18, 2013
    Posts:
    239
    Hey @Lanre! Congratulations on the release. I just bought a copy.
    Would it be at all possible for an 'idiots guide' to setting up the complete script to capture, record, playback and share. I know you have provided a guide but I am feeling a bit more 'idiot' than usual today. Not enough coffee... Thank you so much.
     
  25. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    By noise audio, do you mean stuttering? If so, this is a Unity issue with realtime microphone streaming. The workaround we found for the ReplayCam example was changing this:
    Code (CSharp):
    1. audioSource.clip = Microphone.Start(null, true, 15, 44100);
    To this:
    Code (CSharp):
    1. audioSource.clip = Microphone.Start(null, true, 1, 44100);
     
  26. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    We have a few written tutorials planned. I will keep you updated as they are released.
     
  27. mrmdesign

    mrmdesign

    Joined:
    Apr 18, 2013
    Posts:
    239
    Great, Thank you. I started with the ReplayCam Script and I thought it would be quite easy to modify it for sharing but I got a few errors. I tried to shove this bit in from the Medium article:

    ---

    // Invoked by NatCorder once recording is finished
    void OnReplay (string path) {
    // Get the video thumbnail
    Texture2D thumbnail = Sharing.GetThumbnail(path, 5f); // Get the thumbnail after 5 seconds of video
    // Do stuff with the thumbnail
    DisplayThumbnail(thumbnail);
    // Save the path to the replay so we can use it in `OnShare`
    this.pathToReplay = path;
    }

    // Invoked by UI when user clicks share button
    void OnShare () {
    // Share the replay using the native sharing UI
    Sharing.Share(this.pathToReplay);
    }

    ---
     
  28. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    We made a slight change to the `Sharing.GetThumbnail` API. I have updated the gist with the new API.
     
  29. mrmdesign

    mrmdesign

    Joined:
    Apr 18, 2013
    Posts:
    239
    Thank you @Lanre.
    I am getting: The type or namespace name `Sharing' could not be found. Are you missing `NatCorderU.Extensions' using directive?
     
  30. mrmdesign

    mrmdesign

    Joined:
    Apr 18, 2013
    Posts:
    239
    I removed all traces of the beta from my project and replaced it with the Asset Store version I downloaded today.
     
  31. mrmdesign

    mrmdesign

    Joined:
    Apr 18, 2013
    Posts:
    239
    I am sure I have obviously done it wrong somehow. Is this right:


    namespace NatCorderU.Examples {

    using UnityEngine;
    using UnityEngine.UI;
    using System.Collections;
    using Core;
    using Sharing;
     
    Gangsta-Geek likes this.
  32. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    The namespace is `Extensions`, not `Sharing`. The class name is what is `Sharing`.
     
    Gangsta-Geek and mrmdesign like this.
  33. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    Hello all!

    I'd like to post a mini update on the state of NatCorder and what you can expect in the coming weeks:

    - We are working on adding a macOS backend in NatCorder 1.1. The current Standalone backend requires FFmpeg and has some limitations (like not supporting frame timestamps or audio recording). We are moving to a full native backend implementation.
    - We are also considering adding a Windows backend in 1.1. This might not happen because we want to push 1.1 out as soon as possible, but stay tuned!
    - We are adding a number of fixes, especially related to audio-related bugs, based on some issues in Unity.
    - We are working on more written tutorials on Medium, going into more advanced recording, the NatCorder audio recording pipeline, and switching from Everyplay.

    Happy coding!
     
  34. mrmdesign

    mrmdesign

    Joined:
    Apr 18, 2013
    Posts:
    239
    Doh! Thank you so much and sorry for being a hair brained fool. :)
     
    Lanre likes this.
  35. Gangsta-Geek

    Gangsta-Geek

    Joined:
    Aug 11, 2012
    Posts:
    24
    Bought this asset yesterday it seems to work but I have some questions.

    I am having the same audio issues on iPhones. I tried changing the audio as suggested but that only allows the microphone to be active for 1 second? Is there another work around for this. When running the example scene ReplayCam the first audio recording works sometimes but after the first recording it goes back to being choppy.

    When using Sharing.SaveToCameraRoll() the video quality is really compressed. Is there a way to stop that from happening? But if you use Sharing.Share() and save the video when the native dialog box appears the video is not compressed.

    But the audio issue is a big deal.

     
    Last edited: Mar 6, 2018
  36. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    This is a bug in the Unity microphone API. The stuttering is coming somewhere from FMOD (Unity's audio backend to my understanding). Currently, we have not found a better workaround.
    This sort of issue would be out of scope for NatCorder. What this API does is simply to alert the Photos app that there is a video at the specified URI to be added; NatCorder doesn't actually touch the video. Perhaps the lower quality you are seeing is due to iCloud syncing? I know that low res photos are kept on the device and the full res ones are uploaded to iCloud, but I'm not sure if it also affects videos.
     
  37. alejobrainz

    alejobrainz

    Joined:
    Sep 10, 2005
    Posts:
    250
    Is there a filed unity bug around this microphone behavior? It’s a showstopper if you want any interaction in the avenue of Animojis.
     
    Last edited: Mar 8, 2018
  38. mrmdesign

    mrmdesign

    Joined:
    Apr 18, 2013
    Posts:
    239
    It would be beyond awesome if you could share a full script containing recording, playback and native sharing. If this was one of the example scenes in the package, it would help a lot of people get off to a flying start.
     
  39. pjccccc

    pjccccc

    Joined:
    Oct 7, 2015
    Posts:
    43
    Have you ever seen this issue? This only occurs in Galxy Note 8.

    Caused by java.lang.IllegalStateException
    at android.media.MediaCodec.native_dequeueOutputBuffer(MediaCodec.java)
    at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2570)
    at com.yusufolokoba.natcorder.Encoder.drainEncoder(Encoder.java:62)
    at com.yusufolokoba.natcorder.VideoEncoder.onRender(VideoEncoder.java:128)
    at com.yusufolokoba.natcam.rendering.GLRenderContext.run(GLRenderContext.java:153)
    at java.lang.Thread.run(Thread.java:762)
     
  40. HansAppLab

    HansAppLab

    Joined:
    Dec 7, 2017
    Posts:
    6
    I have same issue in Lenovo Tab 2. (Not tested in other devices yet.)
    Compiled script is ReplayCam scene of examples.

    FATAL EXCEPTION: NatCam Render Context
    Process: com.hansapp.natcordersample, PID: 4133
    java.lang.Error: FATAL EXCEPTION [NatCam Render Context]
    Unity version : 2017.3.1p2
    Device model : Lenovo Lenovo TAB 2 A10-70F
    Device fingerprint: Lenovo/LenovoTAB2A10-70F/A10-70F:6.0/MRA58K/A10-70F
    _S000216_170601_ROW:user/release-keys

    Caused by: java.lang.IllegalStateException
    at android.media.MediaCodec.native_dequeueOutputBuffer(Native Method)
    at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2392)
    at com.yusufolokoba.natcorder.Encoder.drainEncoder(Encoder.java:62)
    at com.yusufolokoba.natcorder.VideoEncoder.onRender(VideoEncoder.java:128)
    at com.yusufolokoba.natcam.rendering.GLRenderContext.run(GLRenderContext.java:153)
     
  41. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    Not that I know of. I will be filing one myself. I will let you know the ID when I do.
     
  42. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    Here is a minimal example using the GreyWorld example as a foundation:
    Code (CSharp):
    1. /*
    2. *   NatCorder
    3. *   Copyright (c) 2017 Yusuf Olokoba
    4. */
    5.  
    6. namespace NatCorderU.Examples {
    7.  
    8.     using UnityEngine;
    9.     using UnityEngine.UI;
    10.     using System.Collections;
    11.     using Core;
    12.  
    13.     public class GreyWorld : MonoBehaviour {
    14.  
    15.         /**
    16.         * GreyWorld Example
    17.         * ------------------
    18.         * This example records a WebCamTexture using the low-level `NatCorder` API
    19.         * The WebCamTexture is recorded with a filter applied (using a shader/material)
    20.         * When the user touches the screen, the greyness value is set to 1, making the preview become grey, and recording is started
    21.         * Then in `Update`, we blit the WebCamTexture to encoder surfaces (NatCorder.AcquireFrame) with the greyscale material/shader
    22.         * When the user stops pressing the screen, we revert the greyness and stop recording
    23.         */
    24.  
    25.         [Header("UI")]
    26.         public RawImage preview;
    27.         public AspectRatioFitter aspectFitter;
    28.  
    29.         private WebCamTexture cameraTexture;
    30.         private bool isPortrait;
    31.         private float greyness;
    32.         private const float GreySpeed = 3f;
    33.  
    34.         private string lastVideoPath;
    35.  
    36.         IEnumerator Start () {
    37.             NatCorder.Verbose = true;
    38.             // Request user authorization
    39.             yield return Application.RequestUserAuthorization(UserAuthorization.WebCam);
    40.             if (!Application.HasUserAuthorization(UserAuthorization.WebCam)) yield break;
    41.             // Start the camera
    42.             preview.material = new Material(Shader.Find("Hidden/NatCorder/GreyWorld"));
    43.             preview.texture =
    44.             cameraTexture = new WebCamTexture(null, 1280, 720);
    45.             cameraTexture.Play();
    46.             yield return new WaitUntil(() => cameraTexture.width != 16 && cameraTexture.height != 16); // Weird bug on macOS
    47.             // Orient the preview
    48.             preview.material.SetFloat("_Rotation", cameraTexture.videoRotationAngle * Mathf.PI / 180f);
    49.             preview.material.SetFloat("_Scale", cameraTexture.videoVerticallyMirrored ? -1 : 1);
    50.             // Scale the preview panel
    51.             isPortrait = cameraTexture.videoRotationAngle == 90 || cameraTexture.videoRotationAngle == 270;
    52.             aspectFitter.aspectMode = AspectRatioFitter.AspectMode.HeightControlsWidth;
    53.             aspectFitter.aspectRatio = isPortrait ? (float)cameraTexture.height / cameraTexture.width : (float)cameraTexture.width / cameraTexture.height;
    54.         }
    55.  
    56.         void Update () {
    57.             // Animate the greyness
    58.             preview.material.SetFloat("_Greyness", Mathf.Lerp(preview.material.GetFloat("_Greyness"), greyness, GreySpeed * Time.deltaTime));
    59.             // Record frames
    60.             if (NatCorder.IsRecording && cameraTexture.didUpdateThisFrame) {
    61.                 // Acquire an encoder frame
    62.                 var frame = NatCorder.AcquireFrame();
    63.                 // Blit with the preview material
    64.                 Graphics.Blit(cameraTexture, frame, preview.material);
    65.                 // Commit the encoder frame for encoding
    66.                 NatCorder.CommitFrame(frame);
    67.             }
    68.         }
    69.  
    70.         public void StartRecording () {
    71.             // Become grey
    72.             greyness = 1f;
    73.             // If the camera is in a potrait rotation, then we swap the width and height for recording
    74.             int recordingWidth = isPortrait ? cameraTexture.height : cameraTexture.width;
    75.             int recordingHeight = isPortrait ? cameraTexture.width : cameraTexture.height;
    76.             // Start recording
    77.             NatCorder.StartRecording(new Configuration(recordingWidth, recordingHeight), OnVideo);
    78.         }
    79.  
    80.         public void StopRecording () {
    81.             // Revert to normal color
    82.             greyness = 0f;
    83.             // Stop recording
    84.             NatCorder.StopRecording();
    85.         }
    86.  
    87.         void OnVideo (string path) {
    88.             Debug.Log("Saved recording to: "+path);
    89.             #if UNITY_IOS || UNITY_ANDROID
    90.             // Playback the video
    91.             Handheld.PlayFullScreenMovie(path);
    92.             #endif
    93.             // Save path to video so that we can use it for sharing
    94.             lastVideoPath = path;
    95.         }
    96.  
    97.         public void OnShare () { // Called by UI system when user clicks a button
    98.             // Share the recorded video
    99.             Sharing.Share(lastVideoPath);
    100.         }
    101.     }
    102. }
     
    mrmdesign likes this.
  43. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    Please email me the full logs (no filtering) from logcat and your script (if you aren't using an example scene). In your code, make sure you set `NatCorder.Verbose = true` before calling any NatCorder/Replay function (I usually just place this line at the very start of the Start method in my script).
     
  44. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    Please email me the logs too (same as above post).
     
  45. fssdev

    fssdev

    Joined:
    Jan 16, 2017
    Posts:
    50
    Hello,
    I just started using this plugin today and I'm hoping you can clear up some questions for me.
    Is the video saved Raw? or is it compressed?
    Is it possible for this plugin to be able to continuously record video a single video into a buffer, while constantly deleting earlier footage in order to maintain a specific recorded length?
    Our goal is to be able to always have the webcam recording to a small buffer, and when an event happens, save the past 10 seconds of video.

    Or should we be using NatCam Pro for this?
     
    Last edited: Mar 9, 2018
  46. Mr-Oliv

    Mr-Oliv

    Joined:
    Sep 14, 2012
    Posts:
    26
    Hi!
    I'm using NatCorder in an Android project that works when I build out an apk. But when I export the project using Gradle and import it into an Android Studio project, NatCore doesn't respond. I can see that both NatCamRenderPipeline.aar and NatCorder.aar are included in the export. There's tons of other stuff in the project that survives the export (like ARCore). Any idea what might cause this?
    Thanks
     
  47. wesense

    wesense

    Joined:
    Jun 8, 2017
    Posts:
    2
    hello there,

    there's a bug when you update the android for the 8.0.0 version Oreo.

    This is the logcat from adb when I ask for share.


    03-10 11:04:51.867 8993 9012 E Unity : AndroidJavaException: android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.wesense.wesenseAR/files/recording_2018_03_10_11_04_44_892.mp4 exposed beyond app through ClipData.Item.getUri()
    03-10 11:04:51.867 8993 9012 E Unity : android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/com.wesense.wesenseAR/files/recording_2018_03_10_11_04_44_892.mp4 exposed beyond app through ClipData.Item.getUri()
    03-10 11:04:51.867 8993 9012 E Unity : at android.os.StrictMode.onFileUriExposed(StrictMode.java:1958)
    03-10 11:04:51.867 8993 9012 E Unity : at android.net.Uri.checkFileUriExposed(Uri.java:2348)
    03-10 11:04:51.867 8993 9012 E Unity : at android.content.ClipData.prepareToLeaveProcess(ClipData.java:944)
    03-10 11:04:51.867 8993 9012 E Unity : at android.content.Intent.prepareToLeaveProcess(Intent.java:10480)
    03-10 11:04:51.867 8993 9012 E Unity : at android.content.Intent.prepareToLeaveProcess(Intent.java:10486)
    03-10 11:04:51.867 8993 9012 E Unity : at android.content.Intent.prepareToLeaveProcess(Intent.java:10465)
    03-10 11:04:51.867 8993 9012 E Unity : at android.app.Instrumentation.execStartActivity(Instrumentation.java:1616)
    03-10 11:04:51.867 8993 9012 E Unity : at android.app.Activity.startActivityForResult(Activity.java:4564)
    03-10 11:04:51.867 8993 9012 E Unity : at android.app.Activity.startActivityForResult(Activity.java:4522)
     
  48. Alex_Brazil

    Alex_Brazil

    Joined:
    Sep 2, 2014
    Posts:
    6
    Hello,


    I bought your plugin in the Unity3D store and I'm trying to implement the screen recording with an AR application. I have already tried with Vuforia and with EasyAR (https://www.easyar.com/) and not successive. Are you looking for an example of an AR application with your plugin to serve as an example for me? Or is there something guidance for me?


    Thanks,


    AlexBrazil
     
    Railon23 likes this.
  49. HansAppLab

    HansAppLab

    Joined:
    Dec 7, 2017
    Posts:
    6
    (*EDIT) This is workaround in my case.
    In my device, crash occures when recording if ShortSideLength is larger than 1130.
    Code (CSharp):
    1. // Set length of short side of video (eg. 720 when video size is 1280x720).
    2. const int ShortSideLength = 800;
    3. // Calculates video size by aspect ratio.
    4. float aspectRatio = (float)Screen.width / Screen.height;
    5. int videoWidth, videoHeight;
    6. if (Screen.width > Screen.height) // Landscape
    7. {
    8.     videoHeight = ShortSideLength;
    9.     videoWidth = (int)(ShortSideLength * aspectRatio);
    10.     videoWidth = (videoWidth % 2 == 0) ? videoWidth : videoWidth + 1;
    11. }
    12. else // Portrait
    13. {
    14.     videoWidth = ShortSideLength;
    15.     videoHeight = (int)(ShortSideLength / aspectRatio);
    16.     videoHeight = (videoHeight % 2 == 0) ? videoHeight : videoHeight + 1;
    17. }
    18. Configuration myConfig = new Configuration(videoWidth, videoHeight, Application.targetFrameRate);
    19. //Replay.StartRecording(Camera.main, myConfig, OnReplay, ...);
     
    Last edited: Mar 13, 2018
  50. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,377
    Hi there! I have inline responses below:
    The video is encoded with the H.264 codec (MPEG-4 AVC).
    This is not possible. NatCorder is solely meant for recording to a file.
    NatCam Pro doesn't support this functionality either. NatCam Pro records the camera feed to a file.
     
unityunity