Code Monkey home page Code Monkey logo

videokit-ffmpeg-android's Introduction

Video processing library based on FFmpeg

Main purpose

Main purpose of this library is to allow developers to embed FFmpeg into their application with literally one line of code in gradle.build. Using native code in Java in general and in Android environment especially always related to some problems. Hopefully VideoKit will resolve some of them.

Setup

Basic setup just add following line of code to your gradle.build file:
compile 'com.infullmobile.android:videokit-release:1.1.2'
Also, if you haven't use inFullMobile public maven in your project before, don't forget to add following line to your repositories:
maven { url 'https://maven.infullmobile.com/public' }
That's pretty much all.

Example usage

Module sample is showing usage of VideoKit. Please note, that VideoKit is basically invoking FFmpeg main() with CLI arguments so you will use commands almost like you use standard FFmpeg on Linux or Windows or MacOS.
Well, let me show you some code:

        final VideoKit videoKit = new VideoKit();
        final Command command = videoKit.createCommand()
                .overwriteOutput()
                .inputPath(path)
                .outputPath(path + POSTFIX)
                .customCommand("-ss 1 -t 3")
                .copyVideoCodec()
                .experimentalFlag()
                .build();

Command is basically set of instructions for FFmpeg. Please note, that order in which you adding instructions in CommandBuilder is quite important. Sometimes, when you mess up order, FFmpeg will not recognize command and end up with error. After you've built a command you should execute it: either with execute() or you can pass it to AsyncCommandExecutor.
Please note, that:
command.execute();
will be executed on thread on which it was called, while:
new AsyncCommandExecutor(command, this).execute();
will be executed in background thread and you have to provide implementation of ProcessingListener to get result of processing either in onSuccess (you will get path to processed file here) or onFailure (you will get error code here).

Other functions

VideoKit is also providing logging mechanism for FFmpeg. You can set logging level by calling function:
videoKit.setLogLevel(level)
where level is enum which consists of:

NO_LOG
ERRORS_ONLY
FULL

Specific behavior of flags

As I already have mentioned: FFmpeg is quite sensible to the order of flags. To help out with that to user VideoKit have default behavior for particular flags, namely: input paths, output path and experimental flag.
The order in which VideoKit is laying those flags is following:

  1. Input paths are always going first (doesn't matter in which place of chain you have added particular path)
  2. Output path is always going at the end of command
  3. Experimental flag is always just before output path

Error codes

I've tried to make library as debuggable as it even possible, taking in account that we're working with native code. If you getting failures from VideoKit and log in not really helpfull try to look into docs folder in ffmpeg_return_codes file. In this file you not only have list of possible return codes with which FFMpeg can exit, but also file and number of line of code in which exit was called.
Version of FFmpeg is 3.2.4 and changed sources can be found over here:
Development Kit

License

FFmpeg is licensed under LGPL:
License
This software uses libraries from the FFmpeg project under the LGPLv2.1

videokit-ffmpeg-android's People

Contributors

iljakosynkin avatar kolipass avatar masayukisuda avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

wizx

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.