media icon indicating copy to clipboard operation
media copied to clipboard

transformer.getProgress get wrong progress in version 1.3.1/1.4.1 but it play well in version 1.1.1/1.2.1

Open yifanLon opened this issue 1 year ago • 1 comments

Version

Media3 1.4.1

More version details

it can Reproduce bug on version 1.3.1 and 1.4.1

Devices that reproduce the issue

OnePlus PGZ110 running android 14

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

I tried to to use media3 to compress video,and i tried to get compress Progress, it play well on version1.1.1/1.2.1 but on version 1.3.1/1.4.1, the progress seems can't upto 60, when i get probably 60% the transform is complete, and the video compressed is normal. so i tried many video and many times. it reproduce everytime

this is my demo code to reproduce this bug

   String localVideoPath = "/storage/emulated/0/Movies/CameraX-Video/2024-03-01-17-37-18-143.mp4";
    String videoPath = getFilesDir().getAbsolutePath() + File.separator + "outPutVideo"+File.separator + "compressVideo.mp4";
    try {
        File file = new File(videoPath);
        if(file.exists()){
            file.delete();
        }
        if (file.getParent() != null && !new File(file.getParent()).exists()) {
            new File(file.getParent()).mkdirs();
        }
        if (!file.exists()) {
            file.createNewFile();
        }
    }catch (Exception e){}
MediaItem mediaItem = MediaItem.fromUri(localVideoPath);
ImmutableList<AudioProcessor> audioProcessors = ImmutableList.of();
ImmutableList.Builder<Effect> effectBuilder = new ImmutableList.Builder<>();

ScaleAndRotateTransformation scaleAndRotateTransformation = new ScaleAndRotateTransformation.Builder()
        .setScale(0.5f,0.5f)
        .build();
effectBuilder.add(scaleAndRotateTransformation);
//effectBuilder.add(Presentation.createForHeight(1080));
EditedMediaItem editedMediaItem = new EditedMediaItem.Builder(mediaItem).setEffects(new Effects(audioProcessors,effectBuilder.build())).build();
Transformer transformer = new Transformer.Builder(this)
        .addListener(new Transformer.Listener() {
            @Override
            public void onCompleted(Composition composition, ExportResult exportResult) {
                Transformer.Listener.super.onCompleted(composition, exportResult);
                ThreadHelper.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        r.progressBar.setProgress(100);
                    }
                });
            }

            @Override
            public void onError(Composition composition, ExportResult exportResult, ExportException exportException) {
                ThreadHelper.runOnUIThread(new Runnable() {
                    @Override
                    public void run() {
                        Log.d("test2",""+exportResult.exportException.getMessage());
                    
                    }
                });
            }
        }).build();
transformer.start(editedMediaItem,videoPath);

ProgressHolder progressHolder = new ProgressHolder();
mainHandler.post(
        new Runnable() {
            @OptIn(markerClass = UnstableApi.class) @Override
            public void run() {
                @Transformer.ProgressState int progressState = transformer.getProgress(progressHolder);
                updateProgressInUi(progressState, progressHolder);
                if (progressState != PROGRESS_STATE_NOT_STARTED) {
                    mainHandler.postDelayed(/* r= */ this, /* delayMillis= */ 33L);
                }
            }
        });

Expected result

get progress correctly

Actual result

get progress not correct, seems can't up to 60%

Media

Not applicable

Bug Report

  • [X] You will email the zip file produced by adb bugreport to [email protected] after filing this issue.

yifanLon avatar Oct 14 '24 12:10 yifanLon

@yifanLon could you clarify if the output file produced is a valid file. The problem is only in the progress calculation, is it correct?

droid-girl avatar Oct 15 '24 17:10 droid-girl

Hey @yifanLon. We need more information to resolve this issue but there hasn't been an update in 14 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

google-oss-bot avatar Nov 04 '24 02:11 google-oss-bot

Since there haven't been any recent updates here, I am going to close this issue.

@yifanLon if you're still experiencing this problem and want to continue the discussion just leave a comment here and we are happy to re-open this.

google-oss-bot avatar Nov 13 '24 02:11 google-oss-bot