parent
00884bb881
commit
c6411b7b79
|
@ -766,12 +766,20 @@ class CameraPreview : ViewGroup, TextureView.SurfaceTextureListener, MyPreview {
|
||||||
try {
|
try {
|
||||||
val videoSize = getCurrentResolution()
|
val videoSize = getCurrentResolution()
|
||||||
mLastVideoPath = mActivity.getOutputMediaFile(false)
|
mLastVideoPath = mActivity.getOutputMediaFile(false)
|
||||||
|
val uri = if (context.isPathOnSD(mLastVideoPath)) {
|
||||||
|
context.getDocumentFile(mLastVideoPath.getParentPath())?.createFile("video/mp4", mLastVideoPath.getFilenameFromPath())!!.uri
|
||||||
|
} else {
|
||||||
|
Uri.fromFile(File(mLastVideoPath))
|
||||||
|
}
|
||||||
|
|
||||||
|
val fileDescriptor = context.contentResolver.openFileDescriptor(uri, "w").fileDescriptor
|
||||||
|
|
||||||
val rotation = mActivity.windowManager.defaultDisplay.rotation
|
val rotation = mActivity.windowManager.defaultDisplay.rotation
|
||||||
mMediaRecorder!!.apply {
|
mMediaRecorder!!.apply {
|
||||||
setAudioSource(MediaRecorder.AudioSource.MIC)
|
setAudioSource(MediaRecorder.AudioSource.MIC)
|
||||||
setVideoSource(MediaRecorder.VideoSource.SURFACE)
|
setVideoSource(MediaRecorder.VideoSource.SURFACE)
|
||||||
setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
|
setOutputFormat(MediaRecorder.OutputFormat.MPEG_4)
|
||||||
setOutputFile(mLastVideoPath)
|
setOutputFile(fileDescriptor)
|
||||||
setVideoEncodingBitRate(10000000)
|
setVideoEncodingBitRate(10000000)
|
||||||
setVideoFrameRate(30)
|
setVideoFrameRate(30)
|
||||||
setVideoSize(videoSize.width, videoSize.height)
|
setVideoSize(videoSize.width, videoSize.height)
|
||||||
|
|
Loading…
Reference in New Issue