diff options
| author | Lester Caine <lester@lsces.co.uk> | 2026-05-25 12:02:17 +0100 |
|---|---|---|
| committer | Lester Caine <lester@lsces.co.uk> | 2026-05-25 12:02:17 +0100 |
| commit | 76a8a21a09b5fb59e9840521b713d9947c49db19 (patch) | |
| tree | b85a317df1db21164340ed0c57258b976c7f62cf /plugins | |
| parent | 572b562f433532429423a5ccace64838efec93c7 (diff) | |
| download | liberty-76a8a21a09b5fb59e9840521b713d9947c49db19.tar.gz liberty-76a8a21a09b5fb59e9840521b713d9947c49db19.tar.bz2 liberty-76a8a21a09b5fb59e9840521b713d9947c49db19.zip | |
mime.video: add timeout guards and fix short-video offset
- Wrap ffmpegthumbnailer and ffmpeg shell_exec calls with timeout 60
so a hung process doesn't stall gallery-level thumbnail regeneration
- Drop $pOffset default from 60s to 5s so the ffmpeg fallback works
for clips shorter than one minute
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'plugins')
| -rwxr-xr-x | plugins/mime.video.php | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/plugins/mime.video.php b/plugins/mime.video.php index cff98e8..1b108c3 100755 --- a/plugins/mime.video.php +++ b/plugins/mime.video.php @@ -504,7 +504,7 @@ function mime_video_converter( &$pParamHash, $pOnlyGetParameters = false ) { * @access public * @return bool true on success, false on failure */ -function mime_video_create_thumbnail( $pFile, $pOffset = 60 ) { +function mime_video_create_thumbnail( $pFile, $pOffset = 5 ) { global $gBitSystem; $ret = false; if( !empty( $pFile ) && is_file( $pFile )) { @@ -519,8 +519,7 @@ function mime_video_create_thumbnail( $pFile, $pOffset = 60 ) { $ffmpeg = trim( $gBitSystem->getConfig( 'ffmpeg_path', '/usr/bin/ffmpeg') ); if( !empty( $thumbnailer ) && is_executable( $thumbnailer )) { -// shell_exec( "$ffmpeg -i '$pFile' -ss 00:00:05 -vframes 1 -vf \"scale=1024:-1\" '$destPath/thumb.jpg' "); - shell_exec( "$thumbnailer -i '$pFile' -o '$destPath/thumb.jpg' -s 1024" ); + shell_exec( "timeout 60 $thumbnailer -i '$pFile' -o '$destPath/thumb.jpg' -s 1024" ); } if( is_file( "$destPath/thumb.jpg" ) && filesize( "$destPath/thumb.jpg" ) > 1 ) { @@ -533,10 +532,10 @@ function mime_video_create_thumbnail( $pFile, $pOffset = 60 ) { // remove temp file @unlink( "$destPath/thumb.jpg" ); } else { - // fall back to using ffmepg - $ffmpeg_prog = shell_exec( 'which ffmpeg' ); + // fall back to using ffmpeg + $ffmpeg_prog = shell_exec( 'which ffmpeg' ) ?? ''; $ffmpeg = trim( $gBitSystem->getConfig( 'ffmpeg_path', $ffmpeg_prog) ); - shell_exec( "$ffmpeg -i '$pFile' -an -ss $pOffset -t 00:00:01 -r 1 -y '$destPath/preview%d.jpg'" ); + shell_exec( "timeout 60 $ffmpeg -i '$pFile' -an -ss $pOffset -t 00:00:01 -r 1 -y '$destPath/preview%d.jpg'" ); if( is_file( "$destPath/preview1.jpg" )) { $fileHash['type'] = 'image/jpg'; $fileHash['source_file'] = "$destPath/preview1.jpg"; |
