I followed this link to display a watermark during recording, and it worked. However, I want the watermark not to appear during the recording process but to be visible after the video has been saved. Here is the snippet to display a watermark during recording from the above link
private lateinit var captureRequestBuilder: CaptureRequest.Builder
private var captureSession: CameraCaptureSession? = null
private val captureSessionCallback = object : CameraCaptureSession.StateCallback() {
override fun onConfigured(session: CameraCaptureSession) {
if (cameraDevice == null) return
captureSession = session
captureRequestBuilder.set(CaptureRequest.CONTROL_MODE, CameraMetadata.CONTROL_MODE_AUTO)
session.setRepeatingRequest(captureRequestBuilder.build(), null, null)
btnStartStop.setOnClickListener(::startStopRecording)
btnChangeCamera.setOnClickListener(::changeCamera)
}
override fun onConfigureFailed(session: CameraCaptureSession) = Unit
}
@Suppress("DEPRECATION")
private fun startPreview() {
try {
closePreviewSession()
captureRequestBuilder =
cameraDevice!!.createCaptureRequest(CameraDevice.TEMPLATE_PREVIEW)
val surface = Surface(renderer.cameraSurfaceTexture)
captureRequestBuilder.addTarget(surface) // <-- its possible add another target after this ?
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
val config = SessionConfiguration(
SessionConfiguration.SESSION_REGULAR,
listOf(OutputConfiguration(surface)),
Executors.newSingleThreadExecutor(),
captureSessionCallback
)
cameraDevice?.createCaptureSession(config)
} else {
cameraDevice?.createCaptureSession(
listOf(surface),
captureSessionCallback,
backgroundHandler
)
}
} catch (e: CameraAccessException) {
Log.e(TAG, e.toString())
}
}
My goal is to display two outputs from one camera. With the command I used, I was able to display the camera on a surface. My question is, how can I add a second view placed on top of the first view so that the watermark is not visible during recording? or Are there any other approaches to adding a watermark during video saving?
note: I have tried using ffmpeg to overlay images, but the process is very slow and our users are not comfortable with it.