Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(local): support both time and percent for video thumbnail #7802

Merged
merged 2 commits into from
Jan 10, 2025

Conversation

1024th
Copy link
Contributor

@1024th 1024th commented Jan 9, 2025

The percentage determines the point in the video (as a percentage of the total duration) at which the thumbnail will be generated.

The old implementation selects the 10th frame of the video as its thumbnail, which is typically near the beginning. This approach is not effective for distinguishing videos that have similar starting frames. Using a percentage parameter allows user control over the thumbnail generation point. Users can achieve similar behavior to the old implementation by setting the percentage to 0.

The percentage determines the point in the video (as a percentage of the total duration) at which the thumbnail will be generated.
@Mmx233
Copy link
Contributor

Mmx233 commented Jan 10, 2025

Could you please consider implementing a feature that allows configuration using both frame numbers and percentages? For example, it would be useful to be able to enter a plain number for frames and append a % symbol to indicate a percentage value.

Additionally, given that the integer setting value is ultimately converted to a float64, it would be beneficial to directly accept a float64 in the setting. This would allow users to have more precise control with a single line change of code.

@1024th
Copy link
Contributor Author

1024th commented Jan 10, 2025

I think it may be easier to use if the number represents the time in seconds rather than the frame number. Consider the following config option:

"video_thumb_pos": "Video thumbnail position",
"video_thumb_pos-tips": "The position of the video thumbnail. If the value is a number (integer or floating point), it represents the time in seconds. If the value ends with '%', it represents the percentage of the video duration."

@Mmx233
Copy link
Contributor

Mmx233 commented Jan 10, 2025

I think it may be easier to use if the number represents the time in seconds rather than the frame number. Consider the following config option:

"video_thumb_pos": "Video thumbnail position",
"video_thumb_pos-tips": "The position of the video thumbnail. If the value is a number (integer or floating point), it represents the time in seconds. If the value ends with '%', it represents the percentage of the video duration."

This looks great to me. If floating-point numbers are supported, I believe this would meet the needs of most users.

@1024th
Copy link
Contributor Author

1024th commented Jan 10, 2025

I implemented this feature. If the time in the configuration is longer than the video duration, the seek point will be set to the end of the video. The flag noaccurate_seek is set to address a corner case (see the comment in the code).

@1024th 1024th changed the title feat(local): support percent for video thumbnail feat(local): support both time and percent for video thumbnail Jan 10, 2025
@xhofe xhofe merged commit 31a7470 into AlistGo:main Jan 10, 2025
@Mmx233
Copy link
Contributor

Mmx233 commented Jan 10, 2025

There are two segments of code that are duplicated, and it's unnecessary to parse every time when getting thumbnail. You can add two private field to struct like thumbTokenBucket: a value storages the float number, and a flag determines whether the value represents a percentage or time.

thumbConcurrency int
thumbTokenBucket TokenBucket

By the way, I suggest you provide some test docker images. Refer to the documentation in the PR that has not been merged yet, and bring the ffmpeg build argument:

AlistGo/docs#397

https://deploy-preview-397--alist-doc.netlify.app/guide/install/docker.html#compile-image

docker build -t xhofe/alist:latest-ffmpeg --build-arg INSTALL_FFMPEG=true .

It seems like xhofe has already merged this PR, maybe you can fire a new one or let me write it.

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