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
- Server Tomcat v9.0 Server at localhost failed to start.ServerTomcatlocalhostAI
- This application failed to start because it could not find or load the Qt platform plugin “windows“APPAIQTPlatformPluginWindows
- The Tomcat connector configured to listen on port 80 failed to start. The port may already be inTomcatAI
- 帶庫升級 exp全備 su profile error lead to pkg failed to startErrorAI
- 解決Error Initialization failed for ‘https://start.spring.io‘Please check URL, nErrorAIHTTPSpring
- Mongodb安裝坑 - Service 'MongoDB Server' (MongDB) failed to start. Verify that you have...MongoDBServerAI
- tomcat報錯org.apache.catalina.core.ContainerBase.startInternal A child container failed during startTomcatApacheAI
- 關於解決Server Tomcat v9.0 Server at localhost failed to start的問題ServerTomcatlocalhostAI
- VS中呼叫QT出現This application failed to start because it could not find or load the Qt platform pluginQTAPPAIPlatformPlugin
- start uniappAPP
- Android Bugs——Error:java.lang.RuntimeException: Some file crunching failed, see logs for detailsAndroidErrorJavaExceptionAI
- [20211014]19C Failed Logon Delay.txtAIGo
- rac中 crsctl start/stop crs and crsctl start/stop cluster 區別
- 3.1.5.6 Forcing an Instance to Start
- 開發springboot startSpring Boot
- AUTO START ORACLE ON LINUX(zt)OracleLinux
- where to start, from where the end
- [Kick Start] 2021 Round B
- Installation failed with message INSTALL_FAILED_USER_RESTRICTED錯誤AIREST
- Teamcenter 《POM has not start》處理
- Oracle start with connect by PostgreSQL recursive cteOracleSQL
- fatal: Authentication failedAI
- Gradle sync failed: Cause: dl.google.com:443 failed to respondGradleAIGo
- systemctl status network報錯:Failed to start LSB: Bring up/down networking。網路卡從原來的ens0s3變為enp0s8AIS3
- Oracle Database Cloud - Database as a Service Quick StartOracleDatabaseCloudUI
- React-App:NPM start 報錯ReactAPPNPM
- Linux下安裝Apollo (Quick Start)LinuxUI
- Android resource linking failedAndroidAI
- SDK Manager:failed to installAI
- Gradle Project Sync FailedGradleProjectAI
- Generating Pods project failedProjectAI
- NetworkError: Failed to execute 'send' on 'XMLHttpRequest': Failed to load xxxx錯誤解決方法ErrorAIXMLHTTP
- mysql服務啟動報錯Redirecting to systemctl start mysqld.serviceFailed to start mysqld.service:Unit not found.MySqlAI
- Spring Boot 動手寫一個 StartSpring Boot
- [fabric]Cannot start service orderer: Mounts denied: In MacMac
- PostgreSQL pg_ctl start超時分析SQL
- linux start_udev 導致VIP漂移Linuxdev
- uboot中start.s原始碼指令boot原始碼