Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.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 用于在firebase存储中上载的视频压缩_Android_Video_Compression_Media Queries_Firebase Storage - Fatal编程技术网

Android 用于在firebase存储中上载的视频压缩

Android 用于在firebase存储中上载的视频压缩,android,video,compression,media-queries,firebase-storage,Android,Video,Compression,Media Queries,Firebase Storage,我正在尝试捕获视频并将其上传到firebase存储中。视频正在上传,但上传时间太长。我想压缩它,然后上传它。有什么建议吗?我尝试过使用“Silicompressor”lib,但它也不起作用。我没有使用任何MediaRecorder类,因此,我想我无法使用android视频压缩sdk。我读过关于使用FFMPEG的书,但这对我来说太难理解了,因为我是个新手。请帮忙。如果这里有人知道一些简单的方法,请指导我。提前谢谢。 我的gradel文件中对SilicCompressor的依赖关系- 编译'com.

我正在尝试捕获视频并将其上传到firebase存储中。视频正在上传,但上传时间太长。我想压缩它,然后上传它。有什么建议吗?我尝试过使用“Silicompressor”lib,但它也不起作用。我没有使用任何MediaRecorder类,因此,我想我无法使用android视频压缩sdk。我读过关于使用FFMPEG的书,但这对我来说太难理解了,因为我是个新手。请帮忙。如果这里有人知道一些简单的方法,请指导我。提前谢谢。 我的gradel文件中对SilicCompressor的依赖关系- 编译'com.iceteck.silicompressorr:silicompressor:2.0' 我不知道该在目的地写些什么以及如何继续。 `

private void startRecording(){
Intent takeVideoIntent=新意图(MediaStore.ACTION\u VIDEO\u CAPTURE);
if(takeVideoIntent.resolveActivity(getPackageManager())!=null){
startActivityForResult(获取视频意图、请求视频捕获);
}
}
@凌驾
ActivityResult上的公共void(int请求代码、int结果代码、意图数据){
if(requestCode==REQUEST\u VIDEO\u CAPTURE&&resultCode==Activity.RESULT\u OK){
filePath=data.getData();
file=Environment.getExternalStorageDirectory().getAbsolutePath();
文件+=“/Videos.mp4”;
}
}
公共无效上传视频(){
//setMessage(“您的文件正在上载…”);
//mProgress.show();
字符串uuid=uuid.randomUUID().toString();
字符串filePath=SiliCompressor.with(this.getApplication()).compressVideo(file.toString(),destinationUrString);
storagereferef=mStorageRef.child(mUserId.child)(“视频”+uuid+“.flv”);
riversRef.putFile(filePath).addOnSuccessListener(新的OnSuccessListener(){
@凌驾
成功时公共无效(UploadTask.TaskSnapshot TaskSnapshot){
//mProgress.disclose();
Uri dUrl=taskSnapshot.getDownloadUrl();
downloadUri=dUrl.toString();
Toast.makeText(getApplicationContext(),“Done..”,Toast.LENGTH_SHORT.show();
警惕();
}
});
}
公众虚空警报(){
AlertDialog AlertDialog=新建AlertDialog.Builder(
VideoFragment.this.create();
{
//设置对话框标题
setTitle(“警报对话框”);
//设置对话框消息
setMessage(“有什么要求吗?”);
alertDialog.setButton(Dialog.BUTTON_“是”,新的DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
uploadbutton=(Button)findViewById(R.id.uploadbutton);
uploadbutton.setEnabled(错误);
uploadbuttonR=(按钮)findViewById(R.id.button4);
uploadbuttonR.setEnabled(真);
reqButton=(按钮)findViewById(R.id.reqButton);
reqButton.setEnabled(真);
//在此处编写代码以调用YES事件
Toast.makeText(getApplicationContext(),“要添加需求,请单击需求”,Toast.LENGTH\u SHORT.show();
}
});
//设置负“否”按钮
alertDialog.setButton(Dialog.BUTTON_否定,“否”,新的DialogInterface.OnClickListener(){
public void onClick(DialogInterface dialog,int which){
//r=“是”;
Toast.makeText(getApplicationContext(),“OK!”,Toast.LENGTH\u SHORT.show();
dialog.cancel();
downloadUriR=“NULL”;
上传用户=新上传(“1001p”,“节能”,下载URI,下载URIR);
dataref.child(mUserId.push().setValue(用户);
//sendmail();
Intent i=newintent(getApplicationContext(),ThanksActivity.class);
星触觉(i);
}
});
alertDialog.show();
}
}

使用此库您使用过吗?来吧,请你指导我如何使用它?是的,我在我的项目中使用了这个库,它的工作音频在这个库的压缩视频中被删除了…如何解决这个问题?
private void startRecording() {
    Intent takeVideoIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
    if (takeVideoIntent.resolveActivity(getPackageManager()) != null) {
        startActivityForResult(takeVideoIntent, REQUEST_VIDEO_CAPTURE);
    }
}

@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
    if (requestCode == REQUEST_VIDEO_CAPTURE && resultCode == Activity.RESULT_OK) {
        filePath = data.getData();
        file= Environment.getExternalStorageDirectory().getAbsolutePath();
        file+= "/Videos.mp4";

    }
}

public void upLoadVideo() {
    //mProgress.setMessage("Your file's uploading... ");
   // mProgress.show();
    String uuid = UUID.randomUUID().toString();
String filePath = SiliCompressor.with(this.getApplication()).compressVideo(file.toString(), destinationUriString);
        StorageReference riversRef = mStorageRef.child(mUserId).child("video" + uuid + ".flv");

    riversRef.putFile(filePath).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
        @Override
        public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
           //  mProgress.dismiss();
            Uri dUrl = taskSnapshot.getDownloadUrl();
            downloadUri = dUrl.toString();

            Toast.makeText(getApplicationContext(), "Done..", Toast.LENGTH_SHORT).show();
            alert();
        }
    });

}


public void alert() {


    AlertDialog alertDialog = new AlertDialog.Builder(
            VideoFragment.this).create();

    {
        // Setting Dialog Title
        alertDialog.setTitle("Alert Dialog");

        // Setting Dialog Message
        alertDialog.setMessage("Any requirments in mind?");
        alertDialog.setButton(Dialog.BUTTON_POSITIVE, "YES", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                uploadbutton = (Button) findViewById(R.id.uploadbutton);
                uploadbutton.setEnabled(false);
                uploadbuttonR = (Button) findViewById(R.id.button4);
                uploadbuttonR.setEnabled(true);
                reqButton = (Button) findViewById(R.id.reqButton);
                reqButton.setEnabled(true);
                // Write your code here to invoke YES event
                Toast.makeText(getApplicationContext(), "To add requirments Click Requiments", Toast.LENGTH_SHORT).show();
            }
        });

        // Setting Negative "NO" Button
        alertDialog.setButton(Dialog.BUTTON_NEGATIVE, "NO", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int which) {
                //r= "yes";
                Toast.makeText(getApplicationContext(), "OK!", Toast.LENGTH_SHORT).show();
                dialog.cancel();
                downloadUriR="NULL";
                Upload user = new Upload("1001p","energysaving", downloadUri,downloadUriR);
                dataref.child(mUserId).push().setValue(user);
               // sendEmail();
                Intent i = new Intent(getApplicationContext(), ThanksActivity.class);
                startActivity(i);
            }
        });

        alertDialog.show();

    }
}