CRI Sofdec(Unreal Engine) v1
Introduction 01 Simple playback of Sofdec movies (Mana Player)

In this chapter, you will learn how to simply play a Sofdec movie.

Introduction

For basic knowledge about CRI's Unreal Engine plugin and how to install the Unreal Engine plugin, please refer to the following.

How to encode Sofdec movies

Sofdec is a multi-platform compatible video playback system that provides high quality image and sound.
CRIWARE SDK for Unreal Engine brings Sofdec functionality to your Unreal Engine projects.
Sofdec handles dedicated movie data (Sofdec movies). The CRIWARE SDK for Unreal Engine includes a tool called "Sofdec Encoding Wizard" for encoding Sofdec movies. This tool is located in the following folder:

/cri/tools/Sofdec2/

When encoding your Sofdec movie with the Sofdec Encoding Wizard, choose the following settings:

  • Platform: Standard
  • Video Codec: Sofdec.Prime or h.264 or vp9

Creating, placing and playing movie textures

Sofdec allows you to place and draw videos as textures in game scenes. In addition, by using a dedicated API, you can perform flexible control such as seeking and linked playback.
First, we will explain the simplest method, which is to simply attach a movie texture to a Static Mesh in the level and play it.
The specific steps are as follows:

(1) Importing Sofdec files to create ManaMovie assets

On Windows, drag and drop the Sofdec file from File Explorer into the Content Browser.

This will import the Sofdec file as a ManaMovie asset.
"Mana" refers to the name of the most basic core runtime module in the Sofdec system. Sofdec is a term that refers to the entire system including the encoding tool, and Mana is a term that refers to the runtime library included in Sofdec.


From Add Content, select "Sofdec" -> "Mana Player".


Check “Video output ManaTexture asset” and click “OK”.
This will also create a "Mana Texture" at the same time.

Double-click the "Mana Player" you created in the Content Browser.
Check "Play on Open" in the window that appears.
Additionally, select the texture to use when displaying the Sofdec movie in "Mana Texture".


Next, double-click "Mana Texture". In the window that appears, select the texture for displaying the Sofdec movie in "Movie Source".

Right-click on the generated texture and click "Create Material" from the menu.
Note
Create a material with the “Movie Source” of the “Mana Texture” set as above.


You will be prompted to select a material type, as shown below.


Materials that use "component textures" use each color component (YUV(A)) of the movie as the source for the material.
The YUV to RGB conversion is done within the material, which is what we recommend for performance.

Materials that use "Render to Texture" use textures (RGB) that are pre-rendered offscreen from YUV to RGB.
Specifying this option will automatically enable "Render to Texture" on the ManaTexture and is recommended when RGBA textures are required.

In the steps above, we have created the following three types of assets:

(a) ManaMovie Asset: An asset that holds the path and attribute information of a Sofdec file. It does not contain the Sofdec movie data itself.
(b) ManaPlayer Asset: An asset that controls the playback of Sofdec movies.
(c) ManaTexture Asset: Texture for displaying Sofdec movies
(d) Materials: Materials written to render the Sofdec movie.

(2) Attach a movie to a StaticMesh placed in the level and play it.

Next, prepare a StaticMesh to which the ManaTexture asset will be attached. In this example, we will use a Plane.


Set it in a visible position with a 16:9 ratio.
(The position is just a reference. Any position is fine as long as you can see the video on the screen.)

  • Position: (-300.0, 20.0, 180.0)
  • Rotation: (810.0, 360.0, 90.0)
  • Scale: (1.777, 1.0, 1.0)

In the Details panel, select the material for the Sofdec movie in "Materials>Element 0".


Next, open “Level Blueprint”.


Add the variables as follows:

  • ManaPlayer (see ManaPlayer Object): Owns the Mana Player that plays the movie.


Next, create a Blueprint graph that will start playing when the game starts.

Create it as shown in the figure below.
For “Set Texture” “In Mana Texture”, select the texture to be used to display the Sofdec movie.


Next, add "Open Movie Source" and for "In Mana Movie" select the "ManaMovie Asset" of the Sofdec file you want to play.


Now compile it once.


Next, select "Mana Player" to open the details panel.
For the "Default Value" "Mana Player", select the asset that controls the playback of the Sofdec movie.
Compile again and save.

Stopping a movie and playing it from the beginning

Sofdec allows you to stop videos and play them from the beginning.
Let's create a Blueprint that will stop and play from the beginning by pressing P on the keyboard.
Place it in the level blueprint as shown below.


Note
Use the "Close" node to stop the video, and the "Open Movie Source" node to play the video.

When playing videos, the ManaPlayer's "Play" node can be omitted.
In that case, double-click "ManaPlayer" in the Content Browser and check "Play on Open."

Pause and resume movie playback

Sofdec allows you to pause videos and resume playback from where you left off.
Press P on the keyboard to pause and resume playing.
Place it in the level blueprint as shown below.


Note
To pause the video, press "Pause" node, and to continue playing the video, use "Play" node directly.

Movie switching (advanced)

Here we will create a function to switch between videos with two or more resolutions.
Please add the following variables. After adding the variables, please compile once.

MovieList (array of ManaMovie object references): A list of "Movie Sources" to switch between.
Index (Integer): The index of the currently playing list.

For the MovieList variable, click the "+" next to "Movie List" in "Default Values" to add an element.
(In the image, "Movie Source" for "sample1" and "sample2" are added.)

The blueprint is as follows:


"Update Index" does the following:


The value of "Index" is added by 1, and if it is outside the range of the list, it is set to 0.