You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello. I am not sure what I am doing wrong here. The below method is what I use to get the bitmap from a custom SurfaceView class:
private fun getSnapshot(): Bitmap? {
val surfaceBitmap = Bitmap.createBitmap(800, 600, Bitmap.Config.ARGB_8888)
val lock = Object()
val success = AtomicBoolean(false)
val thread = HandlerThread("PixelCopyHelper")
thread.start()
val sHandler = Handler(thread.looper)
val listener = PixelCopy.OnPixelCopyFinishedListener { copyResult ->
success.set(copyResult == PixelCopy.SUCCESS)
synchronized (lock) {
lock.notify()
}
}
synchronized (lock) {
PixelCopy.request(video_stream_view.holder.surface, surfaceBitmap, listener, sHandler)
lock.wait()
}
thread.quitSafely()
return if (success.get()) surfaceBitmap else null
}
video_stream_view is a view that receives a live video feed from an RTSP camera. I then use the below piece of code to save the bitmap using the encoder:
val bitmap = getSnapshot()
bitmap?.let {
val m = Matrix()
m.preScale(-1f, -1f)
val dst = Bitmap.createBitmap(it, 0, 0, it.width, it.height, m, false)
dst.density = DisplayMetrics.DENSITY_DEFAULT
if (recordVideo) {
encoder.addFrame(dst)
}
The bitmap extracted from the SurfaceView is upside down so I apply some operations to get it upright. When I reapply the bitmap to the SurfaceView from where I extracted it, it looks just fine:
Hello. I am not sure what I am doing wrong here. The below method is what I use to get the bitmap from a custom SurfaceView class:
video_stream_view
is a view that receives a live video feed from an RTSP camera. I then use the below piece of code to save the bitmap using the encoder:The bitmap extracted from the SurfaceView is upside down so I apply some operations to get it upright. When I reapply the bitmap to the SurfaceView from where I extracted it, it looks just fine:
But the recorded video looks like this:
The text was updated successfully, but these errors were encountered: