File: save.php

Recommend this page to a friend!
  Classes of Andras Toth   Expert JS Camera Capture   save.php   Download  
File: save.php
Role: Auxiliary data
Content type: text/plain
Description: Auxiliary data
Class: Expert JS Camera Capture
Capture video and audio and save to files
Author: By
Last change: Update of save.php
Date: 2 years ago
Size: 1,936 bytes
 

Contents

Class file image Download
<?php if (isset($_FILES["video-blob"]) && isset($_FILES["audio-blob"])) { $video = getcwd() . '/uploads/' . $_POST["video-filename"]; $audio = getcwd() . '/uploads/' . $_POST["audio-filename"]; if (move_uploaded_file($_FILES["audio-blob"]["tmp_name"], $audio) && move_uploaded_file($_FILES["video-blob"]["tmp_name"], $video)) { $mergedFile = getcwd() . '/uploads/' . str_replace('.webm', '', $_POST["video-filename"]) . '-merged.webm'; @unlink($mergedFile); if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') { $cmd = '-i ' . $audio . ' -i ' . $video . ' -map 0:0 -map 1:0 ' . $mergedFile; } else { $cmd = ' -i ' . $audio . ' -i ' . $video . ' -c:v mpeg4 -c:a vorbis -b:v 64k -b:a 12k -strict experimental ' . $mergedFile; } exec('ffmpeg ' . $cmd . ' 2>&1', $out, $ret); if ($ret) { echo path2url($video); } else { echo path2url($mergedFile); @unlink($video); @unlink($audio); } } else { echo ("Problem writing video file to disk!"); } } else if (isset($_FILES["audio-blob"])) { $audio = getcwd() . '/uploads/' . $_POST["audio-filename"]; if (move_uploaded_file($_FILES["audio-blob"]["tmp_name"], $audio)) { echo path2url($audio); } else { echo ("Problem writing video file to disk!"); } } else if (isset($_FILES["video-blob"])) { $video = getcwd() . '/uploads/' . $_POST["video-filename"]; if (move_uploaded_file($_FILES["video-blob"]["tmp_name"], $video)) { echo path2url($video); } else { echo ("Problem writing video file to disk!"); } } function path2url($file, $Protocol = 'http://') { return $Protocol . str_replace(str_replace("\\", '/', $_SERVER['DOCUMENT_ROOT']), $_SERVER['HTTP_HOST'] . '/', str_replace("\\", '/', $file)); }