a914-gowtham / android-video-trimmer

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

Video stretched after trimming #46

Closed braver-tool closed 3 years ago

braver-tool commented 3 years ago

I facing a video stretch issue after trimming the video. It does not occur for all video files, only occurs on some videos. I found one thing for the issue, that is height and width of the video are interchanged, also rotation is changed, after executing the below lines. I've attached a sample video file. The actual width and height are 352 and 640, after trimming the changed as 640 and 340. Please help to fix the issue.

   `MediaMetadataRetriever metaRetriever = new MediaMetadataRetriever();
    metaRetriever.setDataSource(String.valueOf(uri));
    String height = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT);
    String width = metaRetriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH);
    String rotation = retriever.extractMetadata(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION);
    int w = TrimmerUtils.clearNull(width).isEmpty() ? 0 : Integer.parseInt(width);
    int h = Integer.parseInt(height);`

https://user-images.githubusercontent.com/49281317/116427818-fd4e6700-a861-11eb-8cac-9bf9535b209f.mp4

a914-gowtham commented 3 years ago

Can you share the trimOption that you used

braver-tool commented 3 years ago

Am not using any compressOption, TrimOption for that. I just use default options for all like below, TrimVideo.activity(data).setCompressOption(new CompressOption()).start(this);

a914-gowtham commented 3 years ago

Thanks for creating a good issue. It occurs when we try to trim a video that has rotation 90 || 360. I was passing width and height in the ffmpeg command and that's where had to make changes. It has been fixed in the latest release. you could use the implementation 'com.github.a914-gowtham:Android-video-trimmer:1.6.4'

a914-gowtham commented 3 years ago

@braver-tool feel free to open this issue if it does happen again.

VivekThummar52 commented 3 years ago

i just want to ask you one question, don't you think that rotation check will be for 90 and 270, if i'm wrong than please explain me why 90 and 360?

a914-gowtham commented 3 years ago

My bad. that should be 270.

a914-gowtham commented 3 years ago

@braver-tool @VivekThummar52 thanks for mentioning it. I don't know how I was careless. Use this latest version

implementation 'com.github.a914-gowtham:Android-video-trimmer:1.6.5'