use custom ffmpeg-kit

* player now supports DASH
This commit is contained in:
jmir1 2022-08-13 01:32:01 +02:00
parent e907211b75
commit 30fd48696d
5 changed files with 14 additions and 5 deletions

View File

@ -113,6 +113,7 @@ android {
"**/libavutil.so",
"**/libswresample.so",
"**/libswscale.so",
"**/libc++_shared.so",
))
}
@ -299,6 +300,7 @@ dependencies {
// FFmpeg
implementation(libs.ffmpeg.kit)
implementation(libs.arthenica.smartexceptions)
// mpv-android
implementation(libs.aniyomi.mpv)

View File

@ -17,6 +17,7 @@
-keep,allowoptimization class app.cash.quickjs.** { public protected *; }
-keep,allowoptimization class uy.kohesive.injekt.** { public protected *; }
-keep,allowoptimization class is.xyz.mpv.** { public protected *; }
-keep,allowoptimization class com.arthenica.** { public protected *; }
##---------------Begin: proguard configuration for RxJava 1.x ----------
-dontwarn sun.misc.**

View File

@ -494,11 +494,15 @@ class AnimeDownloader(
}
}
private fun isMpd(video: Video): Boolean {
return video.videoUrl?.toHttpUrl()?.encodedPath?.endsWith(".mpd") ?: false
}
private fun isHls(video: Video): Boolean {
return video.videoUrl?.toHttpUrl()?.encodedPath?.endsWith(".m3u8") ?: false
}
private fun hlsObservable(video: Video, download: AnimeDownload, tmpDir: UniFile, filename: String): Observable<UniFile> {
private fun ffmpegObservable(video: Video, download: AnimeDownload, tmpDir: UniFile, filename: String): Observable<UniFile> {
isFFmpegRunning = true
val headers = video.headers ?: download.source.headers
val headerOptions = headers.joinToString("", "-headers '", "'") { "${it.first}: ${it.second}\r\n" }
@ -568,7 +572,7 @@ class AnimeDownloader(
}
private fun newObservable(video: Video, download: AnimeDownload, tmpDir: UniFile, filename: String): Observable<UniFile> {
return if (isHls(video)) hlsObservable(video, download, tmpDir, filename)
return if (isHls(video) || isMpd(video)) ffmpegObservable(video, download, tmpDir, filename)
else download.source.fetchVideo(video)
.map { response ->
val file = tmpDir.findFile("$filename.tmp") ?: tmpDir.createFile("$filename.tmp")

View File

@ -1352,6 +1352,7 @@ class PlayerActivity :
MPVLib.setOptionString("http-header-fields", httpHeaderString)
headers["user-agent"]?.let { MPVLib.setOptionString("user-agent", it) }
headers["referer"]?.let { MPVLib.setOptionString("referrer", it) }
// need to fix the cache
// MPVLib.setOptionString("cache-on-disk", "yes")
@ -1439,7 +1440,7 @@ class PlayerActivity :
launchUI {
showLoadingIndicator(false)
if (preferences.adjustOrientationVideoDimensions()) {
if (player.videoW!! / player.videoH!! >= 1) {
if ((player.videoW ?: 1) / (player.videoH ?: 1) >= 1) {
this@PlayerActivity.requestedOrientation = preferences.defaultPlayerOrientationLandscape()
switchOrientation(true)
} else {

View File

@ -102,8 +102,9 @@ sqldelight-gradle = { module="com.squareup.sqldelight:gradle-plugin", version.re
junit = "org.junit.jupiter:junit-jupiter:5.8.2"
ffmpeg-kit = "com.arthenica:ffmpeg-kit-https:4.5.1-1.LTS"
aniyomi-mpv = "com.github.jmir1:aniyomi-mpv-lib:1.3"
ffmpeg-kit = "com.github.jmir1:ffmpeg-kit:4.5.1-1.3.LTS"
arthenica-smartexceptions = "com.arthenica:smart-exception-java:0.1.1"
aniyomi-mpv = "com.github.jmir1:aniyomi-mpv-lib:1.4"
[bundles]
reactivex = ["rxandroid", "rxjava", "rxrelay"]