cooperku_kdanmobile 61558fbb65 Merge branch 'gifSuperMovieMaker' | před 5 roky | |
---|---|---|
src | před 5 roky | |
.gitignore | před 6 roky | |
build.gradle | před 6 roky | |
proguard-rules.pro | před 6 roky | |
readme.md | před 6 roky |
dependencies {
implementation project(':exportmedia')
}
需要先在Application中init mediaHelper類別才能使用
class App : Application() {
private val mediaHelper = MediaHelper()
override fun onCreate() {
super.onCreate()
mediaHelper.init(this)
}
}
剪裁與編輯單音軌時間與音量設定
val audioEditorBuilder = AudioEditor.Builder(mediaHelper)
audioEditorBuilder.editAudioFile = File()
audioEditorBuilder.startTime = "00:00:12"
audioEditorBuilder.endTime = "00:00:30"
audioEditorBuilder.volume = .3f
val audioEditor = audioEditorBuilder.build()
audioEditor.output(File())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<String> {
override fun onComplete() {}
override fun onSubscribe(d: Disposable) {}
override fun onNext(t: String) {}
override fun onError(e: Throwable) {}
})
音軌循環播放設定
val audioLoopBuilder = AudioLooper.Builder(mediaHelper)
audioLoopBuilder.loopAudioFile = File()
audioLoopBuilder.loopDuration = 20000 //mSec
val audioLooper = audioLoopBuilder.build()
audioLooper.output(File())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<String> {
override fun onComplete() {}
override fun onSubscribe(d: Disposable) {}
override fun onNext(t: String) {}
override fun onError(e: Throwable) {}
})
多音軌合併至單一音軌
val audioMuxBuilder = AudioMuxer.Builder(mediaHelper)
for (file in inputFileArray) {
audioMuxBuilder.addInputSource(file)
}
val audioMuxer = audioMuxBuilder.build()
audioMuxer.output(File())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<String> {
override fun onComplete() {}
override fun onSubscribe(d: Disposable) {}
override fun onNext(t: String) {}
override fun onError(e: Throwable) {}
})
圖片素材與音軌素材編碼成mp4影片
val movieMakerBuilder = MovieMaker.Builder(mediaHelper)
for (bitmap in bitmapArray) {
movieMakerBuilder.addImage(bitmapArray.indexOf(bitmap),bitmap)
}
movieMakerBuilder.audioStartTime = "00:00:12"
movieMakerBuilder.audioFile = File()
val movieMaker = movieMakerBuilder.build()
movieMaker.output(File())
.subscribeOn(Schedulers.newThread())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(object : Observer<String> {
override fun onComplete() {}
override fun onSubscribe(d: Disposable) {}
override fun onNext(t: String) {}
override fun onError(e: Throwable) {}
})