mirror of
https://github.com/recloudstream/cloudstream.git
synced 2024-08-15 01:53:11 +00:00
Add min frame interval
This commit is contained in:
parent
3d58f6096a
commit
a2e34b6527
1 changed files with 12 additions and 4 deletions
|
@ -17,13 +17,15 @@ internal class ThumbnailSpriteGenerator(
|
||||||
private val callback: ThumbnailSpriteCallback
|
private val callback: ThumbnailSpriteCallback
|
||||||
) {
|
) {
|
||||||
|
|
||||||
private val maxLines = 10
|
private val maxLines: Int = 10
|
||||||
private val maxColumns = 10
|
private val maxColumns: Int = 10
|
||||||
|
|
||||||
|
private val minFrameIntervalSeconds: Int = 10
|
||||||
|
|
||||||
// By setting this here we can use setDataSource once
|
// By setting this here we can use setDataSource once
|
||||||
// This will improve performance, in particular for online videos
|
// This will improve performance, in particular for online videos
|
||||||
// It means that we don't have to seek through the video multiple times, only once
|
// It means that we don't have to seek through the video multiple times, only once
|
||||||
private val retriever = MediaMetadataRetriever()
|
private val retriever: MediaMetadataRetriever = MediaMetadataRetriever()
|
||||||
|
|
||||||
internal fun generateThumbnailSprite() {
|
internal fun generateThumbnailSprite() {
|
||||||
retriever.setDataSource(videoPath)
|
retriever.setDataSource(videoPath)
|
||||||
|
@ -42,7 +44,13 @@ internal class ThumbnailSpriteGenerator(
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
val frameIntervalMillis: Long = videoDuration / (maxLines * maxColumns)
|
val minFrameIntervalMillis: Long = (minFrameIntervalSeconds * 1000).toLong()
|
||||||
|
val maxFrameIntervalMillis: Long = videoDuration / (maxLines * maxColumns)
|
||||||
|
val frameIntervalMillis: Long = if (minFrameIntervalMillis > maxFrameIntervalMillis) {
|
||||||
|
minFrameIntervalMillis
|
||||||
|
} else {
|
||||||
|
maxFrameIntervalMillis
|
||||||
|
}
|
||||||
|
|
||||||
val videoWidth = videoDimensions.first
|
val videoWidth = videoDimensions.first
|
||||||
val videoHeight = videoDimensions.second
|
val videoHeight = videoDimensions.second
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue