Recording videos with overlay images without using third party library on android

旧巷老猫 提交于 2019-12-10 11:14:43

问题


Iam trying to develop an android based camera application which requires recording videos on live camera preview with overlay images. Is there any way on android using which we can record videos with overlay images without using any third party library .

Currently iam using an additional Surfaceview as an overlay on live camera screen and MediaRecorder class for recording videos.Here is my code :

    recorder = new MediaRecorder();
    recorder.setCamera(mCam);
    String filename="";
    String path="";
    path=  Environment.getExternalStorageDirectory().getAbsolutePath().toString();
    Date date=new Date();
    filename="/rec"+date.toString().replace(" ", "_").replace(":", "_")+".mp4";

    File file=new File(path,filename);
    recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
    recorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
    recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    recorder.setVideoSize(mPreviewSize.width, mPreviewSize.height);
    recorder.setVideoEncodingBitRate(10000000);
    recorder.setVideoFrameRate(30);
    try {

          recorder.prepare();

    } catch (IllegalStateException e) {
        releaseMediaRecorder();
        return false;
    } catch (IOException e) {
        releaseMediaRecorder();
        return false;
    }

The above code crashes the application during the start of recording process. Is there any other way in OpenGL ES 2.0 apart from MediaRecorder for recording videos with overlay.

Please advice.

来源:https://stackoverflow.com/questions/41036805/recording-videos-with-overlay-images-without-using-third-party-library-on-androi

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!