日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

android开发,静音录制视频,在一般清晰度的前提下保证文件大小越小越好

發布時間:2025/3/20 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android开发,静音录制视频,在一般清晰度的前提下保证文件大小越小越好 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
public void startRecord() {mediarecorder = new MediaRecorder();// 創建mediarecorder對象mCamera = getCameraInstance();Parameters parameters = mCamera.getParameters(); mCamera.autoFocus(null);// 解鎖cameramCamera.setDisplayOrientation(90);mCamera.unlock();mediarecorder.setCamera(mCamera);List<Size> supportedPreviewSizes = parameters.getSupportedPreviewSizes(); for(int i=0;i<supportedPreviewSizes.size();i++){Log.v("startRecord", "width="+supportedPreviewSizes.get(i).width+";height="+supportedPreviewSizes.get(i).height);}// 設置錄制視頻源為Camera(相機) // mediarecorder.setAudioSource(MediaRecorder.AudioSource.CAMCORDER); mediarecorder.setVideoSource(MediaRecorder.VideoSource.CAMERA);// 設置錄制文件質量,格式,分辨率之類,這個全部包括了 // mediarecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_480P)); //7.43M 10frame // mediarecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_1080P)); //70.94M 10frame // mediarecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_CIF)); // 2.6M 5frame/10frame // mediarecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_QCIF)); //0.76M 30frame 模糊 // mediarecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_QVGA)); //2.1M // mediarecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_CIF)); //不支持 // mediarecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_LOW)); //766KB 還行 比QUALITY_QCIF好 // mediarecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_LOW)); //1M 質量類似LOW // mediarecorder.setProfile(CamcorderProfile.get(CamcorderProfile.QUALITY_TIME_LAPSE_480P)); //480p效果 // mediarecorder.setAudioEncoder(MediaRecorder.AudioEncoder.); // mediarecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264);// boolean isSupQUALITY_TIME_LAPSE_CIF = CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_TIME_LAPSE_CIF); // boolean isSupQUALITY_LOW = CamcorderProfile.hasProfile(CamcorderProfile.QUALITY_LOW); // Log.v("startRecord", "isSupQUALITY_TIME_LAPSE_CIF="+isSupQUALITY_TIME_LAPSE_CIF+";isSupQUALITY_LOW="+isSupQUALITY_LOW); // // mediarecorder.setVideoFrameRate(30);//start實現錄像靜音 mediarecorder.setOutputFormat(MediaRecorder.OutputFormat.MPEG_4); // mediarecorder.setVideoSize(640,480);mediarecorder.setVideoSize(1280,720);//設置編碼比特率,不設置會使視頻圖像模糊 // mediarecorder.setVideoEncodingBitRate(5*1024*1024); //清晰 512*1024(不清楚)mediarecorder.setVideoEncodingBitRate(900*1024); //較為清晰,且文件大小為3.26M(30秒)mediarecorder.setVideoEncoder(MediaRecorder.VideoEncoder.H264); //H263的貌似有點不清晰 // mediarecorder.setVideoFrameRate(10); //設置無效//end mediarecorder.setPreviewDisplay(surfaceHolder.getSurface());// 設置視頻文件輸出的路徑mediarecorder.setOutputFile(Environment.getExternalStorageDirectory().getAbsolutePath() + "/data/data/"+System.currentTimeMillis()+".mp4");try {// 準備錄制 mediarecorder.prepare();// 開始錄制 mediarecorder.start();} catch (Exception e) {e.printStackTrace();}}

一般情況下,我們直接調用 ?mediarecorder 會產生很大的視頻文件,30秒的為70M,因此,我們需要在錄制視頻時盡量控制視頻文件的大小!

mediarecorder.setVideoEncodingBitRate(900*1024); //設置編碼比特率,不設置會使視頻圖像模糊

總結

以上是生活随笔為你收集整理的android开发,静音录制视频,在一般清晰度的前提下保证文件大小越小越好的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。