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

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

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

MediaRecorder.setVideoFrameRate介绍

暂无

代码示例

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

@Test
public void testVideoFrameRate() throws Exception {
 assertThat(shadowMediaRecorder.getState()).isNotEqualTo(ShadowMediaRecorder.STATE_DATA_SOURCE_CONFIGURED);
 assertThat(shadowMediaRecorder.getVideoFrameRate()).isNotEqualTo(30);
 mediaRecorder.setVideoFrameRate(30);
 assertThat(shadowMediaRecorder.getVideoFrameRate()).isEqualTo(30);
 assertThat(shadowMediaRecorder.getState()).isEqualTo(ShadowMediaRecorder.STATE_DATA_SOURCE_CONFIGURED);
}

代码示例来源: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);

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

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

代码示例来源: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.setAudioEncoder(MediaRecorder.AudioEncoder.AMR_NB);
mMediaRecorder.setVideoEncodingBitRate(512 * 1000);
mMediaRecorder.setVideoFrameRate(30);
mMediaRecorder.setVideoSize(width, height);
mMediaRecorder.setOutputFile(filePath);

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

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

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

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

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

recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setVideoSize(640, 480);
recorder.setVideoFrameRate(20);
recorder.setVideoEncodingBitRate(3000000);
recorder.setAudioEncoder(MediaRecorder.AudioEncoder.DEFAULT);

代码示例来源: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: stackoverflow.com

Socket socket = new Socket(serverAddr, serverPort);
socket.setTcpNoDelay(true);
ParcelFileDescriptor pfd = ParcelFileDescriptor.fromSocket(socket);
Camera camera = Camera.open();
camera.unlock();
MediaRecorder recorder = new MediaRecorder();
recorder.setCamera(camera);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
recorder.setVideoEncoder(MediaRecorder.VideoEncoder.H263);
recorder.setOutputFile(pfd.getFileDescriptor());
recorder.setPreviewDisplay(surfaceView.getHolder().getSurface());
recorder.setVideoFrameRate(15);
recorder.setVideoSize(480, 320);
recorder.prepare();
recorder.start();

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

mMediaRecorder.setOutputFile(videoFile);
mMediaRecorder.setVideoEncodingBitRate(10000000);
mMediaRecorder.setVideoFrameRate(30);
mMediaRecorder.setVideoSize(mVideoSize.getWidth(), mVideoSize.getHeight());
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);

代码示例来源: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.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();
}

相关文章