MediaRecorder start failed -19 java.lang.RuntimeException: start failed
使用MediaRecorder錄製視訊的時候,
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
mMediaRecorder.setVideoFrameRate(20);
mMediaRecorder.setVideoSize(352, 288);
mMediaRecorder.setVideoEncoder(mVideoEncoder);
mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
mMediaRecorder.setMaxDuration(0);
mMediaRecorder.setMaxFileSize(0);
mMediaRecorder.setOutputFile(sender.getFileDescriptor());
try {
mMediaRecorder.setOnInfoListener(this);
mMediaRecorder.setOnErrorListener(this);
mMediaRecorder.prepare();
mMediaRecorder.start();
出現如題錯誤:注意,這段程式碼在小米上面可以跑通,在Htc和聯想的某些機型上面會出現如題錯誤。
修改為以下,註釋掉三行程式碼:
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4);
// mMediaRecorder.setVideoFrameRate(20);
// mMediaRecorder.setVideoSize(352, 288);
mMediaRecorder.setVideoEncoder(mVideoEncoder);
mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());
mMediaRecorder.setMaxDuration(0);
// mMediaRecorder.setMaxFileSize(0);
mMediaRecorder.setOutputFile(sender.getFileDescriptor());
try {
mMediaRecorder.setOnInfoListener(this);
mMediaRecorder.setOnErrorListener(this);
mMediaRecorder.prepare();
mMediaRecorder.start();
即可。
在StackOverFlow上面,也有很多這樣的問題,如果這種方案不能解決,建議在上面找找其他。
如果使用setCamera()方法,前面要呼叫camera.unLock()方法。否則,可能出錯。
相關文章
- Failed to start docker.service: Unit not foundAIDocker
- Start of resource “ora.asm -init” failed -ASMAI
- Failed to start Master instance in admin modeAIAST
- [IOS]解決Failed to start Instruments daemon for ‘iOS’ on iPhoneiOSAIiPhone
- Server Tomcat v7.0 Server at localhost failed to startServerTomcatlocalhostAI
- 處理service named start失敗failed_dnsAIDNS
- Server Tomcat v9.0 Server at localhost failed to start.ServerTomcatlocalhostAI
- 【tomcat報錯】A child container failed during startTomcatAI
- CRS-4000: Command Start failed, or completed with errors.AIError
- CRS-1205:Auto-start failed for the CRS resourceAI
- Oracle 11gR2 RAC ohasd failed to start 解決方法OracleAI
- Failed to start the Clusterware. Last 20 lines of the alert log follow:AIAST
- ORA-12500: TNS:listener failed to start a dedicated server processAIServer
- ORA-12500 TNS : listener failed to start a dedicated server processAIServer
- This application failed to start because it could not find or load the Qt platform plugin “windows“APPAIQTPlatformPluginWindows
- ERROR namenode.NameNode: Failed to start namenode. java.lang.IllegalArgumentErrorAIJava
- Application failed to start because it could not find or load the QT platform plugin “windows”APPAIQTPlatformPluginWindows
- centOS7 Failed to start LSB Bring up/down networkingCentOSAI
- PRCR-1079 : Failed to start resource ora.scan1.vipAI
- CLSRSC-184 CLSRSC-258: Failed to configure and start ASMAIASM
- Dbconsole Fails To Start With Nzos_handshake Failed,Ret=29024AI
- Mongodb安裝坑 - Service 'MongoDB Server' (MongDB) failed to start. Verify that you have...MongoDBServerAI
- 帶庫升級 exp全備 su profile error lead to pkg failed to startErrorAI
- root script (root.sh or rootupgrade.sh) Failed to start resource ora.onsAI
- 解決Error Initialization failed for ‘https://start.spring.io‘Please check URL, nErrorAIHTTPSpring
- 安裝GRID CONTROL The OPMN Process Manager failed to start報錯處理AI
- 安裝Grid Control , OPMN Process Manager failed to start 問題解決AI
- The Tomcat connector configured to listen on port 80 failed to start. The port may already be inTomcatAI
- 關於解決Server Tomcat v9.0 Server at localhost failed to start的問題ServerTomcatlocalhostAI
- why app_start startAPP
- VS中呼叫QT出現This application failed to start because it could not find or load the Qt platform pluginQTAPPAIPlatformPlugin
- RHEL 7 安裝oracle rac 11.2.0.4執行root.sh報錯ohasd failed to startOracleAI
- Oracle 10g 安裝gc:OPMN Process Manager failed to start和OUI - 25031解決方案Oracle 10gGCAIUI
- ERROR Dispatcher Dispatcher initialization failed java.lang.RuntimeException: java.lang.RuntimeExcErrorAIJavaException
- A New Start
- the new start
- fast_start_parallel_rollback與v$fast_start_servers和v$fast_start_transactionsASTParallelServer
- Extract or Replicat Fail to Start (Don't Start) With No Error MessagesAIError