Skip to content

Commit

Permalink
Fix issue where previews for cellphone video were stretched
Browse files Browse the repository at this point in the history
  • Loading branch information
collectiveaccess committed Oct 2, 2024
1 parent 50f4b33 commit e27068a
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion app/lib/Plugins/Media/Video.php
Original file line number Diff line number Diff line change
Expand Up @@ -590,7 +590,10 @@ public function write($filepath, $mimetype, $options=null) {
$preview_height = $this->properties["height"];

if (caMediaPluginFFmpegInstalled() && ($this->media_metadata["mime_type"] != 'application/x-shockwave-flash')) {
caExec(caGetExternalApplicationPath('ffmpeg')." -i ".caEscapeShellArg($this->filepath)." -frames:v 1 -f image2 -ss ".($start_secs)." -t 0.04 -vf \"scale=w={$preview_width}:h={$preview_height}:force_original_aspect_ratio=decrease,pad={$preview_width}:{$preview_height}:(ow-iw)/2:(oh-ih)/2\" -y ".caEscapeShellArg("{$filepath}.{$ext}"). (caIsPOSIX() ? " 2> /dev/null" : ""), $output, $return);
// Pad dimensions should be one more than scale dimensions to deal with rounding issues
$pad_width = $preview_width + 1;
$pad_height = $preview_height + 1;
caExec(caGetExternalApplicationPath('ffmpeg')." -i ".caEscapeShellArg($this->filepath)." -frames:v 1 -f image2 -ss ".($start_secs)." -t 0.04 -vf \"scale=w={$preview_width}:h={$preview_height}:force_original_aspect_ratio=decrease,pad={$pad_width}:{$pad_height}:(ow-iw)/2:(oh-ih)/2\" -y ".caEscapeShellArg("{$filepath}.{$ext}"). (caIsPOSIX() ? " 2> /dev/null" : ""), $output, $return);
$exists = file_exists("{$filepath}.{$ext}");
if (($return < 0) || ($return > 1) || (!$exists || !@filesize("{$filepath}.{$ext}"))) {
if($exists) { @unlink("{$filepath}.{$ext}"); }
Expand Down

0 comments on commit e27068a

Please sign in to comment.