Invision Power Services: PHP Convert video to FLV - Invision Power Services

Jump to content

Web Design and Coding

Our community chat forum areas are for off-topic discussion only. Please do not post topics about IPS or its products and services here. We provide other forum areas for IPS discussion.

Do you need technical support on IPS products or services?

You can obtain support via the client area, or you can try to obtain peer-to-peer support at IPS Resources.

Did you find a bug in one of our products?

If you believe you've found a bug please post it to the bug tracker.

Have a suggestion or feedback?

Use the company feedback forum or appropriate product feedback forum. You can also submit a ticket in your client area if it's a private matter.
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

PHP Convert video to FLV Rate Topic: -----

#1 User is offline   Vince G. Icon

  • Lead Developer
  • PipPipPipPipPipPip
  • View blog
  • Group: Community Devs
  • Posts: 1,492
  • Joined: 05-February 07
  • Location:Israel / USA

Posted 12 May 2009 - 09:21 AM

Did any one actually tried this and got this working? I am stuck in a position where ffmpeg is loaded and everything seems to be working but my exec command just won't do anything.

Here is what i have so far:

<?php
// Set our source file
$root_path = dirname(__FILE__).'/';

$srcFile = $root_path."video.wmv";
$destFile = $root_path."video.flv";
$ffmpegPath = "/usr/local/bin/ffmpeg";
$flvtool2Path = "/usr/bin/flvtool2";
// Create our FFMPEG-PHP class
$ffmpegObj = new ffmpeg_movie($srcFile);
// Save our needed variables
$srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth());
$srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
$srcFPS = $ffmpegObj->getFrameRate();
$srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
$srcAR = $ffmpegObj->getAudioSampleRate();
// Call our convert using exec()
//exec($ffmpegPath . " -i " . $srcFile . " -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . " " . $destFile);
exec("{$ffmpegPath} -i {$srcFile} -f flv -acodec mp3 -ab 64 -ac 1  {$destFile}");

echo "done";
// -i video.avi -ar 22050 -ab 32 -f flv -s 320x240 video.flv
// Make multiples function
function makeMultipleTwo ($value)
{
	$sType = gettype($value/2);
	if($sType == "integer")
	{
		return $value;
	}
	else
	{
		return ($value-1);
	}
}


That doesn't work. No error but the flv file is not created. Any ideas?

Thanks.
Vince Gabriel, Lead Developer.
Posted ImagePosted Image

formerly known as vadimg88
0

#2 User is offline   Vince G. Icon

  • Lead Developer
  • PipPipPipPipPipPip
  • View blog
  • Group: Community Devs
  • Posts: 1,492
  • Joined: 05-February 07
  • Location:Israel / USA

Posted 12 May 2009 - 05:16 PM

OK got this working.
Vince Gabriel, Lead Developer.
Posted ImagePosted Image

formerly known as vadimg88
0

#3 User is offline   arikbh Icon

  • IPB Newbie
  • Pip
  • View blog
  • Group: Members
  • Posts: 5
  • Joined: 04-July 09

Posted 04 July 2009 - 12:29 PM

How did u solved it ?

im stuck with my script ... it just load empty white page and it doesnt create the flv file ... where am i wrong here ?

<?php
// Set our source file
$srcFile = "/home/smsssco/public_html/1.avi";
$destFile = "/public_html/2.flv";
$ffmpegPath = " /usr/local/bin/ffmpeg";
$flvtool2Path = "/usr/local/bin/flvtool2 ";

// Create our FFMPEG-PHP class
$ffmpegObj = new ffmpeg_movie($srcFile);

// Save our needed variables
$srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth());
$srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
$srcFPS = $ffmpegObj->getFrameRate(20);
$srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
$srcAR = $ffmpegObj->getAudioSampleRate();

