I can't process the video loaded by OpenCV for Android into a frame and output the video

I want to make an mp4 file read by the following code into a frame with video capture, process the image and then save it as a video, but

I / CCodecBufferChannel: [c2.qti.avc.decoder# 870] cannot render buffer without surface I get the error .

I am in trouble because it is very difficult to solve… Please help me.

           val file = File(
                Environment.getExternalStorageDirectory()
                    .toString() + "/DCIM/Camera/sample.mp4"
            )
            val output = File(
                Environment.getExternalStorageDirectory()
                    .toString() + "/DCIM/Camera/output.mp4"
            )
            val cap = VideoCapture(file.path)
            val frame = Mat()
            val frameSize = Size(1920.0, 1080.0)
            val fps = 30.0
            val writer = VideoWriter(
                output.path,
                VideoWriter.fourcc('m', 'p', '4', 'v'),
                fps,
                frameSize,
                true
            )
            if (cap.isOpened) {
                while (cap.read(frame)) {
                    writer.write(frame)
                }
            }