Jump to content

Error in class


graham23s

Recommended Posts

Hi Guys,

 

i'm using  class to convert uploaded video files to .flv but im getting an error:

 

Parse error: syntax error, unexpected T_PUBLIC on line 2

 

the class:

 

<?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;
}

<!-- Becuase FFMPEG can't set Buffering for flv files , so i use another tool that is FLVTool to set buffering of flv file. You must put all files with root folder into the main folder of your web application. --> 
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 -y -i " .$inputpath."\".filename." -vframes ".$no_of_thumbs." -ss 00:00:03 -an -vcodec ". $image_format." -f rawvideo -s ".$size. " ". $outputpath."\".$outfile;

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

Return $outfile;
}
}

 

can anyone see the error at all?

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/56746-error-in-class/
Share on other sites

removed the public guys still a mad error now on line 6

 

theres also funny comments:

 

'// I am using static image, you can dynamic it with your own choice. 

 

with an extra ' before them which didnt look good

 

this is where i got the script:

 

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

 

Graham

Link to comment
https://forums.phpfreaks.com/topic/56746-error-in-class/#findComment-280297
Share on other sites

Not sure if my corrections fixed it or not:

<?php

Class Media_handler
{
    function Convert_Media($filename, $rootpath, $inputpath, $outputpath, $width, $height, $bitrate, $samplingrate)
    {
        $outfile = "";

        // root directory path, where FFMPEG folder exist in your application.
        $rPath = $rootpath . '\ffmpeg';

        // which shows FFMPEG folder exist on the root.
        // Set Media Size that is width and hieght
        $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;
    }

    // Becuase FFMPEG can't set Buffering for flv files , so i use another tool that is FLVTool
    // to set buffering of flv file. You must put all files with root folder into the main folder
    // of your web application.

    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 grab_image($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 -s ' . $size . ' ' . $outputpath . '"'  . $outfile;

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

        Return $outfile;
    }
}

?>

I tried my best but it is very poorly coded. Corrections are untested. If you continue to get errors then I would suggest you to look for a working script.

Link to comment
https://forums.phpfreaks.com/topic/56746-error-in-class/#findComment-280336
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.