Video thumbnails - suggest taking a capture at 1s rather than 0s #4623
EnhancementSometimes the 0s thumbnail produces a blank / black thumbnail - If the video starts with a black frame, a fade-in, or container delays, the thumbnail will end up entirely black. adding the below in app/Image/Handlers/VideoHandler.php seems to have solved the issue: |
Replies: 1 comment 2 replies
|
Worth knowing before this gets patched: Lychee isn't actually aiming at 0s. Both callers of $position = is_numeric($state->photo->aperture) ? floatval($state->photo->aperture) / 2 : 0.0;
$state->source_image = $video_handler->extractFrame($position);Same line in So 0.0 isn't the intended behaviour, it's the fallback when that value isn't numeric. Which means the black thumbnails you're seeing are telling you something more specific than "0s is a bad default" — for those particular videos the duration wasn't available, so the midpoint couldn't be computed and it fell back to the first frame. That makes your fix work, but it sits a layer below where the decision is made. Forcing 1.0 inside $position = is_numeric($state->photo->aperture) ? floatval($state->photo->aperture) / 2 : 1.0;One caveat either way — 1s is still a guess against a container that might have a longer fade. If the duration is known the midpoint is strictly better, so it may be worth checking whether duration is being populated for the videos that misbehave. If it isn't, that's the more useful bug, and the thumbnail is just the visible symptom of it. (Minor thing on the patch as written: |
Here we go: #4624