Jump to content

[SOLVED] EXEC not exactly working (unexpected T_AS)


Recommended Posts

My path and folder setup is below:

/----------------------MAIN DIRECTORY----------------------\
|   flvtool2.exe
|   index.php
|   videos.php
|
+---ffmpeg
  |   avcodec-51.dll
  |   avformat-51.dll
  |   avutil-49.dll
  |   ffmpeg.exe
  |   ffplay.exe
  |   libdts.dll
  |   libfaac.dll
  |   libfaad.dll
  |   libgsm.dll
  |   libmp3lame-0.dll
  |   libogg-0.dll
  |   libvorbis-0.dll
  |   libvorbisenc-2.dll
  |   libx264-54.dll
  |   postproc-51.dll
  |   SDL.dll
  |   xvidcore.dll
  |
  +---include
  |   +---ffmpeg
  |   |       adler32.h
  |   |       avcodec.h
  |   |       avformat.h
  |   |       avio.h
  |   |       avutil.h
  |   |       common.h
  |   |       fifo.h
  |   |       integer.h
  |   |       intfloat_readwrite.h
  |   |       log.h
  |   |       mathematics.h
  |   |       md5.h
  |   |       opt.h
  |   |       rational.h
  |   |       rgb2rgb.h
  |   |       rtp.h
  |   |       rtsp.h
  |   |       rtspcodes.h
  |   |       swscale.h
  |   |
  |   \---postproc
  |           postprocess.h
  |
  +---lib
  |   |   avcodec-51.lib
  |   |   avformat-51.lib
  |   |   avutil-49.lib
  |   |   postproc-51.lib
  |   |
  |   \---pkgconfig
  |           libavcodec.pc
  |           libavformat.pc
  |           libavutil.pc
  |           libpostproc.pc
  |           libswscale.pc
  |
  \---man
      \---man1
              ffmpeg.1
              ffplay.1

 

My code for index.php is below:

<body bgcolor="black" text="white">
<form action="videos.php" method="POST" enctype="multipart/form-data">
<input type="file" style="background-color: black;font-color: white;text-color: white;" name="file1" size="50" />
<input type="submit" style="background-color: black;font-color: white;text-color: white;" name="submit" value="Upload!" />
</form></body>

 

My code for videos.php is below:

<?php

error_reporting(E_ALL);
$rootpath = realpath('.'); $rootpath.="/";

chdir('C:/');

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

$outfile = $rootpath.'out_file.flv';

$ffmpegcmd1 = "ffmpeg -i ".$rootpath.$filename." -acodec mp3 -ar ".$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outfile;
$ret = exec($rPath.$ffmpegcmd1);
echo "\r\n<br/>Converting: $ret\r\n<br/>";
return $outfile;
}

function set_buffering($filename,$root)
{
$ffmpegcmd1 = "flvtool2 -U ".$root."/".$filename;
$ret = exec($root.$ffmpegcmd1);
echo "\r\n<br/> Buffering: $ret\r\n<br/>";
} 

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

$outfile = $rootpath.'sample.png'; 

$ffmpegcmd1 = "ffmpeg -i ".$rootpath.$filename." -vframes ".$no_of_thumbs." -ss 00:00:03 -an -vcodec ".$image_format." -f rawvideo -s ".$size. " ".$outfile;
$ret = exec($_rootpath.$ffmpegcmd1);
echo "\r\n<br/> Grab_bing: $ret\r\n<br/>";
return $outfile;
}

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

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

$name=$rootpath.$name;

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

echo "\r\n<br/>image_name: ".$image_name."\r\n<br/>";
echo "rootpath: ".$rootpath."\r\n<br/>";
echo "outfile: ".$outfile."\r\n<br/>";
echo "size: ".$fileSize."\r\n<br/>";
echo "type: ".$filetype."\r\n<br/>";
echo "name: ".$name."\r\n<br/>";
echo "source: ".$source;
?>

 

The output of this process is currently:

Converting: 
Grab_bing: 
Buffering: ERROR: lib/flvtool2.rb:228

image_name: C:\wamp\www\videoshare/sample.png 
rootpath: C:\wamp\www\videoshare/ 
outfile: C:\wamp\www\videoshare/out_file.flv 
size: 322290 
type: video/avi 
name: C:\wamp\www\videoshare/[a-g] Cardcaptor Sakura - 01-1.avi 
source: c:/windows/temp\php306.tmp

 

Additional Information:

Testing upload with a 342 kB split of an AVI file.

PHP: 5.4.2
Windows XP

 

My Problem / Issue:

There seems to be a problem at step three in the file, and it does
not seem to properly convert any ifle I upload to an FLV file.  If it
never makes an FLV file, step three will never start and will return
an error.  Steps 1 and 2 Return nothing and do not show any errors
or information.  The AVI I am uploading as a test is a 342 kByte
*1 Minute* part of a card captor sakura episode.  This file is a
windows/avi file with a divx encoding.  This file uploaded to youtube
sucessfully and is readable in windows media player.  My problem is
that for no reason that I can figure out, my script is not creating a
FLV file.  (I think it is not calling FFMPEG properly) EDIT: The AVI file
IS uploaded sucessfully and copied to its permanent directory at
/videoshare.  The paths are all absolute and are all valid, says the
output.  I am not sure as to why it will not create the FLV file.  If
anyone knows of any other software that can make an FLV file from
the command line (or from a php file) please inform me.

I have found an alternative program:

 

"Sothink Video Encoder for Adobe Flash (Command-Line Version)"

 

Although it may not be free, it shall work for what I need.

 

 

/--------------\

|*Self-Solved*|

\--------------/

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.