Skip to content

Commit

Permalink
feat: optimize ffmpeg (rhunk#906)
Browse files Browse the repository at this point in the history
  • Loading branch information
VendorAttestation authored and sn-o-w committed Sep 4, 2024
1 parent f7aa752 commit ced5fcc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ class FFMpegProcessor(
// load ffmpeg native sync to avoid native crash
synchronized(this) { FFmpegKit.listSessions() }
val globalArguments = ArgumentList().apply {
this += "-hwaccel mediacodec" //Use hwaccel If Available
this += "-y"
this += "-threads" to ffmpegOptions.threads.get().toString()
}
Expand All @@ -127,7 +128,7 @@ class FFMpegProcessor(

val outputArguments = ArgumentList().apply {
this += "-preset" to (ffmpegOptions.preset.getNullable() ?: "ultrafast")
this += "-c:v" to (ffmpegOptions.customVideoCodec.get().takeIf { it.isNotEmpty() } ?: "libx264")
this += "-c:v" to (ffmpegOptions.customVideoCodec.get().takeIf { it.isNotEmpty() } ?: "h264_mediacodec")
this += "-c:a" to (ffmpegOptions.customAudioCodec.get().takeIf { it.isNotEmpty() } ?: "copy")
this += "-crf" to ffmpegOptions.constantRateFactor.get().let { "\"$it\"" }
this += "-b:v" to ffmpegOptions.videoBitrate.get().toString() + "K"
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ recyclerview = "1.3.2"
compose-bom = "2024.02.01"
bcprov-jdk18on = "1.77"
dexlib2 = "3.0.5"
ffmpeg-kit = "5.1.LTS" # DO NOT UPDATE FFMPEG-KIT TO "5.1" it breaks stuff :3
ffmpeg-kit = "6.0-2.LTS"
gson = "2.10.1"
junit = "5.10.2"
material3 = "1.2.0"
Expand Down Expand Up @@ -61,4 +61,4 @@ androidLibrary = { id = "com.android.library", version.ref = "agp" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }


[bundles]
[bundles]

0 comments on commit ced5fcc

Please sign in to comment.