我正在使用此库进行视频共享应用程序项目,我正在使用CameraDemo_layout,我将com.commonsware.cwac.camera.CameraView尺寸设置为320dip,高度和宽度。但是,录制的视频似乎具有电话屏幕尺寸的录制,这使得它看起来很错误。您能否指导我完成设置视频录制的过程,以遵循相机视图组布局的尺寸。谢谢。
我的活动:
public class RecordingActivity extends Activity implements
CameraHostProvider { private DemoCameraFragment current = null;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_recording);
current=new DemoCameraFragment();
getFragmentManager().beginTransaction()
.replace(R.id.container, current).commit();
}
@Override
public CameraHost getCameraHost() {
return(new SimpleCameraHost(this));
}
我的片段:
public class DemoCameraFragment extends CameraFragment {
android.hardware.Camera camera;
@Override
public View onCreateView(LayoutInflater inflater,
ViewGroup container,
Bundle savedInstanceState) {
View content=inflater.inflate(R.layout.camera, container, false);
CameraView cameraView=(CameraView)content.findViewById(R.id.camera);
Log.d("daba", "the cameraview attrs: " + cameraView.getHeight() + " -- " + cameraView.getWidth());
setCameraView(cameraView);
// SimpleCameraHost.Builder builder = new SimpleCameraHost.Builder(getActivity());
// builder.useFullBleedPreview(false);
//
// setHost(builder.build());
final ImageButton record = (ImageButton) content.findViewById(R.id.record);
final ImageButton next = (ImageButton) content.findViewById(R.id.next);
next.setEnabled(false);
record.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
if(record.getTag().toString().equals("Hi!")){
try {
record();
record.setTag("By!");
record.setBackgroundColor(Color.DKGRAY);
next.setEnabled(true);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
else{
try {
stopRecording();
record.setTag("Hi!");
record.setBackgroundColor(Color.TRANSPARENT);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
});
next.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
if(isRecording())
Toast.makeText(getActivity(), "Finish recording first", Toast.LENGTH_SHORT).show();
else{
Intent i = new Intent(getActivity(), VideoSetData.class);
getActivity().startActivity(i);
}
}
});
if(isRecording()){
}
return(content);
}
}
我的Camera.xml:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<com.commonsware.cwac.camera.CameraView
android:id="@+id/camera"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@drawable/cancel" />
<ImageButton
android:id="@+id/next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@drawable/right" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:gravity="center"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/record"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/record"
android:tag="Hi!" >
</ImageButton>
</LinearLayout>
答案 0 :(得分:1)
然而,录制的视频似乎有电话屏幕尺寸的录音,这看起来很错误
录音的分辨率应与CameraView
的尺寸无关。录制的分辨率应来自the MediaRecorder
使用setProfile()
的配置。
setProfile()
用于CameraHost
中的configureRecorderProfile()
。 SimpleCameraHost
使用自己的算法来选择配置文件;您需要继承SimpleCameraHost
并覆盖configureRecorderProfile()
以使用不同的算法来选择配置文件。