Giter VIP home page Giter VIP logo

velvet-video's Introduction

velvet-video

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:

  • create video from still images
  • extract frames from a video
  • extract audio tracks from video files
  • remux video or audio from one container format to another (like mp4 to mkv)
  • transcode (recompress) videos/audios using another codec (like x264 to vp9 or wav to mp3)
  • change video timing (slo-mo, timelapse etc)
  • merge videos or split them to segments
  • apply filters of transformations (before encoding or after decoding)

velvet-video supports dozens of container formats (including mp4, avi, webm, matroska) and codecs (including x264, hevc, vp9, av1).

Travis CI velvet-video on bintray

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:

  • Windows 64 bit
  • Linux 64 bit

Please contact me if you need support for a platform not listed here.

Setup

To use velvet-video add the core dependency plus an appropriate native FFmpeg components package. velvet-video is available on bintray

The choice for native package is:

  • velvet-video-natives:free

    • only royalty-free components are included
    • encoders/decoders: Google VP8 and VP9, AOM av1
    • muxers/demuxers: webm, mkv, ogg
  • velvet-video-natives:full

    • maximum FFmpeg functionality included
    • the included components use patented technologies and may require royalty fees for commercial usage

gradle

dependencies {
    compile 'com.github.zakgof:velvet-video:0.5.0'
    compile 'com.github.zakgof:velvet-video-natives:0.2.6.full'
}

maven

<dependency>
  <groupId>com.github.zakgof</groupId>
  <artifactId>velvet-video</artifactId>
  <version>0.5.0</version>
  <type>pom</type>
</dependency>
<dependency>
  <groupId>com.github.zakgof</groupId>
  <artifactId>velvet-video-natives</artifactId>
  <version>0.2.6.full</version>
  <type>pom</type>
</dependency>

Quick start

Encode images into a video:

    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);
    }      

Obtain images from a video:

	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...
	    }
	}      

More examples

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

Advanced example: video player

See https://github.com/zakgof/velvet-video-player

License

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 later
  • velvet-video-natives:full - under GPL 3.0 or later

velvet-video-natives build scripts are licensed under Apache 2.0

velvet-video's People

Contributors

zakgof avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.