Repository navigation
Update ADTS CBR SeekMap end position to last complete frame at EOF - #3576
sahuadarsh0 wants to merge 5 commits into
Conversation
|
Thanks for the fix. The trailing-metadata case passed when I ran the ADTS sources from Could we require |
|
Good catch — updated |
…iling-metadata # Conflicts: # RELEASENOTES.md
…iling-metadata # Conflicts: # RELEASENOTES.md
…iling-metadata # Conflicts: # RELEASENOTES.md
Fixes #3571
Root cause
When constant-bitrate seeking is enabled on
AdtsExtractor,maybeOutputSeekMap()initializesConstantBitrateSeekMapwith the fullinput.getLength(). If the stream ends with non-audio trailing data (such as an APEv2 or ID3v1 tag, or an incomplete trailing frame),AdtsExtractornever refines the seek map whenRESULT_END_OF_INPUTis reached. That leaves the reported duration and seek range inflated by the trailer size, delaying playlist transitions inExoPlayer.In addition, for shorter streams (<
NUM_FRAMES_FOR_AVERAGE_FRAME_SIZE= 1000 frames) that end with trailing metadata,calculateAverageFrameSize()zeroednumValidFramesupon hitting the non-ADTS trailer bytes, disabling CBR seeking altogether.Changes
AdtsReader(getLastAudioSampleEndOffset(), ignoring ID3 metadata samples).endPositionOfLastSampleReadinAdtsExtractor(reset onseek(), mirroringMp3Extractor.maybeUpdateCbrDurationToLastSample()). WhenRESULT_END_OF_INPUTis reached with a finite CBR seek map andendPositionOfLastSampleReadlies betweenfirstFramePositionand the current seek-map end position, re-publish theConstantBitrateSeekMapbounded toendPositionOfLastSampleRead.calculateAverageFrameSize(), keep the computed average when a non-sync word is encountered after at least 4 consecutive valid ADTS frames.sample_cbs_truncated.adts.{0,1,2,3}.dumpto reflect the truncated trailing frame no longer inflating CBR duration, add unit tests inAdtsExtractorNonParameterizedTestcovering short and >1000-frame streams with trailing APEv2 metadata, mid-stream seek before EOF, and seek-past-last-frame without shortening duration, and add aRELEASENOTES.mdentry.Verification
./gradlew :lib-extractor:testDebugUnitTest --tests "androidx.media3.extractor.ts.Adts*"— all passing./gradlew :lib-inspector:testDebugUnitTest --tests "androidx.media3.inspector.MetadataRetrieverTest"— all passingExoPlayerRobolectric playback with the issue's attached01-clean.aac,01-tagged.aac, and02-next.aacfiles (both from start and afterseekTo(0, 12_000)beforeprepare()) confirmed01-tagged.aacrefines from38684 msto30128 ms(matching01-clean.aac) and transitions cleanly to02-next.aac.