â €
Looking for a powerful camera library to take videos? Take a look at our CameraView.
Need support, consulting, or have any other business-related question? Feel free to get in touch.
Like the project, make profit from it, or simply want to thank back? Please consider sponsoring me!
Transcoder
Transcodes and compresses video files into the MP4 format, with audio support, using hardware-accelerated Android codecs available on the device. Works on API 18+.
implementation 'com.otaliastudios:transcoder:0.10.5'
- Fast transcoding to AAC/AVC
- Hardware accelerated
- Convenient, fluent API
- Thumbnails support
- Concatenate multiple video and audio tracks [docs]
- Clip or trim video segments [docs]
- Choose output size, with automatic cropping [docs]
- Choose output rotation [docs]
- Choose output speed [docs]
- Choose output frame rate [docs]
- Choose output audio channels [docs]
- Choose output audio sample rate [docs]
- Override frames timestamp, e.g. to slow down the middle part of the video [docs]
- Error handling [docs]
- Configurable validators to e.g. avoid transcoding if the source is already compressed enough [docs]
- Configurable video and audio strategies [docs]
â €
â €
This project started as a fork of ypresto/android-transcoder. With respect to the source project, which misses most of the functionality listed above, we have also fixed a huge number of bugs and are much less conservative when choosing options that might not be supported. The source project will always throw - for example, accepting only 16:9, AVC Baseline Profile videos - we prefer to try and let the codec fail if it wants to.
Support
If you like the project, make profit from it, or simply want to thank back, please consider sponsoring me through the GitHub Sponsors program! You can have your company logo here, get private support hours or simply help me push this forward.
Transcoder is trusted and supported by ShareChat, a social media app with over 100 million downloads.
Feel free to contact me for support, consulting or any other business-related question.
Setup
Please read the official website for setup instructions and documentation. You might also be interested in our changelog. Using Transcoder is extremely simple:
Transcoder.into(filePath)
.addDataSource(context, uri) // or...
.addDataSource(filePath) // or...
.addDataSource(fileDescriptor) // or...
.addDataSource(dataSource)
.setListener(new TranscoderListener() {
public void onTranscodeProgress(double progress) {}
public void onTranscodeCompleted(int successCode) {}
public void onTranscodeCanceled() {}
public void onTranscodeFailed(@NonNull Throwable exception) {}
}).transcode()
Take a look at the demo app for a complete example.