Transcoder icon indicating copy to clipboard operation
Transcoder copied to clipboard

Output size is 3X larger than the input size

Open mukswilly opened this issue 5 years ago • 3 comments
trafficstars

Just like in the title. My very first usage yielded a 6.12mb file from a 2.1mb file

mukswilly avatar Oct 19 '20 12:10 mukswilly

your code please

moxgeek avatar Dec 08 '20 12:12 moxgeek

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();

shianra avatar Oct 19 '21 12:10 shianra

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()
        )

gvravikumar avatar Jan 24 '22 03:01 gvravikumar