Jump to content

Unexpected T_AS


d22552000

Recommended Posts

Hmm how do I include a class:

 

$_mediahandler AS NEW media_handler;

 

that is the line it doesnt like (line 45).  Here is the whole code:

 

<?php
class media_handler
{
function convert_media($filename, $rootpath, $inputpath, $outputpath, $width, $height, $bitrate, $samplingrate)
{
$outfile = "";
$rPath = $rootpath."\ffmpeg";
$size = $width."x".$height;
$outfile =$filename;

$size = Width & "x" & Height;

$outfile = 'out_file.flv';

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".$filename. " -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate."
-f flv -s ".$size." ".$outputpath."\\".outfile;
$ret = shell_exec($ffmpegcmd1);

return $outfile;
}

function set_buffering($filename,$rootpath,$path)
{
$_rootPath = rootpath."\\flvtool";

$ffmpegcmd1 = "flvtool2 -U ".Path."\\".$filename;
$ret = shell_exec($ffmpegcmd1);

} 

function grab_image($filename, $rootpath, $inputpath,$outputpath, $no_of_thumbs, $frame_number, $image_format, $width, $height)
{
$_rootpath = rootpath."\\ffmpeg";
$size = width. "x".height;

$outfile = "sample.png"; 

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".filename." -vframes ".$no_of_thumbs." -ss 00:00:03 -an -vcodec ". $image_format." -f rawvideo -s ".$size. " ". $outputpath."\\".$outfile;
$ret = shell_exec($ffmpegcmd1);

return $outfile;
}
}

$_mediahandler AS NEW media_handler;
$rootpath ="./";
$nputpath = $rootpath."/Default";
$outputpath = $rootpath. "/FLV"
$ThumbPath = $rootpath. "/Thumbs"

$source = $HTTP_POST_FILES['file1']['tmp_name'];
$name = $HTTP_POST_FILES['file1']['name'];
$fileSize = $HTTP_POST_FILES['file1']['size']; 
$filetype = $HTTP_POST_FILES['file1']['type']; 
$dest = ''; 

copy($source, $inputpath . $name);

$outfile = $_mediahandler.convert_media($name,$rootpath, $inputpath, $outputpath, 320, 240, 32, 22050);
$image_name = $_mediahandler.grab_image($outfile, $rootpath, $outputpath, $thumbpath, 1, 2, "png", 110, 90)
$_mediahandler.Set_Buffering($outfile, $rootpath, $outputpath)

?>

 

I did not make the code, and it had a few errors I had to fix (stupid things like not doing \\ and ;)  I need to use this code though, nothing on the entire intraweb was even close to this.

 

Please tell me why I cant use AS NEW? (PHP 5.2.4 *NEWEST*)

Link to comment
Share on other sites

BUMP (Please help me out, im making a thing like youtube and I hate youtube cause its slow as **** and it uploads rlly slow)  So I decided to make my OWN video sharing services (I already made a picture and photo sharing service, and a program sharing service) now just to make a video sharing service...

Link to comment
Share on other sites

This script is the only I have ever seen to properly convert files to FLV, I am doing everything else and will rewrite this code once I see what it does and how it works.  I still ahve to make the entire portal and wbepages, including the hit counters and rating system.  Not to mention the code I posted doesnt even do a thing with the file after making it lol.

 

I tried yoiur code and,...:

 

Parse error: syntax error, unexpected '}' in C:\wamp\www\videoshare\videos.php on line 44

 

It doesn't like your extra bracket... what I do now?

Link to comment
Share on other sites

try this

