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

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

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

MediaRecorder.setProfile介绍

暂无

代码示例

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

mrec.setAudioSource(MediaRecorder.AudioSource.MIC); 
mrec.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
mrec.setPreviewDisplay(surfaceHolder.getSurface());
mrec.setOutputFile("/sdcard/zzzz.3gp");

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

mediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));

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

recorder.setProfile(cpHigh);
recorder.setOutputFile("/sdcard/videocapture_example.mp4");
recorder.setMaxDuration(50000); // 50 seconds

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

mediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));

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

recorder.setProfile(cpHigh);
recorder.setOutputFile("/sdcard/videocapture_example.mp4");
recorder.setMaxDuration(50000); // 50 seconds

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

// establish the media recorder
 MediaRecorder media_recorder = new MediaRecorder();
 media_recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
 media_recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
 // Customise your profile based on a pre-existing profile
 CamcorderProfile profile = CamcorderProfile.get(CameraInfo.CAMERA_FACING_FRONT,CamcorderProfile.QUALITY_LOW);
 profile.fileFormat = MediaRecorder.OutputFormat.MPEG_4;
 profile.videoCodec = MediaRecorder.VideoEncoder.MPEG_4_SP;
 profile.videoFrameHeight = 240;
 profile.videoFrameWidth = 320;
 profile.videoBitRate = 15;
 // Apply to MediaRecorder
 media_recorder.setProfile(profile);

代码示例来源:origin: cn.leancloud.android/avoscloud-push

private void initRecorder() {
 mediaRecorder = new MediaRecorder();
 mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
 mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 mediaRecorder.setProfile(this.profile);
 mediaRecorder.setOutputFile(this.localPath);
 mediaRecorder.setMaxDuration(this.maxDuration); // seconds
 mediaRecorder.setMaxFileSize(this.maxFileSize); // Approximately 5 megabytes
 SurfaceHolder holder = this.surfaceView.getHolder();
 holder.addCallback(this);
 holder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}

代码示例来源:origin: tyrex-team/senslogs

/**
 * Start the camera recording process
 *
 * @param videoPath The path where the video will be stored
 */
public void startInternal(String videoPath) {
  mBackgroundThread = new HandlerThread(CAMERA_THREAD);
  mBackgroundThread.start();
  mBackgroundHandler = new Handler(mBackgroundThread.getLooper());
  try {
    CameraCharacteristics characteristics = mCameraManager.getCameraCharacteristics(
        String.valueOf(CAMERA_LENS));
    Integer sensorOrientation = characteristics.get(CameraCharacteristics.SENSOR_ORIENTATION);
    mMediaRecorder = new MediaRecorder();
    mMediaRecorder.setAudioSource(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ?
        MediaRecorder.AudioSource.UNPROCESSED : MediaRecorder.AudioSource.CAMCORDER);
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
    mMediaRecorder.setOutputFile(videoPath);
    mMediaRecorder.setOrientationHint(sensorOrientation == null ? 0 : sensorOrientation);
    mMediaRecorder.setProfile(CamcorderProfile.get(CAMERA_LENS, mSettings.outputQuality.profile));
    mMediaRecorder.prepare();
    mCameraManager.openCamera(String.valueOf(CAMERA_LENS),
        cameraDeviceStateCallback, mBackgroundHandler);
  } catch (IOException | CameraAccessException | SecurityException e) {
    e.printStackTrace();
  }
}

代码示例来源:origin: chengzichen/KrGallery

protected void configureRecorder(int quality, MediaRecorder recorder) {
  Camera.CameraInfo info = new Camera.CameraInfo();
  Camera.getCameraInfo(cameraInfo.cameraId, info);
  int displayOrientation = getDisplayOrientation(info, false);
  recorder.setOrientationHint(displayOrientation);
  int highProfile = getHigh();
  boolean canGoHigh = CamcorderProfile.hasProfile(cameraInfo.cameraId, highProfile);
  boolean canGoLow = CamcorderProfile.hasProfile(cameraInfo.cameraId, CamcorderProfile.QUALITY_LOW);
  if (canGoHigh && (quality == 1 || !canGoLow)) {
    recorder.setProfile(CamcorderProfile.get(cameraInfo.cameraId, highProfile));
  } else if (canGoLow) {
    recorder.setProfile(CamcorderProfile.get(cameraInfo.cameraId, CamcorderProfile.QUALITY_LOW));
  } else {
    throw new IllegalStateException("cannot find valid CamcorderProfile");
  }
  isVideo = true;
}

代码示例来源:origin: FacePlusPlus/MegviiFacepp-Android-SDK

+ camcorderProfile.videoFrameHeight);
mMediaRecorder.setProfile(camcorderProfile);
mMediaRecorder.setVideoEncodingBitRate(1048576 * 40);

代码示例来源:origin: zhantong/AndroidCamera-TouchToFocusMeteringZoom

