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: - <?php
-
ini_set( "max_execution_time", "3600" ); // sets the maximum execution time of this script to 1 hour.
-
$fileName = $_FILES['audio']['name']; // get client side file name
-
-
-
if( $fileName ) {
-
// Check File Type
-
$fileNameParts = explode( ".", $fileName ); // seperate the name from the ext
-
$fileExtension = end( $fileNameParts ); // part behind last dot
-
$fileExtension = strtolower( $fileExtension ); // reduce to lower case
-
-
if( !$fileExtension == "mpg" && !$fileExtension == "avi" && !$fileExtension == "mpeg" && !$fileExtension == "wmv" && !$fileExtension == "rm" && !$fileExtension == "dat" ) {
-
die( "Invalid Video Format." );
-
}
-
// Check File Size
-
$fileSize = $_FILES['audio']['size']; // size of uploaded file
-
if( $fileSize == 0 ) {
-
-
die( "Sorry. The upload of $fileName has failed. The file size is 0." );
-
} else if( $fileSize > 10240000 ) { //10 MB
-
die( "Sorry. The file $fileName is larger than 10MB. Advice: reduce the file quality and upload again." );
-
-
} else {
-
$uploadDir = 'uploaded/'; // Where the temp file will go
-
$uploadFile = str_replace( " ", "", $uploadDir . $_FILES['audio']['name'] ); // Get rid of spaces in the filename
-
-
$finalDir = 'converted/'; // Where the final file will go
-
$finalFile = str_replace( " ", "", $finalDir . $fileNameParts[0] . ".flv" ); // Get rid of spaces in the filename
-
-
if ( !move_uploaded_file( $_FILES['audio']['tmp_name'], $uploadFile ) ) {
-
echo "Possible file upload attack! Here's some debugging info:\n";
-
echo( $_FILES );
-
}
-
-
-
$encode_cmd = "/usr/bin/ffmpeg -i $uploadFile -acodec mp3 -ar 22050 -ab 32 -f flv -author \"Clip Author\" -copyright \"Clip Copyright\" $finalFile";
-
exec( $encode_cmd );
-
-
unlink( $uploadFile );
-
chmod( $finalFile, 0644 );
-
}
-
}
-
?>
The error: - 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. 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.
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.
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.
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: - $encode_cmd = "ffmpeg -i $uploadFile -acodec mp3 -ar 22050 -ab 32 -f flv -author \"Clip Author\" -copyright \"Clip Copyright\" $finalFile";
Atli 5,058
Expert 4TB
So should I write the following code instead: - $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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
by: Yannick Benoit |
last post by:
anyone knows any other ways that ffmpeg to take screenshots from videos ?
|
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
|
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{...
|
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,...
|
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...
|
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...
|
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,...
|
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:
...
|
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...
|
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...
|
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...
|
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,...
|
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$) {
}
...
|
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...
|
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...
|
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...
|
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...
| |