<?php
class media_handler
{
function convert_media($filename, $rootpath, $inputpath, $outputpath, $width, $height, $bitrate, $samplingrate)
{
	$outfile = "";
	$rPath = $rootpath."\ffmpeg";
	$size = $width."x".$height;
	$outfile =$filename;

	$size = Width & "x" & Height;

	$outfile = 'out_file.flv';

	$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".$filename. " -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."\\".outfile;
	$ret = shell_exec($ffmpegcmd1);

	return $outfile;
}

function set_buffering($filename,$rootpath,$path)
{
	$_rootPath = rootpath."\\flvtool";

	$ffmpegcmd1 = "flvtool2 -U ".Path."\\".$filename;
	$ret = shell_exec($ffmpegcmd1);

} 

function grab_image($filename, $rootpath, $inputpath,$outputpath, $no_of_thumbs, $frame_number, $image_format, $width, $height)
{
	$_rootpath = rootpath."\\ffmpeg";
	$size = width. "x".height;

	$outfile = "sample.png"; 

	$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".filename." -vframes ".$no_of_thumbs." -ss 00:00:03 -an -vcodec ". $image_format." -f rawvideo -s ".$size. " ". $outputpath."\\".$outfile;
	$ret = shell_exec($ffmpegcmd1);

	return $outfile;
}
}

$_mediahandler as new media_handler;
$rootpath ="./";
$nputpath = $rootpath."/Default";
$outputpath = $rootpath. "/FLV"
$ThumbPath = $rootpath. "/Thumbs"

$source = $HTTP_POST_FILES['file1']['tmp_name'];
$name = $HTTP_POST_FILES['file1']['name'];
$fileSize = $HTTP_POST_FILES['file1']['size']; 
$filetype = $HTTP_POST_FILES['file1']['type']; 
$dest = ''; 

copy($source, $inputpath.$name);

$outfile = $_mediahandler.convert_media($name,$rootpath, $inputpath, $outputpath, 320, 240, 32, 22050);
$image_name = $_mediahandler.grab_image($outfile, $rootpath, $outputpath, $thumbpath, 1, 2, "png", 110, 90);
$_mediahandler.Set_Buffering($outfile, $rootpath, $outputpath);

?>

Link to comment
Share on other sites

OMFG WOOT 400th post.

 

Ya sry, I bumped it cause it was halfway down the page when I posted "bump".

 

I used your code and:

 

(lol im testing it with a 390mb file cause I have no smaller movies)

 

Parse error: syntax error, unexpected T_VARIABLE in C:\wamp\www\videoshare\videos.php on line 48

 

I fixed this...

$outputpath = $rootpath. "/FLV";
$ThumbPath = $rootpath. "/Thumbs";

 

Then I ran it again and got:

 

Fatal error: Call to undefined function convert_media() in C:\wamp\www\videoshare\videos.php on line 58

Link to comment
Share on other sites

since this is all in one file could you please tell me how to get it out of a class??

 

"class media_handler

{" remove that.. and "}"

 

and then remove what else to make it without a class?

 

ok I think its not a class no mroe:

 

<?php

function convert_media($filename, $rootpath, $inputpath, $outputpath, $width, $height, $bitrate, $samplingrate)
{
$outfile = "";
$rPath = $rootpath."\ffmpeg";
$size = $width."x".$height;
$outfile =$filename;

$size = Width & "x" & Height;

$outfile = 'out_file.flv';

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".$filename. " -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."\\".outfile;
$ret = shell_exec($ffmpegcmd1);

return $outfile;
}

function set_buffering($filename,$rootpath,$path)
{
$_rootPath = rootpath."\\flvtool";

$ffmpegcmd1 = "flvtool2 -U ".Path."\\".$filename;
$ret = shell_exec($ffmpegcmd1);

} 

function grab_image($filename, $rootpath, $inputpath,$outputpath, $no_of_thumbs, $frame_number, $image_format, $width, $height)
{
$_rootpath = rootpath."\\ffmpeg";
$size = width. "x".height;

$outfile = "sample.png"; 

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".filename." -vframes ".$no_of_thumbs." -ss 00:00:03 -an -vcodec ". $image_format." -f rawvideo -s ".$size. " ". $outputpath."\\".$outfile;
$ret = shell_exec($ffmpegcmd1);

return $outfile;
}

$rootpath ="./";
$nputpath = $rootpath."/Default";
$outputpath = $rootpath. "/FLV";
$ThumbPath = $rootpath. "/Thumbs";

$source = $HTTP_POST_FILES['file1']['tmp_name'];
$name = $HTTP_POST_FILES['file1']['name'];
$fileSize = $HTTP_POST_FILES['file1']['size']; 
$filetype = $HTTP_POST_FILES['file1']['type']; 
$dest = ''; 

copy($source, $inputpath.$name);

$outfile = convert_media($name,$rootpath, $inputpath, $outputpath, 320, 240, 32, 22050);
$image_name = grab_image($outfile, $rootpath, $outputpath, $thumbpath, 1, 2, "png", 110, 90);
Set_Buffering($outfile, $rootpath, $outputpath);

?>

 

I run it and get:

 

(lol..... 390mb file.... Waiting...) (I think it might time out)

 

oo I got:

 

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=windows-1252"></HEAD>
<BODY></BODY></HTML>

 

And I look in the three folders, "DEFAULT" "FLV" and "THUMB" they have:

 

They Are EMPTY!

Link to comment
Share on other sites

hmm I noticed:

 

$outfile = "";
$rPath = $rootpath."\ffmpeg";
$size = $width."x".$height;
$outfile =$filename;

$size = Width & "x" & Height;

$outfile = 'out_file.flv';

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".$filename. " -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."\\".outfile;
$ret = shell_exec($ffmpegcmd1);

return $outfile;

 

That there...  hmm shouldnt shell_exec($ffmpegcmd1); be shell_exec($rPath."\\".$ffmpegcmd1);

Link to comment
Share on other sites

try

$outfile = convert_media($name,$rootpath, $inputpath, $outputpath, 320, 240, 32, 22050);
echo "$outfile<br>";
$image_name = grab_image($outfile, $rootpath, $outputpath, $thumbpath, 1, 2, "png", 110, 90);
echo $image_name;
Set_Buffering($outfile, $rootpath, $outputpath);

 

you really need some error capturing, ie atleast test via CLI and then compare

Link to comment
Share on other sites

kk I am now using:

 

<?php

function convert_media($filename, $rootpath, $inputpath, $outputpath, $width, $height, $bitrate, $samplingrate)
{
$outfile = "";
$rPath = $rootpath."\\ffmpeg";
$size = $width."x".$height;
$outfile =$filename;

$size = Width & "x" & Height;

$outfile = 'out_file.flv';

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".$filename. " -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."\\".outfile;
$ret = shell_exec($rPath."\\".$ffmpegcmd1);

return $outfile;
}

function set_buffering($filename,$rootpath,$path)
{
$_rootPath = rootpath."\\flvtool";

$ffmpegcmd1 = "flvtool2 -U ".Path."\\".$filename;
$ret = shell_exec($_rootPath."\\".$ffmpegcmd1);

} 

function grab_image($filename, $rootpath, $inputpath,$outputpath, $no_of_thumbs, $frame_number, $image_format, $width, $height)
{
$_rootpath = rootpath."\\ffmpeg";
$size = width."x".height;

$outfile = "sample.png"; 

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".filename." -vframes ".$no_of_thumbs." -ss 00:00:03 -an -vcodec ". $image_format." -f rawvideo -s ".$size. " ". $outputpath."\\".$outfile;
$ret = shell_exec($_rootpath."\\".$ffmpegcmd1);

return $outfile;
}

$rootpath =".\\";
$nputpath = $rootpath."\\Default";
$outputpath = $rootpath. "\\FLV";
$ThumbPath = $rootpath. "\\Thumbs";

$source = $HTTP_POST_FILES['file1']['tmp_name'];
$name = $HTTP_POST_FILES['file1']['name'];
$fileSize = $HTTP_POST_FILES['file1']['size']; 
$filetype = $HTTP_POST_FILES['file1']['type']; 
$dest = ''; 

copy($source, $inputpath.$name);

$outfile = convert_media($name,$rootpath, $inputpath, $outputpath, 320, 240, 32, 22050);
echo "$outfile<br>";
$image_name = grab_image($outfile, $rootpath, $outputpath, $thumbpath, 1, 2, "png", 110, 90);
echo $image_name;
Set_Buffering($outfile, $rootpath, $outputpath);

?>

(I replaced all the slashes and shell_execs)

 

This outputs:

 

