DJI-Mobile-SDK-Tutorials / Android-VideoStreamDecodingSample

This sample project demonstrates how to use FFmpeg for video frame parsing and to use MediaCodec for hardware decoding on DJI Products.
MIT License
170 stars 81 forks source link

Record video #16

Open tuanbipa opened 7 years ago

tuanbipa commented 7 years ago

I use FFmpegFrameRecorder to record video from byte[] yuvFrame , but it seems that delayed

        byte[] bytes = new byte[yuvFrame.length];
        System.arraycopy(y, 0, bytes, 0, y.length);
        for (int i = 0; i < u.length; i++) {
            bytes[y.length + (i * 2)] = nv[i];
            bytes[y.length + (i * 2) + 1] = nu[i];
        }
        opencv_core.IplImage yuvImage1 = opencv_core.IplImage.create(width, height * 3 / 2, IPL_DEPTH_8U, 1);
                yuvImage1.getByteBuffer().put(bytes);
                opencv_core.IplImage bgrImage = opencv_core.IplImage.create(width, height, IPL_DEPTH_8U, 3);
                cvCvtColor(yuvImage1, bgrImage, CV_YUV2BGR_NV21);
                Bitmap modifiedBitmap = IplImageToBitmap(bgrImage);
                org.bytedeco.javacv.AndroidFrameConverter converter = new AndroidFrameConverter();
                Frame modifiedFrame = converter.convert(modifiedBitmap);
                recorder.record(modifiedFrame);

what is solution for recording?

oliverou commented 6 years ago

Hi @tubipham, we help to fix some bugs in the sample, please get the latest code and check if the issues still exist.