2015-07-20 54 views
1

我得到一個錯誤libstreaming機器人。mediarecoder啓動失敗-19採用與索尼Z系列

10月7日至20日:49:37.832:E/MediaRecorder(6752):啓動失敗:-19 ConfNotSupportedException當我改變在視頻的幀速率,則拋出

此錯誤(15 < fps < 30或fps> 30)。如果我設置fps = 15或fps = 30,則不會拋出此錯誤。這個錯誤只在sony z設備上,在一些不同的設備上是三星,HTC,Nexus沒有。

我下載了Wowza Gocoder應用程序來測試這個錯誤是否只在sony z上。而且,我可以將fps從15改爲60,不會有任何錯誤。所以,我猜想庫流有問題。

我的配置代碼:

// Configures the SessionBuilder 
mSession = SessionBuilder.getInstance() 
     .setContext(getApplicationContext()) 
     .setAudioEncoder(SessionBuilder.AUDIO_AAC) 
     .setAudioQuality(new AudioQuality(8000, 16000)) 
     .setVideoEncoder(SessionBuilder.VIDEO_H264) 
     .setSurfaceView(mSurfaceView).setPreviewOrientation(0) 
     .setCallback(this).build(); 

// Configures the RTSP client 
mClient = new RtspClient(); 
mClient.setSession(mSession); 
mClient.setCallback(this); 

// Use this to force streaming with the MediaRecorder API 
mSession.getVideoTrack().setStreamingMethod(
     MediaStream.MODE_MEDIARECORDER_API); 

下面開始流這段代碼:

protected void encodeWithMediaRecorder() throws IOException, ConfNotSupportedException { 

     Log.d(TAG,"Video encoded using the MediaRecorder API"); 

     // We need a local socket to forward data output by the camera to the packetizer 
     createSockets(); 

     // Reopens the camera if needed 
     destroyCamera(); 
     createCamera(); 

     // The camera must be unlocked before the MediaRecorder can use it 
     unlockCamera(); 

     try { 
      mMediaRecorder = new MediaRecorder(); 
      mMediaRecorder.setCamera(mCamera); 
      mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); 
      mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); 
      mMediaRecorder.setVideoEncoder(mVideoEncoder); 
      mMediaRecorder.setPreviewDisplay(mSurfaceView.getHolder().getSurface()); 
      mMediaRecorder.setVideoSize(mRequestedQuality.resX,mRequestedQuality.resY); 
      mMediaRecorder.setVideoFrameRate(mRequestedQuality.framerate); 

      // The bandwidth actually consumed is often above what was requested 
      mMediaRecorder.setVideoEncodingBitRate((int)(mRequestedQuality.bitrate*0.8)); 

      // We write the output of the camera in a local socket instead of a file !   
      // This one little trick makes streaming feasible quiet simply: data from the camera 
      // can then be manipulated at the other end of the socket 
      FileDescriptor fd = null; 
      if (sPipeApi == PIPE_API_PFD) { 
       fd = mParcelWrite.getFileDescriptor(); 
      } else { 
       fd = mSender.getFileDescriptor(); 
      } 
      mMediaRecorder.setOutputFile(fd); 

      mMediaRecorder.prepare(); 
      mMediaRecorder.start(); 

     } catch (Exception e) { 
      throw new ConfNotSupportedException(e.getMessage()); 
     } 

任何一個有想法?謝謝!

回答

0

註釋掉

mMediaRecorder.setVideoFrameRate(mRequestedQuality.framerate); 

解決我的問題。