Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video is getting stretched in android 12 samsung A 52 device #72

Open
PatelJa02 opened this issue Feb 21, 2022 · 9 comments
Open

Video is getting stretched in android 12 samsung A 52 device #72

PatelJa02 opened this issue Feb 21, 2022 · 9 comments

Comments

@PatelJa02
Copy link

No description provided.

@PatelJa02
Copy link
Author

Hello @a914-gowtham
I am using this library but I am facing the issue with the android 12 device Samsung A52 video is getting stretched after the Can you please help me?

@a914-gowtham
Copy link
Owner

@PatelJa02 Could you share the code you used to open video trimmer activity.
ex:

TrimVideo.activity(String.valueOf(videoUri))
          .setHideSeekBar(true)
          .start(this,startForResult); 

@PatelJa02
Copy link
Author

TrimVideo.activity(fileUri.toString())
.setTrimType(TrimType.MIN_MAX_DURATION)
.setMinToMax(15.toLong(), 60.toLong())
.setCompressOption(
CompressOption().apply {
frameRate = 30
bitRate = 1M
width = 420
height = 360
}
)
.start(this, startForResult)

@a914-gowtham
Copy link
Owner

a914-gowtham commented Feb 21, 2022

@PatelJa02 looks like you pass static height and width cause this issue.
width = 420 height = 360

could you try following snippet. default compress option will use framerate=30, bitRate=1M,
width= if video's width is more than 800 width(high resolution video (ex: taken with camera) ). width is divided by 2 else use the original video's width is used
height= same like video width

TrimVideo.activity(fileUri.toString())
.setTrimType(TrimType.MIN_MAX_DURATION)
.setMinToMax(15.toLong(), 60.toLong())
.setCompressOption(
CompressOption())
.start(this, startForResult)

@PatelJa02
Copy link
Author

Sure Let me do it and then give you the update

@PatelJa02
Copy link
Author

PatelJa02 commented Feb 21, 2022

@a914-gowtham The above code is working fine but the problem with the code is when I record the video of 59 seconds the size of the trimmed video will remain around 100 MB which is throwing out of the memory during the API upload so I need the video size almost near to 1 or 2 MB(Max 7 MB). Can you please help?

@a914-gowtham
Copy link
Owner

@PatelJa02 You can try this. but, I'm not sure about the compressed video quality.

val list= TrimmerUtils.getVideoWidthHeight(this, fileUri.toString()) // will return width and height in a list [width,height]
log.d("TAG","Video width $list[0]")
log.d("TAG","Video height $list[1]")
val reducedWidth= list[0]/3    //check the video size after trimming it. if it is still large try increasing the 3 to 4 and more
val reducedHeight= list[1]/3 //. do the same like width

TrimVideo.activity(fileUri.toString())
.setTrimType(TrimType.MIN_MAX_DURATION)
.setMinToMax(15.toLong(), 60.toLong())
.setCompressOption(
CompressOption().apply {
frameRate = 30
bitRate = 1M.  //you  can try changing bit rate between 500k to 900k 
width = reducedWidth
height = reducedHeight
})
.start(this, startForResult)

@PatelJa02
Copy link
Author

PatelJa02 commented Feb 21, 2022

Thanks for the code, I have checked the above code but again the video is stretched. even tried different alternations with the width and height but still the same.

@PatelJa02
Copy link
Author

Hello @a914-gowtham I have applied the below code and the video is not stretched in the android 11 Samsung A50 device but it's stretched in the android 12 Samsung A52 device.

val list= TrimmerUtils.getVideoWidthHeight(this, fileUri.toString()) // will return width and height in a list [width,height]
log.d("TAG","Video width $list[0]")
log.d("TAG","Video height $list[1]")
val reducedWidth= list[0]/2 //check the video size after trimming it. if it is still large try increasing the 3 to 4 and more
val reducedHeight= list[1]/2 //. do the same like width

TrimVideo.activity(fileUri.toString())
.setTrimType(TrimType.MIN_MAX_DURATION)
.setMinToMax(15.toLong(), 60.toLong())
.setCompressOption(
CompressOption().apply {
frameRate = 30
bitRate = 1M. //you can try changing bit rate between 500k to 900k
width = reducedWidth
height = reducedHeight
})
.start(this, startForResult)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants