Page 1 of 1
upload video and ffmpeg
Posted: Mon Sep 25, 2006 12:54 pm
by ansa
Hi,
1) I have a website that will enable a user to upload a video. So far, in my test environment, I've used move_uploaded_file function, but I want to be able to restrict the extensions, only wmv and mov (or any other types later).
Is there a best way to upload a video and check if it's really a video file?
2) I've browsed around this forum and found a topic about ffmpeg, but unfortunately there are no further explanations. All I know that we use ffmpeg so that the video link will display a screenshot automatically on the website. How to this?
Thanks!
Posted: Mon Sep 25, 2006 2:52 pm
by thomas777neo
about the restriction of file types, i use the following piece of code to check for valid image types:
Code: Select all
// an array of valid file types allowed
$valid_image_types = array("jpg","jpeg","gif","png","bmp"); // uploadable images
if (!in_array(strtolower($_FILES["{$var_prefix}icon"]["type"]),$valid_files_image_types))
{
$icon_message = "Invalid Image Type: ".$_FILES["{$var_prefix}icon"]["type"]." ".$_FILES["{$var_prefix}icon"]["error"];
$validation_passed++; // general validation failure
$icon_validation++; // icon validation failure
} // if (!in_array(strtolower($_FILES["{$var_prefix}icon"]["type"]),$valid_files_image_types))
Posted: Mon Sep 25, 2006 2:57 pm
by feyd
Checking the file extension and the type sent by the user isn't very secure, just so you know.
Posted: Mon Sep 25, 2006 3:12 pm
by thomas777neo
feyd: I am always open for correction will would like to know what I can do to make it more secure if you have the time.
Posted: Mon Sep 25, 2006 3:29 pm
by brendandonhue
thomas777neo - The image filetypes you listed can all be checked by getimagesize()
For video files, you can use the ffmpeg-php extension to load the movie then do getFrame(), toGDImage(), and then use imagepng() or imagejpeg(), etc., to get your screenshot into a usable format. You need to have both ffmpeg-php and GD installed to do this.
Posted: Tue Sep 26, 2006 7:06 am
by ansa
That's what I need to know.
What is GD?
Are ffmpeg-php and GD two separate programs, so that I have to install each one by one? What are the latest stable version of both?
Is there a step-by-step instruction how to do this, ideally from the installation to getting a screenshot?
Posted: Tue Sep 26, 2006 4:04 pm
by brendandonhue
You probably already have GD installed. ffmpeg-php has installation instructions on their website.