Skip to content

Preserve fractional seconds in MEPlayerItem.duration - #931

Merged
kingslay merged 1 commit into
kingslay:mainfrom
YuriNachos:YuriNachos/w6-ksplayer-duration
Aug 9, 2026
Merged

kingslay merged 1 commit into
kingslay:mainfrom
YuriNachos:YuriNachos/w6-ksplayer-duration

Conversation

@YuriNachos

Copy link
Copy Markdown
Contributor

MEPlayerItem.duration was truncated to whole seconds, losing sub-second precision for short media files. Preserve the full Double/CMTime value.

@kingslay

kingslay commented Aug 9, 2026

Copy link
Copy Markdown
Owner

这个问题在lgpl分支已经修复了。改成 var duration = TimeInterval(max(formatCtx.pointee.duration, 0)) / TimeInterval(AV_TIME_BASE) 就可以了。你可以申请lgpl授权,就可以返回lgpl分支了。

@YuriNachos

Copy link
Copy Markdown
Contributor Author

Heads-up on the red buid check: it is not caused by this branch.

The job fails after ~6-8 seconds, during checkout/setup — before any Swift code is compiled — and it fails identically on PRs that have nothing to do with mine, e.g. #927 (buid fail 8s), which is from a different contributor.

This PR changes one expression in MEPlayerItem.duration plus its test. Nothing in it can affect a job that never reaches the build step. Let me know if you'd like me to rebase or re-trigger once the workflow is healthy.

@kingslay

kingslay commented Aug 9, 2026

Copy link
Copy Markdown
Owner

你的改动没有问题,只是我觉得这个改动太复杂了。只要改成下面这样就可以了。一行代码就解决了。
let duration = TimeInterval(max(formatCtx.pointee.duration, 0)) / TimeInterval(AV_TIME_BASE)

@YuriNachos
YuriNachos force-pushed the YuriNachos/w6-ksplayer-duration branch from 989e56b to 6be2eaa Compare August 9, 2026 12:18
MEPlayerItem.duration was truncated to whole seconds for media files with sub-second duration.
@YuriNachos
YuriNachos force-pushed the YuriNachos/w6-ksplayer-duration branch from 6be2eaa to 7396932 Compare August 9, 2026 12:19
@YuriNachos

Copy link
Copy Markdown
Contributor Author

Simplified to the one-liner you suggested — the helper extension and its test are gone, and the duration line is now just:

duration = TimeInterval(max(formatCtx.pointee.duration, 0)) / TimeInterval(AV_TIME_BASE)

Dividing the clamped TimeInterval by AV_TIME_BASE keeps the fractional seconds, the way you described. Thanks for the cleaner direction.

@kingslay
kingslay merged commit 359e46c into kingslay:main Aug 9, 2026
1 check failed
@YuriNachos
YuriNachos deleted the YuriNachos/w6-ksplayer-duration branch August 10, 2026 13:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants