【问题标题】:Screen video recording with sound in Android在Android中录制带声音的屏幕视频
【发布时间】:2017-07-20 06:09:08
【问题描述】:

目前我正在开发一个应用程序,该应用程序根据用户交互记录移动屏幕的视频(屏幕录制)。现在我想用音频或声音录制视频。如何实现此功能?

对于视频录制,我使用以下代码:

    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
    mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    mMediaRecorder.setOutputFile(videofilePath);
    mMediaRecorder.setVideoSize(DISPLAY_WIDTH, DISPLAY_HEIGHT);
    mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    mMediaRecorder.setVideoEncodingBitRate(3000000);
    mMediaRecorder.setVideoFrameRate(24);
    mMediaRecorder.prepare();
    mMediaRecorder.start();

【问题讨论】:

    标签: android android-mediaprojection


    【解决方案1】:

    插入此代码

    mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    

    【讨论】:

    • 我添加了相同但它给了我异常:java.lang.IllegalStateException at android.media.MediaRecorder.start(Native Method)
    • 添加权限.RECORD_AUDIO
    • 做同样的事情,只是我在点击按钮后开始录制
    猜你喜欢
    • 1970-01-01
    • 2020-05-30
    • 1970-01-01
    • 2012-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多