Exemple #1
0
/**
 * This function is called after the file is successfully uploaded and added to db
 * This function will create the video thumb
 */
function video2flash_ffmpeg_add_file_data($pic_data)
{
    global $CONFIG;
    $filepath = $pic_data['filepath'];
    $filename = $pic_data['filename'];
    $image = $CONFIG['fullpath'] . $filepath . $filename;
    if (is_movie($image)) {
        preg_match("/(.+)\\.(.*?)\\Z/", $filename, $matches);
        $thumb = $CONFIG['fullpath'] . $filepath . $CONFIG['thumb_pfx'] . $matches[1] . ".jpg";
        $normal = $CONFIG['fullpath'] . $filepath . $CONFIG['normal_pfx'] . $matches[1] . ".jpg";
        $flv = $CONFIG['fullpath'] . $filepath . $matches[1] . ".flv";
        $videoThumb = create_movie_thumb($image);
        $tmpFlv = convert_to_flv($image);
        // If we have the flv file
        if ($tmpFlv) {
            // move it to the final location
            rename($tmpFlv, $flv);
            // Add the fileszie of flv to total filesize
            $pic_data['total_filesize'] += filesize($flv);
        }
        $imagesize = getimagesize($videoThumb);
        if ($videoThumb) {
            if (!resize_image($videoThumb, $thumb, $CONFIG['thumb_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'])) {
                // If resize fails then we are not doing anything as the file is already uploaded and if no video thumb is created then nothing should be done.
            } else {
                // Also create a normal size image to show as a preview in flash player
                if (resize_image($videoThumb, $normal, $CONFIG['video2flash_ffmpeg_player_width'], $CONFIG['thumb_method'], $CONFIG['thumb_use'])) {
                    // Add the filesize of normal to the total filesize
                    $pic_data['total_filesize'] += filesize($normal);
                }
                $pic_data['pwidth'] = $imagesize[0];
                $pic_data['pheight'] = $imagesize[1];
                $pic_data['total_filesize'] += filesize($thumb);
            }
            @unlink($videoThumb);
        } else {
            // If video thumb is not created then proceed and don't stop here. We are not stopping as the file is already uploaded.
        }
    }
    return $pic_data;
}
Exemple #2
0
<video width="320" height="240" controls="controls" autoplay="autoplay">
    <source src="videofilename.mp4" type="video/mp4">
    <object data="" width="320" height="240">
        <embed width="320" height="240" src="videofilename.mp4">
    </object>
</video>




<?php 
//thumb path should be added in the below code
//test for thumb
$dir_img = 'uploads/';
$mediapath = 'videoplayback.MP4';
$file_thumb = create_movie_thumb($dir_img . $mediapath, $mediapath);
$name_file = explode(".", $mediapath);
$imgname = "thumb_" . $name_file[0] . ".jpg";
//// where ffmpeg is located
//$ffmpeg = '/usr/bin/ffmpeg';
////video dir
//$video = 'uploads/videoplayback.MP4';
////where to save the image
//$image = 'uploads/thumbs/image.jpg';
////time to take screenshot at
//$interval = 5;
////screenshot size
//$size = '640x480';
////ffmpeg command
//$cmd = "$ffmpeg -i $video -deinterlace -an -ss $interval -f mjpeg -t 1 -r 1 -y -s $size $image 2>&1";
//var_dump(cmd);