EditedMediaItem.setFrameRate cap stops working after a slower part of a variable-speed SpeedProvider

Aperta
#3,539 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 4 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
57/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Attiva
Stack tecnologico
android, java

Direzione di ricerca

Start by reading SequenceRenderersFactory.TargetFrameRateHelper.onOutputFrameRendered and ExoAssetLoaderVideoRenderer.feedConsumerFromDecoder, where the issue reports the same timestamp-advancement logic in CompositionPlayer and Transformer. Reproduce the variable-speed sequence and count delivered frames per output second. Done means both preview and export stay at or below 30 frames per second across the slow-to-fast transition while steady-speed behavior remains unchanged.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug needs triage
Version

Media3 1.11.0

More version details

Reproduced on 1.11.0 (CompositionPlayer preview and Transformer export). The same code is in main as of 2026-11-12 (read, not run): SequenceRenderersFactory.TargetFrameRateHelper.onOutputFrameRendered and ExoAssetLoaderVideoRenderer.feedConsumerFromDecoder.

Devices that reproduce the issue

Samsung Galaxy S20 (Android 13), Samsung Galaxy S8+ (Android 9)

Devices that do not reproduce the issue

None known

Reproducible in the demo app?

Not tested

Reproduction steps
  1. Create an EditedMediaItem from a 30 fps clip, clipped to its first 8 s, with setSpeed(...) using a variable SpeedProvider: 1x from 0 s, 0.5x from 2 s, 2x from 4 s (original media time), and setFrameRate(30).
  2. Play it in CompositionPlayer and export it with Transformer.
  3. Count the frames the item delivers per second of output time (for example with a pass-through MatrixTransformation in the item's video effects).
Expected result

At most 30 frames per second in every part: 30, 30, 15, 15, 15, 15, 30, 30.

Actual result

30, 30, 15, 15, 15, 15, 60, 60: the 2x part is not capped, in preview and export. With the order reversed (2x first, then 0.5x) the cap works. A short slow part (0.4 s of original time at 0.5x) lets about 0.4 s of the following 2x part through uncapped (24, 36 frames in those seconds).

Cause: the same logic is in SequenceRenderersFactory.TargetFrameRateHelper.onOutputFrameRendered (CompositionPlayer) and ExoAssetLoaderVideoRenderer.feedConsumerFromDecoder (Transformer): after each rendered frame the next expected timestamp is advanced by one step (next + delta), not from the frame's own timestamp. While frames are further apart than one step (a slowed part), the expected timestamp falls behind, so in a following faster part no frame is dropped until it catches up.

Fix we use (patched 1.11.0, measured on the S20, the S8+ and a Galaxy S23 on Android 17): after advancing by one step, if the expected timestamp is still at or before the rendered frame's timestamp, advance it in whole steps until it is past that frame:

nextExpectedUs += deltaUs;
if (nextExpectedUs <= presentationTimeUs) {
  long behindUs = presentationTimeUs - nextExpectedUs;
  nextExpectedUs += (behindUs / deltaUs + 1) * deltaUs;
}

Steady speeds keep the same grid and drop the same frames as before (measured at 2x and 4x); the ramp above gives 30, 30, 15, 15, 15, 15, 30, 30 in preview and export.

Media

Not applicable: any 30 fps H.264 clip reproduces it (ours: 1080x1920, 15.9 s).

Bug Report
  • You will email the zip file produced by adb bugreport to [email protected] after filing this issue.
Lingua principale
Java
Stelle
3.1k
Fork
1k
Merge medio
8g 8h
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di androidx/media

Tutte le issue di androidx/media

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.