Java library for encoding/decoding/muxing/demuxing video and audio. The API is high level, so the library users do not need to dive deep into details of video/audio encoding technology.
In particular, with velvet-video it's easy to:
velvet-video supports dozens of container formats (including mp4, avi, webm, matroska) and codecs (including x264, hevc, vp9, av1).
velvet-video embeds FFmpeg libraries under the hood, so it works at native speed and uses all FFmpeg's hardware optimization. Extracting and loading native libs is fully covered by velvet-video.
Supported platforms:
Please contact me if you need support for a platform not listed here.
To use velvet-video
add the core dependency plus an appropriate native FFmpeg components package. velvet-video
is available on Maven Central
The choice for native package is:
velvet-video-natives:free
velvet-video-natives:full
dependencies {
compile 'com.github.zakgof:velvet-video:0.5.2'
compile 'com.github.zakgof:velvet-video-natives:0.2.8.full'
}
<dependency>
<groupId>com.github.zakgof</groupId>
<artifactId>velvet-video</artifactId>
<version>0.5.2</version>
<type>pom</type>
</dependency>
<dependency>
<groupId>com.github.zakgof</groupId>
<artifactId>velvet-video-natives</artifactId>
<version>0.2.8.full</version>
<type>pom</type>
</dependency>
IVelvetVideoLib lib = VelvetVideoLib().getInstance();
try (IMuxer muxer = lib.muxer("matroska")
.video(lib.videoEncoder("libaom-av1").bitrate(800000))
.build(new File("/some/path/output.mkv"))) {
IEncoderVideoStream videoStream = muxer.videoStream(0);
videoStream.encode(image1);
videoStream.encode(image2);
videoStream.encode(image3);
}
IVelvetVideoLib lib = VelvetVideoLib().getInstance();
try (IDemuxer demuxer = lib.demuxer(new File("/some/path/example.mp4"))) {
IDecoderVideoStream videoStream = demuxer.videoStream(0);
IFrame videoFrame;
while ((videoFrame = videoStream.nextFrame()) != null) {
BufferedImage image = videoFrame.image();
// Use image as needed...
}
}
https://github.com/zakgof/velvet-video/tree/master/src/example/java/com/zakgof/velvetvideo/example
Example | Description |
---|---|
ImagesToVideoAndBack | Extract frame images from a video + compose a video from images |
TranscodeVideoWithTimingEffects | Transcode a video using another codec and applying slomo |
RemuxVideo | Repackage a video into another container format without transcoding |
ScreenCaptureToVideo | Capture the whole desktop to video |
AudioPlayback | Play a compressed audio file |
ExtractAndTranscodeAudio | Fetch audio tracks from a video file and save them as mp3 files |
See https://github.com/zakgof/velvet-video-player
velvet-video-core
is dual-licensed under Apache 2.0 and GPL 3.0 (or any later version).
To comply with the FFMpeg components license present bundles into velvet-video-natives
, choose Apache-2.0
when using with velvet-video-natives:free
or GPL-3.0-or-later
when using with velvet-video-natives:full
SPDX-License-Identifier: Apache-2.0 OR GPL-3.0-or-later
velvet-video-natives
binaries on jcenter are licensed:
velvet-video-natives:free
- under LGPL 3.0 or latervelvet-video-natives:full
- under GPL 3.0 or latervelvet-video-natives
build scripts are licensed under Apache 2.0