我想录制最高质量的视频。对于我的设备 (LG G Flex 2),它是 3840x2160。此分辨率提供库存相机。除了相机参数信息之外,第 3 方应用程序还可以使用视频大小。
如果我尝试使用配置文件:
CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_2160P)
Run Code Online (Sandbox Code Playgroud)
它返回假。没有这样的配置文件。
我也试过这个:
CamcorderProfile prof = CamcorderProfile.get(CamcorderProfile.QUALITY_1080P);
prof.videoFrameHeight = 2160;
prof.videoFrameWidth = 3840;
mMediaRecorder.setProfile(prof);
Run Code Online (Sandbox Code Playgroud)
但它也不起作用。
最后:
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);
mMediaRecorder.setVideoSize(3840, 2160);
Run Code Online (Sandbox Code Playgroud)
也不行。
错误是
03-20 01:53:02.800: E/MediaRecorder(17459): start failed: -19
Run Code Online (Sandbox Code Playgroud)
有没有其他方法可以录制视频?我正在使用 camera1 api 并camera.getParameters().getSupportedVideoSizes()包含 3840x2160
如何自定义前台服务通知?我试过了:
private void startForegoundService() {
RemoteViews remoteViews = new RemoteViews(getPackageName(),
R.layout.custom_notification);
Notification.Builder mBuilder = new Notification.Builder(this)
.setContent(remoteViews);
startForeground(mforegroundNotificationId, mBuilder.build());
}
Run Code Online (Sandbox Code Playgroud)
其中R.layout.custom_notification是:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/notification_layout_root"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#7777"
android:padding="3dp" >
<ImageView
android:id="@+id/button_enable_alarm"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_marginRight="10dp"
android:contentDescription="Eye"
android:src="@drawable/action_enable_alarm" />
<TextView
android:id="@+id/text"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#FFF"
android:textSize="24sp" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
但这没有任何作用。我需要完全自定义前台服务通知。不仅是“假”服务通知。
我需要加速捕获camera2 API.我试图从谷歌样本构建"android-Camera2Basic"项目.对于来自示例的默认捕获请求:
if (null == activity || null == mCameraDevice) {
return;
}
// This is the CaptureRequest.Builder that we use to take a picture.
final CaptureRequest.Builder captureBuilder =
mCameraDevice.createCaptureRequest(CameraDevice.TEMPLATE_STILL_CAPTURE);
captureBuilder.addTarget(mImageReader.getSurface());
// Use the same AE and AF modes as the preview.
captureBuilder.set(CaptureRequest.CONTROL_AF_MODE,
CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE);
captureBuilder.set(CaptureRequest.CONTROL_AE_MODE,
CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH);
// Orientation
int rotation = activity.getWindowManager().getDefaultDisplay().getRotation();
captureBuilder.set(CaptureRequest.JPEG_ORIENTATION, ORIENTATIONS.get(rotation));
CameraCaptureSession.CaptureCallback CaptureCallback
= new CameraCaptureSession.CaptureCallback() {
@Override
public void onCaptureCompleted(CameraCaptureSession session, CaptureRequest request,
TotalCaptureResult result) {
showToast("Saved: " + mFile);
unlockFocus();
}
};
mCaptureSession.stopRepeating();
mCaptureSession.capture(captureBuilder.build(), CaptureCallback, …Run Code Online (Sandbox Code Playgroud)