浩恩网络
抖音短视频培训联系:【微信:xiaoqizmt | QQ:2777772774 】
文章956 浏览150801

microshow/RxFFmpeg

private void runFFmpegRxJava() {

String text = "ffmpeg -y -i /storage/emulated/0/1/input.mp4 -vf boxblur=25:5 -preset superfast /storage/emulated/0/1/result.mp4";

String[] commands = text.split(" ");

myRxFFmpegSubscriber = new MyRxFFmpegSubscriber(this);

//开始执行FFmpeg命令

RxFFmpegInvoke.getInstance()

.runCommandRxJava(commands)

.subscribe(myRxFFmpegSubscriber);

}

public static class MyRxFFmpegSubscriber extends RxFFmpegSubscriber {

private WeakReference mWeakReference;

public MyRxFFmpegSubscriber(HomeFragment homeFragment) {

mWeakReference = new WeakReference<>(homeFragment);

}

@Override

public void onFinish() {

final HomeFragment mHomeFragment = mWeakReference.get();

if (mHomeFragment != null) {

mHomeFragment.cancelProgressDialog("处理成功");

}

}

@Override

public void onProgress(int progress, long progressTime) {

final HomeFragment mHomeFragment = mWeakReference.get();

if (mHomeFragment != null) {

//progressTime 可以在结合视频总时长去计算合适的进度值

mHomeFragment.setProgressDialog(progress, progressTime);

}

}

@Override

public void onCancel() {

final HomeFragment mHomeFragment = mWeakReference.get();

if (mHomeFragment != null) {

mHomeFragment.cancelProgressDialog("已取消");

}

}

@Override

public void onError(String message) {

final HomeFragment mHomeFragment = mWeakReference.get();

if (mHomeFragment != null) {

mHomeFragment.cancelProgressDialog("出错了 onError:" + message);

}

}

}

@Override

public void onDestroy() {

super.onDestroy();

if (myRxFFmpegSubscriber != null) {

myRxFFmpegSubscriber.dispose();

}

}

发表评论

访问本站需知:

本站内容以及图片均来源于互联网,本着免费分享学习的目的,如果涉嫌侵权等问题请联系站长删除,本站为个人团队培训服务,并非官方运营站点,跟官方无任何关系,感谢官方提供平台!