(waiting caues as I said above, its a 390 file im testing with)

 

out_file.flv
sample.png

 

The default, flv, and thumb folders are:

 

EMPTY

Link to comment
Share on other sites

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".$filename. " -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."\\".outfile;

 

should be

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".$filename. " -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."\\".$outfile;

Link to comment
Share on other sites

ok I took your above code and used that;

 

my current code is:

 

<?php

function convert_media($filename, $rootpath, $inputpath, $outputpath, $width, $height, $bitrate, $samplingrate)
{
$outfile = "";
$rPath = $rootpath."\\ffmpeg";
$size = $width."x".$height;
$outfile =$filename;

$size = Width & "x" & Height;

$outfile = 'out_file.flv';

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".$filename. " -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."\\".$outfile;
$ret = shell_exec($rPath."\\".$ffmpegcmd1);

return $outfile;
}

function set_buffering($filename,$rootpath,$path)
{
$_rootPath = rootpath."\\flvtool";

$ffmpegcmd1 = "flvtool2 -U ".Path."\\".$filename;
$ret = shell_exec($_rootPath."\\".$ffmpegcmd1);

} 

function grab_image($filename, $rootpath, $inputpath,$outputpath, $no_of_thumbs, $frame_number, $image_format, $width, $height)
{
$_rootpath = rootpath."\\ffmpeg";
$size = width."x".height;

$outfile = "sample.png"; 

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".filename." -vframes ".$no_of_thumbs." -ss 00:00:03 -an -vcodec ". $image_format." -f rawvideo -s ".$size. " ". $outputpath."\\".$outfile;
$ret = shell_exec($_rootpath."\\".$ffmpegcmd1);

return $outfile;
}

$rootpath = realpath(".\\");$rootpath.="\\";
$rootpath = str_replace('/','\\',$rootpath);
echo $rootpath;

$nputpath = $rootpath."\\Default";
$outputpath = $rootpath. "\\FLV";
$ThumbPath = $rootpath. "\\Thumbs";

$source = $HTTP_POST_FILES['file1']['tmp_name'];
$name = $HTTP_POST_FILES['file1']['name'];
$fileSize = $HTTP_POST_FILES['file1']['size']; 
$filetype = $HTTP_POST_FILES['file1']['type']; 
$dest = ''; 

copy($source, $inputpath.$name);

$outfile = convert_media($name,$rootpath, $inputpath, $outputpath, 320, 240, 32, 22050);
echo "$outfile<br>";
$image_name = grab_image($outfile, $rootpath, $outputpath, $thumbpath, 1, 2, "png", 110, 90);
echo $image_name;
Set_Buffering($outfile, $rootpath, $outputpath);

?>

 

I added a thing to show the real path instead of just a relative path, now it outputs:

 

C:\**PATH**\www\shares\video\
out_file.flv
sample.png

 

Again, nothing is in any folder.  No errors, hmm Im gonna set error reporting to notices and see if anything comes up...

Link to comment
Share on other sites

Well this explains it:

 

Notice: Undefined index: file1 in * on line 52
Notice: Undefined index: file1 in * on line 53
Notice: Undefined index: file1 in * on line 54
Notice: Undefined index: file1 in * on line 55

Notice: Undefined variable: inputpath in * on line 58
Notice: Undefined variable: inputpath in * on line 60
Notice: Use of undefined constant Width - assumed 'Width' in  * on line 12
Notice: Use of undefined constant Height - assumed 'Height' in * on line 12

out_file.flv

Notice: Undefined variable: thumbpath in * on line 62
Notice: Use of undefined constant rootpath - assumed 'rootpath' in * on line 33
Notice: Use of undefined constant width - assumed 'width' in * on line 34
Notice: Use of undefined constant height - assumed 'height' in * on line 34
Notice: Use of undefined constant filename - assumed 'filename' in * on line 38

sample.png

Notice: Use of undefined constant rootpath - assumed 'rootpath' in * on line 24
Notice: Use of undefined constant Path - assumed 'Path' in * on line 26

Link to comment
Share on other sites

the form that submits the file to this has the following code:

 

