How To Import Volumetric Video Container Into Unity

Volumetric Video Container

Let’s first begin by talking about volumetric video frames. Each frame of a volumetric video sequence is more different than traditional video frames. As we mentioned before, generally, each frame contains one reconstructed obj file, one jpg file band, one mtl file. The file sizes for 3D models can often be very large and when the number of scenes increases, most of the time, the following may happen:

  • File management for each frame gets confusing
  • Memory needs increases
  • Selecting a specific frame is extremely difficult
  • Takes a hit on the performance

Solution:

Using a combination of compressed .obj files and a wrapper we can implement a buffer for volumetric video streams which we can manage the frames. This tutorial will be a brief guide to understand how to import volumetric video container into Unity.

Implementation Details:

Getting Frame List From Container

To start warming up, here is a simple definition of a BinaryReader. Binary Reader is the class for C# reading primitive data types as binary values in a specific encoding. As we say, this specific encoding should not be considered as regular streams that store arbitrary data. To restore data, we access it as we stored it, using the same data types in the same order. Now let’s get down to business. In the following figure, there is a bird’s eye view of the structure of the frame list inside the volumetric video container:

Volumetric Video Player Frame List

The first thing we’ll do is to create a binary reader and write our basic frameList loop. But be careful, boost::serialization expects to take a 40-byte memory space by default at the beginning of the archive. So we utilize the first 40 bytes of the stream. The next 64 bytes correspond to the number of frames. The code is just for demo purposes. Instead of reading all parts, the same part can be reduced to hold some of the blocks wrapped in the container.

Read Frame List From Volumetric Video Container

Decode Mesh With Draco

Even if it’s true that Unity developing support for 3D applications, but there is limited support for importing 3D Objects at run time fluently. We use Draco to decode frames from the container. Draco is an open-source library for compressing and decompressing 3D geometric meshes and point clouds. It’s aimed at improving 3D graphics storage. Here we read meshes from the container in 64-byte chunks and send them to the function
ConvertDracoMeshToUnity(). The structure stays as the same.

Decode Mesh From Volumetric Video Container

Put Frames Into The Buffer

Volumetric Video Frames

With the above code, our container is almost ready to import. However, imagine that you have thousands of frames. As all these scenes begin to load, your workspace will start to fill unnecessarily or if you want to fast forward the video, and if the frame there is not loaded, you have to wait until it loads.  We use a fixed-size queue to overcome the problem. When a new frame is imported from the container, we push forward the head pointer and when the frame is consumed, the tail pointer pushes forward. If we reach the end of the buffer, the pointers simply wrap around to the beginning. When the buffer is full, we do not import any frame until any frame is displayed and there is free space in the buffer. We’re not going to dive into the details of implementing the buffer here. After import the volumetric video container, this part can refactor for your specific purpose.

Consequently

In this post, we covered how to import Volumetric Video Container into Unity. It should not be forgotten that the container makes it very easy to move frames from one disc to another or upload/download them to/from a server. In addition, there is a difference in performance between loading a frame directly into Unity and loading it in a compressed version. We import frames really quick so we do not take a hit on performance with Spaceport Container.

The next part is How To Play Spaceport Volumetric Live Video In Unity.

Hope you enjoyed the blog post. If you have any questions please do not hesitate to contact us.

hello@spaceport.tv