Skip to content

Commit 371fee1

Browse files
committed
chore: support milliseconds startTime and duration value for precise trim.
1 parent 69c0e3f commit 371fee1

2 files changed

Lines changed: 3 additions & 3 deletions

File tree

android/src/main/kotlin/com/example/video_compress/VideoCompressPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ class VideoCompressPlugin : MethodCallHandler, FlutterPlugin {
139139

140140
val dataSource = if (startTime != null || duration != null){
141141
val source = UriDataSource(context, Uri.parse(path))
142-
TrimDataSource(source, (1000 * 1000 * (startTime ?: 0)).toLong(), (1000 * 1000 * (duration ?: 0)).toLong())
142+
TrimDataSource(source, (1000 * (startTime ?: 0)).toLong(), (1000 * (duration ?: 0)).toLong())
143143
}else{
144144
UriDataSource(context, Uri.parse(path))
145145
}

ios/Classes/SwiftVideoCompressPlugin.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,9 @@ public class SwiftVideoCompressPlugin: NSObject, FlutterPlugin {
188188
Utility.getPathUrl("\(Utility.basePath())/\(Utility.getFileName(path))\(uuid.uuidString).\(sourceVideoType)")
189189

190190
let timescale = sourceVideoAsset.duration.timescale
191-
let minStartTime = Double(startTime ?? 0)
191+
let minStartTime = Double(startTime ?? 0) / 1000.0
192192

193-
let videoDuration = sourceVideoAsset.duration.seconds
193+
let videoDuration = sourceVideoAsset.duration.seconds * 1000.0
194194
let minDuration = Double(duration ?? videoDuration)
195195
let maxDurationTime = minStartTime + minDuration < videoDuration ? minDuration : videoDuration
196196

0 commit comments

Comments
 (0)