<form action="videos.php" method="POST">
<input type="file" name="file1" size="50" />
<input type="submit" name="submit" value="Upload!" />
</form>

 

Soo IDK why file1 is undefined.

 

print_r($_FILES); returns:

 

Array
(
)

 

so files is empty!?!?!?!?!?

 

I tried resending the form using a 5mb mov file and got:

 

Array
(
)

 

Why wouldn't files being sent properly?  I dont get it.

 

PHP_MAX_FILE_SIZE is over 50mb

PHP_MAX_MEM_SIZE is over 64mb

PHP_MAX_UPLOAD_SIZE is over 128mb

Link to comment
Share on other sites

you mean you didn't post/upload the file ?

 

I did, but it doesnt seem to think I did...

 

the form that uploads is:

 

index.php:

<form action="videos.php" method="POST">
<input type="file" name="file1" size="50" />
<input type="submit" name="submit" value="Upload!" />
</form>

 

videos.php:

<?php

error_reporting(E_ALL);
print_r($_FILES);

function convert_media($filename, $rootpath, $inputpath, $outputpath, $width, $height, $bitrate, $samplingrate)
{
$outfile = "";
$rPath = $rootpath."\\ffmpeg";
$size = $width."x".$height;
$outfile =$filename;

$size = Width & "x" & Height;

$outfile = 'out_file.flv';

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".$filename. " -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."\\".$outfile;
$ret = shell_exec($rPath."\\".$ffmpegcmd1);

return $outfile;
}

function set_buffering($filename,$rootpath,$path)
{
$_rootPath = rootpath."\\flvtool";

$ffmpegcmd1 = "flvtool2 -U ".Path."\\".$filename;
$ret = shell_exec($_rootPath."\\".$ffmpegcmd1);

} 

function grab_image($filename, $rootpath, $inputpath,$outputpath, $no_of_thumbs, $frame_number, $image_format, $width, $height)
{
$_rootpath = rootpath."\\ffmpeg";
$size = width."x".height;

$outfile = "sample.png"; 

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".filename." -vframes ".$no_of_thumbs." -ss 00:00:03 -an -vcodec ". $image_format." -f rawvideo -s ".$size. " ". $outputpath."\\".$outfile;
$ret = shell_exec($_rootpath."\\".$ffmpegcmd1);

return $outfile;
}

$rootpath = realpath(".\\");$rootpath.="\\";
$rootpath = str_replace('/','\\',$rootpath);
echo $rootpath;

$nputpath = $rootpath."\\Default";
$outputpath = $rootpath. "\\FLV";
$ThumbPath = $rootpath. "\\Thumbs";

$source = $HTTP_POST_FILES['file1']['tmp_name'];
$name = $HTTP_POST_FILES['file1']['name'];
$fileSize = $HTTP_POST_FILES['file1']['size']; 
$filetype = $HTTP_POST_FILES['file1']['type']; 
$dest = ''; 

copy($source, $inputpath.$name);

$outfile = convert_media($name,$rootpath, $inputpath, $outputpath, 320, 240, 32, 22050);
echo "$outfile<br>";
$image_name = grab_image($outfile, $rootpath, $outputpath, $thumbpath, 1, 2, "png", 110, 90);
echo $image_name;
Set_Buffering($outfile, $rootpath, $outputpath);

?>

 

Related php.ini settings:

;;;;;;;;;;;;;;;;;;;
; Resource Limits ;
;;;;;;;;;;;;;;;;;;;

max_execution_time = 180     ; Maximum execution time of each script, in seconds
max_input_time = 120	; Maximum amount of time each script may spend parsing request data
memory_limit = 128M      ; Maximum amount of memory a script may consume (8MB)

;;;;;;;;;;;;;;;;;
; Data Handling ;
;;;;;;;;;;;;;;;;;
;
; Maximum size of POST data that PHP will accept.
post_max_size = 128M

;;;;;;;;;;;;;;;;
; File Uploads ;
;;;;;;;;;;;;;;;;

; Whether to allow HTTP file uploads.
file_uploads = On

; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
upload_tmp_dir = "C:/*/tmp"

