Skip to content

Commit

Permalink
Merge pull request #157 from biigle/patch-1
Browse files Browse the repository at this point in the history
Adjust annotated video trySeek again
  • Loading branch information
mzur authored Feb 22, 2024
2 parents 19cc90b + e633a96 commit e34ce93
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/Jobs/ProcessAnnotatedVideo.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected function getVideo($path)
*
* @return \Jcupitt\Vips\Video
*/
protected function getVideoFrame(Video $video, float $time, int $trySeek = 5)
protected function getVideoFrame(Video $video, float $time, int $trySeek = 30)
{
// Sometimes an annotation is near the end of the video (or exactly at the end).
// FFMpeg often returns an empty buffer in this case. If there is an empty frame,
Expand All @@ -122,7 +122,9 @@ protected function getVideoFrame(Video $video, float $time, int $trySeek = 5)
$buffer = $video->frame(TimeCode::fromSeconds($time))
->save(null, false, true);
$trySeek -= 1;
$time = max(0, $time - 0.0333); // Roughly estimated framerate of 30 fps.
// Roughly estimated framerate of 30 fps. With 30 iterations, we seek back up
// to 1 s.
$time = max(0, $time - 0.033333333);
} while (empty($buffer) && $trySeek > 0);

return VipsImage::newFromBuffer($buffer);
Expand Down

0 comments on commit e34ce93

Please sign in to comment.