Back to mods
VideoLib project artwork

Modrinth · Minecraft mod

VideoLib

A library enabling video playback in Minecraft

Choose a version Pick your version below, then grab the matching file.

Quick answer

Which VideoLib release matches 1.18.2?

Updated 4 years ago
Best match for your filters 0.1.0
Game version 1.18.2
Loader Fabric

VideoLib 0.1.0 targets 1.18.2 with Fabric. It must be installed on the client. Do not install it on the dedicated server. No extra mods listed for this file.

Where it goes

Is VideoLib required on the client, server, or both?

It must be installed on the client. Do not install it on the dedicated server.

Client Required
Dedicated server Not supported
Loader for this release Fabric
Required install it here Optional supported, not mandatory Not supported do not install here Source doesn’t say do not assume

This file is marked client-only.

What else does VideoLib 0.1.0 need?

0.1.0 on 1.18.2. Every mod below is checked against that same setup.

No extra mods listed for this file

This file does not list any required mods. Do not add a library just because a different file uses it.

This file does not list any required or optional mods.

Before you install it

Add VideoLib without breaking your instance.

Built for VideoLib 0.1.0 on 1.18.2. Pick another file and the loader, install side or required mods may change.

  1. 01

    Stick to this file

    Use 0.1.0. It targets 1.18.2 with Fabric; another release may have different loader, side or dependency requirements.

  2. 02

    Bring the mods it needs

    This file does not list any required mods. Do not add a library just because a different file uses it.

  3. 03

    Put it on the correct side

    It must be installed on the client. Do not install it on the dedicated server.

  4. 04

    Pick the file you checked

    Use the “Get this file” button beside 0.1.0. It opens that exact file at the source.

About this project

What does VideoLib add?

This library is for Minecraft 1.18.2. Ports for other versions will come in time. If you wish to port it yourself, pull requests are welcome!

VideoLib

Ever since its inception, Minecraft's engine has been... interesting, to say the least. It seems to lack many standard features such as GPU mesh caching and, in this case, simple video playback. This mod aims to remedy this, providing a clean API for mod-makers to use pre-rendered video playback in their mods.

Note: this mod provides no functionality on its own. It is simply a library for other mods to make use of.

Setup

An installation guide will be provided once the maven dependencies are setup. It's worth noting that the default implementation requires VLC Media Player to be installed on the user's system.

Usage

To use VideoLib, you must get a reference to a VideoManager. This video manager is the basis for all interactions with the library, and is vital to the functionality of the mod:

VideoManager videoManager = VideoLib.getInstance().getVideoManager();

The VideoManager can be used to create multiple VideoPlayers. Due to the performance overhead of video playback, each video player is registered with the video manager using a unique ID. Only the video manager can create new VideoPlayer instances.

 VideoPlayer videoPlayer = videoManager.getOrCreate(new Identifier("mymod", "my_video_player"));

Each VideoPlayer has a getTexture() function, which returns a Minecraft texture identifier that can be used in an entity renderer (or anywhere else that non-atlas textures are used). This texture is automatically updated for every frame of the video, and it can be applied like any other texture.

Identifier texture = videoPlayer.getTexture();
VertexConsumer consumer = vertexConsumers.getBuffer(RenderLayer.getEntityCutout(texture));

// render geometry however you want

Video Handles

There are a number of ways to tell a video player to begin playing, but most of them revolve around the VideoHandle. A video handle is essentially a pointer to a video file stored in an external location, whether it be on the local disk or somewhere on the internet. To create a VideoHandle, you need a VideoHandleFactory. This can be obtained from the VideoManager.

It's important to note that not all video handles will work with all video managers. Make sure you're only using video handles provided by the video manager's factory. (Most API functions already do this).

VideoHandleFactory factory = videoManager.getVideoHandleFactory();

The VideoHandleFactory provides two primary functions: getVideoHandle(Identifier) and getVideoHandle(URL).

  • getVideoHandle(Identifier) expects the resource identifier of a video file from any mod. This file must be in the videos folder of your resourcepack. (ex: mymod:videos/myvideo.mp4)

  • getVideoHandle(URL) expects the URL where a video can be found. This may be over the internet or on the local filesystem. (ex: http://mywebsite.com/myvideo.mp4). This file must be directly accessible via a GET request. Google Drive links and other services where the user must navigate a download page are not allowed.

The video handle can then be passed to the video player for playback.

VideoHandle idHandle = factory.getVideoHandle(new Identifier("mymod", "videos/myvideo.mp4"))
VideoHandle urlHandle = factory.getVideoHandle(new URL("http://mywebsite.com/myvideo.mp4"));


videoPlayer.getMediaInterface().play(idHandle);

Media players also provide overloads of play() that take identifiers and urls directly. These are simply shortcuts for creating video handles and playing them.

Playback Control

Video players provide a set of interfaces allowing for finer control of media playback: MediaInterface, ControlsInterface, and CodecInterface. These can be accessed as follows:

MediaInterface mediaInterface = videoPlayer.getMediaInterface();
ControlsInterface controlsInterface = videoPlayer.getControlsInterface();
CodecInterface codecInterface = videoPlayer.getCodecInterface();

These three interfaces provide a multitude of essential functions, such as pause, play, and setTime. Details on these API features can be found in the javadoc.

Events

VideoLib provides a number of callbacks that trigger at certain events during video playback. Regardless of where they're triggered in native code, all event listeners are called on the Minecraft client thread.

VideoEvents events = videoPlayer.getEvents();
events.onBuffering(e -> {
    LogManager.getLogger().info("Buffering!");
})

Like, the playback interfaces, event functions are detailed in the javadoc.

A Note on Licenses

The default implementation of VideoLib relies on VLCJ, which is licensed under the GNU GPL. This means that everything in the vlc package is licensed under the GPL. The rest of the repo, however, provided it doesn't directly depend on the vlc package, is licensed under the MIT license. Additionally, the vlc package is not considered a part of the public API, and it may be moved to a separate Gradle project at a later time.

Planned Features

  • Audio control.

    • Right now, VLC directly pipes audio to your operating system, bypassing Minecraft all-together. I intend to change this.
  • Standardize supported formats.

  • Warn users when VideoLib fails to initialize (usually due to missing natives).

  • Rendering utility functions.

Project description from Modrinth.

Pick your setup

VideoLib by Minecraft version and loader

Choose the version and loader you play, then open the matching release.

1 available setups

Check the dependencies, then try the file in a copied instance before changing a world you care about.

Recent files

VideoLib versions and loaders

1 of 1 releases match

Looking for an older file? The official Modrinth project page is in Resources.