; Maximum allowed size for uploaded files.
upload_max_filesize = 128M

Link to comment
Share on other sites

*********** IM AN IDIOT

 

In this form, for some idiotic reason, I forgot to put: "enctype="multipart/form-data"" in the form request...

 

(Trying with a 5mb mov file)

Now That I add that into it I get:

 

**A BUNCH OF UNDEFINED CONSTANTS**

 

I am an idiot and have looked at the code and fixed most undefined constants  NOW I get...

 

(waiting for it to load...)

Notice: Undefined variable: Width in * on line 13

Notice: Undefined variable: Height in * on line 13
out_file.flv

Notice: Undefined variable: thumbpath in * on line 63

Notice: Use of undefined constant rootpath - assumed 'rootpath' in * on line 34
sample.png
Notice: Undefined variable: Path in * on line 27

 

 

I went over the code again to fix these undefined variables and now I get

 

**PROPER contents of the $_FILES array**

C:\wamp\www\videoshare\
out_file.flv
sample.png

 

The folders now have:

 

Folder: Default
Files: None

Folder: Flv
Files: None new

Folder: Thumb
Files: None

Folder: flvtool
Files: None new

Folder: ffmpeg
Files: None new

 

So now there are no errors (OR EVEN NOTICES), but now the script doestn seem to make any file...

 

Current Code is:

<?php

error_reporting(E_ALL);
print_r($_FILES);

function convert_media($filename, $rootpath, $inputpath, $outputpath, $width, $height, $bitrate, $samplingrate)
{
$outfile = "";
$rPath = $rootpath."\\ffmpeg";
$size = $width."x".$height;
$outfile =$filename;

$size = $width & "x" & $height;

$outfile = 'out_file.flv';

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".$filename. " -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."\\".$outfile;
$ret = shell_exec($rPath."\\".$ffmpegcmd1);

return $outfile;
}

function set_buffering($filename,$rootpath,$path)
{
$_rootPath = $rootpath."\\flvtool";

$ffmpegcmd1 = "flvtool2 -U ".$path."\\".$filename;
$ret = shell_exec($_rootPath."\\".$ffmpegcmd1);

} 

function grab_image($filename, $rootpath, $inputpath,$outputpath, $no_of_thumbs, $frame_number, $image_format, $width, $height)
{
$_rootpath = $rootpath."\\ffmpeg";
$size = $width."x".$height;

$outfile = "sample.png"; 

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."\\".$filename." -vframes ".$no_of_thumbs." -ss 00:00:03 -an -vcodec ". $image_format." -f rawvideo -s ".$size. " ". $outputpath."\\".$outfile;
$ret = shell_exec($_rootpath."\\".$ffmpegcmd1);

return $outfile;
}

$rootpath = realpath(".\\");$rootpath.="\\";
$rootpath = str_replace('/','\\',$rootpath);
echo $rootpath;

$inputpath = $rootpath."\\Default";
$outputpath = $rootpath. "\\FLV";
$thumbpath = $rootpath. "\\Thumbs";

$source = $HTTP_POST_FILES['file1']['tmp_name'];
$name = $HTTP_POST_FILES['file1']['name'];
$fileSize = $HTTP_POST_FILES['file1']['size']; 
$filetype = $HTTP_POST_FILES['file1']['type']; 
$dest = ''; 

copy($source, $inputpath.$name);

$outfile = convert_media($name,$rootpath, $inputpath, $outputpath, 320, 240, 32, 22050);
echo "$outfile<br>";
$image_name = grab_image($outfile, $rootpath, $outputpath, $thumbpath, 1, 2, "png", 110, 90);
echo $image_name;
Set_Buffering($outfile, $rootpath, $outputpath);

?>

Link to comment
Share on other sites

also

 

DefaultLineTexture.mov

LineTexture.mov

 

now show up in the main folder...

 

I just made all of the paths realpath *using an expression regular replacement*

 

current code is:

<?php

error_reporting(E_ALL);

