androidx / media

Jetpack Media3 support libraries for media use cases, including ExoPlayer, an extensible media player for Android
https://developer.android.com/media/media3
Apache License 2.0
1.54k stars 373 forks source link

Wrong Transformer progress calculation if the input is just image with duration #1181

Open landicefu opened 5 months ago

landicefu commented 5 months ago

Version

Media3 main branch

More version details

This is not related to version

Devices that reproduce the issue

This is not related to device

Devices that do not reproduce the issue

This is not related to device

Reproducible in the demo app?

No

Reproduction steps

I am creating video with only images, and the progress calculation is wrong in that case. In TransformerInternal, the progress is based on the average progress of sequenceAssetLoader. However, for sequence that only has image, the progress is jumping from 0 to 100.

The correct progress should be based on the frame count that's already rendered. That is (renderFrameCount / totalFrameCount) or currentPresentationTime / longestSequenceDuration.

See the issue in the following youtube link: In this video, I change the export duration to only 5 seconds, when it's longer the progress is making even less sense. https://youtube.com/shorts/PCSO4bRTQM0

Expected result

Provide a more accurate progress even if the input is just images.

Actual result

The progress jump from 0 to 100 and then I still have to wait for like 30 seconds before my transformation is done.

Media

https://youtube.com/shorts/PCSO4bRTQM0

droid-girl commented 5 months ago

The issue might be related to #1164

tof-tof commented 5 months ago

This was a known part of the the design with image transcoding. Normally the progress updates is based off the duration of the input media as the video frames get loaded and transformed sequentially, but with image input since there is only 1 "frame" to load out of the input media, the loading progress "jumps" from 0 to 100 as the image goes from a "not loaded" state to "loaded". Our progress is divided amongst all the items in the sequence/compositions, so if your not seeing any progress when loading multiple images, then all the images must be loading almost immediately

Right now we don't have a way of signalling the "rendered" frame count (or better yet, the "written" or muxed frame count/presentation time to the asset loaders, but this may be possible with a few changes. The bigger problem is that we don't know the the final frame count or longestSequenceDuration when we first start outputting/writing frames, since video/audio media have intrinsic durations/frameCount that aren't known when we start transformation. I doubt we can make this work for just images giving it need to work for mixed sequences of images and videos as well.