Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Playback exception on cmaf vod stream which the first segment have emsg box #1002

Open
1 task
guoen21 opened this issue Jan 19, 2024 · 5 comments
Open
1 task
Assignees
Labels

Comments

@guoen21
Copy link

guoen21 commented Jan 19, 2024

Version

Media3 1.2.0

More version details

No response

Devices that reproduce the issue

samsung SM-S911U1 (RFCW11VVC1X) Android 13

Devices that do not reproduce the issue

No response

Reproducible in the demo app?

Not tested

Reproduction steps

Play a cmaf vod stream which the first segment contains emsg box e.g. the stream have pre-roll ads

Expected result

Start and watch this video normally.

Actual result

For media v1.0.2 it works well and no any exception.
But for media v1.2.0 sometimes we can not start the playback and throws exceiption, sometimes it start normally.
playback exception

I guess this issue will occur when we have pending metadata samples within fmp4 extractor. Our video chunk contain video + emsg samples and audio chuck only contain audio samples. If the audio chuck is extracted first and then no pending metadata (when extract video chuck the timeadjuster had inited), but if the video chuck is extracted first and then we will have pending metadata samples on media3 v1.2.0 (no peding emsg on v1.0.2). I think for the former the playback will be normal but for the latter it will break the playback.

On v1.2.0 for the case video chunk is extracted first, FragmentedMp4Extractor#onEmsgLeafAtomRead() have following logic:

  • commit emsg sample via emsgTrackOutput.sampleData() and then pending emsg to pendingMetadataSampleInfos. The emsgTrackOutput just cache the sample in local buffer, not commit sample to data queue yet.
  • at the time of audio chunk is extracted it will commit the audio samples, and then output all pendingMetadataSampleInfos via emsgTrackOutput.sampleMetadata() with offset. e.g we have 4 pending emsg, and the offset of first emsg is 441.
    Screen Shot 2024-01-19 at 13 30 47
    Here I think we should pass 0 instead of offset to delegate.sampleMetadata() call. It may cause the offset is set to -441 for the first sample of emsg queue and cause the exception while reading emsg samples.

Media

Our stream use ssai ad solution, cmaf drm stream, and diffcult to make it to be public for debug.

Bug Report

@CarlLindqvist
Copy link

@etanmtv
Copy link

etanmtv commented Apr 4, 2024

This issue seems to have been introduced with the Media3 1.1.0 release

@marcbaechinger
Copy link
Contributor

Thanks everyone for reporting! We will look into this.

From the duplicate #1203 and the information here it looks like this was introduced with 1.1.0:

For media v1.0.2 it works well and no any exception.

From #1203:

Issue introduced in: Media3 1.1.0
Not reproducable with: Media3 1.0.0

Note: there is another test stream in #1203 for repro and to verify a fix when available.

@CarlLindqvist
Copy link

The test stream in #1203 is actually the same test stream.

The midrolls trigger the issue consistently, so as soon as you get an ad you should get the index out of bounds error, most probably triggered by the emsg info.

@marcbaechinger
Copy link
Contributor

Thanks! We can repro this with the stream. The analysis from @guoen21 is to the point. When calling sampleMetadata immediately after sampleData, the offset needs to be set to 0 (zero). The code is there since a while and was working because it apparently never happened that multiple EMSG samples were pending. A change shipped with 1.1.0 made this more likely and together this caused the problems starting with 1.1.0.

A fix for this will be referenced here when it lands on GitHub.

copybara-service bot pushed a commit that referenced this issue Apr 9, 2024
When delegating EMSG samples in `HlsSampleStreamWrapper`,
the offset passed into `sampleMetadata(..)` of the delegate
`TrackOutput` must be zero because it is called immediately
after `sampleData(..)` is called.

The condition to trigger this issue is that more than one
metadata samples are pending in `pendingMetadataSampleInfos`
of `FragmentedMp4Extractor` which produces non-zero offsets.

Issue: #1002
Issue: #1203
PiperOrigin-RevId: 623210835
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants