El Bringy
Intermediate OT User
- Joined
- Jan 5, 2013
- Messages
- 129
- Solutions
- 4
- Reaction score
- 103
dunno if something like that is even possible on cam files, never tried cam files loading.
sudo apt update
sudo apt install ffmpeg
firstI may be mistaken, but I believed you worked with clients and that this might interest you. The purpose is not for players to watch their cams directly through the browser, but for an admin to monitor flagged cams directly in his or her browser instead of downloading cams, but perhaps there are better ways.
I apologize for tagging you; I thought you might find this relevant
sudo apt update
sudo apt install ffmpeg
PHP:
<?php
// Define the directory where your .cam files are stored
$cam_folder = "path/to/cams"; // Replace with your folder path
$converted_folder = "path/to/converted"; // Folder where .mp4 files will be saved
// Ensure the converted folder exists
if (!is_dir($converted_folder)) {
mkdir($converted_folder, 0777, true); // Create the folder if it doesn't exist
}
// Function to get all .cam files from the directory
function get_cam_files($folder) {
$files = [];
if (is_dir($folder)) {
if ($handle = opendir($folder)) {
while (false !== ($file = readdir($handle))) {
// Only add .cam files
if (pathinfo($file, PATHINFO_EXTENSION) == 'cam') {
$files[] = $file;
}
}
closedir($handle);
}
}
return $files;
}
// Function to convert .cam file to .mp4 using FFmpeg
function convert_cam_to_mp4($input_file, $output_file) {
// Command to convert .cam to .mp4 (adjust depending on actual .cam format compatibility with FFmpeg)
$command = "ffmpeg -i " . escapeshellarg($input_file) . " " . escapeshellarg($output_file) . " 2>&1";
// Execute the command and capture the output and status
exec($command, $output, $status);
// Check if conversion was successful
if ($status === 0) {
return true;
} else {
// If there was an error, log or print the output for debugging
error_log("Error converting file: " . implode("\n", $output));
return false;
}
}
// Get all .cam files in the folder
$cam_files = get_cam_files($cam_folder);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Converted CAM Video Files</title>
<style>
video {
width: 600px;
height: auto;
margin-bottom: 20px;
}
</style>
</head>
<body>
<h1>Converted CAM Video Files</h1>
<?php if (empty($cam_files)): ?>
<p>No CAM files found in the directory.</p>
<?php else: ?>
<?php foreach ($cam_files as $cam_file): ?>
<?php
// Define the input and output file paths
$input_file = $cam_folder . '/' . $cam_file;
$output_file = $converted_folder . '/' . pathinfo($cam_file, PATHINFO_FILENAME) . '.mp4';
// Check if the converted file already exists
if (!file_exists($output_file)) {
// Convert the file if it doesn't exist
$conversion_successful = convert_cam_to_mp4($input_file, $output_file);
if (!$conversion_successful) {
echo "<p>Error converting {$cam_file}</p>";
continue;
}
}
?>
<div>
<h3><?php echo htmlspecialchars($cam_file); ?> (Converted)</h3>
<!-- Embed video player for the converted .mp4 file -->
<video controls>
<source src="<?php echo htmlspecialchars($output_file); ?>" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
<?php endforeach; ?>
<?php endif; ?>
</body>
</html>