a914-gowtham / android-video-trimmer

Helps to trim local videos with compress option on Android applications using Exoplayer 2 and FFmpeg.
Other
372 stars 117 forks source link

How to send trimmedvideo to server #58

Closed Narendrakumar-Vanamala closed 3 years ago

Narendrakumar-Vanamala commented 3 years ago

I have requirement like need to trimmed video to the server, It would be great help with a piece of code sending trimmed video to the API's.

Is there anyway to attach audio to the trimmed video, if any let me know info on this.

a914-gowtham commented 3 years ago

You could use AWS S3 or Firebase storage. then, use the result url as per your case.

   new Thread(new Runnable() {
            @Override
            public void run() {
                CognitoCachingCredentialsProvider provider = new CognitoCachingCredentialsProvider(
                        context,
                        "your key",
                        Regions.US_WEST_2
                );
                amazonS3Client = new AmazonS3Client(provider);
                String bucket = "your-bucket-name";
                String fileName = currentTime + "/" + currentTime + "." +
                        Utils.getFileExtension(context, selectedVideoUri);
                PutObjectRequest putRequest = new PutObjectRequest(
                        bucket, fileName, new File(videoFilePath));
                putRequest.setCannedAcl(CannedAccessControlList.PublicRead);
                amazonS3Client.putObject(putRequest);
                 String uploadedUrl=amazonS3Client.getUrl(bucket, fileName).toString()
            }
        }).start();

Firebase storage

 private void uploadVideoToStorage(SStorageReference secondFolder, tring currentTime) {
        StorageReference mStorageRef;
        mStorageRef = FirebaseStorage.getInstance().getReference("updates");
        StorageReference secondFolder = mStorageRef.child(currentTime);
        final StorageReference videoRef = secondFolder.child(currentTime + "." +
               "mp4");
        LogMessage.v(currentTime + Utils.getFileExtension(context, selectedVideoUri));
        LogMessage.v("selectedVideoUri22::"+selectedVideoUri);
     UploadTask  uploadTask = videoRef.putFile(Uri.fromFile(new File(String.valueOf(selectedVideoUri))));
        uploadTask.addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
                videoRef.getDownloadUrl().addOnCompleteListener(new OnCompleteListener<Uri>() {
                    @Override
                    public void onComplete(@NonNull Task<Uri> task) {
                        Toast.makeText(context, "Video uploaded", Toast.LENGTH_SHORT).show();
                        String uploadedUrl = task.getResult().toString();
                        Log.d("TAG", "UploadedVideo::" + uploadedUrl);
                      }
                });
            }
        }).addOnProgressListener(new OnProgressListener<UploadTask.TaskSnapshot>() {
            @Override
            public void onProgress(UploadTask.TaskSnapshot taskSnapshot) {
                Log.d("TAG", "" + progress);
            }
        }).addOnFailureListener(new OnFailureListener() {
            @Override
            public void onFailure(@NonNull Exception e) {
                Toast.makeText(context, e.getMessage(), Toast.LENGTH_SHORT).show();
            }
        });

    }
Narendrakumar-Vanamala commented 3 years ago

Thanks a lot Gowtham for the support.

I hope you miss the query am putting, is there any way to add audio file to trimmed video.

Please share me the thoughts on this.

a914-gowtham commented 3 years ago

No, we can't add audio to the video using this library. You can use the FFmpeg library to achieve it.

Narendrakumar-Vanamala commented 3 years ago

Shall I use FFmpeg library and add audio part to this video file.is this correct Gowtham??

On Sat, 10 Jul, 2021, 12:51 pm Gowtham Balamurugan, < @.***> wrote:

No, we can't add audio to the video using this library. You can use the FFmpeg library to achieve it.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/a914-gowtham/android-video-trimmer/issues/58#issuecomment-877586212, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACDM5X2H75AH6GDEJ6PMGILTW7YF5ANCNFSM5ADK77GQ .

a914-gowtham commented 3 years ago

Yes, programmatically you can do it easily using ffmpeg commands. when it comes to handling the audio part by UI like video editing apps it might take some time.

FFmpeg-kit
FFmpeg

Narendrakumar-Vanamala commented 3 years ago

Thanks a lot Gowtham, so let me summarise on this. Video trimming part from camera/gallery I can use this library when ever audio part comes to picture I can use FFfmpeg library and I can achieve it.

Please confirm once for the same

On Sat, 10 Jul, 2021, 1:31 pm Gowtham Balamurugan, @.***> wrote:

Yes, programmatically you can do it easily using ffmpeg commands. when it comes to handling the audio part by UI like video editing apps it might take some time.

FFmpeg-kit https://github.com/tanersener/ffmpeg-kit FFmpeg https://github.com/FFmpeg/FFmpeg

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/a914-gowtham/android-video-trimmer/issues/58#issuecomment-877591842, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACDM5X35FSN5VN7EPOE5WCTTW746DANCNFSM5ADK77GQ .

a914-gowtham commented 3 years ago

yes @Narendrakumar-Vanamala , This library can be only used for video trimming with compression. otherwise, u have to use ffmpeg to create custom video processing

Narendrakumar-Vanamala commented 3 years ago

Am using this library for video processing, for audio processing I can use FFmpeg library and add audio into the video and do the merge processing. I hope this will work right Gowtham ?

On Sat, 10 Jul, 2021, 1:55 pm Narendra Kumar, @.***> wrote:

Thanks a lot Gowtham, so let me summarise on this. Video trimming part from camera/gallery I can use this library when ever audio part comes to picture I can use FFfmpeg library and I can achieve it.

Please confirm once for the same

On Sat, 10 Jul, 2021, 1:31 pm Gowtham Balamurugan, < @.***> wrote:

Yes, programmatically you can do it easily using ffmpeg commands. when it comes to handling the audio part by UI like video editing apps it might take some time.

FFmpeg-kit https://github.com/tanersener/ffmpeg-kit FFmpeg https://github.com/FFmpeg/FFmpeg

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/a914-gowtham/android-video-trimmer/issues/58#issuecomment-877591842, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACDM5X35FSN5VN7EPOE5WCTTW746DANCNFSM5ADK77GQ .

a914-gowtham commented 3 years ago

@Narendrakumar-Vanamala that will work.

Narendrakumar-Vanamala commented 3 years ago

Thanks a lot Gowtham for your support

On Mon, 12 Jul, 2021, 1:15 am Gowtham Balamurugan, @.***> wrote:

@Narendrakumar-Vanamala https://github.com/Narendrakumar-Vanamala that will work.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/a914-gowtham/android-video-trimmer/issues/58#issuecomment-877851066, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACDM5XYEZX5OC475LTBJG3TTXHYEJANCNFSM5ADK77GQ .