Android 音視頻深入 八 小視頻錄製(附源碼下載)

來源:互聯網
上載者:User

標籤:follow   視頻編碼   abs   surf   UI   order   螢幕   hold   https   

本篇項目地址,求start
https://github.com/979451341/Audio-and-video-learning-materials/tree/master/%E5%B0%8F%E8%A7%86%E9%A2%91%E5%BD%95%E5%88%B6

這個項目我覺得厲害,因為之前錄屏用了很多代碼,而這個真正實現錄屏功能的代碼一百行都不到

還有就是關於整個介面UI也做得不錯,但是關於介面如何?的我就不多說了,直接說如何?錄屏的代碼

首先Camera如何給資料SurfaceView,從而在螢幕顯示Camera拍到的東西,這個之前說多了,不在提了

1.錄屏

這一次將視頻資料如何將資料給MediaRecorder,兩行就可以了
mMediaRecorder.setCamera(mCamera);
mMediaRecorder.setPreviewDisplay(mSurfaceHolder.getSurface());

設定音視頻兩個資料來源的格式
mMediaRecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);
mMediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC);

設定解析度,顯示螢幕的大小
//設定視頻的解析度
mMediaRecorder.setVideoSize(mProfile.videoFrameWidth, mProfile.videoFrameHeight);

設定編碼的速率
mMediaRecorder.setAudioEncodingBitRate(44100);
if (mProfile.videoBitRate > 2 1024 1024) {
mMediaRecorder.setVideoEncodingBitRate(2 1024 1024);
} else {
mMediaRecorder.setVideoEncodingBitRate(mProfile.videoBitRate);
}

設定視頻播放的幀率
mMediaRecorder.setVideoFrameRate(mProfile.videoFrameRate);

這是音視頻編碼的格式
mMediaRecorder.setAudioEncoder(MediaRecorder.AudioEncoder.AAC);
mMediaRecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);

設定輸出檔案的路徑
mMediaRecorder.setOutputFile(mRecordFile.getAbsolutePath());

這項目要說缺陷就是無法在錄屏的時候加特效,但是代碼短,適合一些專門的用途

Android 音視頻深入 八 小視頻錄製(附源碼下載)

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.