android-video-trimmer
android-video-trimmer copied to clipboard
Video is getting stretched in android 12 samsung A 52 device
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?
@PatelJa02 Could you share the code you used to open video trimmer activity. ex:
TrimVideo.activity(String.valueOf(videoUri))
.setHideSeekBar(true)
.start(this,startForResult);
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)
@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)
Sure Let me do it and then give you the update
@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?
@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)
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.
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)