Giter VIP home page Giter VIP logo

videoprocessor's Introduction

VideoProcessor

VideoProcessor使用Android原生的MediaCodec实现视频压缩、剪辑、混音、快慢放及倒流的功能(快慢放及倒流支持音频同步变化),在支持MediaCodec的手机上优于使用FFmpeg的方案

  • 体积小 :编译后的aar只有262K,ffmpeg一个so就7、8M,精简之后也差不多还有一半大小
  • 速度快 :在huaweiP9上压缩(1080P 20s 20000k -> 720p 2000k)
lib 耗时
VideoProcessor 13.3s
ffmpeg 172s
ffmpeg(ultrafast) 74s

Gradle

在根目录下的build.gradle里添加maven仓库

allprojects {
		repositories {
			...
			maven { url 'https://www.jitpack.io' }
		}
	}

添加依赖 要求minSdkVersion 21

	dependencies {
	        implementation 'com.github.yellowcath:VideoProcessor:2.4.2'
	}

Changelog

2.4.2

  • 解决arm64的机器上crash的问题
  • 解决某些情况下进度计算错误的问题

2.4.0

  • 兼容Android Q
  • 去掉对support lib的依赖

使用

基本用法如下

    VideoProcessor.processor(context)
            .input(inputVideoPath)
            .output(outputVideoPath)
            .outWidth(outWidth)
            .outHeight(outHeight)
            .process();

VideoProcessor支持多种参数同时处理,完整参数如下

VideoProcessor.processor(context)
       .input(inputVideoPath) // .input(inputVideoUri)
       .output(outputVideoPath)
       //以下参数全部为可选
       .outWidth(width)
       .outHeight(height)
       .startTimeMs(startTimeMs)//用于剪辑视频
       .endTimeMs(endTimeMs)    //用于剪辑视频
       .speed(speed)            //改变视频速率,用于快慢放
       .changeAudioSpeed(changeAudioSpeed) //改变视频速率时,音频是否同步变化
       .bitrate(bitrate)       //输出视频比特率
       .frameRate(frameRate)   //帧率
       .iFrameInterval(iFrameInterval)  //关键帧距,为0时可输出全关键帧视频(部分机器上需为-1)
       .progressListener(listener)      //可输出视频处理进度
       .process();

用户使用时可自行根据需要调用,例如

    //视频两倍速
    VideoProcessor.processor(context)
            .input(inputVideoPath)
            .output(outputVideoPath)
            .speed(2.0f)
            .process();

此外,其它功能

//视频逆序
VideoProcessor.reverseVideo(context, inputVideoPath, outputVideoPath,reverseAudio,listener);
//混音,支持渐入渐出
VideoProcessor.mixAudioTrack(context, inputVideoPath, aacAudioPath, outputVideoPath, startMs, endMs, videoVolume, audioVolume,fadeInSec, fadeOutSec);

Demo

enter image description here

videoprocessor's People

Contributors

pinguo-huangwei avatar yellowcath avatar

Watchers

James Cloos 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.