i am using MediaMuxer to Record a view as MP4 video file. i successfully implemented this https://github.com/rogererill/LottieRecorderTest. but after that when i was implemetation UI/UX i place Progress Loading View animated. but It got Stuck until this videoencoder processs finished.
i also tried with thread() but app got crashed without any error. can you guys help me in this?
snippet code below where i got error in app:
fun start() {
object : Thread() {
override fun run() {
super.run()
while (isRecording()) {
recorder.nextFrame(frameCreator.generateFrame())
}
recorder.end()
listener()
}
}.start()
}
fun nextFrame(currentFrame: Drawable) {
drainEncoder(false)
val canvas = inputSurface.lockCanvas(null)
try {
canvas.drawColor(Color.TRANSPARENT, PorterDuff.Mode.CLEAR) // Here you need to set some kind of background. Could be any color
currentFrame.draw(canvas)
} finally {
inputSurface.unlockCanvasAndPost(canvas)
}
}
fun end() {
drainEncoder(true)
close()
}