Giter VIP home page Giter VIP logo

androidffmpeg's Introduction

推流 所在项目 Streaming

推流

左边是推流端,右边是播放端, 由于gif图片过大,如果加载不出来,请查看art/streaming.gif

感谢

支持如下功能:

  • Android mini API 16.
  • H.264/AAC 硬编.
  • H.264/AAC 软编.
  • 前后摄像头切换.

编译

clone libx264extra目录,执行 sh tools/compile-x264.sh all 生成libx264.a静态库 导入Streaming到Android Studio

使用方式:

encoder = new Encoder.Builder()
				// 是否使用软编
                .setSoftEncoder(Encoder.SOFT_ENCODE)
                // 设置CameraView
                .setCameraView(mCameraView)
                .build();

释放资源 调用代码如下:

encoder.stop();



FFmpeg Library for Android
Building
export ANDROID_NDK=you_ndk_path

因为arm64和x86,x86-64使用了yasm,所以需要安装yasm,由于我使用的是mac,所以使用brew安装,brew install yasm,brew安装文档brew

然后在终端运行

./build-android.sh

会去下载ffmpeg和x264的源码,编译完成之后会在tools目录下的ffmpeg-build下生成对应的libffmpeg.so,编译完成之后把项目导入Android Studio就可以了.

使用

压缩

压缩

FFmpeg ffmpeg = FFmpeg.getInstance();
ffmpeg.setInputDataSource("you input path");
ffmpeg.setOutputDataSource("you output path");
//视频的宽
int videoWidth = ffmpeg.getVideoWidth();
//视频的高
int videoHeight = ffmpeg.getVideoHeight();
//视频的角度,90,180,270,360
doule roation = ffmpeg.getRotation();
int result = ffmpeg.setCompress(需要缩放的宽,需要缩放的高);
ffmpeg.release();
//result >= 0 success
if (result < 0) {
    //error
}

裁剪

下面是裁剪的效果图

FFmpeg ffmpeg = FFmpeg.getInstance();
ffmpeg.setInputDataSource("you input path");
ffmpeg.setOutputDataSource("you outpu path");
int result = ffmpeg.crop(x, y, width, height);
ffmpeg.release();
// result >= 0 success
if (result < 0) {
    //error
}

播放

采用FFmpeg + SDL2来进行解码和播放

note 目前还没有做快进和暂停操作,还有一些细节操作需要调整,不建议用在项目中

播放状态

About me:

wlanjie,任职于teambition Android工程师 联系方式:qq:153920981

androidffmpeg's People

Contributors

wlanjie avatar x13945 avatar

Watchers

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