@stefanmartin/expo-video-watermark 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -19,6 +19,8 @@ import androidx.media3.effect.StaticOverlaySettings
|
|
|
19
19
|
import androidx.media3.effect.TextureOverlay
|
|
20
20
|
import androidx.media3.transformer.Composition
|
|
21
21
|
import androidx.media3.transformer.EditedMediaItem
|
|
22
|
+
import androidx.media3.transformer.EditedMediaItemSequence
|
|
23
|
+
import androidx.media3.common.C
|
|
22
24
|
import androidx.media3.transformer.Effects
|
|
23
25
|
import androidx.media3.transformer.ExportException
|
|
24
26
|
import androidx.media3.transformer.ExportResult
|
|
@@ -329,27 +331,33 @@ class ExpoVideoWatermarkModule : Module() {
|
|
|
329
331
|
// Step 13: Create media item from video
|
|
330
332
|
val mediaItem = MediaItem.fromUri("file://$cleanVideoPath")
|
|
331
333
|
|
|
332
|
-
// Step 14: Create edited media item
|
|
333
|
-
// This is the modern API for handling HDR in Media3, replacing the deprecated setHdrMode.
|
|
334
|
+
// Step 14: Create edited media item (HDR mode is set on Composition, not EditedMediaItem in 1.9.1+)
|
|
334
335
|
val editedMediaItem = try {
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
builder.setForceHdrToSdrToneMap(true)
|
|
339
|
-
} else {
|
|
340
|
-
Log.d(TAG, "[Step 14] SDR video detected. No tone-mapping needed.")
|
|
341
|
-
}
|
|
342
|
-
builder.build()
|
|
336
|
+
EditedMediaItem.Builder(mediaItem)
|
|
337
|
+
.setEffects(effects)
|
|
338
|
+
.build()
|
|
343
339
|
} catch (e: Exception) {
|
|
344
340
|
scaledWatermark.recycle()
|
|
345
341
|
promise.reject("STEP14_EDITED_MEDIA_ERROR", "[Step 14] Failed to create edited media item: ${e.message}", e)
|
|
346
342
|
return
|
|
347
343
|
}
|
|
348
344
|
|
|
349
|
-
// Step 14b: Create composition
|
|
345
|
+
// Step 14b: Create composition with EditedMediaItemSequence (required in Media3 1.9.1+)
|
|
350
346
|
val composition = try {
|
|
351
|
-
|
|
347
|
+
// Wrap EditedMediaItem in a sequence (must specify track types in 1.9.1+)
|
|
348
|
+
val sequence = EditedMediaItemSequence.Builder(setOf(C.TRACK_TYPE_VIDEO, C.TRACK_TYPE_AUDIO))
|
|
349
|
+
.addItem(editedMediaItem)
|
|
352
350
|
.build()
|
|
351
|
+
|
|
352
|
+
// Build composition with HDR mode if needed
|
|
353
|
+
val compositionBuilder = Composition.Builder(sequence)
|
|
354
|
+
if (isHdr) {
|
|
355
|
+
Log.d(TAG, "[Step 14b] HDR video detected. Applying tone-mapping to composition.")
|
|
356
|
+
compositionBuilder.setHdrMode(Composition.HDR_MODE_TONE_MAP_HDR_TO_SDR_USING_MEDIACODEC)
|
|
357
|
+
} else {
|
|
358
|
+
Log.d(TAG, "[Step 14b] SDR video detected. No tone-mapping needed.")
|
|
359
|
+
}
|
|
360
|
+
compositionBuilder.build()
|
|
353
361
|
} catch (e: Exception) {
|
|
354
362
|
scaledWatermark.recycle()
|
|
355
363
|
promise.reject("STEP14B_COMPOSITION_ERROR", "[Step 14b] Failed to create composition: ${e.message}", e)
|