android.media.MediaRecorder.setVideoEncodingBitRate()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(12.9k)|赞(0)|评价(0)|浏览(249)

本文整理了Java中android.media.MediaRecorder.setVideoEncodingBitRate()方法的一些代码示例,展示了MediaRecorder.setVideoEncodingBitRate()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MediaRecorder.setVideoEncodingBitRate()方法的具体详情如下:
包路径:android.media.MediaRecorder
类名称:MediaRecorder
方法名:setVideoEncodingBitRate

MediaRecorder.setVideoEncodingBitRate介绍

暂无

代码示例

代码示例来源:origin: robolectric/robolectric

@Test
public void testVideoEncodingBitRate() throws Exception {
 assertThat(shadowMediaRecorder.getVideoEncodingBitRate()).isNotEqualTo(320000);
 mediaRecorder.setVideoEncodingBitRate(320000);
 assertThat(shadowMediaRecorder.getVideoEncodingBitRate()).isEqualTo(320000);
}

代码示例来源:origin: commonsguy/cw-omnibus

void start() {
 recorder=new MediaRecorder();
 recorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
 recorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
 recorder.setVideoFrameRate(config.frameRate);
 recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
 recorder.setVideoSize(config.width, config.height);
 recorder.setVideoEncodingBitRate(config.bitRate);
 recorder.setOutputFile(output.getAbsolutePath());
 try {
  recorder.prepare();
  vdisplay=projection.createVirtualDisplay("andcorder",
   config.width, config.height, config.density,
   VIRT_DISPLAY_FLAGS, recorder.getSurface(), null, null);
  beeper.startTone(ToneGenerator.TONE_PROP_ACK);
  recorder.start();
 }
 catch (IOException e) {
  throw new RuntimeException("Exception preparing recorder", e);
 }
}

代码示例来源:origin: florent37/CameraFragment

videoRecorder.setVideoFrameRate(camcorderProfile.videoFrameRate);
videoRecorder.setVideoSize(videoSize.getWidth(), videoSize.getHeight());
videoRecorder.setVideoEncodingBitRate(camcorderProfile.videoBitRate);
videoRecorder.setVideoEncoder(camcorderProfile.videoCodec);

代码示例来源:origin: florent37/CameraFragment

videoRecorder.setVideoFrameRate(camcorderProfile.videoFrameRate);
videoRecorder.setVideoSize(videoSize.getWidth(), videoSize.getHeight());
videoRecorder.setVideoEncodingBitRate(camcorderProfile.videoBitRate);
videoRecorder.setVideoEncoder(camcorderProfile.videoCodec);

代码示例来源:origin: willowtreeapps/Hyperion-Android

static void prepare(@NonNull Context context) throws RecordingException {
  mediaRecorder = new MediaRecorder();
  projectionManager = (MediaProjectionManager) context
      .getSystemService(Context.MEDIA_PROJECTION_SERVICE);
  WindowManager windowManager = (WindowManager)
      context.getSystemService(Context.WINDOW_SERVICE);
  displayMetrics = new DisplayMetrics();
  windowManager.getDefaultDisplay().getMetrics(displayMetrics);
  createDirectoryIfNeeded(context);
  String videoId = UUID.randomUUID().toString();
  outputPath = context.getFilesDir().getPath() + "/hyperion_recorder/" + videoId + ".mp4";
  try {
    //mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
    mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
    mediaRecorder.setOutputFile(outputPath);
    mediaRecorder.setVideoSize(displayMetrics.widthPixels, displayMetrics.heightPixels);
    mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    //mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
    mediaRecorder.setVideoEncodingBitRate(512 * 2000);
    mediaRecorder.setVideoFrameRate(30);
    int rotation = windowManager.getDefaultDisplay().getRotation();
    int orientation = ORIENTATIONS.get(rotation + 90);
    mediaRecorder.setOrientationHint(orientation);
    mediaRecorder.prepare();
  } catch (IOException e) {
    throw new RecordingException("Failed to initialize the media recorder.", e);
  }
}

代码示例来源:origin: googlesamples/android-Camera2Video

