2017-08-10 21 views
2

私はギャラリーから選んだビデオファイルを圧縮しようとしています。それをSiliCompressor(https://github.com/Tourenathan-G5organisation/SiliCompressor)で圧縮し、FirebaseStorageにアップロードします。問題は、圧縮されたビデオのファイルパスが有効でないことです。ビデオを圧縮してFirebaseStorageにアップロードするにはどうすればいいですか?私はどんな助けにもうれしいです、ありがとう。android-ビデオをfirebaseのストレージに圧縮

uploadBtn.setOnClickListener(new View.OnClickListener() { 
     @Override 
     public void onClick(View v) { 
      Intent pickIntent = new Intent(); 
      pickIntent.setAction(Intent.ACTION_GET_CONTENT); 
      pickIntent.setType("video/*"); 
      startActivityForResult(Intent.createChooser(pickIntent, "Pick video"), RC_PICK_VIDEO); 
     } 
    }); 


     @Override 
protected void onActivityResult(int requestCode, int resultCode, final Intent data) { 
    super.onActivityResult(requestCode, resultCode, data); 
    if (requestCode == RC_PICK_VIDEO && resultCode == RESULT_OK && data != null){ 
     final Uri filepath = data.getData(); 
     final String name = "VIDEO" + filepath.getLastPathSegment().toString() + ".mp4"; 

     mDatabaseReference = mDatabase.push(); 

     String compressFilePath = ""; 
     try { 
      compressFilePath = SiliCompressor.with(MainActivity.this).compressVideo(filepath.toString(), mDatabase.toString()); 

     } catch (URISyntaxException e) { 
      e.printStackTrace(); 
      Log.v("Error", e.getMessage()); 
     } 
     StorageReference videoRef = mStorageReference.child(compressFilePath); 

     videoRef.putFile(Uri.parse(compressFilePath)).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() { 
      @Override 
      public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) { 
       Uri downloadedUrl = taskSnapshot.getDownloadUrl(); 

       String url = downloadedUrl.toString(); 

       getDownloadedUrl(url); 

       uploadToDatabase(name, url); 

      } 
     }).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() { 
      @Override 
      public void onProgress(UploadTask.TaskSnapshot taskSnapshot) { 
       int progress = (int) ((100 * taskSnapshot.getBytesTransferred())/taskSnapshot.getTotalByteCount()); 
       Toast.makeText(getApplicationContext(), "Upload is " + progress + "% done", Toast.LENGTH_LONG).show(); 

      } 
     }).addOnFailureListener(new OnFailureListener() { 
      @Override 
      public void onFailure(@NonNull Exception e) { 
       Toast.makeText(getApplicationContext(), "Error: " + e.getMessage(), Toast.LENGTH_LONG).show(); 
       Log.v("Error: ", e.getMessage()); 
      } 
     }); 

    } 
} 

圧縮ビデオの結果ファイルパスが無効です。リンクを開くと、どこに圧縮されたビデオを保存する必要がありますか、何もありません。

そして、私のlogcatは、次のとおりです。

08-10 17:48:49.256 10009-10009/com.example.admin.databaseproject E/tmessages: https:/firechat-99dd1.firebaseio.com/VideoItem/VIDEO_20170810_174849.mp4: open failed: ENOENT (No such file or directory) 
    08-10 17:48:49.256 10009-10009/com.example.admin.databaseproject E/tmessages: time = 0 
    08-10 17:48:49.256 10009-10009/com.example.admin.databaseproject E/ViratPath: /storage/sdcard0/Movies/Instagram/VID_22750407_161649_344.mp4 
    08-10 17:48:49.256 10009-10009/com.example.admin.databaseproject E/ViratPath: https:/firechat-99dd1.firebaseio.com/VideoItem/VIDEO_20170810_174849.mp4 
    08-10 17:48:49.256 10009-10009/com.example.admin.databaseproject E/ViratPath: /storage/sdcard0/Movies/Instagram/VID_22750407_161649_344.mp4 
    08-10 17:48:49.258 10009-10009/com.example.admin.databaseproject E/UploadTask: could not locate file for uploading:https:/firechat-99dd1.firebaseio.com/VideoItem/VIDEO_20170810_174849.mp4 
    08-10 17:48:49.258 10009-10009/com.example.admin.databaseproject E/StorageException: StorageException has occurred. 
                       An unknown error occurred, please check the HTTP result code and inner exception for server response. 
                        Code: -13000 HttpResult: 0 
    08-10 17:48:49.259 10009-10009/com.example.admin.databaseproject E/StorageException: No content provider: https:/firechat-99dd1.firebaseio.com/VideoItem/VIDEO_20170810_174849.mp4 
                       java.io.FileNotFoundException: No content provider: https:/firechat-99dd1.firebaseio.com/VideoItem/VIDEO_20170810_174849.mp4 
                        at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1066) 
                        at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:921) 
                        at android.content.ContentResolver.openInputStream(ContentResolver.java:646) 
                        at com.google.firebase.storage.UploadTask.<init>(Unknown Source) 
                        at com.google.firebase.storage.StorageReference.putFile(Unknown Source) 
                        at com.example.admin.databaseproject.MainActivity.onActivityResult(MainActivity.java:137) 
                        at android.app.Activity.dispatchActivityResult(Activity.java:6235) 
                        at android.app.ActivityThread.deliverResults(ActivityThread.java:3584) 
                        at android.app.ActivityThread.handleSendResult(ActivityThread.java:3631) 
                        at android.app.ActivityThread.access$1300(ActivityThread.java:151) 
                        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1359) 
                        at android.os.Handler.dispatchMessage(Handler.java:102) 
                        at android.os.Looper.loop(Looper.java:135) 
                        at android.app.ActivityThread.main(ActivityThread.java:5268) 
                        at java.lang.reflect.Method.invoke(Native Method) 
                        at java.lang.reflect.Method.invoke(Method.java:372) 
                        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:902) 
                        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:697) 

答えて

0

がAsyncTask

 String compressFilePath = ""; 
    try { 
     compressFilePath = SiliCompressor.with(MainActivity.this).compressVideo(filepath.toString(), mDatabase.toString()); 

    } catch (URISyntaxException e) { 
     e.printStackTrace(); 
     Log.v("Error", e.getMessage()); 
    } 
内部に次のコードを入れて
関連する問題