upload video and ffmpeg

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
ansa
Forum Commoner
Posts: 31
Joined: Tue Aug 29, 2006 1:58 am
Location: Hamburg, Germany

upload video and ffmpeg

Post 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!
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post 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))
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Checking the file extension and the type sent by the user isn't very secure, just so you know.
User avatar
thomas777neo
Forum Contributor
Posts: 214
Joined: Mon Mar 10, 2003 6:12 am
Location: Johannesburg,South Africa

Post 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.
brendandonhue
Forum Commoner
Posts: 71
Joined: Mon Sep 25, 2006 3:21 pm

Post 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.
ansa
Forum Commoner
Posts: 31
Joined: Tue Aug 29, 2006 1:58 am
Location: Hamburg, Germany

Post 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?
brendandonhue
Forum Commoner
Posts: 71
Joined: Mon Sep 25, 2006 3:21 pm

Post by brendandonhue »

You probably already have GD installed. ffmpeg-php has installation instructions on their website.
Post Reply