private void setUpMediaRecorder() throws IOException {
  final Activity activity = getActivity();
  if (null == activity) {
    return;
  }
  mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
  mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
  if (mNextVideoAbsolutePath == null || mNextVideoAbsolutePath.isEmpty()) {
    mNextVideoAbsolutePath = getVideoFilePath(getActivity());
  }
  mMediaRecorder.setOutputFile(mNextVideoAbsolutePath);
  mMediaRecorder.setVideoEncodingBitRate(10000000);
  mMediaRecorder.setVideoFrameRate(30);
  mMediaRecorder.setVideoSize(mVideoSize.getWidth(), mVideoSize.getHeight());
  mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
  mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
  int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
  switch (mSensorOrientation) {
    case SENSOR_ORIENTATION_DEFAULT_DEGREES:
      mMediaRecorder.setOrientationHint(DEFAULT_ORIENTATIONS.get(rotation));
      break;
    case SENSOR_ORIENTATION_INVERSE_DEGREES:
      mMediaRecorder.setOrientationHint(INVERSE_ORIENTATIONS.get(rotation));
      break;
  }
  mMediaRecorder.prepare();
}

代码示例来源:origin: stackoverflow.com

mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mMediaRecorder.setVideoEncodingBitRate(512 * 1000);
mMediaRecorder.setVideoFrameRate(30);
mMediaRecorder.setVideoSize(width, height);

代码示例来源:origin: guoxiaoxing/phoenix

mMediaRecorder.setVideoFrameRate(mCamcorderProfile.videoFrameRate);
mMediaRecorder.setVideoSize(mVideoSize.getWidth(), mVideoSize.getHeight());
mMediaRecorder.setVideoEncodingBitRate(mCamcorderProfile.videoBitRate);
mMediaRecorder.setVideoEncoder(mCamcorderProfile.videoCodec);

代码示例来源:origin: guoxiaoxing/phoenix

mMediaRecorder.setVideoFrameRate(mCamcorderProfile.videoFrameRate);
mMediaRecorder.setVideoSize(mVideoSize.getWidth(), mVideoSize.getHeight());
mMediaRecorder.setVideoEncodingBitRate(mCamcorderProfile.videoBitRate);
mMediaRecorder.setVideoEncoder(mCamcorderProfile.videoCodec);

代码示例来源:origin: stackoverflow.com

MediaRecorder mr = new MediaRecorder();
mr.setVideoEncodingBitRate(someint);

代码示例来源:origin: dalong982242260/SmallVideoRecording

/**
 * 自定义的设置mediaeecorder 这里设置视频质量最低  录制出来的视频体积很小 对质量不是要求不高的可以使用
 */
public void customMediaRecorder(){
  if (mediaRecorder != null) {
    mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
    mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
    //设置分辨率,应设置在格式和编码器设置之后
    mediaRecorder.setVideoSize(previewWidth, previewHeight);
    mediaRecorder.setVideoEncodingBitRate(800 * 1024);
  }
}

代码示例来源:origin: google-ar/sceneform-android-sdk

private void setUpMediaRecorder() throws IOException {
 mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
 mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
 mediaRecorder.setOutputFile(videoPath.getAbsolutePath());
 mediaRecorder.setVideoEncodingBitRate(bitRate);
 mediaRecorder.setVideoFrameRate(frameRate);
 mediaRecorder.setVideoSize(videoSize.getWidth(), videoSize.getHeight());
 mediaRecorder.setVideoEncoder(videoCodec);
 mediaRecorder.prepare();
 try {
  mediaRecorder.start();
 } catch (IllegalStateException e) {
  Log.e(TAG, "Exception starting capture: " + e.getMessage(), e);
 }
}

代码示例来源:origin: GitEliteNovice/CustomCamera

@RequiresApi(api = Build.VERSION_CODES.LOLLIPOP)
private void setUpMediaRecorder() throws IOException {
  final Activity activity = getActivity();
  if (null == activity) {
    return;
  }
  Log.d("things called","setUpMediaRecording");
  mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
  mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
  if (mNextVideoAbsolutePath == null || mNextVideoAbsolutePath.isEmpty()) {
    mNextVideoAbsolutePath = getVideoFilePath(getActivity());
  }
  mMediaRecorder.setOutputFile(mNextVideoAbsolutePath);
  mMediaRecorder.setVideoEncodingBitRate(10000000);
  mMediaRecorder.setVideoFrameRate(30);
  mMediaRecorder.setVideoSize(mVideoSize.getWidth(), mVideoSize.getHeight());
  mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
  mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
  int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
  Log.d("orentataions", String.valueOf(global_orm));
  mMediaRecorder.setOrientationHint(getOrientation(rotation));
  mMediaRecorder.prepare();
}

代码示例来源:origin: EzequielAdrianM/Camera2Vision

mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mMediaRecorder.setOutputFile(videoFile);
mMediaRecorder.setVideoEncodingBitRate(10000000);
mMediaRecorder.setVideoFrameRate(30);
mMediaRecorder.setVideoSize(mVideoSize.getWidth(), mVideoSize.getHeight());

