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

Specific MPEG-TS video, getDuration returns TIME_UNSET #8571

Closed
moneytoo opened this issue Feb 9, 2021 · 2 comments
Closed

Specific MPEG-TS video, getDuration returns TIME_UNSET #8571

moneytoo opened this issue Feb 9, 2021 · 2 comments
Assignees
Labels

Comments

@moneytoo
Copy link
Contributor

moneytoo commented Feb 9, 2021

When I play LG Demo DolbyVision Trailer (from kodi.wiki samples), SimpleExoPlayer.getDuration() returns C.TIME_UNSET. This causes PlayerView to show video duration as 00:00 and prevents scrubbing.

Even though the filename ends with .mkv, it's a MPEG-TS container. (The same video is also shared elsewhere, with the correct extension.)

Player using platform MediaPlayer reports the correct duration (of ~ 1 min 20 s).

  • ExoPlayer version number: 2.13.0
  • Android version: 10
  • Android device: OnePlus 7

BTW: The Files by Google app also reports incorrect duration (of -2562047:47:17).

@kim-vde
Copy link
Contributor

kim-vde commented Feb 10, 2021

To be more efficient, ExoPlayer does not parse the whole media file before starting media. Instead, to compute the duration, it scans the last bytes of the media to get the last PCR value, then it scans the first bytes to have the first PCR value and finally it computes the duration based on the difference between the last and first PCR values (see TsDurationReader.java). Also for performance reasons, the number of bytes to scan at the start and end of the file is limited and, if one of the PCR values was not found, the duration is set to C.TIME_UNSET.

That's what's happening in your case. To prevent that, you can set the maximum number of bytes to search by customizing the extractors factory and setting the desired value for DefaultExtractorsFactory.setTsExtractorTimestampSearchBytes() (the value 1500 * TsExtractor.TS_PACKET_SIZE = 282000 works for the content you provided for example).

@moneytoo
Copy link
Contributor Author

Thank you for your detailed and exhausting answer. Suggested solution works.

@google google locked and limited conversation to collaborators Apr 12, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants