Skip to content

Conversation

@yujune
Copy link

@yujune yujune commented Apr 23, 2025

Issue

The current startTime and duration values support seconds only; using milliseconds would provide greater precision for trimming.

val startTime = call.argument<Int>("startTime")
val duration = call.argument<Int>("duration")
val startTime = call.argument<Double>("startTime")
val duration = call.argument<Double>("duration")

Choose a reason for hiding this comment

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

@yujune shouldn't this use Long ?

Copy link
Author

Choose a reason for hiding this comment

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

The current startTime and duration values are in seconds. The use of the double type allows for fractional seconds (e.g., 1.5s).
E.g.

 final mediaInfo = await VideoCompress.compressVideo(
      ...
      startTime: 1.5,
      duration: 5.5,
    );

Choose a reason for hiding this comment

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

The problem is that double value is not precise. You are doing decimal math on non decimal double values.

It would be more precise either pass value in milliseconds, or use a string format like ffmpeg is using or something like "01:02.500"

Copy link
Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, I have changed it to milliseconds.

int? startTime,
int? duration,
double? startTime,
double? duration,

Choose a reason for hiding this comment

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

The Dart's int is already 64-bit on all platforms (except web). No need to change it to a floating-point double type

https://stackoverflow.com/a/50429767

@yujune yujune force-pushed the double_type_seconds branch from e79a687 to 371fee1 Compare April 24, 2025 03:43
@yujune yujune force-pushed the double_type_seconds branch from 371fee1 to 74d5c70 Compare April 24, 2025 04:21
@yujune yujune changed the title chore: use double type instead of int for more precise trim. chore: support startTime and duration value in milliseconds Apr 24, 2025
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