홈 페이지에는 압축 툴킷이 필요합니다.
1. 그래들
구현 'com.iceteck.silicompressorr:silicompressor:2.2.3'
2. 관련 권한 추가 (휴대폰에서 동적으로 권한을 신청해야 함)
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
3.사용
사용법은 매우 간단합니다. 해당 메소드를 호출하고 파일 경로를 전달하면 압축 후 새 파일의 경로를 얻을 수 있습니다.
<1> 비디오 압축(하위 스레드에서 사용해야 함)
비디오 파일을 압축하고 새 비디오의 파일 경로를 반환합니다(원본 비디오의 videoPath와 압축된 DestinationDirectory가 저장된 폴더에 매개 변수가 전달되고 압축된 이미지의 절대 경로가 반환됩니다). 가로 화면 영상의 outWidth 너비와 outHeight 높이가 더 높으며, 비트레이트(코드 레이트)가 높을수록 데이터 용량이 커지고 볼륨도 커집니다. 일반적으로 450000입니다.
String filePath=SiliCompressor.with(Context).compressVideo(videoPath, DestinationDirectory,outWidth,outHeight,bitrate);
String filePath=SiliCompressor.with(Context).compressVideo(videoPath, DestinationDirectory);默认
<2> 이미지 압축
이미지를 압축하고 새 이미지의 파일 경로를 반환합니다.
String filePath=SiliCompressor.with(Context).compress(imagePath, DestinationDirectory);
이미지를 압축하고 원본 이미지가 삭제되면 새 이미지의 파일 경로를 반환합니다.
String filePath=SiliCompressor.with(Context).compress(imagePath, DestinationDirectory,true);
이미지 드로어블을 압축하고 새 이미지의 파일 경로를 반환합니다.
String filePath=SiliCompressor.with(Context).compress(R.drawable.icon);
이미지를 압축하고 새 이미지의 비트맵 데이터를 반환합니다.
비트맵 imageBitmap=SiliCompressor.with(Context).getCompressBitmap(imagePath);
이미지를 압축하고 원본 이미지를 제거하는 동안 새 이미지의 비트맵 데이터를 반환합니다.
비트맵 imageBitmap=SiliCompressor.with(Context).getCompressBitmap(imagePath,true)
좋아, 우선 이걸 녹음하자!