暫無描述

cooperku_kdanmobile 61558fbb65 Merge branch 'gifSuperMovieMaker' 6 年之前
src 3fa85d483e Refactor (fix package typo) 6 年之前
.gitignore 9aef116483 Init: encode media module 6 年之前
build.gradle 9aef116483 Init: encode media module 6 年之前
proguard-rules.pro 9aef116483 Init: encode media module 6 年之前
readme.md 9aef116483 Init: encode media module 6 年之前

readme.md

Media Helper Module

Import

dependencies {
	implementation project(':exportmedia')
}

Init

需要先在Application中init mediaHelper類別才能使用

class App : Application() {
    private val mediaHelper = MediaHelper()
    
	override fun onCreate() {
    	super.onCreate()
        
        mediaHelper.init(this)
	}
}

Audio Editor

剪裁與編輯單音軌時間與音量設定

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) {}
        })

Audio Looper

音軌循環播放設定

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) {}
       	})

Audio Muxer

多音軌合併至單一音軌

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) {}
       	})

Movie Maker

圖片素材與音軌素材編碼成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) {}
        })