Giter VIP home page Giter VIP logo

videoslimmer's Introduction

VideoSlimmer

A video converter for Android to compress video using MediaCodec(decode and encode). 一个安卓视频压缩工具,使用了Mediacodec

screenshot1~

Features

  • Using Mediacodec to decode and encode video,support mp4/3gp format
  • High-performance

Dependency

Add this in your build.gradle file

compile 'com.zolad:videoslimmer:1.0.0'

Usage

Call VideoSlimmer.convertVideo and set params

  /**
   * @param srcPath     string, filepath of source file
   * @param destPath    string, ouput filepath
   * @param outputWidth  pixels, output video width
   * @param outputHeight pixels, output video height
   * @param bitrate  int, in bits per second
   * @param listener  the listenr of convert progress
   */
  VideoSlimmer.convertVideo(srcPath, destPath, 200, 360, 200 * 360 * 30, new VideoSlimmer.ProgressListener() {
                        @Override
                        public void onStart() {
                           //convert start

                        }

                        @Override
                        public void onFinish(boolean result) {
                            //convert finish,result(true is success,false is fail)
                        }


                        @Override
                        public void onProgress(float percent) {
                           //percent of progress
                        }
                    });
        

License

Copyright 2018 Zolad

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.

videoslimmer's People

Contributors

zolad avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

videoslimmer's Issues

Proper exception handling needed

Hi there 👋

We are currently facing an issue with your library that we get an IllegalStateException when calling the VideoSlimmer.releaseCoder() method.

    android.media.MediaCodec.native_stop MediaCodec.java
    android.media.MediaCodec.stop MediaCodec.java:2251
    com.zolad.videoslimmer.VideoSlimEncoder.releaseCoder VideoSlimEncoder.java:613
    com.zolad.videoslimmer.VideoSlimEncoder.convertVideo VideoSlimEncoder.java:391
    com.zolad.videoslimmer.VideoSlimTask.doInBackground VideoSlimTask.java:30
    com.zolad.videoslimmer.VideoSlimTask.doInBackground VideoSlimTask.java:11
    android.os.AsyncTask$3.call AsyncTask.java:394
    java.util.concurrent.FutureTask.run FutureTask.java:266
    android.os.AsyncTask$SerialExecutor$1.run AsyncTask.java:305
    java.util.concurrent.ThreadPoolExecutor.runWorker ThreadPoolExecutor.java:1167
    java.util.concurrent.ThreadPoolExecutor$Worker.run ThreadPoolExecutor.java:641
    java.lang.Thread.run Thread.java:923

We found out that this comes up when an encoder was already released when calling stop. See here https://developer.android.com/reference/android/media/MediaCodec?hl=en#stop()

We would suggest to wrap the releaseCoder() method in an exception handling block and catching RuntimeExceptions ( see #8).

private void releaseCoder() {
if (VERBOSE) Log.d(TAG, "releasing encoder objects");
if (mEncoder != null) {
mEncoder.stop();
mEncoder.release();
mEncoder = null;
}
if (mDecoder != null) {
mDecoder.stop();
mDecoder.release();
mDecoder = null;
}
if (mInputSurface != null) {
mInputSurface.release();
mInputSurface = null;
}
if (mMuxer != null) {
mMuxer.stop();
mMuxer.release();
mMuxer = null;
}
}

压缩失效

下载你的代码执行,然后压缩运行不成功!

[HELP] MediaCodec.CryptoInfo AES

Hi,
This is not an issue, I am just trying to figure out how to set AES encryption for this awesome project?
Some sample lines of code would help us a lot.

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.