• Stars
    star
    309
  • Rank 135,306 (Top 3 %)
  • Language
    C++
  • License
    Other
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

HAP video player plugin for Unity

KlakHAP

GIF

KlakHAP is a Unity plugin that allows playing back a video stream encoded with the HAP video codecs.

HAP is a fast and high-quality video codec often used in real-time interactive applications. From the HAP Codecs website:

The HAP codecs are designed to fit the needs of a variety of real-time video workflows where ultra high resolution video is needed such as live event production, set design, 360 video for gaming, projection mapping and creative coding.

KlakHAP provides video frames as textures that can be used in any way on Unity's rendering pipeline — attaching to a material, presenting a full-screen video, animating a UI element, etc. Thanks to the performant design and implementation of the HAP codecs, it can dynamically control the playback time/speed without any hiccups.

System requirements

  • Unity 2019.4 or later

At the moment, KlakHAP only supports 64-bit desktop platforms (Windows, macOS and Linux).

Supported formats

KlakHap supports HAP, HAP Alpha and HAP Q. At the moment HAP Q Alpha is not supported.

KlakHap only supports QuickTime File Format as a container — in other words, it only supports .mov files.

Installation

This package uses the scoped registry feature to resolve package dependencies. Please add the following sections to the manifest file (Packages/manifest.json).

To the scopedRegistries section:

{
  "name": "Keijiro",
  "url": "https://registry.npmjs.com",
  "scopes": [ "jp.keijiro" ]
}

To the dependencies section:

"jp.keijiro.klak.hap": "0.1.20"

After changes, the manifest file should look like below:

