Best approach for timeline preview in a video editor using Media3 CompositionPlayer


I am building an Android video editor with a timeline similar to CapCut. A project can contain:

- Multiple video clips

- Multiple audio tracks playing in parallel

- Text overlays

- Image overlays

The goal is to provide a smooth, real-time preview of the final composition while the user edits the timeline. I initially used Media3's "CompositionPlayer" to preview everything but I ran into several problems:

- Video freezes when switching between clips.

- Poor performance because the "Composition" has to be recreated after almost every editing operation (trim, split, delete, move, etc).

- Random internal exceptions that are difficult to diagnose.

To work around this, I tried a different architecture:

- A single "ExoPlayer" instance for video playback.

- A pool of "ExoPlayer" instances for the audio tracks.

This avoided some of the "CompositionPlayer" issues but introduced new ones. Keeping multiple players synchronized during seeking and timeline scrubbing became very expensive and the audio playback often became choppy or out of sync.

My next attempt was to use:

- One "ExoPlayer" for video.

- One "CompositionPlayer" containing only the audio composition (multiple parallel audio tracks).

However, even with a relatively simple audio-only composition, "CompositionPlayer" still appears unreliable and occasionally throws unexpected exceptions. At this point I am unsure what the recommended architecture is for a professional timeline preview.

My questions are:

1. Is "CompositionPlayer" mature enough for building a production quality video editor preview?

2. How are apps like CapCut, VN, or InShot typically implementing their timeline preview?

3. Is there a recommended Media3 architecture for handling multiple video clips together with parallel audio tracks and overlays during editing?

4. If "CompositionPlayer" is not the right solution, what approach would you recommend for achieving smooth, accurate preview playback?

I'm specifically interested in solutions that provide smooth seeking, accurate synchronization, and good performance while the user is actively editing the timeline.

0
Jul 23 at 3:30 PM
User AvatarKhawar Raza
#android#android-media3

No answer found for this question yet.