代码示例来源:origin: yangjie10930/OpenGL4Android

private void setUpMediaRecorder() throws IOException {
  final Activity activity = getActivity();
  if (null == activity) {
    return;
  }
  mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
  mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
  if (mNextVideoAbsolutePath == null || mNextVideoAbsolutePath.isEmpty()) {
    mNextVideoAbsolutePath = getVideoFilePath(getActivity());
  }
  mMediaRecorder.setOutputFile(mNextVideoAbsolutePath);
  mMediaRecorder.setVideoEncodingBitRate(10000000);
  mMediaRecorder.setVideoFrameRate(30);
  mMediaRecorder.setVideoSize(mVideoSize.getWidth(), mVideoSize.getHeight());
  mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
  mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
  int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
  switch (mSensorOrientation) {
    case SENSOR_ORIENTATION_DEFAULT_DEGREES:
      mMediaRecorder.setOrientationHint(DEFAULT_ORIENTATIONS.get(rotation));
      break;
    case SENSOR_ORIENTATION_INVERSE_DEGREES:
      mMediaRecorder.setOrientationHint(INVERSE_ORIENTATIONS.get(rotation));
      break;
  }
  mMediaRecorder.prepare();
}

代码示例来源:origin: chinmoyp/screenrecorder

private void initRecorder() {
    if (mMediaRecorder == null) {
      mMediaRecorder = new MediaRecorder();
      mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
      mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
      mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
      mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
      mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
      mMediaRecorder.setVideoEncodingBitRate(512 * 1000);
      mMediaRecorder.setVideoFrameRate(30);
      mMediaRecorder.setVideoSize(DISPLAY_WIDTH, DISPLAY_HEIGHT);
      mMediaRecorder.setOutputFile(getFilePath());
    }
  }
}

代码示例来源:origin: mobapptuts/android_camera2_api_video_app

private void setupMediaRecorder() throws IOException {
  mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
  mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
  mMediaRecorder.setOutputFile(mVideoFileName);
  mMediaRecorder.setVideoEncodingBitRate(1000000);
  mMediaRecorder.setVideoFrameRate(30);
  mMediaRecorder.setVideoSize(mVideoSize.getWidth(), mVideoSize.getHeight());
  mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
  mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
  mMediaRecorder.setOrientationHint(mTotalRotation);
  mMediaRecorder.prepare();
}

代码示例来源:origin: zx391324751/weChatDemo

private void setUpMediaRecorder() throws IOException {
  mediaRecorder = new MediaRecorder();
  CameraCharacteristics characteristics = null;
  try {
    characteristics = cameraManager.getCameraCharacteristics(cameraId);
  } catch (CameraAccessException e) {
    e.printStackTrace();
  }
  if(characteristics == null)
    return;
  StreamConfigurationMap map = characteristics.get(CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP);
  mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
  mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
  mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
  if (TextUtils.isEmpty(VIDEO_PATH)) {
    return;
  }
  mediaRecorder.setOutputFile(VIDEO_PATH);
  mediaRecorder.setVideoEncodingBitRate(10000000);
  mediaRecorder.setVideoFrameRate(30);
  size = chooseVideoSize(map.getOutputSizes(MediaRecorder.class));
  mediaRecorder.setVideoSize(size.getWidth(), size.getHeight());
  mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
  mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
  int rotation = getWindowManager().getDefaultDisplay().getRotation();
  mediaRecorder.setOrientationHint(ORIENTATIONS.get(rotation));
  mediaRecorder.prepare();
}

代码示例来源:origin: UncorkedStudios/recordablesurfaceview

mediaRecorder.setVideoEncodingBitRate(12000000);
mediaRecorder.setVideoFrameRate(30);
mediaRecorder.setVideoSize(displayWidth, displayHeight);

代码示例来源:origin: duanhong169/Camera

private void setUpMediaRecorder(MediaRecorderConfigurator configurator) throws IOException {
  if (configurator == null || configurator.useDefaultConfigs()) {
    mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);
    mediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
    mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
    mediaRecorder.setOutputFile(nextVideoAbsolutePath);
    mediaRecorder.setVideoEncodingBitRate(10000000);
    mediaRecorder.setVideoFrameRate(30);
    mediaRecorder.setVideoSize(videoSize.getWidth(), videoSize.getHeight());
    mediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
    mediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
  }
  if (configurator != null) {
    configurator.configure(mediaRecorder);
  }
  mediaRecorder.setOrientationHint(Utils.getOrientation(sensorOrientation, currentDeviceRotation));
  mediaRecorder.prepare();
}

相关文章