Search Unity

NatCorder - Video Recording API

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

  1. MasterControlProgram

    MasterControlProgram

    Joined:
    Apr 18, 2015
    Posts:
    40
    Hi Lanre! Just saw the Natcorder update. First, amazing. This actually seems to address some memory pressure we've been seeing on low-end Android devices. Question - We're targeting devices in the Amazon ecosystem that use Android 22. Is there a reason why this newer version targets 24 API and above? Is there anything we can do to lower the Android requirement to 22 on our end?
     
  2. jiraphatK

    jiraphatK

    Joined:
    Sep 29, 2018
    Posts:
    116
    Hi, I found 2 problems using the latest NatCorder

    My setup
    Unity 2020.3.4 LTS
    Natcorder 1.8
    NCPX
    Android IL2CPP, gles2, gles3

    Natrender

    1.On Android device, the first frame was always black.
    the code used for recording
    Code (CSharp):
    1. recorder = new MP4Recorder(width, height, 30, microphone?.sampleRate ?? 0, microphone?.channelCount ?? 0);
    2.         cameraInput = new CameraInput(recorder, clock, camList.ToArray());
    3.         if (Application.platform == RuntimePlatform.Android)
    4.             cameraInput.textureInput = new GLESTextureInput(recorder, multithreading: true);
    5.         else if (Application.platform ==  RuntimePlatform.IPhonePlayer)
    6.             cameraInput.textureInput = new MTLTextureInput(recorder, multithreading: true);
    7.         microphone?.StartRunning((sampleBuffer, timestamp) => recorder.CommitSamples(sampleBuffer, clock.timestamp));
    2.I have tried recording model with stencil buffer shader, but the record video result in black frame.
    this is the log shown in android log cat
    2021/04/20 16:44:54.245 21097 21179 Info Unity Record video
    2021/04/20 16:44:54.245 21097 21179 Info Unity CameraCaptureButton:RecordVideo()
    2021/04/20 16:44:54.245 21097 21179 Info Unity UnityEngine.Events.UnityAction:Invoke()
    2021/04/20 16:44:54.245 21097 21179 Info Unity UnityEngine.Events.UnityEvent:Invoke()
    2021/04/20 16:44:54.245 21097 21179 Info Unity UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
    2021/04/20 16:44:54.245 21097 21179 Info Unity UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    2021/04/20 16:44:54.245 21097 21179 Info Unity UnityEngine.EventSystems.StandaloneInputModule:processTouchPress(PointerEventData, Boolean, Boolean)
    2021/04/20 16:44:54.245 21097 21179 Info Unity UnityEngine.EventSystems.StandaloneInputModule:processTouchEvents()
    2021/04/20 16:44:54.245 21097 21179 Info Unity UnityEngine.EventSystems.StandaloneInputModule:process()
    2021/04/20 16:44:54.245 21097 21179 Info Unity
    2021/04/20 16:44:54.263 21097 21266 Info AudioTrack isLongTimeZoreData zoer date time 12 Seconds
    2021/04/20 16:44:54.348 21097 21179 Debug MPEG4Writer PreAllocation disabled. fallocate : Operation not supported on transport endpoint, 95
    2021/04/20 16:44:54.352 21097 23112 Info OMXClient IOmx service obtained
    2021/04/20 16:44:54.357 21097 23112 Info ExtendedACodec setupVideoEncoder()
    2021/04/20 16:44:54.357 21097 23112 Warn OMXUtils do not know color format 0x7fa30c06 = 2141391878
    2021/04/20 16:44:54.357 21097 23112 Warn OMXUtils do not know color format 0x7fa30c04 = 2141391876
    2021/04/20 16:44:54.357 21097 23112 Warn OMXUtils do not know color format 0x7fa30c00 = 2141391872
    2021/04/20 16:44:54.357 21097 23112 Warn OMXUtils do not know color format 0x7fa30c09 = 2141391881
    2021/04/20 16:44:54.357 21097 23112 Warn OMXUtils do not know color format 0x7fa30c0a = 2141391882
    2021/04/20 16:44:54.357 21097 23112 Warn OMXUtils do not know color format 0x7fa30c08 = 2141391880
    2021/04/20 16:44:54.358 21097 23112 Warn OMXUtils do not know color format 0x7fa30c07 = 2141391879
    2021/04/20 16:44:54.358 21097 23112 Warn OMXUtils do not know color format 0x7f000789 = 2130708361
    2021/04/20 16:44:54.358 21097 23112 Info ACodec [OMX.qcom.video.encoder.avc] using color format 0x15 in place of 0x7f420888
    2021/04/20 16:44:54.359 21097 23112 Warn AString ctor got NULL, using empty string instead
    2021/04/20 16:44:54.359 21097 23112 Info ACodec setupAVCEncoderParameters with [profile: Baseline] [level: Level1]
    2021/04/20 16:44:54.359 21097 23112 Info ACodec [OMX.qcom.video.encoder.avc] cannot encode HDR static metadata. Ignoring.
    2021/04/20 16:44:54.359 21097 23112 Info ACodec setupVideoEncoder succeeded
    2021/04/20 16:44:54.359 21097 23112 Info ExtendedACodec [OMX.qcom.video.encoder.avc] configure, AMessage : AMessage(what = 'conf', target = 11) = {
    2021/04/20 16:44:54.359 21097 23112 Info ExtendedACodec int32_t color-format = 2135033992
    2021/04/20 16:44:54.359 21097 23112 Info ExtendedACodec int32_t i-frame-interval = 2
    2021/04/20 16:44:54.359 21097 23112 Info ExtendedACodec string mime = "video/avc"
    2021/04/20 16:44:54.359 21097 23112 Info ExtendedACodec int32_t width = 896
    2021/04/20 16:44:54.359 21097 23112 Info ExtendedACodec int32_t bitrate = 10000000
    2021/04/20 16:44:54.359 21097 23112 Info ExtendedACodec float frame-rate = 30.000000
    2021/04/20 16:44:54.359 21097 23112 Info ExtendedACodec int32_t height = 1920
    2021/04/20 16:44:54.359 21097 23112 Info ExtendedACodec int32_t flags = 1
    2021/04/20 16:44:54.359 21097 23112 Info ExtendedACodec int32_t encoder = 1
    2021/04/20 16:44:54.359 21097 23112 Info ExtendedACodec }
    2021/04/20 16:44:54.360 21097 23112 Info ACodec [OMX.qcom.video.encoder.avc] input format is AMessage(what = 0x00000000) = {
    2021/04/20 16:44:54.360 21097 23112 Info ACodec string mime = "video/raw"
    2021/04/20 16:44:54.360 21097 23112 Info ACodec int32_t stride = 896
    2021/04/20 16:44:54.360 21097 23112 Info ACodec int32_t slice-height = 1920
    2021/04/20 16:44:54.360 21097 23112 Info ACodec int32_t color-format = 21
    2021/04/20 16:44:54.360 21097 23112 Info ACodec Buffer *image-data = 0xb400006f8ce5edc0
    2021/04/20 16:44:54.360 21097 23112 Info ACodec int32_t color-range = 0
    2021/04/20 16:44:54.360 21097 23112 Info ACodec int32_t color-standard = 0
    2021/04/20 16:44:54.360 21097 23112 Info ACodec int32_t color-transfer = 0
    2021/04/20 16:44:54.360 21097 23112 Info ACodec int32_t width = 896
    2021/04/20 16:44:54.360 21097 23112 Info ACodec int32_t height = 1920
    2021/04/20 16:44:54.360 21097 23112 Info ACodec }
    2021/04/20 16:44:54.362 21097 23112 Info ACodec [OMX.qcom.video.encoder.avc] output format is AMessage(what = 0x00000000) = {
    2021/04/20 16:44:54.362 21097 23112 Info ACodec int32_t bitrate = 10000000
    2021/04/20 16:44:54.362 21097 23112 Info ACodec int32_t max-bitrate = 10000000
    2021/04/20 16:44:54.362 21097 23112 Info ACodec int32_t frame-rate = 30
    2021/04/20 16:44:54.362 21097 23112 Info ACodec string mime = "video/avc"
    2021/04/20 16:44:54.362 21097 23112 Info ACodec int32_t width = 896
    2021/04/20 16:44:54.362 21097 23112 Info ACodec int32_t height = 1920
    2021/04/20 16:44:54.362 21097 23112 Info ACodec }
    2021/04/20 16:44:54.365 21097 21179 Verbose NatSuite NatCorder: MP4Recorder prepared video encoder with format: {color-format=2135033992, i-frame-interval=2, mime=video/avc, width=896, bitrate=10000000, frame-rate=30.0, height=1920}
    2021/04/20 16:44:54.367 21097 23118 Debug CCodec allocate(c2.android.aac.encoder)
    2021/04/20 16:44:54.368 21097 23118 Info Codec2Client Available Codec2 services: "default" "software"
    2021/04/20 16:44:54.369 21097 23118 Info CCodec setting up 'default' as default (vendor) store
    2021/04/20 16:44:54.371 21097 23118 Info CCodec Created component [c2.android.aac.encoder]
    2021/04/20 16:44:54.371 21097 23118 Debug CCodecConfig read media type: audio/mp4a-latm
    2021/04/20 16:44:54.372 21097 23118 Debug ReflectedParamUpdater extent() != 1 for single value type: algo.buffers.max-count.values
    2021/04/20 16:44:54.372 21097 23118 Debug ReflectedParamUpdater extent() != 1 for single value type: output.subscribed-indices.values
    2021/04/20 16:44:54.372 21097 23118 Debug ReflectedParamUpdater extent() != 1 for single value type: input.buffers.allocator-ids.values
    2021/04/20 16:44:54.372 21097 23118 Debug ReflectedParamUpdater extent() != 1 for single value type: output.buffers.allocator-ids.values
    2021/04/20 16:44:54.373 21097 23118 Debug ReflectedParamUpdater extent() != 1 for single value type: algo.buffers.allocator-ids.values
    2021/04/20 16:44:54.373 21097 23118 Debug ReflectedParamUpdater extent() != 1 for single value type: output.buffers.pool-ids.values
    2021/04/20 16:44:54.373 21097 23118 Debug ReflectedParamUpdater extent() != 1 for single value type: algo.buffers.pool-ids.values
    2021/04/20 16:44:54.373 21097 23118 Info CCodecConfig query failed after returning 9 values (BAD_INDEX)
    2021/04/20 16:44:54.373 21097 23118 Debug CCodecConfig c2 config diff is Dict {
    2021/04/20 16:44:54.373 21097 23118 Debug CCodecConfig c2::u32 coded.bitrate.value = 64000
    2021/04/20 16:44:54.373 21097 23118 Debug CCodecConfig c2::u32 coded.pl.level = 0
    2021/04/20 16:44:54.373 21097 23118 Debug CCodecConfig c2::u32 coded.pl.profile = 8192
    2021/04/20 16:44:54.373 21097 23118 Debug CCodecConfig c2::u32 coding.aac-sbr-mode.value = 3
    2021/04/20 16:44:54.373 21097 23118 Debug CCodecConfig c2::u32 input.buffers.max-size.value = 2048
    2021/04/20 16:44:54.373 21097 23118 Debug CCodecConfig c2::u32 input.delay.value = 0
    2021/04/20 16:44:54.373 21097 23118 Debug CCodecConfig string input.media-type.value = "audio/raw"
    2021/04/20 16:44:54.373 21097 23118 Debug CCodecConfig string output.media-type.value = "audio/mp4a-latm"
    2021/04/20 16:44:54.373 21097 23118 Debug CCodecConfig c2::u32 raw.channel-count.value = 1
    2021/04/20 16:44:54.373 21097 23118 Debug CCodecConfig c2::u32 raw.sample-rate.value = 44100
    2021/04/20 16:44:54.373 21097 23118 Debug CCodecConfig }
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec [c2.android.aac.encoder] buffers are bound to CCodec for this session
    2021/04/20 16:44:54.374 21097 23118 Debug CCodecConfig no c2 equivalents for channel-mask
    2021/04/20 16:44:54.374 21097 23118 Debug CCodecConfig no c2 equivalents for aac-profile
    2021/04/20 16:44:54.374 21097 23118 Debug CCodecConfig no c2 equivalents for flags
    2021/04/20 16:44:54.374 21097 23118 Debug CCodecConfig no c2 equivalents for encoder
    2021/04/20 16:44:54.374 21097 23118 Warn Codec2Client query -- param skipped: index = 1107298332.
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec setup formats input: AMessage(what = 0x00000000) = {
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec int32_t aac-sbr-mode = 3
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec int32_t channel-count = 1
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec int32_t max-input-size = 16384
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec string mime = "audio/raw"
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec int32_t sample-rate = 44100
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec int32_t channel-mask = 16
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec } and output: AMessage(what = 0x00000000) = {
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec int32_t aac-sbr-mode = 3
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec int32_t bitrate = 64000
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec int32_t channel-count = 1
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec int32_t level = 0
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec int32_t max-bitrate = 64000
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec string mime = "audio/mp4a-latm"
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec int32_t profile = 2
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec int32_t sample-rate = 44100
    2021/04/20 16:44:54.374 21097 23118 Debug CCodec }
    2021/04/20 16:44:54.374 21097 21179 Verbose NatSuite NatCorder: MP4Recorder prepared audio encoder with format: {channel-mask=16, sample-rate=44100, mime=audio/mp4a-latm, channel-count=1, bitrate=64000, aac-profile=2, max-input-size=16384}
    2021/04/20 16:44:54.389 21097 23118 Warn Codec2Client query -- param skipped: index = 1342179345.
    2021/04/20 16:44:54.389 21097 23118 Warn Codec2Client query -- param skipped: index = 2415921170.
    2021/04/20 16:44:54.390 21097 23118 Error FMQ grantorIdx must be less than 3
    2021/04/20 16:44:54.390 21097 23118 Error FMQ grantorIdx must be less than 3
    2021/04/20 16:44:54.390 21097 23118 Debug CCodecBufferChannel [c2.android.aac.encoder#795] Created input block pool with allocatorID 16 => poolID 17 - OK (0)
    2021/04/20 16:44:54.391 21097 23118 Info CCodecBufferChannel [c2.android.aac.encoder#795] Created output block pool with allocatorID 16 => poolID 517 - OK
    2021/04/20 16:44:54.391 21097 23118 Debug CCodecBufferChannel [c2.android.aac.encoder#795] Configured output block pool ids 517 => OK
    2021/04/20 16:44:54.391 21097 23118 Debug CCodecBufferChannel [c2.android.aac.encoder#795] start: updating output delay 0
    2021/04/20 16:44:54.391 21097 23118 Error ion ioctl c0044901 failed with code -1: Inappropriate ioctl for device
    2021/04/20 16:44:54.406 21097 21179 Debug AudioRecord set(): inputSource 1, sampleRate 44100, format 0x1, channelMask 0x10, frameCount 1792, notificationFrames 0, sessionId 0, transferType 0, flags 0, opPackageName com.spacears.space.android uid -1, pid -1
    2021/04/20 16:44:54.413 21097 21179 Debug AudioRecord start(602): sync event 0 trigger session 0, mSessionID=4377
    2021/04/20 16:44:54.424 21097 21179 Debug AudioService broadcastRecorderState:com.spacears.space.android
    2021/04/20 16:44:54.424 21097 21179 Verbose NatSuite NatDevice: AudioDevice 1 started recording with format: 1@44100Hz
    2021/04/20 16:44:54.426 21097 21179 Info Unity Capture Video Screenshot done, start recording....
    2021/04/20 16:44:54.426 21097 21179 Info Unity <DoCaptureThumbnailForVideo>d__28:MoveNext()
    2021/04/20 16:44:54.426 21097 21179 Info Unity UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
    2021/04/20 16:44:54.426 21097 21179 Info Unity
    2021/04/20 16:44:54.478 21097 23112 Info ACodec [OMX.qcom.video.encoder.avc] output format is AMessage(what = 0x00000000) = {
    2021/04/20 16:44:54.478 21097 23112 Info ACodec int32_t bitrate = 10000000
    2021/04/20 16:44:54.478 21097 23112 Info ACodec int32_t max-bitrate = 10000000
    2021/04/20 16:44:54.478 21097 23112 Info ACodec int32_t frame-rate = 30
    2021/04/20 16:44:54.478 21097 23112 Info ACodec string mime = "video/avc"
    2021/04/20 16:44:54.478 21097 23112 Info ACodec int32_t width = 896
    2021/04/20 16:44:54.478 21097 23112 Info ACodec int32_t height = 1920
    2021/04/20 16:44:54.478 21097 23112 Info ACodec }
    2021/04/20 16:44:54.484 21097 23123 Error Utils csd0 too small
    2021/04/20 16:44:54.484 21097 23123 Error ExtendedUtils csd0 too small
    2021/04/20 16:44:54.484 21097 23123 Debug MPEG4Writer fpathconf _PC_FILESIZEBITS:64
    2021/04/20 16:44:54.484 21097 23123 Debug MPEG4Writer File size limit set to 4503599627370495 bytes implicitly
    2021/04/20 16:44:54.484 21097 23123 Debug MPEG4Writer MP4WtrCtrlHlpLooper Started
    2021/04/20 16:44:54.484 21097 23123 Info MPEG4Writer limits: 4503599627370495/0 bytes/us, bit rate: -1 bps and the estimated moov size 3192 bytes
    2021/04/20 16:44:54.484 21097 23132 Debug MPEG4Writer kWhatNoIOErrorSoFar
    2021/04/20 16:44:54.487 21097 23133 Info MPEG4Writer setStartTimestampUs: 0
    2021/04/20 16:44:54.487 21097 23133 Info MPEG4Writer Earliest track starting time: 0
    2021/04/20 16:44:54.501 21097 22899 Error native motion_tracking_context.cc:1331 Unable to find measurements corresponding to VIO status at timestamp 25781854800335.
    2021/04/20 16:44:54.536 21097 23118 Error FMQ grantorIdx must be less than 3
    2021/04/20 16:44:54.539 21097 22854 Error FMQ grantorIdx must be less than 3
    2021/04/20 16:44:54.540 21097 23134 Info MPEG4Writer setStartTimestampUs: 103892
    2021/04/20 16:44:55.279 21097 21266 Info AudioTrack isLongTimeZoreData zoer date time 13 Seconds
    2021/04/20 16:44:55.707 21097 22899 Error native motion_tracking_context.cc:1331 Unable to find measurements corresponding to VIO status at timestamp 25783054583928.
    2021/04/20 16:44:56.291 21097 21266 Info AudioTrack isLongTimeZoreData zoer date time 14 Seconds
    2021/04/20 16:44:56.653 21097 22984 Info native motion_analysis_calculator.cc:626 Analyzed frame 801
    2021/04/20 16:44:57.307 21097 21266 Info AudioTrack isLongTimeZoreData zoer date time 15 Seconds
    2021/04/20 16:44:57.667 21097 23119 Debug CCodecBufferChannel [c2.android.aac.encoder#795] DEBUG: elapsed: n=4 [in=0 pipeline=0 out=0 smoothness=4]
    2021/04/20 16:44:57.667 21097 23119 Debug PipelineWatcher DEBUG: elapsed 0 / 4
    2021/04/20 16:44:58.323 21097 21266 Info AudioTrack isLongTimeZoreData zoer date time 16 Seconds
    2021/04/20 16:44:59.339 21097 21266 Info AudioTrack isLongTimeZoreData zoer date time 17 Seconds
    2021/04/20 16:44:59.390 21097 23121 Debug BufferPoolAccessor2.0 bufferpool2 0xb400006fb6609828 : 5(81920 size) total buffers - 4(65536 size) used buffers - 0/5 (recycle/alloc) - 4/240 (fetch/transfer)
    2021/04/20 16:44:59.390 21097 23121 Debug BufferPoolAccessor2.0 evictor expired: 1, evicted: 1
    2021/04/20 16:44:59.986 21097 22984 Info native motion_analysis_calculator.cc:626 Analyzed frame 901
    2021/04/20 16:45:00.281 21097 21179 Error ACameraMetadata getConstEntry: cannot find metadata tag 65578
    2021/04/20 16:45:00.355 21097 21266 Info AudioTrack isLongTimeZoreData zoer date time 18 Seconds
    2021/04/20 16:45:01.000 21097 23119 Debug CCodecBufferChannel [c2.android.aac.encoder#795] DEBUG: elapsed: n=4 [in=0 pipeline=0 out=0 smoothness=4]
    2021/04/20 16:45:01.000 21097 23119 Debug PipelineWatcher DEBUG: elapsed 0 / 4
    2021/04/20 16:45:01.371 21097 21266 Info AudioTrack isLongTimeZoreData zoer date time 19 Seconds
    2021/04/20 16:45:01.700 21097 22899 Error native motion_tracking_context.cc:1331 Unable to find measurements corresponding to VIO status at timestamp 25789053501741.
    2021/04/20 16:45:01.809 21097 23130 Debug AudioRecord stop mSessionID=4377
    2021/04/20 16:45:01.809 21097 23130 Debug AudioRecord stop(602): mActive:1
    2021/04/20 16:45:01.844 21097 23130 Debug AudioService broadcastRecorderState:com.spacears.space.android
    2021/04/20 16:45:01.844 21097 23130 Debug AudioRecord stop mSessionID=4377
    2021/04/20 16:45:01.844 21097 23130 Debug AudioRecord stop(602): mActive:0
    2021/04/20 16:45:01.844 21097 23130 Debug AudioService broadcastRecorderState:com.spacears.space.android
    2021/04/20 16:45:01.844 21097 23130 Debug AudioRecord stop mSessionID=4377
    2021/04/20 16:45:01.844 21097 23130 Debug AudioRecord stop(602): mActive:0
    2021/04/20 16:45:01.844 21097 23130 Debug AudioRecord stop mSessionID=4377
    2021/04/20 16:45:01.844 21097 23130 Debug AudioRecord stop(602): mActive:0
    2021/04/20 16:45:01.844 21097 23130 Verbose NatSuite NatDevice: AudioDevice 1 stopped recording
    2021/04/20 16:45:01.855 21097 23123 Verbose NatSuite NatCorder: MP4Recorder video encoder encountered EOS
    2021/04/20 16:45:01.855 21097 23124 Verbose NatSuite NatCorder: MP4Recorder audio encoder encountered EOS
    2021/04/20 16:45:01.856 21097 23118 Debug CCodecBufferChannel [c2.android.aac.encoder#795] MediaCodec discarded an unknown buffer
    2021/04/20 16:45:01.856 21097 23118 Info chatty uid=10374(com.spacears.space.android) identical 1 line
    2021/04/20 16:45:01.856 21097 23118 Debug CCodecBufferChannel [c2.android.aac.encoder#795] MediaCodec discarded an unknown buffer
    2021/04/20 16:45:01.856 21097 23118 Info hw-BpHwBinder onLastStrongRef automatically unlinking death recipients
    2021/04/20 16:45:01.859 21097 21179 Info Unity Stop record video
    2021/04/20 16:45:01.859 21097 21179 Info Unity CameraCaptureButton:StopRecord()
    2021/04/20 16:45:01.859 21097 21179 Info Unity UnityEngine.Events.UnityAction:Invoke()
    2021/04/20 16:45:01.859 21097 21179 Info Unity UnityEngine.Events.UnityEvent:Invoke()
    2021/04/20 16:45:01.859 21097 21179 Info Unity UnityEngine.EventSystems.EventFunction`1:Invoke(T1, BaseEventData)
    2021/04/20 16:45:01.859 21097 21179 Info Unity UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    2021/04/20 16:45:01.859 21097 21179 Info Unity UnityEngine.EventSystems.StandaloneInputModule:processTouchPress(PointerEventData, Boolean, Boolean)
    2021/04/20 16:45:01.859 21097 21179 Info Unity UnityEngine.EventSystems.StandaloneInputModule:processTouchEvents()
    2021/04/20 16:45:01.859 21097 21179 Info Unity UnityEngine.EventSystems.StandaloneInputModule:process()
    2021/04/20 16:45:01.859 21097 21179 Info Unity
    2021/04/20 16:45:01.872 21097 21179 Info ExoPlayerImpl Init bdc1fce [ExoPlayerLib/2.8.4] [apollo, M2007J3SG, Xiaomi, 30]
    2021/04/20 16:45:01.877 21097 23123 Debug MPEG4Writer reset()
    2021/04/20 16:45:01.877 21097 23123 Debug MPEG4Writer Audio track stopping. Stop source
    2021/04/20 16:45:01.877 21097 23133 Verbose MediaWriter Track event err/info msg:101, trackId:1, type:1000,val:-1011
    2021/04/20 16:45:01.877 21097 23133 Info MPEG4Writer Received total/0-length (220/0) buffers and encoded 220 frames. - Video
    2021/04/20 16:45:01.878 21097 23134 Verbose MediaWriter Track event err/info msg:101, trackId:2, type:1000,val:-1011
    2021/04/20 16:45:01.878 21097 23134 Info MPEG4Writer Received total/0-length (313/0) buffers and encoded 313 frames. - Audio
    2021/04/20 16:45:01.878 21097 23134 Info MPEG4Writer Audio track drift time: 0 us
    2021/04/20 16:45:01.878 21097 23123 Debug MPEG4Writer Audio track source stopping
    2021/04/20 16:45:01.878 21097 23123 Debug MPEG4Writer Audio track source stopped
    2021/04/20 16:45:01.878 21097 23123 Debug MPEG4Writer Audio track stopped. Status:0. Stop source
    2021/04/20 16:45:01.878 21097 23123 Debug MPEG4Writer Video track stopping. Stop source
    2021/04/20 16:45:01.878 21097 23123 Debug MPEG4Writer audio will wait 0ns for video to stop
    2021/04/20 16:45:01.879 21097 23123 Warn MPEG4Writer Timed-out waiting for video track to reach final audio timestamp !
    2021/04/20 16:45:01.880 21097 23123 Debug MPEG4Writer Video track source stopping
    2021/04/20 16:45:01.880 21097 23123 Debug MPEG4Writer Video track source stopped
    2021/04/20 16:45:01.880 21097 23123 Debug MPEG4Writer Video track stopped. Status:0. Stop source
    2021/04/20 16:45:01.880 21097 23123 Debug MPEG4Writer Duration from tracks range is [7333244, 7375738] us
    2021/04/20 16:45:01.880 21097 23131 Debug MPEG4Writer 0 chunks are written in the last batch
    2021/04/20 16:45:01.883 21097 23123 Debug MPEG4Writer WriterThread stopped. Status:0
    2021/04/20 16:45:01.883 21097 23123 Info MPEG4Writer Adjust the moov start time from 0 us -> 0 us
    2021/04/20 16:45:01.885 21097 23123 Info MPEG4Writer The mp4 file will not be streamable.
    2021/04/20 16:45:01.885 21097 23123 Info MPEG4Writer MOOV atom was written to the file
    2021/04/20 16:45:01.885 21097 23123 Debug MPEG4Writer release()
    2021/04/20 16:45:01.896 21097 23123 Debug MPEG4Writer MP4WtrCtrlHlpLooper stopped
    2021/04/20 16:45:01.896 21097 23123 Debug MPEG4Writer Top 5 write durations(microseconds): #1:53 #2:57 #3:67 #4:87 #5:1317
    2021/04/20 16:45:01.896 21097 23123 Debug MPEG4Writer reset()
    2021/04/20 16:45:01.899 21097 23123 Debug MPEG4Writer Video track stopping. Stop source
    2021/04/20 16:45:01.899 21097 23123 Error MPEG4Writer Stop() called but track is not started or stopped
    2021/04/20 16:45:01.899 21097 23123 Debug MPEG4Writer Audio track stopping. Stop source
    2021/04/20 16:45:01.899 21097 23123 Error MPEG4Writer Stop() called but track is not started or stopped
    2021/04/20 16:45:01.913 21097 21179 Info Unity Saved recording to: /storage/emulated/0/Android/data/com.spacears.space.android/files/recording_2021_04_20_16_44_54_342.mp4
    2021/04/20 16:45:01.913 21097 21179 Info Unity <StopRecording>d__26:MoveNext()

    EDIT I just tried Natcorder 1.8 without NCPX and NatRender, the frame is still black
    EDIT2 Here is an example video with black frame

    the result video
     
    Last edited: Apr 21, 2021
  3. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    Hey there. The upgrade to Android 24 is for parity with the other NatSuite Framework components, specifically NatML (upcoming machine learning library) and NatDevice. I believe NatCorder can still run on API level 21+, it just requires complicated build instructions. You have to export the Gradle project with API level 24 from Unity, then in Android Studio, revert the minimum to API level 22 and add a library override for NatCorder (api.natsuite.natcorder).
     
  4. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    An issue has been opened for this, and I'll be looking into it today or tomorrow.
     
  5. MasterControlProgram

    MasterControlProgram

    Joined:
    Apr 18, 2015
    Posts:
    40
    Thanks Lanre! We'll try this out. We actually integrate Unity into a native project vial UAAL. So this might just work for us. Will report back :D
     
  6. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    Sounds good, keep me posted.
     
  7. Krimelz

    Krimelz

    Joined:
    May 5, 2020
    Posts:
    1
    Hi
    can I using unity as a library with NatCorder?
     
    Last edited: Apr 27, 2021
  8. markinovus

    markinovus

    Joined:
    Apr 27, 2021
    Posts:
    5
    Hi,

    We're getting the following error and wondered if you had any pointers as to how to narrow down the cause of this issue.... The build works on most machines but just not on some... Should we put in a proper support request? (via the email address on github?)

    Code (CSharp):
    1. DllNotFoundException: NatCorder
    2. NatCorder.MP4Recorder..ctor (System.Int32 videoWidth, System.Int32 videoHeight, System.Int32 videoFramerate, System.Int32 audioSampleRate, System.Int32 audioChannelCount, System.Action`1[T] recordingCallback, System.String recordingDirectory, System.String recordingFilename, System.Int32 videoBitrate, System.Int32 videoKeyframeInterval) (at <b718adeea08544b9955e811addc8646e>:0)
    3. Inovus.InoScreenRecorder.StartRecording () (at <b718adeea08544b9955e811addc8646e>:0)
    4. Inovus.InoScene.TrackingStartSession () (at <b718adeea08544b9955e811addc8646e>:0)
    5. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
    6. Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    7. System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <437ba245d8404784b9fbab9b439ac908>:0)
    8.  
     
  9. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    Hm I've never tried this, but I expect it to work. There shouldn't be any difference in how Unity libraries are loaded.
     
  10. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    It looks like you're using an outdated version of NatCorder. Upgrade to 1.8 on the Asset Store (make sure to delete NatCorder in your project before pulling the new version) and try again. What platform are you running on?
     
  11. tamizhan

    tamizhan

    Joined:
    Feb 23, 2018
    Posts:
    5
    How to save the recorded video from particular album(path).Where to change it.
     
  12. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    You can't set where NatCorder saves the recording, because it always saves to the app's private documents directory. If you want to move it somewhere else, you can use the functions in System.IO. If you'd like to copy the recording to the camera roll, you can use NatShare.
     
    tamizhan likes this.
  13. markinovus

    markinovus

    Joined:
    Apr 27, 2021
    Posts:
    5
    We're running Unity 2019.3.15f1 on PC and macOS. Is there anywhere you can point me towards a release note or readme or anything that shows a fix for this issue as the only think I could see was that a similar error occurred on OSX but that was from a really really long time ago. Thanks
     
  14. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    Here's the changelog. I need to know the full specifications of the system where you saw this error. There was a similar error on Windows that was fixed sometime ago, but wasn't mentioned in the changelog. You'll want to upgrade to the latest version, and on Windows, make sure you install the latest Visual C++ Redistributable.
     
  15. tamizhan

    tamizhan

    Joined:
    Feb 23, 2018
    Posts:
    5
    Thanks
     
    Lanre likes this.
  16. Archi_16

    Archi_16

    Joined:
    Apr 7, 2017
    Posts:
    72
    Hi. I have noticed strange issue.
    I have video player, with video(with sound)
    when I start recording before playing video, video will play normally during recording.
    But when i start recording when video is playing, video got paused(or freeze)

    the issue doesn't exist when video has no audio.
    Any idea what can be the reason?
     
  17. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    I'm not sure why this happens. Have you checked the logs for any clues? What device and OS version does this happen on?
     
  18. Icecubez

    Icecubez

    Joined:
    Apr 18, 2018
    Posts:
    4
    I'm having a similar issue.

    Recorded videos with audio are as if in slow-motion, but if I mute the audio in terms of setting samples/channels to 0, the video is smooth.
     
  19. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    Sounds like you found the cause of the issue: the app was set to use Mono audio instead of Stereo.
     
  20. MasterControlProgram

    MasterControlProgram

    Joined:
    Apr 18, 2015
    Posts:
    40
    Just FYI, we use Unity as a Library with Natcorder and it works for us.
     
    Lanre likes this.
  21. microwavesam

    microwavesam

    Joined:
    Jun 17, 2017
    Posts:
    1
    Hi Lanre, I was using the
    NatCorder Performance Extensions for Android.

    I had a quick question on:

    Code (CSharp):
    1. GLESTextureInput(...);
    I have the recording part being generated, and I was wondering if when I choose to stop recording,

    should I Dispose() the
    GLESTextureInput?


    Do I need to Dispose() anything when stopping recording?

    Thank you for a very cool asset.
     
  22. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    Hey there, glad to see you're using NCPX. If you attach the `GLESTextureInput` to a `CameraInput`, then you don't need to dispose. The `CameraInput` disposes its texture input when it gets disposed.
     
    microwavesam likes this.
  23. monda

    monda

    Joined:
    May 14, 2015
    Posts:
    25
    Hi, maybe this question was already answered but cannot find it anywhere.

    My project is using NGUI, ARFoundation and URP.

    Using Natcorder to record the video works fine but the video has the UI (Which I don't want).

    ARCamera is Base, NGUI Camera is Overlay, is there a way to record the video of the Base Camera without the Overlayed UI?
    Thanks!
     
  24. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    I'm not familiar with NGUI at all. If you are recording with a CameraInput, have you tried excluding the NGUI camera when you create the camera input?
     
  25. monda

    monda

    Joined:
    May 14, 2015
    Posts:
    25
    NGUI just creates an extra camera with 2D textures, I set that camera as overlay while the main Camera as Base with the NGUI Camera as overlay.

    What do you mean by exclude NGUI? Like disabled it? I did a solution like this but then because the UI disappears, users can't play the game while recording :(

    PS: I use the Camera Input only on the Camera.main
    The UI Layer is disabled on the Main Camera, so only the overlaid UI is shown
     
  26. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    So if you don't have to explicitly record the NGUI camera, then that means there must be some things going on with NGUI that allows it to be rendered on screen. I recommend reaching out to NGUI support on this issue; it has more to do with how their rendering system is architected.
     
  27. mosheAR51

    mosheAR51

    Joined:
    Jun 11, 2020
    Posts:
    3
    Getting a very strange crash on IOS (iPhoneX).
    When I record video using an AudioInput from the scene's AudioListener or a specific AudioSource I get a system exception from the recorder saying "recorder failed to finish writing" which is thrown from a concurrent dictionary.
    I would also like to point out that without the AudioInput the video is created and saved correctly.

    Unity: 2020.1
    NatCorder: 1.8.0
    Device: iPhoneX

    StartRecording:
    Code (CSharp):
    1.         private void PerformRecordingInitialization()
    2.         {
    3.             var videoHeight = (int) (RecordingVideoWidth/Camera.main.aspect);
    4.             videoHeight = videoHeight >> 1 << 1; // Ensure divisible by 2
    5.  
    6.             var resolution = new Vector2(RecordingVideoWidth, videoHeight);
    7.             _clock = new RealtimeClock();
    8.             _recorder = new MP4Recorder(
    9.                 (int) resolution.x,
    10.                 (int) resolution.y,
    11.                 RecordingFramerate,
    12.                 RecordAudioSource ? AudioSettings.outputSampleRate : 0,
    13.                 RecordAudioSource ? (int) AudioSettings.speakerMode : 0,
    14.                 VideoBitRate,
    15.                 KeyframeInterval,
    16.                 AudioBitRate);
    17.  
    18.             _cameraInput = new CameraInput(_recorder, _clock, Camera.main) {frameSkip = FrameSkip};
    19.             if (Application.platform == RuntimePlatform.Android)
    20.                 _cameraInput.textureInput = GenerateTextureInput();
    21.  
    22.             if (RecordAudioSource)
    23.             {
    24.                 var sourceAudio = ContentNode.GetComponentInChildren<AudioSource>(true);
    25.                 _audioInput = new AudioInput(_recorder, _clock, sourceAudio);
    26.             }
    27.             else _audioInput = null;
    28.  
    29.             IsRecording = true;
    30.         }
    StopRecording:
    Code (CSharp):
    1.         private async void ShutdownRecording()
    2.         {
    3.             _audioInput?.Dispose();
    4.             _cameraInput?.Dispose();
    5.             OutputPath = await _recorder.FinishWriting();
    6. #if !UNITY_EDITOR
    7.             this.LogMessage($"SavingCameraRollPayload: {OutputPath}");
    8.             var payload = new SavePayload();
    9.             payload.AddMedia(OutputPath);
    10.  
    11.             var saved = await payload.Commit();
    12.             this.LogMessage($"PayrollSaved: {saved}");
    13. #endif
    14.         }
     
    Last edited: May 20, 2021
  28. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    A hard crash is typically unrelated to the recorder failing to finish writing. For the former, this typically happens if the recorder is used after `FinishWriting` is called. For the latter, it typically happens if your timestamps are not strictly monotonic. How long is a typical recording in your app? If it's long enough, C#'s System.Diagnostics.Stopwatch (which is what the RealtimeClock uses) seems to drift, although this is rare.
     
  29. mosheAR51

    mosheAR51

    Joined:
    Jun 11, 2020
    Posts:
    3
    Typically around 10-15 seconds of recording. I've actually just managed to record correctly. Before I was recording with an audio-bitrate of around 16000 and the default sample-rate from the AudioSettings (which was set to 24000). Increasing my audio-bitrate to 96000 seemed to have solved it. Any idea why?
     
  30. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    I don't recommend setting the audio bitrate (or video bitrate) if you're not familiar with the standards used in media encoding. a 16kbps bitrate sounds incredibly low. Common values are 64kbps or 96kbps.
     
  31. mosheAR51

    mosheAR51

    Joined:
    Jun 11, 2020
    Posts:
    3
    The annoying part is the reaction delta between IOS and Android devices; but then again write once, deploy everywhere is good for a laugh most days :p

    Thanks for the quick replies by the way. Really awesome.

    Is there a way to throw out a better exception for this case? It really seems like a strange race condition.
     
    Lanre likes this.
  32. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    I don't think there is. On iOS, the encoder only provides a vague status code if something goes wrong. Let me know if you run into any other crashes after setting the audio bitrate to 64kbps or 96kbps. If it still happens, then we can look into it more carefully.
     
  33. richardzzzarnold

    richardzzzarnold

    Joined:
    Aug 2, 2012
    Posts:
    114
    Hi I am having trouble signing the bundle for deployment to the MacAppStore.
    I am getting in XCode a CFBundleIdentifierCollision error.

    CFBundleIdentifier Collision. The Info.plist CFBundleIdentifier value 'api.natsuite.NatCorder' of 'XXXXXXXX.app/Contents/PlugIns/NatCorder.bundle' is already in use by another application.

    I had this same problem with another plugin in the same project and was able to solve it by adding another suffix to the bundle identifier in the bundles info.plist ( eg. api.natsuite.NatCorder.123456787654 ). This worked for the other plugin, but doesnt for the NatCorder plugin.

    Any idea how I can overcome this issue?

    I also tried removing the _CodeSignature folder from the xcode project but it also didn't seem to make any difference.

    Using v1.8
    Unity 2021

    In addition, if I change the bundle identifier in the bundles info.plist to ( for example ) com.xxxxxxx.APPNAME.NatCorder
    I get the error message:

    Invalid Code Signature Identifier. The identifier "api.natsuite.NatCorder" in your code signature for "NatCorder" must match its Bundle Identifier "com.xxxxxxx.APPNAME.NatCorder"

    Also tried reinstalling NatCorder, as suggested to Arjun-Gupte, but to no avail.
     
    Last edited: May 21, 2021
  34. Ikaro88

    Ikaro88

    Joined:
    Jun 6, 2016
    Posts:
    199
    Hi, I am using natcode with a plugin AVPRO.
    Seems that on IOS sometimes (after 2 to 6 recordings) when recording i get this error:

    unity EXC_BAD_ACCESS (code=1 address=0x110)

    It happens when the code execute this line:

    var path = await recorder.FinishWriting();

    any solution?

    Please help me....
     
  35. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    Hey there, it sounds like you might have multiple NatCorder bundles in your project. Here's what to try:

    1. In your project, search for and delete every folder named NatCorder or NatSuite. Make sure that the API is completely removed from your project.
    2. Reimport NatCorder into your project from the Asset Store.
    3. Build a clean Xcode project from Unity (Replace instead of Append).
    Let me know if the issue persists.
     
  36. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    Can you share your full recording code? This typically happens if you try to call any function on a recorder after `FinishWriting` has been called.
     
    Ikaro88 likes this.
  37. richardzzzarnold

    richardzzzarnold

    Joined:
    Aug 2, 2012
    Posts:
    114

    Yes I tried that before..
    I deleted the entire NatSuite folder , checked for any other files, reimported built new clean
    Issue persists
     
  38. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    Can you check the second answer in this SO question? Perhaps Xcode is incorrectly copying the bundle's Info.plist. You can also try removing the NatCorder bundle from your Xcode project (remove reference, don't move to trash), then add it back and see if that works.
     
  39. richardzzzarnold

    richardzzzarnold

    Joined:
    Aug 2, 2012
    Posts:
    114
    Actually I just resolved it. You were right there was script i had modified earlier that referred to an earlier version of a class. It worked somehow but caused the signing issue.
    All fixed.

    Actually the reason this problem exists is primarily because due to failures in the design of the PackageManager, reimported updates are reverting to the 2018 version ( in my case)

    It seems to unpredictably install prior versions and blend them together
     
    Last edited: May 21, 2021
  40. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    Ah I see, that's good to know. UPM is promising but still feels very incomplete.
     
  41. richardzzzarnold

    richardzzzarnold

    Joined:
    Aug 2, 2012
    Posts:
    114
    Actually this is still a mess though I am fairly certain that at one point it DID pass validation.
    I have now completely removed the NatSuite folder and then installed the NatCorder 2021 asset directly from the Asset store cache in the Library folder.
    However I am now back to CFBundleIdentifier collision.


    And again I have completely removed the folder.
    Reinstalled from Asset store ( confirming that this time it is the 2021 version)
    Validation fails again with CFBundleIdentifier collision

    So frustrating.
     
    Last edited: May 21, 2021
  42. richardzzzarnold

    richardzzzarnold

    Joined:
    Aug 2, 2012
    Posts:
    114
    Tried all these things . They all fail to resolve it.

    try removing the NatCorder bundle from your Xcode project (remove reference, don't move to trash), then add it back ( this did work for a seperate plugin (AVProVideo) but would not work with NatCorder)
     
    Last edited: May 21, 2021
    Lanre likes this.
  43. shodgson_nl

    shodgson_nl

    Joined:
    Jan 8, 2018
    Posts:
    9
    Looks like the issue was coming from the audio engine after all but caused by other factors after we 'paused'
     
    Lanre likes this.
  44. Ikaro88

    Ikaro88

    Joined:
    Jun 6, 2016
    Posts:
    199
    Sure

    Code (CSharp):
    1.  
    2.  
    3.  public class CameraRecorderReplay1 : MonoBehaviour
    4.     {
    5.         [Header(@"Recording")]
    6.         private int videoWidth = 720;
    7.         private int videoHeight = 1280;
    8.         public bool recordMicrophone = true;
    9.         public Camera CameraRecorded;
    10.         private IMediaRecorder recorder;
    11.         private CameraInput cameraInput;
    12.         private AudioInput audioInput;
    13.         private AudioSource microphoneSource;
    14.         public static CameraRecorderReplay1 instance;
    15.         public AudioMixer audioMixer;
    16.         private void Awake()
    17.         {
    18.             videoWidth = Screen.width;
    19.             videoHeight = Screen.height;
    20.         }
    21.         public void ExternalStartRecording()
    22.         {
    23.             StartCoroutine(StartRecordingCheck());
    24.         }
    25.         private IEnumerator Start()
    26.         {
    27.        
    28.                 instance = this;
    29.  
    30.             yield return new WaitForEndOfFrame();
    31.         }
    32.      
    33.         private IEnumerator InitMicrophone()
    34.         {
    35.             microphoneSource = gameObject.AddComponent<AudioSource>();
    36.             microphoneSource.mute =
    37.             microphoneSource.loop = true;
    38.             if (Microphone.devices.Length > 0)
    39.             {
    40.                 microphoneSource.clip = Microphone.Start(Microphone.devices[0], true, 180, AudioSettings.outputSampleRate);
    41.                 yield return new WaitUntil(() => Microphone.GetPosition(null) > 0);
    42.                 microphoneSource.Play();
    43.             }
    44.             else
    45.             {
    46.                 ToastMessage.Instance.SendSpecificMessage("NO MICHROPONE DETECTED");
    47.             }
    48.          
    49.         }
    50.         public IEnumerator StartRecordingCheck()
    51.         {
    52.             Debug.Log("INIZIO");
    53.                 if (microphoneSource == null)
    54.                 {
    55.                     StartCoroutine(InitMicrophone());
    56.                     yield return new WaitUntil(() => microphoneSource != null);
    57.                 }
    58.             StartRecording();
    59.         }
    60.         public void StartRecording()
    61.         {
    62.             // Start recording
    63.             var frameRate = 30;
    64.             var sampleRate = recordMicrophone ? AudioSettings.outputSampleRate : 0;
    65.             var channelCount = recordMicrophone ? (int)AudioSettings.speakerMode : 0;
    66.                 RealtimeClock clock = new RealtimeClock();
    67.                 recorder = new MP4Recorder(videoWidth, videoHeight, frameRate, sampleRate, channelCount);
    68.             // Create recording inputs
    69.             cameraInput = new CameraInput(recorder, clock, CameraRecorded);
    70.      
    71.                 audioInput = recordMicrophone ? new AudioInput(recorder, clock, microphoneSource, true) : null;
    72.        
    73.             // Unmute microphone
    74.             if (microphoneSource != null)
    75.                 microphoneSource.mute = audioInput == null;
    76.          
    77.         }
    78.         public async void StopRecording(UnityAction<string> callback)
    79.         {
    80.                 // Mute microphone
    81.              
    82.                     if (microphoneSource != null)
    83.                         microphoneSource.mute = true;
    84.                 // Stop recording
    85.                 audioInput?.Dispose();
    86.                 cameraInput?.Dispose();
    87.                     Debug.Log("still ok");
    88.                 var path = await recorder.FinishWriting();
    89.             Debug.Log("never go here when there is the error");
    90.             // Playback recording
    91.             Debug.Log($"Saved recording to: {path}");
    92.                 StartCoroutine(DeleteMic());
    93.                 callback(path);
    94.          
    95.         }
    96.         public IEnumerator DeleteMic()
    97.         {
    98.                     yield return new WaitForSeconds(0.2f);
    99.             microphoneSource.Stop();
    100.             yield return new WaitForSeconds(0.1f);
    101.             Destroy(microphoneSource);
    102.         }
    103.     }
    104.  
    105.  
    106.  
    Can you help me with this?
     
    Last edited: May 21, 2021
  45. Viniterra

    Viniterra

    Joined:
    Dec 4, 2014
    Posts:
    151
    Hi, I am having an issue with the cast area of the buttons on my UI when recording a video with non 16:9 aspect ratio. For example, with 18:9, 20:9 aspect ratio, like some mobile devices have.

    The basic setup to reproduce the issue is to use a main camera (perspective depth -1) and a UI camera (orthographic depth 1, clear flags: don't clear).

    The UI canvas with the buttons is set to screen space - camera, with the UI camera on it. The canvas scaler is set to scale with screen size, with the base resolution set as 1280x720, and the Match does not seem to have any influence (it is currently used on 0.5)

    Put both cameras on the CameraInput and use a MP4Recorder. When not recording, the cast area of all the components in the UI works perfectly. When recording, it seems to be all messed.

    Even when using only the UI camera on the CameraInput the problem persists. By removing it, the problem is gone, but the UI is not recorded obviously.

    I am sending the code I use, with the setup functions for video resolution I have tested. Both of the functions lead to the same problem. It can be tested on editor, using both NatCorder and NatShare packages.

    Is it something that is messing with the ortographic camera when used on the CameraInput, or am I doing something wrong here?

    Any help is appreciated.

    Code (CSharp):
    1. using NatSuite.Recorders;
    2. using NatSuite.Recorders.Clocks;
    3. using NatSuite.Recorders.Inputs;
    4. using NatSuite.Sharing;
    5. using UnityEngine;
    6.  
    7. public class VideoManager : MonoBehaviour
    8. {
    9.     public int refVideoMax = 1280;
    10.     public int refVideoMin = 720;
    11.     //[HideInInspector]
    12.     public int finalWidth, finalHeight;
    13.     public Camera[] cameras;
    14.  
    15.     private IMediaRecorder recorder;
    16.     private CameraInput cameraInput;
    17.  
    18.     void Start()
    19.     {
    20.         SetCurrentResolution();
    21.         //SetCurrentResolutionAlt();
    22.     }
    23.  
    24.     private void SetCurrentResolution()
    25.     {
    26.         if (Screen.width > Screen.height)
    27.         {
    28.             finalWidth = refVideoMax;
    29.             finalHeight = (int)((float)Screen.height / Screen.width * refVideoMax);
    30.             finalHeight = finalHeight >> 1 << 1;
    31.         }
    32.         else if (Screen.height > Screen.width)
    33.         {
    34.             finalHeight = refVideoMax;
    35.             finalWidth = (int)((float)Screen.width / Screen.height * refVideoMax);
    36.             finalWidth = finalWidth >> 1 << 1;
    37.         }
    38.     }
    39.  
    40.     private void SetCurrentResolutionAlt()
    41.     {
    42.         var videoHeight = (int)(refVideoMax / cameras[0].aspect);
    43.         videoHeight = videoHeight >> 1 << 1; // Ensure divisible by 2
    44.         finalWidth = refVideoMin;
    45.         finalHeight = videoHeight;
    46.     }
    47.  
    48.     public void StartRecording()
    49.     {
    50.         // Start recording
    51.         var frameRate = 30;
    52.         var clock = new RealtimeClock();
    53.         recorder = new MP4Recorder(finalWidth, finalHeight, frameRate, 0, 0);
    54.         // Create recording input
    55.         cameraInput = new CameraInput(recorder, clock, cameras);
    56.     }
    57.  
    58.     public async void StopRecording()
    59.     {
    60.         // Stop recording
    61.         cameraInput.Dispose();
    62.         var path = await recorder.FinishWriting();
    63.         // Save on gallery
    64.         var payload = new SavePayload("TEST ALBUM");
    65.         payload.AddMedia(path);
    66.         await payload.Commit();
    67. #if !UNITY_EDITOR
    68.             File.Delete(path);
    69. #endif
    70.     }
    71.  
    72. }
    73.  
     
    Last edited: May 21, 2021
  46. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    I'll try to reproduce this with Xcode and follow up on Discord.
     
  47. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    Your code looks good. Can you reproduce a crash and share a screenshot of the Xcode window when the crash happens? I'd like to see the call stack when the crash happens.
     
  48. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    Hey there. I'm not entirely sure what you mean by "cast area". Are you seeing some weird scaling of your UI elements in the recorded video? If so, it sounds like this bug I discovered with Unity's CanvasScaler.
     
  49. Ikaro88

    Ikaro88

    Joined:
    Jun 6, 2016
    Posts:
    199
    I took this photo, it is enough?



     
  50. Lanre

    Lanre

    Joined:
    Dec 26, 2013
    Posts:
    3,773
    Thanks for sharing these pictures. They don't show the exact cause of the crash, so can you go to the breakpoints tab in the left pane, then add an exception breakpoint that is triggered on all exceptions. Then try to reproduce the crahs; it should have more information.

    Also, when you build from Unity, in Player Settings, make sure that IL2CPP builds in Debug mode, not Release. Then in Build Settings, make sure you run in Xcode as Debug, not Release.
     
unityunity