2015-04-07 269 views
0

這似乎是一個愚蠢的問題,我一直在這一整晚都在努力,無法從我的手機上錄製一個webm視頻。在android mediarecorder設置或camprofile調整中錄製Webm格式?

mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC); 
    mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA); 

    mMediaRecorder.setOutputFormat(MediaRecorder.OutputFormat.WEBM); 

    //mMediaRecorder.setOutputFormat(outFormat); 

    //CamcorderProfile camPro = CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_480P); 
    //camPro.fileFormat = MediaRecorder.OutputFormat.WEBM; 
    //camPro.videoFrameRate = 30; 
    mMediaRecorder.setCaptureRate(30f); 
    //camPro.videoFrameWidth = 360; 
    //camPro.videoFrameHeight = 640; 
    //camPro.videoBitRate = 2000000; 
    //camPro.audioCodec = MediaRecorder.AudioEncoder.VORBIS; 

    mMediaRecorder.setVideoSize(640,360); 
    mMediaRecorder.setVideoEncodingBitRate(2000000); 

    mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.VORBIS); 
    mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.VP8); 
    //camPro.videoCodec = MediaRecorder.VideoEncoder.VP8; 
    mMediaRecorder.setVideoFrameRate(30); 
    //mMediaRecorder.setProfile(camPro); 

我已經評論了攝像機配置文件行,因爲我認爲只有一個必須使用。我還看到一個說法,說API級別21是必需的,所以我在我的棒棒糖5.0.2的摩托車G上。

我得到的錯誤是攝像機死了錯誤100. 有時媒體recorder.prepare()發生,但然後media recorder.start()拋出一個錯誤。 我很困惑應該做些什麼。一旦我沒有錯誤。但我只有6.19KB的文件無法播放。

回答

0

我不能告訴你是否想要寫入一個文件或一個套接字或什麼。但是如果你想寫一個Socket,那麼棒棒糖似乎有問題。你必須使用這種技術來寫入Socket。

但是,WEBM似乎在前兩個數據包之後停止爲我傳輸數據。我目前不確定爲什麼會出現這種情況。

Anyone Have MediaRecorder Working with ParcelFileDescriptor and createPipe()?