コード例 #1
0
ファイル: function_video.php プロジェクト: ecr007/pr0n
function extract_video_thumbs($video_path, $video_id)
{
    global $config;
    $duration = get_video_duration($video_path, $video_id);
    if ($duration > 180) {
        $ss = 60;
        $step = 5;
    } elseif ($duration > 120) {
        $ss = 15;
        $step = 5;
    } elseif ($duration > 60) {
        $ss = 10;
        $step = 2;
    } else {
        $ss = 1;
        $step = 1;
    }
    $i = 0;
    mkdir($config['TMP_DIR'] . '/thumbs/' . $video_id);
    mkdir($config['TMB_DIR'] . '/' . $video_id);
    while ($i <= 20) {
        $width = $config['img_max_width'];
        $height = $config['img_max_height'];
        if ($i == 0) {
            $width = 320;
            $height = 240;
        }
        if ($config['thumbs_tool'] == 'ffmpeg') {
            $cmd = $config['ffmpeg'] . ' -i ' . $video_path . ' -f image2 -ss ' . $ss . ' -s ' . $width . 'x' . $height . ' -vframes 2 -y ' . $config['TMP_DIR'] . '/thumbs/' . $video_id . '/%08d.jpg';
        } else {
            $cmd = $config['mplayer'] . ' ' . $video_path . ' -ss ' . $ss . ' -nosound -vop scale=' . $width . ':' . $height . ' -vo jpeg:outdir=' . $config['TMP_DIR'] . '/thumbs/' . $video_id . ' -frames 2';
        }
        log_conversion($config['LOG_DIR'] . '/' . $video_id . '.log', $cmd);
        exec($cmd . ' 2>&1', $output);
        log_conversion($config['LOG_DIR'] . '/' . $video_id . '.log', implode("\n", $output));
        if (file_exists($config['TMP_DIR'] . '/thumbs/' . $video_id . '/00000002.jpg')) {
            $src = $config['TMP_DIR'] . '/thumbs/' . $video_id . '/00000002.jpg';
        } else {
            $src = $config['TMP_DIR'] . '/thumbs/' . $video_id . '/00000001.jpg';
        }
        $dst = $i == 0 ? $config['TMB_DIR'] . '/' . $video_id . '/default.jpg' : $config['TMB_DIR'] . '/' . $video_id . '/' . $i . '.jpg';
        log_conversion($config['LOG_DIR'] . '/' . $video_id . '.log', $src . "\n" . $dst);
        copy($src, $dst);
        $ss = $ss + $step;
        if ($ss > $duration) {
            $ss = $ss - $step;
        }
        ++$i;
    }
    @unlink($config['TMP_DIR'] . '/thumbs/' . $video_id);
}
コード例 #2
0
ファイル: function_video.php プロジェクト: humor-zo/chaofan
function extract_video_thumbs($video_path, $video_id)
{
    global $config, $conn;
    // Logfile
    $logfile = $config['LOG_DIR'] . '/' . $video_id . '.thumbs.log';
    @chmod($logfile, 0777);
    @unlink($logfile);
    // Default Thumbs Width & Height
    $thumb_width = $config['img_max_width'];
    $thumb_height = $config['img_max_height'];
    // Get Duration of Video from Database
    $duration = get_video_duration($video_path, $video_id);
    // Only continue if source video exists
    if (file_exists($video_path)) {
        // Temp & Final Thumbnails Directories
        $temp_thumbs_folder = $config['TMP_DIR'] . '/thumbs/' . $video_id;
        $final_thumbs_folder = get_thumb_dir($video_id);
        // Create Thumbs Directories
        @mkdir($temp_thumbs_folder, 0777);
        @mkdir($final_thumbs_folder, 0777);
        // Duration - set se = start/end
        if ($duration > 5) {
            $seconds = $duration - 4;
            $se = 2;
        } elseif ($duration > 3) {
            $seconds = $duration - 2;
            $se = 1;
        } elseif ($duration > 2) {
            $seconds = $duration - 1;
            $se = 0.5;
        } else {
            $seconds = $duration;
            $se = 0;
        }
        // Divided by 20 thumbs
        $timeseg = $seconds / 20;
        // Loop for 20 thumbs
        for ($i = 0; $i <= 20; $i++) {
            if ($i == 0) {
                // Thumbnail Size
                $mplayer_scale = "scale=640:360";
                $ffmpeg_scale = "640x360";
                // Destination
                $final_thumbnail = $final_thumbs_folder . '/default.jpg';
                // Get Seek Time
                $ss = 5 * $timeseg + $se;
            } else {
                // Thumbnail Size
                $mplayer_scale = "scale=" . $thumb_width . ":" . $thumb_height . "";
                $ffmpeg_scale = $thumb_width . "x" . $thumb_height;
                // Destination
                $final_thumbnail = $final_thumbs_folder . '/' . $i . '.jpg';
                // Get Seek Time
                $ss = $i * $timeseg + $se;
            }
            // Work out seconds to hh:mm:ss format
            $hms = "";
            $hours = intval($ss / 3600);
            $hms .= str_pad($hours, 2, "0", STR_PAD_LEFT) . ':';
            $minutes = intval($ss / 60 % 60);
            $hms .= str_pad($minutes, 2, "0", STR_PAD_LEFT) . ':';
            $secs = intval($ss % 60);
            $hms .= str_pad($secs, 2, "0", STR_PAD_LEFT);
            $seek = $hms;
            // Temporary filename convention. used by ffmpeg only.
            $temp_thumbs = $temp_thumbs_folder . '/%08d.jpg';
            // Temporary Thumbnail File
            $temp_thumb_file = $temp_thumbs_folder . '/00000001.jpg';
            // Set Permission and Delete Temporary Thumbnail File
            @chmod($temp_thumb_file, 0777);
            @unlink($temp_thumb_file);
            // Thumbnails extraction commands
            if ($config['thumbs_tool'] == 'ffmpeg') {
                // FFMPEG Command
                $cmd = $config['ffmpeg'] . " -ss " . $seek . " -i '" . $video_path . "' -r 1 -s " . $ffmpeg_scale . " -vframes 1 -an -vcodec mjpeg -y " . $temp_thumbs;
            } else {
                // Mplayer Command
                $cmd = $config['mplayer'] . " -zoom " . $video_path . " -ss " . $seek . " -nosound -frames 1 -vf " . $mplayer_scale . " -vo jpeg:outdir=" . $temp_thumbs_folder;
            }
            // Send data to logfile
            log_conversion($logfile, $cmd);
            // Execute Command
            exec($cmd, $output);
            // Send data to logfile
            log_conversion($logfile, implode("\n", $output));
            // Check if file exists
            if (file_exists($temp_thumb_file)) {
                copy($temp_thumb_file, $final_thumbnail);
                // Set permission
                @chmod($temp_thumb_file, 0777);
            }
        }
        // Delete Temporary Thumbnail
        delete_directory($temp_thumbs_folder);
        // Figure out which was last thumb
        $i = 20;
        // Update Thumbs count in database
        $sql = "UPDATE video SET thumb = '1', thumbs = '" . $i . "' WHERE VID = '" . $video_id . "' LIMIT 1";
        $conn->execute($sql);
    }
    return;
}
コード例 #3
0
ファイル: all.php プロジェクト: humor-zo/chaofan
                } else {
                    extract_video_thumbs($config['IPHONE_DIR'] . '/' . $VID . '.mp4', $VID);
                }
                $_SESSION['message'] = 'Thumbs regenerated successfuly!';
                $remove = '&=regenthumbs&VID=' . $VID;
                VRedirect::go('videos.php?m=' . $module_keep . '&page=' . $page);
                break;
            case 'duration':
                if (file_exists($config['HD_DIR'] . '/' . $VID . '.mp4')) {
                    $duration = get_video_duration($config['HD_DIR'] . '/' . $VID . '.mp4', $VID);
                } elseif (file_exists($config['FLV_DIR'] . '/' . $VID . '.flv')) {
                    $duration = get_video_duration($config['FLV_DIR'] . '/' . $VID . '.flv', $VID);
                } elseif (file_exists($config['FLV_DIR'] . '/' . $VID . '.mp4')) {
                    $duration = get_video_duration($config['FLV_DIR'] . '/' . $VID . '.mp4', $VID);
                } else {
                    $duration = get_video_duration($config['IPHONE_DIR'] . '/' . $VID . '.mp4', $VID);
                }
                $sql = "UPDATE video SET duration = " . $duration . " WHERE VID = " . $VID . " LIMIT 1";
                $conn->execute($sql);
                $_SESSION['message'] = 'Duration regenerated successfuly!';
                $remove = '&=duration&VID=' . $VID;
                VRedirect::go('videos.php?m=' . $module_keep . '&page=' . $page);
                break;
        }
    } else {
        $err = 'Invalid video id. Video does not exist!?';
    }
}
$query = constructQuery($module_keep);
$sql = $query['count'];
$rs = $conn->execute($sql);
コード例 #4
0
ファイル: all.php プロジェクト: ecr007/pr0n
                break;
            case 'activate':
                $sql = "UPDATE video SET active = '1' WHERE VID = '" . mysql_real_escape_string($VID) . "' LIMIT 1";
                $conn->execute($sql);
                send_video_approve_email($VID);
                $messages[] = 'Video activated successfuly!';
                $remove = '&a=activate&VID=' . $VID;
                break;
            case 'regenthumbs':
                extract_video_thumbs($config['BASE_DIR'] . '/media/videos/flv/' . $VID . '.flv', $VID);
                $_SESSION['message'] = 'Thumbs regenerated successfuly!';
                $remove = '&=regenthumbs&VID=' . $VID;
                VRedirect::go('videos.php?m=' . $module_keep . '&page=' . $page);
                break;
            case 'duration':
                $duration = get_video_duration($config['BASE_DIR'] . '/media/videos/flv/' . $VID . '.flv', $VID);
                $sql = "UPDATE video SET duration = " . $duration . " WHERE VID = " . $VID . " LIMIT 1";
                $conn->execute($sql);
                $_SESSION['message'] = 'Duration regenerated successfuly!';
                $remove = '&=duration&VID=' . $VID;
                VRedirect::go('videos.php?m=' . $module_keep . '&page=' . $page);
                break;
        }
    } else {
        $err = 'Invalid video id. Video does not exist!?';
    }
}
$query = constructQuery($module_keep);
$sql = $query['count'];
$rs = $conn->execute($sql);
$total_videos = $rs->fields['total_videos'];
コード例 #5
0
ファイル: video.php プロジェクト: humor-zo/chaofan
         $lx = explode("=", $v);
         $vidinfo[$lx[0]] = $lx[1];
     }
 }
 $duration = $vidinfo['ID_LENGTH'];
 $height = $vidinfo['ID_VIDEO_HEIGHT'];
 $width = $vidinfo['ID_VIDEO_WIDTH'];
 $fps = $vidinfo['ID_VIDEO_FPS'];
 $id_video_format = $vidinfo['ID_VIDEO_FORMAT'];
 $cgi = strpos(php_sapi_name(), 'cgi') ? 'env -i ' : NULL;
 // Proc
 $cmd = $cgi . $config['phppath'] . " " . $config['BASE_DIR'] . "/scripts/convert_videos.php" . " " . $vdoname . " " . $video_id . " " . $vdo_path . "";
 log_conversion($config['LOG_DIR'] . '/' . $video_id . '.log', $cmd);
 $lg = $config['LOG_DIR'] . '/' . $video_id . '.log2';
 run_in_background($cmd . ' > ' . $lg);
 $duration = get_video_duration($vdo_path, $video_id);
 $vkey = substr(md5($video_id), 11, 20);
 $sql = "UPDATE video SET duration = '" . mysql_real_escape_string($duration) . "', vkey = '" . $vkey . "',\n                                            vdoname = '" . mysql_real_escape_string($vdoname) . "', flvdoname = '" . mysql_real_escape_string($flvdoname) . "'\n                           WHERE VID = " . intval($video_id) . " LIMIT 1";
 $conn->execute($sql);
 $video_url = $config['BASE_URL'] . '/video/' . $video_id . '/' . prepare_string($title);
 $video_link = '<a href="' . $video_url . '">' . $video_url . '</a>';
 $sql = "SELECT sv.SUID, s.username, s.email FROM video_subscribe AS sv, signup AS s\n                           WHERE sv.UID = " . $uid . " AND sv.UID = s.UID";
 $rs = $conn->execute($sql);
 if ($conn->Affected_Rows() > 0) {
     $subscribers = $rs->getrows();
     $mail = new VMail();
     $mail->setNoReply();
     $sql = "SELECT * FROM emailinfo WHERE email_id = 'subscribe_email' LIMIT 1";
     $rs = $conn->execute($sql);
     $email_path = $config['BASE_DIR'] . '/templates/' . $rs->fields['email_path'];
     $sender = $anonymous == 'yes' ? 'anonymous' : $_SESSION['username'];