added mp4 preview image generation

This commit is contained in:
Chris
2018-12-22 17:18:03 +01:00
parent 00580d8bcc
commit 16688fae3c
2 changed files with 23 additions and 1 deletions

View File

@@ -20,10 +20,10 @@ PictShare is a selfhostable, open source image, video and text hosting as well a
- [x] Write permission detection
### Image hosting
- [x] Upload of images
- [ ] Resizing
- [ ] Filters
- [ ] Gif to mp4 conversion
- [x] Upload of images
### Text file hosting
- [x] Upload of text files
@@ -36,6 +36,7 @@ PictShare is a selfhostable, open source image, video and text hosting as well a
### MP4 hosting
- [ ] Resizing
- [x] Preview image generation
- [x] Upload of videos
- [x] Automatic conversion if not mobile friendly or wrong encoder used
- [x] Render template for videos

View File

@@ -14,6 +14,18 @@ class VideoController
if(in_array('raw',$url))
$this->serveMP4($path,$hash);
else if(in_array('preview',$url))
{
$preview = ROOT.DS.'data'.DS.$hash.DS.'preview.jpg';
if(!file_exists($preview))
{
$this->saveFirstFrameOfMP4($path,$preview);
}
header ("Content-type: image/jpeg");
readfile($preview);
}
else if(in_array('download',$url))
{
if (file_exists($path)) {
@@ -174,4 +186,13 @@ class VideoController
unlink(ROOT.DS.'tmp'.DS.$hash.'.txt');
return false;
}
function saveFirstFrameOfMP4($path,$target)
{
$bin = escapeshellcmd(FFMPEG_BINARY);
$file = escapeshellarg($path);
$cmd = "$bin -y -i $file -vframes 1 -f image2 $target";
system($cmd);
}
}