bibigone / k4a.net

K4A.Net - Three-in-one .NET library to work with Azure Kinect devices (also known as Kinect for Azure, K4A, Kinect v4). It includes sensor API, recording and playback API, body tracking API. Samples for WPF, .NET Core and Unity are included.
MIT License
165 stars 39 forks source link

Cannot initialise recording to file "<<filepath>>" #23

Closed viswadeep-sarangi closed 4 years ago

viswadeep-sarangi commented 4 years ago

Thank you for this wrapper. This is splendid!

I'm trying to create a Unity application that can record the captures from the Azure Kinect to a .mkv file in My Documents. I'm using the Recorder class for this. This is the statement where it throws the error:

_recorder = new Recorder(video_output_filename, captureManager._device, captureManager.Configuration);

Here captureManager is the same as that mentioned in the Unity sample project of showing the live Color and Depth stream from the Kinect to a RawTexture in Unity. Looking at the source code, it looks like this is the part where it throws the error:

var res = NativeApi.RecordCreate(pathAsBytes, Sensor.Device.ToHandle(device), config, out var handle); if (res != NativeCallResults.Result.Succeeded || handle == null || handle.IsInvalid) throw new RecordingException($"Cannot initialize recording to file \"{filePath}\".", filePath);

Any help regarding this would really mean a lot. Thank you.

baSSiLL commented 4 years ago

I guess you configured format for color camera to BGRA32. Unfortunately, recording API of Kinect SDK doesn't support recording color in this format. https://docs.microsoft.com/en-us/azure/kinect-dk/record-file-format The most straightforward way is to set color camera format to MJPEG and use System.Windows.Media.Imaging.JpegBitmapDecoder to decompress frames into bitmap images for rendering.

bibigone commented 4 years ago

In version 1.3.5 we added better diagnostic message for this case.