// Call our convert using exec()
exec($ffmpegPath . " -i " . $srcFile . " -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . " " . $destFile . " | " . $flvtool2Path . " -U stdin " . $destFile);


// Make multiples function
function makeMultipleTwo ($value)
{
$sType = gettype($value/2);
if($sType == "integer")
{
return $value;
} else {
return ($value-1);
}
}
?>
0

#4 User is offline   Vince G. Icon

  • Lead Developer
  • PipPipPipPipPipPip
  • View blog
  • Group: Community Devs
  • Posts: 1,492
  • Joined: 05-February 07
  • Location:Israel / USA

Posted 04 July 2009 - 06:08 PM

This is what i used:

$video_path = $this->ipsclass->vars['videos_localfilepath'] . '/' . $video['video_filename'];
		$video_flv_path = $this->ipsclass->vars['videos_localfilepath'] . '/' . $this->_get_file_no_extension($video['video_filename']).'.flv';
		exec("ffmpeg -i {$video_path} -ar 22050 -ab 32 -f flv -s 320x240 {$video_flv_path}");

Vince Gabriel, Lead Developer.
Posted ImagePosted Image

formerly known as vadimg88
1

#5 User is offline   Mat (FDNZ) Icon

  • Let's say my yearly license expired in...
  • Icon
  • View blog
  • Group: +Active Customers
  • Posts: 3,869
  • Joined: 07-November 03
  • Location:Auckland, NZ

Posted 05 July 2009 - 06:16 AM

View Postarikbh, on 05 July 2009 - 01:29 AM, said:

How did u solved it ?

im stuck with my script ... it just load empty white page and it doesnt create the flv file ... where am i wrong here ?



Your web host may have disabled exec(). In fact, if you're on shared hosting this is almost a certainty. Check your PHP error log (this can be found in cPanel, I think) for the actual error.

If you've a dedicated server, then I assume that you or the company who manages the server for you can get the PHP error log.
0

#6 User is offline   abu Icon

  • IPB Newbie
  • Pip
  • View blog
  • Group: Members
  • Posts: 6
  • Joined: 01-December 09

Posted 01 December 2009 - 12:02 PM

What's wrog with this. everything going okey, but output flv file is 0kb. Plz help

View PostVince G., on 12 May 2009 - 09:21 AM, said:

Did any one actually tried this and got this working? I am stuck in a position where ffmpeg is loaded and everything seems to be working but my exec command just won't do anything.

Here is what i have so far:

<?php
// Set our source file
$root_path = dirname(__FILE__).'/';

$srcFile = $root_path."video.wmv";
$destFile = $root_path."video.flv";
$ffmpegPath = "/usr/local/bin/ffmpeg";
$flvtool2Path = "/usr/bin/flvtool2";
// Create our FFMPEG-PHP class
$ffmpegObj = new ffmpeg_movie($srcFile);
// Save our needed variables
$srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth());
$srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
$srcFPS = $ffmpegObj->getFrameRate();
$srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
$srcAR = $ffmpegObj->getAudioSampleRate();
// Call our convert using exec()
//exec($ffmpegPath . " -i " . $srcFile . " -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . " " . $destFile);
exec("{$ffmpegPath} -i {$srcFile} -f flv -acodec mp3 -ab 64 -ac 1  {$destFile}");

echo "done";
// -i video.avi -ar 22050 -ab 32 -f flv -s 320x240 video.flv
// Make multiples function
function makeMultipleTwo ($value)
{
	$sType = gettype($value/2);
	if($sType == "integer")
	{
		return $value;
	}
	else
	{
		return ($value-1);
	}
}


That doesn't work. No error but the flv file is not created. Any ideas?

Thanks.

0

#7 User is offline   abu Icon

  • IPB Newbie
  • Pip
  • View blog
  • Group: Members
  • Posts: 6
  • Joined: 01-December 09

Posted 01 December 2009 - 12:04 PM

Here is my code it will convert to flv but size can be 0KB.

<?php
function makeMultipleTwo ($value){
$sType = gettype($value/2);
if($sType == "integer"){
return $value;
} else {
return ($value-1);
}
}

$srcFile = "kabhi-alvida.avi";
$destFile = ".flvs/kabhi-alvida.flv";
$ffmpegPath = "/usr/local/bin/ffmpeg";
$flvtool2Path = "/usr/local/bin/flvtool2";


$ffmpegObj = new ffmpeg_movie($srcFile);


$srcWidth = makeMultipleTwo($ffmpegObj->getFrameWidth());
$srcHeight = makeMultipleTwo($ffmpegObj->getFrameHeight());
$srcFPS = $ffmpegObj->getFrameRate();
$srcAB = intval($ffmpegObj->getAudioBitRate()/1000);
$srcAR = $ffmpegObj->getAudioSampleRate();


$command = $ffmpegPath . " -i " . $srcFile . " -ar " . $srcAR . " -ab " . $srcAB . " -f flv -s " . $srcWidth . "x" . $srcHeight . " " . $destFile . " | " . $flvtool2Path . " -U stdin " . $destFile;
$convert = exec($command);



if(!$convert){
echo "FAILED!!!";
}

?>
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users