OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
cream
/
zvideoAI
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
06/17/2025 10:17:24 AM
rwxrwxr-x
📄
export.php
1.63 KB
05/19/2025 10:07:15 AM
rwxrwxrwx
📁
files
-
01/20/2025 09:45:20 AM
rwxrwxrwx
📄
index.html
3.99 KB
01/20/2025 09:45:19 AM
rw-r--r--
📄
script.js
5.78 KB
01/20/2025 09:45:19 AM
rw-r--r--
📄
styles.css
929 bytes
01/20/2025 09:45:19 AM
rw-r--r--
📄
video_process.php
10.29 KB
05/19/2025 10:07:15 AM
rwxrwxrwx
Editing: video_process.php
Close
<?php function texttovoice($timestamp, $data) { $apiKey = "sk-proj-FrlWqCTIyid7DZGorv0uT3BlbkFJzqrUB0km57kpp4aFPNV7"; $url = "https://api.openai.com/v1/audio/speech"; $payload = array( "model" => "tts-1", "input" => $data, "voice" => "shimmer" ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($payload)); curl_setopt($ch, CURLOPT_HTTPHEADER, array( "Content-Type: application/json", "Authorization: Bearer $apiKey" )); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($ch); if ($response === false) { echo 'cURL Error: ' . curl_error($ch); curl_close($ch); return false; } // Save the response to a file if it's valid $root = $_SERVER['DOCUMENT_ROOT'] . '/audio/_' . $timestamp . 'speech.mp3'; if (file_put_contents($root, $response) === false) { echo 'Failed to save the audio file.'; curl_close($ch); return false; } curl_close($ch); return '/audio/_' . $timestamp . 'speech.mp3'; } function deleteDirectory($dir) { if (!file_exists($dir)) { return false; } if (!is_dir($dir)) { return unlink($dir); } $files = array_diff(scandir($dir), array('.', '..')); foreach ($files as $file) { $filePath = "$dir/$file"; (is_dir($filePath)) ? deleteDirectory($filePath) : unlink($filePath); } return rmdir($dir); } function uploadFiles($fileInputName, $uploadDir = 'uploads/') { // Ensure the upload directory exists and is writable if (!is_dir($uploadDir)) { mkdir($uploadDir, 0755, true); // Create directory if it does not exist } // Check if files are uploaded if (isset($_FILES[$fileInputName])) { $files = $_FILES[$fileInputName]; $results = []; // To collect results or errors foreach ($files['tmp_name'] as $key => $tmpName) { $fileName = basename($files['name'][$key]); $fileTmpName = $files['tmp_name'][$key]; $fileError = $files['error'][$key]; $fileSize = $files['size'][$key]; $fileType = $files['type'][$key]; // Check for upload errors if ($fileError === UPLOAD_ERR_OK) { // Validate file size (e.g., limit to 5MB) $maxFileSize = 5 * 1024 * 1024; // 5MB if ($fileSize > $maxFileSize) { $results[] = "File $fileName is too large."; continue; } // Validate file type (e.g., only allow image files) $allowedTypes = ['image/jpeg', 'image/png', 'image/gif']; if (!in_array($fileType, $allowedTypes)) { $results[] = "File $fileName type is not allowed."; continue; } // Move file to the upload directory $fileDestination = $uploadDir . $fileName; if (move_uploaded_file($fileTmpName, $fileDestination)) { $results[] = "File $fileName uploaded successfully."; } else { $results[] = "Failed to move file $fileName."; } } else { // Handle upload errors $results[] = "Error uploading file $fileName: " . $fileError; } } return $results; // Return an array of results or errors } else { return ["No files were uploaded."]; } } if ($_SERVER['REQUEST_METHOD'] === 'POST') { // Check if files are uploaded if (isset($_FILES['images']) && !empty($_FILES['images']['name'][0])) { $outputDir = 'https://knoblycream.com/videoAI/files/output/'; $tempDir = 'https://knoblycream.com/videoAI/files/temp/'; // Create temporary directory if it does not exist if (!is_dir($tempDir)) { mkdir($tempDir, 0777, true); } $timestamp = time(); $imageFiles = $_FILES['images']; $tempImagePaths = []; $captions = isset($_POST['captions']) ? $_POST['captions'] : []; $audioString = ''; foreach ($captions as $caption) { $audioString .= $caption . ". "; } // Generate audio file (assuming texttovoice() is defined elsewhere) $audioDir = texttovoice($timestamp, $audioString); $durations = isset($_POST['durations']) ? $_POST['durations'] : []; $imageCount = 0; // Debugging: Print file upload errors foreach ($imageFiles['error'] as $error) { if ($error !== UPLOAD_ERR_OK) { echo "File upload error: $error<br>"; } } foreach ($imageFiles['tmp_name'] as $key => $tmpName) { if ($imageFiles['error'][$key] === UPLOAD_ERR_OK) { $fileName = sprintf('image%04d.png', ++$imageCount); $tempImagePath = $tempDir . $fileName; if (move_uploaded_file($tmpName, $tempImagePath)) { $tempImagePaths[] = $tempImagePath; } else { echo "Failed to move uploaded file: $tmpName<br>"; } } else { echo "File upload error: " . $imageFiles['error'][$key] . "<br>"; } } if (!is_array($durations) || count($durations) !== count($tempImagePaths)) { $durations = array_fill(0, count($tempImagePaths), 5); } $listFilePath = $tempDir . 'filelist.txt'; $fileListContent = ''; foreach ($tempImagePaths as $index => $path) { $duration = isset($durations[$index]) ? floatval($durations[$index]) : 5; $fileListContent .= "file '" . $path . "'\n"; $fileListContent .= "duration " . $duration . "\n"; } $fileListContent .= "file '" . $tempImagePaths[count($tempImagePaths) - 1] . "'\n"; $fileListContent .= "duration " . $durations[count($durations) - 1] . "\n"; file_put_contents($listFilePath, $fileListContent); $outputFileName = $timestamp . 'output_video.mp4'; $outputPath = $outputDir . $outputFileName; // FFmpeg command $ffmpegPath = escapeshellcmd('ffmpeg'); $listFilePathEscaped = escapeshellarg($listFilePath); $outputPathEscaped = escapeshellarg($outputPath); $command = "$ffmpegPath -f concat -safe 0 -i $listFilePathEscaped -c:v libx264 -vf scale=1280:720,fps=30,format=yuv420p -vsync vfr $outputPathEscaped"; exec($command . " 2>&1", $outputLog, $returnVar); // Debugging: Print command and output log echo "<br>Command:<br>$command<br>"; echo "<br>Output Log:<br><pre>" . implode("\n", $outputLog) . "</pre>"; // Cleanup // array_map('unlink', $tempImagePaths); // unlink($listFilePath); // deleteDirectory($tempDir); $outputLogString = implode("\n", $outputLog); $videoSourcePath = "/videoAI/files/output/" . $outputFileName; if ($returnVar === 0) { $message = "Video created successfully!"; $videoLink = '<video id="videoPreview" width="640" height="360" controls> <source src="' . $videoSourcePath . '" type="video/mp4"> Your browser does not support the video tag. </video>'; } else { $message = "Failed to create video."; $videoLink = "<pre>$outputLogString</pre>"; } } else { $message = "Error uploading images."; $videoLink = ""; } } else { $message = "Invalid request method."; $videoLink = ""; } // Output the result message and video link // echo $message; // echo $videoLink; ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Video and Audio Result</title> <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/5.3.0/css/bootstrap.min.css"> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/2.11.8/umd/popper.min.js"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/5.3.3/js/bootstrap.min.js"></script> <script src="script.js"></script> </head> <body> <div class="container"> <h1>Generated Video</h1> <!-- <?= $message ?><br> --> <?= $videoLink ?><br> <h1>Generated Audio</h1> <?php if ($audioDir): ?> <audio id="audioPreview" controls> <source src="<?= $audioDir ?>" type="audio/mpeg"> Your browser does not support the audio element... </audio> <?php else: ?> <p>No audio generated.</p> <?php endif; ?><br> <button class="btn btn-primary" onclick="playAll()"> Play all</button> <button class="btn btn-primary" onclick="mergeAudioVideo('<?= $audioDir ?>','<?= $videoSourcePath ?>')"> Merge</button> </div> </body> <script> function mergeAudioVideo(audio, video) { // Create a form element var form = $('<form>', { 'action': 'export.php', 'method': 'post' }); // Append the audio input $('<input>', { 'type': 'hidden', 'name': 'audio', 'value': audio }).appendTo(form); // Append the video input $('<input>', { 'type': 'hidden', 'name': 'video', 'value': video }).appendTo(form); // Append the form to the body and submit it form.appendTo('body').submit(); } function playAll() { // Get the video and audio elements var video = document.getElementById('videoPreview'); var audio = document.getElementById('audioPreview'); // Play both video and audio video.play(); audio.play(); } </script> </html>