Transcoder
Transcoder copied to clipboard
Output size is 3X larger than the input size
trafficstars
Just like in the title. My very first usage yielded a 6.12mb file from a 2.1mb file
your code please
This is my code where the original size of file is 16 MB After transcoding it is 27 MB and compression is very slow. Am I missing something in my code?
try {
File outputDir = new File(getExternalFilesDir(null), "outputs");
outputDir.mkdir();
mTranscodeOutputFile = File.createTempFile("transcode_test", ".mp4", outputDir);
} catch (IOException e) {
Toast.makeText(this, "Failed to create temporary file.", Toast.LENGTH_LONG).show();
return;
}
String spath = "content://media/external/file/10558"
Transcoder.into( mTranscodeOutputFile.getAbsolutePath())
.addDataSource(this,Uri.parse(spath))
.setListener(new TranscoderListener() {
public void onTranscodeProgress(double progress) {
}
public void onTranscodeCompleted(int successCode) {
}
public void onTranscodeCanceled() {
}
public void onTranscodeFailed(@NonNull Throwable exception)
{
}
}).transcode();
you need to use video strategies. like this...
.setVideoTrackStrategy(
DefaultVideoStrategy.Builder()
.addResizer(PassThroughResizer())
.addResizer(FractionResizer(1F / 3F))
.addResizer(AtMostResizer(500))
.frameRate(24) // .keyFrameInterval(4F)
.build()
)