Preview frame scale & encoder to h264 using native libraries
override fun onPreviewFrame(data: ByteArray, camera: Camera) {
val rotated = yuvUtils.nV21Rotate(
data,
widthPreview,
heightPreview,
Key.ROTATE_90,
true
)
val rotatedNScaled = yuvUtils.nV21Scale(
rotated,
heightPreview,
widthPreview,
widthOut,
heightOut,
Key.SCALE_MODE_LINEAR,
)
h264Encoder.nV21ToH264(rotatedNScaled) { h264Frame ->
// process h264Frame
}
}
This example record a video h264 and save in
storage/emulated/0/Download/sample.h264
To reproduce this video you can use VLC for Android
- configure your local NDK, HOST_TAG and TOOLCHAIN in build_x264.sh script
export NDK=/home/dani/Android/Sdk/ndk-bundle
export HOST_TAG=linux-x86_64
export TOOLCHAIN=$NDK/toolchains/llvm/prebuilt/$HOST_TAG
- execute build_x264.sh - This script clone x264 repository and build different ABIs for android
# ./build_x264.sh
- Coming soon..
This project is based in: sszhangpengfei encoder and doggycoder AndroidLibyuv