【问题标题】:How to record mute video in android programatically如何以编程方式在android中录制静音视频
【发布时间】:2014-02-09 10:06:01
【问题描述】:

我正在尝试使用 MediaRecorder 在 android 中创建视频录像机,用户可以选择录制静音视频,即录制没有音频的视频。我检查了是否有任何选项可以在 android 中录制静音视频,经过大量搜索后我没有找到任何完美的方法来做到这一点,我也尝试了以下 AudioManager 方法:

audioManager.setStreamMute(AudioManager.STREAM_SYSTEM, true);

audioManager.setMicrophoneMute(true);

audioManager.setStreamVolume(AudioManager.STREAM_SYSTEM, 0,   AudioManager.FLAG_REMOVE_SOUND_AND_VIBRATE)

但它们都不适合我。

谁能帮我解决这个问题。

谢谢!!!

【问题讨论】:

    标签: android mediarecorder android-mediarecorder video-recording


    【解决方案1】:

    我是这样处理的。

      boolean settingsSound = sharedPrefSettings.getBoolean("settingsSound", true);
    
      if (!settingsSound) {   
          mediarecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); 
          mediarecorder.setVideoFrameRate(profile.videoFrameRate); 
          mediarecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight); 
          mediarecorder.setVideoEncodingBitRate(profile.videoBitRate); 
          mediarecorder.setVideoEncoder(profile.videoCodec); 
      } else{ 
          mediarecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT); 
          mediarecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); 
          mediarecorder.setVideoFrameRate(profile.videoFrameRate); 
          mediarecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight); 
          mediarecorder.setVideoEncodingBitRate(profile.videoBitRate); 
          mediarecorder.setAudioEncodingBitRate(profile.audioBitRate); 
          mediarecorder.setAudioChannels(profile.audioChannels); 
          mediarecorder.setAudioSamplingRate(profile.audioSampleRate); 
          mediarecorder.setVideoEncoder(profile.videoCodec); 
          mediarecorder.setAudioEncoder(profile.audioCodec); 
      }
    

    只是不要设置音频源。我得到这样的个人资料

    profile = CamcorderProfile.get(CamcorderProfile.QUALITY_1080P);
    

    由于没有声音无法设置CamcorderProfile,您需要逐个设置每个值。

    希望这会有所帮助:)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-12-03
      • 2014-07-11
      • 1970-01-01
      • 2017-07-06
      • 1970-01-01
      • 1970-01-01
      • 2014-05-20
      • 2023-03-20
      相关资源
      最近更新 更多