private boolean prepareVideoRecorder() {
  mCamera = getCameraInstance();
  mMediaRecorder = new MediaRecorder();
  mCamera.unlock();
  mMediaRecorder.setCamera(mCamera);
  mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
  mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
  mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
  SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
  String prefVideoSize = prefs.getString("video_size", "");
  String[] split = prefVideoSize.split("x");
  mMediaRecorder.setVideoSize(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
  mMediaRecorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());
  mMediaRecorder.setPreviewDisplay(mHolder.getSurface());
  int rotation = getDisplayOrientation();
  mMediaRecorder.setOrientationHint(rotation);
  try {
    mMediaRecorder.prepare();
  } catch (IllegalStateException e) {
    Log.d(TAG, "IllegalStateException preparing MediaRecorder: " + e.getMessage());
    releaseMediaRecorder();
    return false;
  } catch (IOException e) {
    Log.d(TAG, "IOException preparing MediaRecorder: " + e.getMessage());
    releaseMediaRecorder();
    return false;
  }
  return true;
}

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

MediaRecorder recorder = new MediaRecorder();
recorder.setAudioSource(MediaRecorder.AudioSource.MIC);
recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
recorder.setOutputFile(PATH_TO_FILE);
recorder.setPreviewDisplay(holder.getSurface());
recorder.prepare();

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

MediaRecorder mediaRecorder = new MediaRecorder(); 
mediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT); 
mediaRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 CamcorderProfile camcorderProfile_HQ = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);
mediaRecorder.setProfile(camcorderProfile_HQ);
 mediaRecorder.setOutputFile("/sdcard/myvideo.mp4");
 mediaRecorder.setMaxDuration(60000); // Set max duration 60 sec. 
mediaRecorder.setMaxFileSize(5000000); // Set max file size 5M

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

private void setupTimelapse() throws IOException {
  mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.SURFACE);
  mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_HIGH));
  mMediaRecorder.setOutputFile(mVideoFileName);
  mMediaRecorder.setCaptureRate(2);
  mMediaRecorder.setOrientationHint(mTotalRotation);
  mMediaRecorder.prepare();
}

代码示例来源:origin: werbhelius/MediaUtils

mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setProfile(profile);

代码示例来源:origin: huangfangyi/YiChat

mediaRecorder.setProfile(profile);
} else {
  mediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);

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

Camera mCamera = getCameraInstance();
 // adjust the camera the way you need
 mCamera.setDisplayOrientation(90);
 MediaRecorder recorder = new MediaRecorder();
 recorder.setCamera(mCamera);
 recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
 recorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
 recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
 recorder.setOutputFile(filePath);
 // add any limits
 recorder.setMaxDuration(50000); // 50 seconds
 recorder.setMaxFileSize(5000000); // Approximately 5 megabytes

代码示例来源:origin: nglauber/dominando_android2

private boolean prepararGravacao() {
  abrirCamera();
  mCamera.unlock();
  mMediaRecorder = new MediaRecorder();
  mMediaRecorder.setCamera(mCamera);
  mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
  mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
  mMediaRecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
  mMediaRecorder.setOutputFile(mCaminhoArquivo.toString());
  mMediaRecorder.setMaxDuration(60000); // 1 minuto
  mMediaRecorder.setOnInfoListener(new MediaRecorder.OnInfoListener() {
    @Override
    public void onInfo(MediaRecorder mr, int what, int extra) {
      if (what == MediaRecorder.MEDIA_RECORDER_INFO_MAX_DURATION_REACHED) {
        concluirGravacao();
      }
    }
  });
  mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());
  try {
    mMediaRecorder.prepare();
  } catch (IOException e) {
    e.printStackTrace();
    liberarMediaRecorder();
    return false;
  }
  return true;
}
private void concluirGravacao() {

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

private void initRecorder() {
  recorder = new MediaRecorder();
  camera = Camera.open(Camera.CameraInfo.CAMERA_FACING_BACK);
  if (camera != null) {
    camera.setDisplayOrientation(90);//摄像图旋转90度
    camera.unlock();
    recorder.setCamera(camera);
  }
  recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
  recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
  recorder.setOrientationHint(90); //旋转90度
  //480的清晰度,相当于高清视频与标清视频之间水准,10秒大概5mb左右
  CamcorderProfile cpHigh = CamcorderProfile.get(CamcorderProfile.QUALITY_480P);
  recorder.setProfile(cpHigh);
  recorder.setOutputFile(VIDEO_PATH); //文件名先随便写吧,毕竟只是demo
  recorder.setMaxDuration(10000); // 10 seconds
  recorder.setMaxFileSize(5000000); // Approximately 5 megabytes
}

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

public class VideoHolderCallback implements SurfaceHolder.Callback{
MediaRecorder recorder;
...
public void configureRecorder(){

  if(camera == null) {
    camera = Camera.open();
    camera.unlock();
  }
  recorder.setCamera(camera);
  recorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
  recorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER);
  recorder.setOutputFormat(MediaRecorder.OutputFormat.THREE_GPP);
  recorder.setVideoEncoder(MediaRecorder.VideoEncoder.MPEG_4_SP);
  recorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
  recorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH));
  recorder.setOutputFile(filePath);
  recorder.setPreviewDisplay(holder.getSurface());
  recorder.prepare();
}

相关文章