linkedin / LiTr

Lightweight hardware accelerated video/audio transcoder for Android.
BSD 2-Clause "Simplified" License
613 stars 85 forks source link

Not found resource to use video compress #233

Open SETsachin opened 1 year ago

SETsachin commented 1 year ago

I am trying to use video compress by using Litr library i implement the library i create obj for mediatranformer use the method .transform implement the listner but didnt get how use listner and implement compression

please share any resources

izzytwosheds commented 1 year ago

I think demo app should be helpful. Listener is a very standard listener that calls back with progress and status updates. Usually you would use it to display progress/status of transcoding in UI.

If you are simply compressing video, all you need is a target video format:

val videoFormat = MediaFormat.createVideoFormat(MimeType.VIDEO_AVC, 1280, 720)
    .apply {
        setInteger(MediaFormat.KEY_BIT_RATE, 5_000_000)
        setInteger(MediaFormat.KEY_FRAME_RATE, 30)
    }

mediaTransformer.transform(
    UUID.randomUUID.toString(),
    sourceUri,
    targetFilePath,
    videoFormat,
    null,
    transformationListener,
    null
)