/android-transcoder

MP4 video transcode on Android device. Pure Java (not LGPL!). Supports API >= 18.

Primary LanguageJavaApache License 2.0Apache-2.0

android-transcoder

Hardware accelerated transcoder for Android, written in pure Java.

Usage

@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    ParcelFileDescriptor parcelFileDescriptor = resolver.openFileDescriptor(data.getData(), "r");
    FileDescriptor fileDescriptor = parcelFileDescriptor.getFileDescriptor();
    MediaTranscoder.Listener listener = new MediaTranscoder.Listener() {
        @Override
        public void onTranscodeProgress(double progress) {
            ...
        }

        @Override
        public void onTranscodeCompleted() {
            startActivity(new Intent(Intent.ACTION_VIEW).setDataAndType(Uri.fromFile(file), "video/mp4"));
            ...
        }

        @Override
        public void onTranscodeFailed(Exception exception) {
            ...
        }
    };
    MediaTranscoder.getInstance().transcodeVideo(fileDescriptor, file.getAbsolutePath(),
            MediaFormatStrategyPresets.createAndroid720pStrategy(), listener); // or createAndroid720pStrategy([your bit rate here])
}

See TranscoderActivity.java in example directory for ready-made transcoder app.

Quick Setup

Gradle

Available from JCenter, which is default repo of gradle script generated by recent android studio.

repositories {
   jcenter()
}
compile 'net.ypresto.androidtranscoder:android-transcoder:0.1.4'

License

Copyright (C) 2014 Yuya Tanaka

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.