function convert_media($filename, $rootpath, $inputpath, $outputpath, $width, $height, $bitrate, $samplingrate)
{
$outfile = "";
$rPath = $rootpath."/ffmpeg";
$size = $width."x".$height;
$outfile =$filename;

$size = $width & "x" & $height;

$outfile = 'out_file.flv';

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."/".$filename. " -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath."/".$outfile;
$ret = shell_exec($ffmpegcmd1);

return $outfile;
}

function set_buffering($filename,$rootpath,$path)
{
$_rootPath = $rootpath."/flvtool";

$ffmpegcmd1 = "flvtool2 -U ".$path."/".$filename;
$ret = shell_exec($ffmpegcmd1);

} 

function grab_image($filename, $rootpath, $inputpath,$outputpath, $no_of_thumbs, $frame_number, $image_format, $width, $height)
{
$_rootpath = $rootpath."/ffmpeg";
$size = $width."x".$height;

$outfile = "sample.png"; 

$ffmpegcmd1 = "ffmpeg -i ".$inputpath."/".$filename." -vframes ".$no_of_thumbs." -ss 00:00:03 -an -vcodec ". $image_format." -f rawvideo -s ".$size. " ". $outputpath."/".$outfile;
$ret = shell_exec($ffmpegcmd1);

return $outfile;
}

$rootpath = realpath(".");$rootpath.="/";
echo $rootpath;

$inputpath = realpath($rootpath."/Default");
$outputpath = realpath($rootpath. "/FLV");
$thumbpath = realpath($rootpath. "/Thumbs");

$source = $HTTP_POST_FILES['file1']['tmp_name'];
$name = $HTTP_POST_FILES['file1']['name'];
$fileSize = $HTTP_POST_FILES['file1']['size']; 
$filetype = $HTTP_POST_FILES['file1']['type']; 
$dest = realpath('.'); 

copy($source, $inputpath.$name);

$outfile = convert_media($name,$rootpath, $inputpath, $outputpath, 320, 240, 32, 22050);
echo "$outfile<br>";
$image_name = grab_image($outfile, $rootpath, $outputpath, $thumbpath, 1, 2, "png", 110, 90);
echo $image_name;
Set_Buffering($outfile, $rootpath, $outputpath);

?>

 

current output is:

C:\wamp\www\videoshare/
out_file.flv
sample.png

 

DefaultLineTexture.mov is in the main folder again.

Link to comment
Share on other sites

im really being such an idiot today -_-

 

C:\wamp\www\videoshare/out_file.flv

sample.png

 

since the COPY command wont copy the file properly ,I changed all paths to allow the file to be in the main directory. I now get...

 

an empty eveyr folder... -_-

 

I am in windows, shouldnt it be exec instead of shell_exec..? whats the difference?

 

for holy shit level of debugging I added:

 

echo "image_name: ".$image_name."\n\r\n\r<br/><br/>";
echo "rootpath: ".$rootpath."\n\r\n\r<br/><br/>";
echo "outputpath: ".$outputpath."\n\r\n\r<br/><br/>";
echo "outfile: ".$outfile."\n\r\n\r<br/><br/>";
echo "name: ".$name."\n\r\n\r<br/><br/>";
echo "source: ".$source."\n\r\n\r<br/><br/>";

 

this echos:

 

image_name: sample.png 
rootpath: C:\wamp\www\videoshare/ 
outputpath: C:\wamp\www\videoshare\Flv 
outfile: out_file.flv 
name: LineTexture.mov 
source: C:\WINDOWS\TEMP\php2F0.tmp 

Link to comment
Share on other sites

now during the step to get the size of the buffer

 

ERROR: No such file or directory - C:/out_file.flv ERROR: flvtool2/base.rb:259:in `initialize' ERROR: flvtool2/base.rb:259:in `open' ERROR: flvtool2/base.rb:259:in `open_stream' ERROR: flvtool2/base.rb:238:in `process_files' ERROR: flvtool2/base.rb:225:in `each' ERROR: flvtool2/base.rb:225:in `process_files' ERROR: flvtool2/base.rb:44:in `execute!' ERROR: lib/flvtool2.rb:168:in `execute!' ERROR: lib/flvtool2.rb:228 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.