mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-22 04:39:32 +03:00
chore: Update FFmpeg and MPV dependencies
This commit is contained in:
parent
1e3e896ea4
commit
f22276f432
3 changed files with 32 additions and 16 deletions
|
@ -11,7 +11,6 @@ import com.arthenica.ffmpegkit.FFprobeSession
|
||||||
import com.arthenica.ffmpegkit.Level
|
import com.arthenica.ffmpegkit.Level
|
||||||
import com.arthenica.ffmpegkit.LogCallback
|
import com.arthenica.ffmpegkit.LogCallback
|
||||||
import com.arthenica.ffmpegkit.SessionState
|
import com.arthenica.ffmpegkit.SessionState
|
||||||
import com.arthenica.ffmpegkit.StatisticsCallback
|
|
||||||
import com.hippo.unifile.UniFile
|
import com.hippo.unifile.UniFile
|
||||||
import com.jakewharton.rxrelay.PublishRelay
|
import com.jakewharton.rxrelay.PublishRelay
|
||||||
import eu.kanade.domain.items.episode.model.toSEpisode
|
import eu.kanade.domain.items.episode.model.toSEpisode
|
||||||
|
@ -506,23 +505,20 @@ class AnimeDownloader(
|
||||||
}
|
}
|
||||||
|
|
||||||
var duration = 0L
|
var duration = 0L
|
||||||
var nextLineIsDuration = false
|
|
||||||
val logCallback = LogCallback { log ->
|
val logCallback = LogCallback { log ->
|
||||||
if (nextLineIsDuration) {
|
|
||||||
parseDuration(log.message)?.let { duration = it }
|
|
||||||
nextLineIsDuration = false
|
|
||||||
}
|
|
||||||
if (log.message == " Duration: ") nextLineIsDuration = true
|
|
||||||
if (log.level <= Level.AV_LOG_WARNING) log.message?.let { logcat { it } }
|
if (log.level <= Level.AV_LOG_WARNING) log.message?.let { logcat { it } }
|
||||||
}
|
if (duration != 0L && log.message.startsWith("frame=")) {
|
||||||
val statisticsCallback = StatisticsCallback {
|
val outTime = log.message
|
||||||
if (duration > 0L) {
|
.substringAfter("time=", "")
|
||||||
video.progress = (100 * it.time.toLong() / duration).toInt()
|
.substringBefore(" ", "")
|
||||||
|
.let { parseTimeStringToSeconds(it) }
|
||||||
|
if (outTime != null && outTime > 0L) video.progress = (100 * outTime / duration).toInt()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val session = FFmpegSession.create(ffmpegOptions, {}, logCallback, statisticsCallback)
|
val session = FFmpegSession.create(ffmpegOptions, {}, logCallback, {})
|
||||||
|
|
||||||
val inputDuration = getDuration(ffprobeCommand(video.videoUrl!!, headerOptions)) ?: 0F
|
val inputDuration = getDuration(ffprobeCommand(video.videoUrl!!, headerOptions)) ?: 0F
|
||||||
|
duration = inputDuration.toLong()
|
||||||
FFmpegKitConfig.ffmpegExecute(session)
|
FFmpegKitConfig.ffmpegExecute(session)
|
||||||
val outputDuration = getDuration(ffprobeCommand(ffmpegFilename(), null)) ?: 0F
|
val outputDuration = getDuration(ffprobeCommand(ffmpegFilename(), null)) ?: 0F
|
||||||
// allow for slight errors
|
// allow for slight errors
|
||||||
|
@ -541,6 +537,27 @@ class AnimeDownloader(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun parseTimeStringToSeconds(timeString: String): Long? {
|
||||||
|
val parts = timeString.split(":")
|
||||||
|
if (parts.size != 3) {
|
||||||
|
// Invalid format
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return try {
|
||||||
|
val hours = parts[0].toInt()
|
||||||
|
val minutes = parts[1].toInt()
|
||||||
|
val secondsAndMilliseconds = parts[2].split(".")
|
||||||
|
val seconds = secondsAndMilliseconds[0].toInt()
|
||||||
|
val milliseconds = secondsAndMilliseconds[1].toInt()
|
||||||
|
|
||||||
|
(hours * 3600 + minutes * 60 + seconds + milliseconds / 100.0).toLong()
|
||||||
|
} catch (e: NumberFormatException) {
|
||||||
|
// Invalid number format
|
||||||
|
null
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun getFFmpegOptions(video: Video, headerOptions: String, ffmpegFilename: String): Array<String> {
|
private fun getFFmpegOptions(video: Video, headerOptions: String, ffmpegFilename: String): Array<String> {
|
||||||
val subtitleInputs = video.subtitleTracks.joinToString(" ", postfix = " ") {
|
val subtitleInputs = video.subtitleTracks.joinToString(" ", postfix = " ") {
|
||||||
"-i \"${it.url}\""
|
"-i \"${it.url}\""
|
||||||
|
|
|
@ -91,8 +91,8 @@ voyager-transitions = { module = "ca.gosyer:voyager-transitions", version.ref =
|
||||||
|
|
||||||
kotlinter = "org.jmailen.gradle:kotlinter-gradle:3.13.0"
|
kotlinter = "org.jmailen.gradle:kotlinter-gradle:3.13.0"
|
||||||
|
|
||||||
aniyomi-mpv = "com.github.jmir1:aniyomi-mpv-lib:1.8.n"
|
aniyomi-mpv = "com.github.aniyomiorg:aniyomi-mpv-lib:1.10.n"
|
||||||
ffmpeg-kit = "com.github.jmir1:ffmpeg-kit:1.8"
|
ffmpeg-kit = "com.github.jmir1:ffmpeg-kit:1.10"
|
||||||
arthenica-smartexceptions = "com.arthenica:smart-exception-java:0.1.1"
|
arthenica-smartexceptions = "com.arthenica:smart-exception-java:0.1.1"
|
||||||
|
|
||||||
seeker = "io.github.2307vivek:seeker:1.1.1"
|
seeker = "io.github.2307vivek:seeker:1.1.1"
|
||||||
|
|
|
@ -200,8 +200,7 @@ actual class LocalAnimeSource(
|
||||||
val duration = ffProbe.allLogsAsString.trim().toFloat()
|
val duration = ffProbe.allLogsAsString.trim().toFloat()
|
||||||
val second = duration.toInt() / 2
|
val second = duration.toInt() / 2
|
||||||
|
|
||||||
val coverFilename = coverPath.toFFmpegString(context)
|
com.arthenica.ffmpegkit.FFmpegKit.execute("-ss $second -i \"${episodeFilename()}\" -frames:v 1 -update true \"$coverPath\" -y")
|
||||||
com.arthenica.ffmpegkit.FFmpegKit.execute("-ss $second -i \"${episodeFilename()}\" -frames 1 -q:v 2 \"$coverFilename\" -y")
|
|
||||||
|
|
||||||
if (File(coverPath).exists()) {
|
if (File(coverPath).exists()) {
|
||||||
anime.thumbnail_url = coverPath
|
anime.thumbnail_url = coverPath
|
||||||
|
|
Loading…
Reference in a new issue