Skip to content

Migrate mediamp-ffmpeg usage from CLI bridge to structured Kotlin API (v0.1.9)#3006

Open
GeneralK1ng wants to merge 3 commits into
mainfrom
k1ng/updated-mediamp
Open

Migrate mediamp-ffmpeg usage from CLI bridge to structured Kotlin API (v0.1.9)#3006
GeneralK1ng wants to merge 3 commits into
mainfrom
k1ng/updated-mediamp

Conversation

@GeneralK1ng

Copy link
Copy Markdown
Member

What

  • Replace the legacy FFmpegKit.execute(List<String>) CLI bridge with the new typed MediaTranscoder().execute(MediaOperation) API introduced in mediamp 0.1.9.
  • Upgrade mediamp version from 0.1.80.1.9 and switch from local composite build to the published Maven Central artifacts.
  • Fix iOS compilation error (JvmField unresolved reference) and Android packaging conflict (META-INF/native-image/** duplicates).

Where

  • utils/http-downloader/src/commonMain/kotlin/KtorHttpDownloader.ktmergeM3u8Segments() now constructs MediaOperation.Remux instead of a raw argument list; executeFfmpeg(args)executeMediaOperation(operation).
  • utils/http-downloader/src/commonTest/kotlin/KtorHttpDownloaderTest.kt — mock override and assertions updated to match the new MediaOperation shape.
  • gradle/libs.versions.toml, settings.gradle.kts, local.properties — version bump and disable local composite build.
  • app/android/build.gradle.kts — add pickFirsts for META-INF/native-image/**.
  • torrent/anitorrent/src/commonMain/kotlin/session/AnitorrentDownloadSession.kt — restore missing import kotlin.jvm.JvmField.

Why

  • The old FFmpegKit API is a thin CLI wrapper that builds and parses command-line strings internally. The new MediaTranscoder API provides a type-safe, structured interface that is easier to maintain, test, and extend (e.g.
    adding per-stream bitstream filters or custom muxer options without string manipulation).
  • Using the published 0.1.9 release removes the need for a local mediamp checkout, simplifying CI and onboarding.

Related

feat(ffmpeg): migrate from CLI bridge to libav*-based Kotlin API with CLI fallback

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR upgrades mediamp to v0.1.9 and migrates the HTTP downloader’s HLS merge flow from the legacy FFmpegKit.execute(List<String>) CLI-args bridge to the new structured MediaTranscoder().execute(MediaOperation) API, while also addressing platform build/packaging issues introduced by the dependency update.

Changes:

  • Replace raw FFmpeg argument list construction with MediaOperation.Remux + MediaTranscoder execution in KtorHttpDownloader.
  • Update downloader tests to mock/validate MediaOperation instead of CLI args.
  • Bump mediamp to 0.1.9 and add Android/proguard packaging adjustments (META-INF native-image duplicates; JavaCPP dontwarns), plus an iOS-related import fix.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
utils/http-downloader/src/commonMain/kotlin/KtorHttpDownloader.kt Switch HLS segment merging from CLI args to MediaOperation.Remux + MediaTranscoder.
utils/http-downloader/src/commonTest/kotlin/KtorHttpDownloaderTest.kt Update test stubs/assertions to validate MediaOperation.Remux fields instead of arg lists.
torrent/anitorrent/src/commonMain/kotlin/session/AnitorrentDownloadSession.kt Restore kotlin.jvm.JvmField import to fix compilation.
gradle/libs.versions.toml Upgrade mediamp version to 0.1.9.
app/shared/proguard-rules.pro Add -dontwarn rules for JavaCPP-referenced JVM-only classes on Android.
app/android/build.gradle.kts Resolve Android packaging conflict via pickFirsts for META-INF/native-image/**.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

input = localPlaylistFile.absolutePath,
output = finalOutput.inSystem.absolutePath,
allowedExtensions = "ALL",
protocolWhitelist = "file,crypto,data",
Comment on lines 1005 to 1007
logger.info {
"Running FFmpeg merge for ${st.downloadId}: ffmpeg ${ffmpegArgs.joinToString(" ") { it.quoteForLog() }}"
"Running FFmpeg merge for ${st.downloadId}: $operation"
}
Comment on lines +443 to +445
val remux = lastMediaOperation as? MediaOperation.Remux
assertEquals("ALL", remux?.allowedExtensions)
assertEquals("file,crypto,data", remux?.protocolWhitelist)
@StageGuard

Copy link
Copy Markdown
Member

Windows runReleaseDistribute 出现这个问题:

Warning: Could not create an instance of class org.bytedeco.javacpp.presets.javacpp: java.lang.InstantiationException: org.bytedeco.javacpp.presets.javacpp
Warning: Could not create an instance of class org.bytedeco.javacpp.presets.javacpp: java.lang.InstantiationException: org.bytedeco.javacpp.presets.javacpp
Error getting static method ID of org/bytedeco/javacpp/Loader/putMemberOffset

应该是 proguard rules 缺失?

@GeneralK1ng

Copy link
Copy Markdown
Member Author

应该是 proguard rules 缺失?

应该是缺 .dll 解包,尝试最新的构建

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.

3 participants