8
A
回答
6
您可以使用MediaRecorder不調用setAudio *就可以了。這是使用MediaRecorder我的第一次,但這個例子似乎工作:
public class CamcorderView extends SurfaceView implements
SurfaceHolder.Callback {
private SurfaceHolder mHolder;
private Camera mCamera;
private MediaRecorder mRecorder;
public CamcorderView(Context context, AttributeSet attrs) {
super(context, attrs);
mHolder = getHolder();
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
mHolder.addCallback(this);
mCamera = Camera.open();
mRecorder = new MediaRecorder();
}
public void stop() {
mRecorder.stop();
}
@Override
public void surfaceChanged(SurfaceHolder holder, int format, int width,
int height) {
}
@Override
public void surfaceDestroyed(SurfaceHolder holder) {
}
@Override
public void surfaceCreated(SurfaceHolder holder) {
mCamera.unlock();
mRecorder.setCamera(mCamera);
mRecorder.setPreviewDisplay(mHolder.getSurface());
// You may want to change these
mRecorder.setVideoSource(MediaRecorder.VideoSource.DEFAULT);
mRecorder.setOutputFormat(MediaRecorder.OutputFormat.DEFAULT);
mRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.DEFAULT);
// You'll definitely want to change this
mRecorder.setOutputFile("/mnt/sdcard/out");
try {
mRecorder.prepare();
} catch (IllegalStateException e) {
Log.e("IllegalStateException", e.toString());
} catch (IOException e) {
Log.e("IOException", e.toString());
}
mRecorder.start();
}
}
你也可以撥打:
setVideoSize(int, int);
setVideoFrameRate(int);
9
你可以準備MediaRecorder通過從內置配置文件(CamcorderProfile)複製必需的字段。只是忽略音頻設置,你應該很好去。編輯下面的代碼以滿足您的需求,第3步是此處的重要部分。
private boolean prepareVideoRecorder() {
mCamera = getCameraInstance();
mMediaRecorder = new MediaRecorder();
// store the quality profile required
CamcorderProfile profile = CamcorderProfile.get(cameraid, CamcorderProfile.QUALITY_HIGH);
// Step 1: Unlock and set camera to MediaRecorder
mCamera.unlock();
mMediaRecorder.setCamera(mCamera);
// Step 2: Set sources
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
// Step 3: Set all values contained in profile except audio settings
mMediaRecorder.setOutputFormat(profile.fileFormat);
mMediaRecorder.setVideoEncoder(profile.videoCodec);
mMediaRecorder.setVideoEncodingBitRate(profile.videoBitRate);
mMediaRecorder.setVideoFrameRate(profile.videoFrameRate);
mMediaRecorder.setVideoSize(profile.videoFrameWidth, profile.videoFrameHeight);
// Step 4: Set output file
mMediaRecorder.setOutputFile(getOutputMediaFile(MEDIA_TYPE_VIDEO).toString());
// Step 5: Set the preview output
mMediaRecorder.setPreviewDisplay(mPreview.getHolder().getSurface());
// Step 6: Prepare configured MediaRecorder
try {
mMediaRecorder.prepare();
} catch (IllegalStateException e) {
releaseMediaRecorder();
return false;
} catch (IOException e) {
releaseMediaRecorder();
return false;
}
return true;
}
+0
效果不錯..謝謝 – 2016-02-19 01:40:21
+0
不錯的解決方案......它對我非常有用..... – jack 2016-07-01 19:37:32
相關問題
- 1. Wowza記錄音頻,但沒有視頻
- 2. Android音頻記錄
- 3. 的Gstreamer記錄音頻和視頻
- 4. WebRTC:Chrome不記錄視頻/音頻
- 5. AVCaptureSession錄製帶有音頻的視頻
- 6. 視頻+錄音機Android
- 7. Android錄音和結果有音頻視頻同步問題
- 8. 沒有freeswitch中的音頻/視頻
- 9. Android的記錄視頻
- 10. Android應用程序 - 視頻/音頻記錄
- 11. 使用音頻播放視頻後錄製音頻和視頻
- 12. iOS流音頻和記錄音頻
- 13. VideoJS音頻但沒有視頻
- 14. iPhone SDK - presentMoviePlayerViewControllerAnimated沒有視頻,但音頻
- 15. J2ME RTSP視頻流,但沒有音頻
- 16. 沒有音頻保存視頻與AVCaptureMovieFileOutput
- 17. Nativescript記錄音頻
- 18. Android記錄廣場視頻
- 19. Android視頻記錄錯誤
- 20. MediaRecorder不記錄只錄制音頻的視頻
- 21. Android Air 3.1上的StageVideo沒有視頻,但音頻?
- 22. Android-x86中沒有音頻
- 23. VLCj錄製視頻 - 從機中沒有音頻和無運動
- 24. Gracenote SDK的音頻記錄android
- 25. 包括音頻的Android記錄屏幕
- 26. Android的記錄音頻NO SDCARD
- 27. Android音頻錄製
- 28. Android音頻錄製
- 29. android音頻錄製
- 30. 如何翻錄視頻中的音頻?
謝謝!真的行!也許你知道如何將這些設置應用於CamcorderProfile?因爲我使用自動生成的PARAMS如'camcorderProfile = CamcorderProfile.get(CamcorderProfile.QUALITY_HIGH);',那麼所有的設置都爲'mediaRecorder.setProfile(camcorderProfile)施加; ' – Sergii 2012-08-12 16:09:34
你能否提供更多的信息,因爲它不適合工作。 – 2015-09-10 08:39:12