Get a thumbnail of a VDO file.
Here is a PHP code on how to get a thumbnail picture of a VDO file.
It basically uses `ffmpeg` which you need it installed. This works with almost every file including flv.
<?php
function GetThumbnailFileName($FileName, $ScreenShortSecond = 10) {
$VDOLastModifiedDate = filemtime($FileName);
$Thumbnail_FileName = sprintf("%s-(%s::%02d).jpg", $FileName, $VDOLastModifiedDate, $ScreenShortSecond);
if (!file_exists($Thumbnail_FileName)) {
$FFMPEG_Command = sprintf(
"ffmpeg -i \"%s\" -y -ss \"00:00:%02d\" -f image2 \"%s\" > /dev/null 2>&1",
$FileName, 0 + $ScreenShortSecond, $Thumbnail_FileName
);
system($FFMPEG_Command);
}
if (!file_exists($Thumbnail_FileName))
return null;
return $Thumbnail_FileName;
}
$FileName = "Test.flv";
$Thumbnail = GetThumbnailFileName($FileName);
if ($Thumbnail != null)
echo "Thumbnail file is: \"$Thumbnail\"\n";
else echo "Fail creating a Thumbnail of \"$FileName\".";
?>
Enjoy coding.
Categories: Uncategorized


Recent Comments