473,385 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Uploading Videos

24
Hello everyone I am creating a project which will upload videos and play them. When a user uploads a video it will be convereted into .flv format. But the problem I have not been able to successfully upload and convert the videos. I have getting an error.

My code:
Expand|Select|Wrap|Line Numbers
  1. <?php
  2. ini_set( "max_execution_time", "3600" ); // sets the maximum execution time of this script to 1 hour.
  3. $fileName = $_FILES['audio']['name']; // get client side file name
  4.  
  5.  
  6. if( $fileName ) {
  7.     // Check File Type
  8.     $fileNameParts = explode( ".", $fileName ); // seperate the name from the ext
  9.     $fileExtension = end( $fileNameParts ); // part behind last dot
  10.     $fileExtension = strtolower( $fileExtension ); // reduce to lower case
  11.  
  12.     if( !$fileExtension == "mpg" && !$fileExtension == "avi" && !$fileExtension == "mpeg" && !$fileExtension == "wmv" && !$fileExtension == "rm" && !$fileExtension == "dat" ) {
  13.         die( "Invalid Video Format." );
  14.     }
  15.     // Check File Size
  16.     $fileSize = $_FILES['audio']['size']; // size of uploaded file
  17.     if( $fileSize == 0 ) {
  18.  
  19.         die( "Sorry. The upload of $fileName has failed. The file size is 0." );
  20.     } else if( $fileSize > 10240000 ) { //10 MB
  21.         die( "Sorry. The file $fileName is larger than 10MB. Advice: reduce the file quality and upload again." );
  22.  
  23.     } else {
  24.         $uploadDir = 'uploaded/'; // Where the temp file will go
  25.         $uploadFile = str_replace( " ", "",  $uploadDir . $_FILES['audio']['name'] ); // Get rid of spaces in the filename
  26.  
  27.         $finalDir = 'converted/'; // Where the final file will go
  28.         $finalFile = str_replace( " ", "",  $finalDir . $fileNameParts[0] . ".flv" ); // Get rid of spaces in the filename
  29.  
  30.         if ( !move_uploaded_file( $_FILES['audio']['tmp_name'], $uploadFile ) ) {
  31.             echo "Possible file upload attack!  Here's some debugging info:\n";
  32.             echo( $_FILES );
  33.         }
  34.  
  35.  
  36.         $encode_cmd = "/usr/bin/ffmpeg -i $uploadFile -acodec mp3 -ar 22050 -ab 32 -f flv -author \"Clip Author\" -copyright \"Clip Copyright\" $finalFile";
  37.         exec( $encode_cmd );
  38.  
  39.         unlink( $uploadFile );
  40.         chmod( $finalFile, 0644 );
  41.     }
  42. }
  43. ?>
The error:

Expand|Select|Wrap|Line Numbers
  1. Warning: chmod() [function.chmod]: No such file or directory in C:\wamp\www\Test\test2.php on line
Can someone please help me on this problem. Thanks in advance.
Sep 21 '08 #1
5 1822
Atli
5,058 Expert 4TB
Hi.

One thing that that confuses me... you execute "/usr/bin/ffmpeg" to convert your file, but then you get a warning in a file at "C:/wamp/...".

The first would indicate that you are on a Unix server, but the second a Windows server.

Which is it?

If this is a Windows server, I would guess the command you are executing isn't working, seeing as it is trying to execute a file using a Unix path.
Sep 21 '08 #2
scan87
24
Hi.

One thing that that confuses me... you execute "/usr/bin/ffmpeg" to convert your file, but then you get a warning in a file at "C:/wamp/...".

The first would indicate that you are on a Unix server, but the second a Windows server.

Which is it?

If this is a Windows server, I would guess the command you are executing isn't working, seeing as it is trying to execute a file using a Unix path.
Hello Atli thanks for replying. Yes I am using a Windows server.
Sep 21 '08 #3
Atli
5,058 Expert 4TB
Then that command wouldn't work.

You would have to install and execute a Windows version of the "ffmpeg" application you are trying to use. That command looks like it is meant to be executed on some sort of a Unix server.

You would probably also have to provide absolute paths to the files you want to use in the command, rather than the relative paths you are currently using.
Sep 21 '08 #4
scan87
24
Then that command wouldn't work.

You would have to install and execute a Windows version of the "ffmpeg" application you are trying to use. That command looks like it is meant to be executed on some sort of a Unix server.

You would probably also have to provide absolute paths to the files you want to use in the command, rather than the relative paths you are currently using.
So should I write the following code instead:

Expand|Select|Wrap|Line Numbers
  1. $encode_cmd = "ffmpeg -i $uploadFile -acodec mp3 -ar 22050 -ab 32 -f flv -author \"Clip Author\" -copyright \"Clip Copyright\" $finalFile";
Sep 21 '08 #5
Atli
5,058 Expert 4TB
So should I write the following code instead:

Expand|Select|Wrap|Line Numbers
  1. $encode_cmd = "ffmpeg -i $uploadFile -acodec mp3 -ar 22050 -ab 32 -f flv -author \"Clip Author\" -copyright \"Clip Copyright\" $finalFile";
Does it work?
This is a shell command you are executing, so how it looks will depend on how your OS is configured. I can't tell you exactly what to do because I simply don't know enough about your system.

You need to have the ffmpeg application installed, and you need to call the executable, which means you need to know where it is. If the path to that file is in the PATH variable, then that might indeed work.

And like I said in the previous post, you will need to use absolute paths rather than the relative paths you used in your example.
Sep 21 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: DavidM | last post by:
Hello - I recently purchased Camtasia for our training folks to begin recording videos on how to use various inhouse applications both for our customers and internal users that access our Extranet...
3
by: Yannick Benoit | last post by:
anyone knows any other ways that ffmpeg to take screenshots from videos ?
6
by: poorna | last post by:
hi all, Can any body guide me please how to upload video files using php and how to maintain it? Is there any thing diffrent way to upload a video files? Regards, poorna
8
by: pamelafluente | last post by:
Hi guys, Is it possible to add "onload" (via Javascript) a new class to the <styleheader section? If yes, how would that be done ? <style type="text/css" media="screen"> .NewStyleClass{...
4
by: Wolfgang Draxinger | last post by:
I'm thinking about writing a script to upload videos to sites like YouTube or Google Video, which is usually done by a HTTP POST. The problem is, that videos, by nature are rather big files,...
0
by: clinnebur | last post by:
We have an ASP.NET web application (C#) that copies videos from a CCTV truck to a Linux server. What I am trying to do is convert the .AVI videos(which is how they are created on the truck) to .WMV...
1
by: Faisal Shafiq | last post by:
I want to upload a file direct to the Silverlight Streaming Service from a Web Client such as silverlight application. As per our product requirement we want to upload a .WMV file directly from...
4
by: scan87 | last post by:
Hello everyone...Can someone please, please help me solve a problem I am facing in my project......Basically the project is about uploading videos and viewing them.....When users upload a video (avi,...
5
by: jessy | last post by:
Hi, All i really need help in this, i downloaded a script from "Phpclasses.org" which is called phptube its supposed to upload videos to youtube but this file contains 3 included files called: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.