SitePoint Sponsor

User Tag List

Results 1 to 8 of 8

Hybrid View

  1. #1
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Error in a class

    Hi Guys,

    i'm using this class from here:

    http://www.iepak.com/30/topicdetail.aspx

    i'm having a few errors with it, i know the public bit is wrong but when i take it away it still doesn't work and ideas on what could be the problem?

    PHP Code:
    <?php
    Public Class Media_handler
    {
    function 
    Convert_Media($filename$rootpath$inputpath$outputpath$width$height$bitrate$samplingrate)
    {
    var 
    $outfile "";
    // root directory path, where FFMPEG folder exist in your application.
    var $rPath $rootpath."\ffmpeg";
    // which shows FFMPEG folder exist on the root.
    // Set Media Size that is width and hieght
    var $size $width."x".$height;
    // remove origination extension from file adn add .flv extension, becuase we must give output file name to ffmpeg command.
    $outfile =$filename;

    // Media Size
    $size  Width "x" Height;

    // remove origination extenstion from file and add .flv extension , becuase we must give output filename to ffmpeg command.

    $outfile 'out_file.flv';
    // Use exec command to access command prompt to execute the following FFMPEG Command and convert video to flv format. 

    // exec('command',output array,int return value)

    $command '/C'._rootpath."\ffmpeg -i "\".$inputpath."\".$filename. " -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate."
    -f flv -".$size." ".$outputpath."\".outfile;

    // return output file name for other operations 
    Return 
    $outfile;
    }

    function set_buffering(
    $filename,$rootpath,$path)

    {
    // root directory path
    $_rootPath = rootpath."\flvtool"


    // Execute FLV TOOL command also on exec , you can also use other tool for executing command prompt commands. 


    // exec('command',output array,int return value)

    $command = "/C".$_rootpath."\flvtool2 U".Path;

    // Execute this command to set buffering for FLV 


    <!-- This function is used to Grab Thumbnail Image from Generated Flv files , to be display on the list, Note that, FFMPEG can create thumbnail only from FLV Files.. --> 


    function(
    $filename$rootpath$inputpath,$outputpath$no_of_thumbs$frame_number$image_format$width$height)
    {
    // root directory path
    $_rootpath = rootpath."\ffmpeg";
    // Media Size
    $size = width. "x".height;

    // I am using static image, you can dynamic it with your own choice. 
    $outfile = "sample.png"; 

    // exec('command',output array,int return value)

    $command = "/C".$_rootpath."\ffmpeg --" .$inputpath."\".filename." -vframes ".$no_of_thumbs." -ss 00:00:03 -an -vcodec ". $image_format." -f rawvideo -".$size. " ". $outputpath."\".$outfile;

    // Execute this command using exec command or any other tool to grab image from converted flv file. 

    Return 
    $outfile;
    }
    }
    thanks guys

    Graham

  2. #2
    SitePoint Evangelist praetor's Avatar
    Join Date
    Aug 2005
    Posts
    479
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What version of php are you using? If the class was written for php5 it might use functions that aren't available in php4

  3. #3
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    HI Praetor,

    my server and localhost have the latest PHP 5.

    cheers

    Graham

  4. #4
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    Hi Graham, there is a parse error on one of the lines:
    PHP Code:
    $command '/C'._rootpath."\ffmpeg -i "".$inputpath."".$filename. " -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate." 
    -f flv -".$size." ".$outputpath."".outfile; 
    should be:
    PHP Code:
    $command '/C'._rootpath."\ffmpeg -i ".$inputpath."".$filename" -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate.
    -f flv -s "
    .$size." ".$outputpath.outfile
    try that.
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  5. #5
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi SpikeZ,

    thanks for the help mate i ammedned the code like you said here it is in full:

    PHP Code:
    <?php
    Public Class Media_handler
    {
    function 
    Convert_Media($filename$rootpath$inputpath$outputpath$width$height$bitrate$samplingrate)
    {
    var 
    $outfile "";
    // root directory path, where FFMPEG folder exist in your application.
    var $rPath $rootpath."\ffmpeg";
    // which shows FFMPEG folder exist on the root.
    // Set Media Size that is width and hieght
    var $size $width."x".$height;
    // remove origination extension from file adn add .flv extension, becuase we must give output file name to ffmpeg command.
    $outfile =$filename;

    // Media Size
    $size  Width "x" Height;

    // remove origination extenstion from file and add .flv extension , becuase we must give output filename to ffmpeg command.

    $outfile 'out_file.flv';
    // Use exec command to access command prompt to execute the following FFMPEG Command and convert video to flv format. 

    // exec('command',output array,int return value)

    $command '/C'._rootpath."\ffmpeg -i ".$inputpath."".$filename" -acodec mp3 -ar " .$samplingrate." -ab ".$bitrate." -f flv -s ".$size." ".$outputpath.outfile

    // return output file name for other operations 
    Return $outfile;
    }

    function 
    set_buffering($filename,$rootpath,$path)

    {
    // root directory path
    $_rootPath rootpath."\flvtool"


    // Execute FLV TOOL command also on exec , you can also use other tool for executing command prompt commands. 


    // exec('command',output array,int return value)

    $command "/C".$_rootpath."\flvtool2 - U".Path;

    // Execute this command to set buffering for FLV 


    <!-- 
    This function is used to Grab Thumbnail Image from Generated Flv files to be display on the list, Note thatFFMPEG can create thumbnail only from FLV Files.. --> 


    function(
    $filename$rootpath$inputpath,$outputpath$no_of_thumbs$frame_number$image_format$width$height)
    {
    // root directory path
    $_rootpath rootpath."\ffmpeg";
    // Media Size
    $size width"x".height;

    // I am using static image, you can dynamic it with your own choice. 
    $outfile "sample.png"

    // exec('command',output array,int return value)

    $command "/C".$_rootpath."\ffmpeg -y -i " .$inputpath."\".filename." -vframes ".$no_of_thumbs." -ss 00:00:03 -an -vcodec ". $image_format." -f rawvideo -".$size. " ". $outputpath."\".$outfile;

    // Execute this command using exec command or any other tool to grab image from converted flv file. 

    Return 
    $outfile;
    }
    }
    it does not seem to get past line 2 it says:

    Parse error: syntax error, unexpected T_PUBLIC on line 2

    it's the same on my server and on localhost any ideas on what th eproblem could be?

    thanks guys

    Graham

  6. #6
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,804
    Mentioned
    157 Post(s)
    Tagged
    3 Thread(s)
    i think thats because functions can be public NOT classes themselves. i havent made the jump to php5 yet so havent explored the public,private etc but I am pretty sure it's that......ish
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  7. #7
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Code:
    Public class...
    is invalid public, private, protected go onto the methods and vars only.

    You have a lot more problems with this code as well. vars missing there var/access prefix

    Ummm scratch this...its all ****ed up....excuse me language...
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  8. #8
    SitePoint Evangelist
    Join Date
    Dec 2006
    Posts
    430
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    lol not all mate, the guy before the PHP turorial did one for ASP, i don't think he fully changed the code over to php lol

    PLUS im on shared hosting, and due to further reading have found out i need ffmpg installed on the server (shared don't do it they say)

    ill need to scrap this idea for now

    thanks for the input though guys

    Graham


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •