DasBoot
DasBoot

Reputation: 707

video streaming with php and javascript

hello so i am uploading several files to my apache server through a php script using the following script

$uploaddir = 'photos/';
$file = basename($_FILES['userfile']['name']);
$uploadfile = $uploaddir . $file;
if (move_uploaded_file($_FILES['userfile']['tmp_name'], $uploadfile)) else

what i am aiming to do is for my server to compress and send them to a webpage in order to livestream the videos and delete them accordingly. how would i go around executing and coverting videos to mpeg or h264 format? Also should i redirect the end webpage everytime there is a new video to upload to the server or would long polling with javascript work with this?

Upvotes: 1

Views: 425

Answers (1)

Brad
Brad

Reputation: 163538

To convert your videos, look into FFMPEG. It handles many codecs and container formats. I recommend simply executing it directly with exec(), but there is a PHP extension available as well.

Also, what you are doing now is terribly insecure! Never leave user uploads within the web root... otherwise, they can upload whatever scripts they want to remotely control your server. Never leave the original file names either. Name files something pseudo-random, outside of the web root, with no file name extension. Save the file details, such as original name and content type in a database.

Upvotes: 1

Related Questions