Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Java压缩从gallery中选择的视频_Java_Android_Video_Compression_Video Compression - Fatal编程技术网

Android Java压缩从gallery中选择的视频

Android Java压缩从gallery中选择的视频,java,android,video,compression,video-compression,Java,Android,Video,Compression,Video Compression,我想选择一个视频并对其进行压缩,以便将其上载到firebase存储 我已经尝试了多个库,但到目前为止还没有成功 我到现在为止所取得的成就 -公开意图 -选择视频 -获取选定的视频uri -将其上载到存储 缺少什么 -在上传之前压缩视频 我试过硅胶压缩机,但在网上找到的东西都不能用 if (data != null) { try { String filePath = SiliCompressor.with(this).compressV

我想选择一个视频并对其进行压缩,以便将其上载到firebase存储

我已经尝试了多个库,但到目前为止还没有成功

我到现在为止所取得的成就

-公开意图 -选择视频 -获取选定的视频uri -将其上载到存储

缺少什么 -在上传之前压缩视频

我试过硅胶压缩机,但在网上找到的东西都不能用

 if (data != null) {

            try {
                String filePath = SiliCompressor.with(this).compressVideo(data.getData(), Environment.getExternalStorageState());


                MediaMetadataRetriever retriever = new MediaMetadataRetriever();
                retriever.setDataSource(this, data.getData());
                String time = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION);
                long timeInMilliSec = Long.parseLong(time);
                long duration = timeInMilliSec / 1000;
                long hours = duration / 3600;
                long minutes = (duration - hours * 3600) / 60;
                long seconds = duration - (hours * 3600 + minutes * 60);

                if (seconds <= 30) {
                    ratio = 1f;
                    rightNavButton.setEnabled(true);
                    rightNavButton.setColorFilter(ContextCompat.getColor(NewPostActivity.this, R.color.AppColor));
                    titleView.setText(R.string.ready_to_share);
                    videoUrl = Uri.parse(filePath);
                } else {
                    Toast.makeText(this, R.string.video_max_length, Toast.LENGTH_SHORT).show();
                }

            } catch (URISyntaxException e) {
                e.printStackTrace();
                Log.d("yyyy", "onActivityResult: " + e.getMessage());
            }
        }
它成功上传 如果我使用上面显示的代码,它将不起作用

E/StorageException: StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response.

E/StorageException: No content provider: mounted/VIDEO_20201003_211227.mp4
java.io.FileNotFoundException: No content provider: mounted/VIDEO_20201003_211227.mp4
videoUrl = data.getData()
E/StorageException: StorageException has occurred.
An unknown error occurred, please check the HTTP result code and inner exception for server response.

E/StorageException: No content provider: mounted/VIDEO_20201003_211227.mp4
java.io.FileNotFoundException: No content provider: mounted/VIDEO_20201003_211227.mp4