{
  "scopedRegistries": [
    {
      "name": "Keijiro",
      "url": "https://registry.npmjs.com",
      "scopes": [ "jp.keijiro" ]
    }
  ],
  "dependencies": {
    "jp.keijiro.klak.hap": "0.1.20",
    ...

How to specify a video file

There are two methods to specify a video file in the plugin:

  • Streaming Assets Mode: Put a video file in the Streaming Assets directory and specify its file name.
  • Local File System Mode: Put a video file somewhere in local drive and specify its full path name.

The former method is recommended when the video file is delivered within the application. The latter method is useful when it needs to play an external content.

Hap Player component

Inspector

File Path and Path Mode are used to specify a source video file. Please see the previous section for details.

Time, Speed and Loop are used to set the initial playback state. You can also use these values to change the current state while playing.

Target Texture is used to store decoded frames into a render texture. Note that it allocates a small amount of GPU time for data transfer.

Target Renderer is used to apply a decoded texture to a specific material property. Although it's the most performant way to render video frames, it needs a few additional steps to be rendered correctly. The following points should be taken into account:

  • UV coordinate incompatibility: Decoded textures will be upside-down due to the difference in the UV coordinates conventions between Unity and HAP. It can be fixed using a vertically-inverted texture scale/offset. You can also use the Klak/Hap shader for this purpose.
  • Color space conversion for HAP Q: YCoCg conversion must be added to a shader when using HAP Q. You can also use the Klak/HAP Q for this purpose.

How to control playback

HapPlayer only provides a few properties/methods for controlling playback. This is an intentional design choice; I don't like to introduce ambiguity by adding common methods like Play, Stop or Pause. You can use the basic properties/methods to control playback instead.

  • To jump to a specific point: Assign a time in seconds to time.
  • To jump to a specific frame: Calculate the time in seconds using frameCount and streamDuration then assign it to time.
  • To reverse the playback direction: Assign a negative value to speed.
  • To pause: Assign 0 to speed.
  • To resume: Assign 1 to speed.
  • To stop: Assign false to enabled.
  • To close the video file: Destroy the HapPlayer component.
  • To open another video file: AddComponent<HapPlayer> then call Open.

Timeline support

GIF

The HAP Player component implements the ITimeControl interface that makes it able to control the playback time from a Control Track in a Timeline. You can easily create a control track with drag-and-dropping a HAP Player game object into the Timeline Editor, or manually create a Control Track/Clip and set the source game object.

More Repositories

1

AICommand

ChatGPT integration with Unity Editor
C#
3,520
star
2

Skinner

Special Effects with Skinned Mesh in Unity
C#
2,963
star
3

KinoGlitch

Video glitch effects for Unity
C#
2,256
star
4

AIShader

ChatGPT-powered shader generator for Unity
C#
1,916
star
5

Klak

Creative coding library for Unity
C#
1,753
star
6

Kino

A collection of custom post processing effects for Unity
C#
1,715
star
7

Voxelman

Unity ECS + C# Job System example
C#
1,504
star
8

Lasp

Low-latency Audio Signal Processing plugin for Unity
C#
1,369
star
9

Pcx

Point cloud importer & renderer for Unity
C#
1,187
star
10

TestbedHDRP

Testbed project for Unity HDRP (High Definition Render Pipeline)
ShaderLab
1,157
star
11

KvantSpray

Object instancing/particle animation system for Unity
C#
1,151
star
12

ShaderGraphExamples

Simple examples of Unity shader graphs.
C#
1,082
star
13

NoiseShader

Noise shader library for Unity
HLSL
1,019
star
14

Pix2Pix

Real-time pix2pix implementation with Unity
C#
1,013
star
15

Reaktion

Audio reactive animation toolkit for Unity
C#
983
star
16

Smrvfx

Skinned mesh sampling with VFX Graph
961
star
17

KinoBloom

Bloom effect for Unity
C#
898
star
18

StableFluids

A straightforward GPU implementation of Jos Stam's "Stable Fluids" on Unity.
C#
880
star
19

FFmpegOut

Video capture plugin for Unity with FFmpeg.
C#
869
star
20

KinoFog

Global fog effect for Unity
C#
842
star
21

PuppetTest

An experiment in procedural dance animation
C#
823
star
22

SdfVfxSamples

Unity VFX Graph samples with SDF (signed distance field)
733
star
23

HdrpVatExample

VAT (Vertex Animation Texture) with Unity Shader Graph and Visual Effect Graph
HLSL
730
star
24

Retro3D

A shader that imitates low grade 3D graphics.
C#
715
star
25

Rsvfx

An example that shows how to connect RealSense depth camera to Unity VFX Graph
C#
699
star
26

KlakNDI

NewTek NDIâ„¢ plugin for Unity
C#
674
star
27

MidiJack

MIDI input plugin for Unity
C#
665
star
28

Swarm

An example of use of compute shaders and procedural instancing.
C#
643
star
29

KinoMotion

Motion blur post-processing effect for Unity
C#
624
star
30

ShaderSketches

KodeLife shader sketches I wrote while commuting
GLSL
600
star
31

KlakSpout

Spout plugin for Unity
C++
557
star
32

Firefly

Unity ECS example for special effects
C#
546
star
33

LaspVfx

Audio reactive Unity VFX with LASP
C#
529
star
34

Akvfx

Azure Kinect plugin for Unity VFX Graph
C#
517
star
35

KvantWig

Non-realistic hair simulation in Unity
C#
515
star
36

UnitySkyboxShaders

Custom skybox shaders
JavaScript
515
star
37

KvantGrass

Animating grass shader for Unity
C#
498
star
38

TimelineParticleControl

An example of controlling particle system from timeline.
C#
496
star
39

MiniEngineAO

SSAO image effect from Microsoft MiniEngine, ported to Unity.
C#
496
star
40

Minis

Minis: MIDI Input for New Input System -- A plugin that adds MIDI input support to Unity's new Input System
C#
486
star
41

SkeletalGeometricEffects

Experiments on geometry shader instancing with skeletal animations
HLSL
472
star
42

UnityMLStableDiffusion

Core ML Stable Diffusion on Unity
C#
469
star
43

BibcamVfx

AR VFX samples with Bibcam (burnt-in barcode metadata camera)
C#
469
star
44

RippleEffect

Water surface ripple effect for Unity
C#
466
star
45

KinoContour

Contour line filter for Unity
C#
462
star
46

Flipbook

Flip book effect example for Unity
C#
456
star
47

CloudSkybox

Skybox shader with volumetric clouds
C#
442
star
48

OscJack

Lightweight C# implementation of OSC server/client
C#
438
star
49

DepthInverseProjection

An example showing how to inverse-project depth samples into the view/world space in Unity.
ShaderLab
431
star
50

HandPoseBarracuda

Hand and finger tracking solution (MediaPipe Hands) for Unity Barracuda
C#
423
star
51

Bibcam

Burnt-in barcode metadata camera
C#
419
star
52

FaceMeshBarracuda

Lightweight facial capture package for Unity
C#
416
star
53

KinoAqua

Watercolor effect for Unity URP/HDRP
C#
410
star
54

Retro3DPipeline

A minimal example of a custom render pipeline with the Retro3D shader.
C#
405
star
55

unity-dither4444

AssetPostProcessor for making high-quality 16-bit color textures in Unity.
C#
402
star
56

SonarFx

Sonar effect for Unity
C#
398
star
57

MidiAnimationTrack

SMF (.mid) file importer for Unity Timeline
C#
388
star
58

SkyboxPlus

Basic skybox extensions for Unity
C#
383
star
59

CosineGradient

Cosine gradient generator for Unity
C#
374
star
60

KinoBokeh

Depth of field effect for Unity
C#
373
star
61

ProceduralMotionTrack

Simple procedural motion with Unity Timeline.
C#
369
star
62

Rcam2

Remote depth camera with iPad Pro with LiDAR sensor
C#
367
star
63

AsyncCaptureTest

Non-blocking screen capture example with asynchronous GPU readback
C#
366
star
64

KvantSwarm

Flowing line renderer for Unity
C#
354
star
65

ShadowDrawer

Shadow matte shader for Unity
ShaderLab
354
star
66

StandardGeometryShader

An example of a geometry shader with Unity's standard lighting model support.
HLSL
349
star
67

KvantStream

A simple GPU particle system for Unity
C#
343
star
68

PerlinNoise

1D/2D/3D Perlin noise function for Unity
C#
340
star
69

GeoVfx

Examples of geographical data visualization with Unity VFX Graph
C#
333
star
70

ComputeMarchingCubes

[Unity] GPU-optimized marching cubes isosurface reconstruction
C#
322
star
71

Metamesh

Unity primitive mesh generator as an asset importer
C#
312
star
72

Ngx

Ngx - Neural network based visual generator and mixer
C#
311
star
73

KvantWall

GPU accelerated object array animator for Unity
C#
311
star
74

VfxGraphTestbed

My testbed for Unity VFX Graph
HLSL
311
star
75

StandardTriplanar

Unity's standard shader with triplanar mapping
ShaderLab
303
star
76

WfcMaze

WFC (Wave Function Collapse) with Unity
C#
295
star
77

RDSystem

Reaction-diffusion system with CustomRenderTexture.
C#
294
star
78

NoiseBall

Mesh deforming shader example (Unity)
C#
291
star
79

Prisma

Pepper's ghost live visuals for VRDG #4
C#
285
star
80

KvantLattice

A GPU accelerated fractal terrain renderer for Unity
C#
281
star
81

ChromaPack

ChromaPack -- A lossy texture compression plugin for Unity.
C#
277
star
82

Cloner

An example of use of procedural instancing.
C#
277
star
83

VideoPlayerEffects

Experimental special effects for VideoPlayer (Unity 5.6 new feature)
C#
275
star
84

NoiseBall2

A small example of procedural modeling with compute shaders.
C#
269
star
85

PostProcessingUtilities

Utility scripts for the post processing stack
C#
263
star
86

Metatex

Metadata-only texture importer for Unity
C#
261
star
87

ContactShadows

Experimental implementation of contact shadows for Unity.
C#
257
star
88

ColorSuite

Multifunctional color adjustment plugin for Unity.
C#
257
star
89

UnityDxrTest

A testbed project for Unity real-time ray tracing features
C#
256
star
90

NNCam

Virtual background with Unity Barracuda
C#
229
star
91

VfxPyro

Fireworks particle effect with Unity VFX Graph
C#
228
star
92

Dkvfx

An example that shows how to use recorded Depthkit footage with Unity VFX Graph
C#
226
star
93

CrossFadingLod

(Unity) Cross-fading LOD shader example
ShaderLab
225
star
94

Boids

Flocking behavior simulation (Unity)
C#
224
star
95

MoonAndEarth

Moon and Earth assets for Unity
C#
223
star
96

KinoBinary

Binary image effect for Unity
C#
220
star
97

UnityAnime4K

Anime4K upscaler for Unity
HLSL
216
star
98

VideolabTest

OP-Z videolab examples
ShaderLab
209
star
99

GVoxelizer

HLSL
206
star
100

KlakSyphon

Syphon plugin for Unity
Objective-C
203
star