/** * 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; }
private function convertVideo($fileName) { $this->load->helper('video'); $outputFile = convert_to_flv($fileName); if ($fileName != $outputFile) { unlink($fileName); } return $outputFile; }