What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Skype & Technology » Tech Talk » FFMPEG-PHP: converting videos

FFMPEG-PHP: converting videos
Author: Message:
Weyzza
Veteran Member
*****

Avatar
SoCal sunset > *

Posts: 1170
Reputation: 29
– / Male / –
Joined: May 2003
O.P. FFMPEG-PHP: converting videos
I want to convert any videos to FLV format.
code:
<?php
convertToFlv( "test.avi", "test.flv" );

function convertToFlv( $input, $output ) {
   echo "Converting $input to $output<br />";
   $command = "ffmpeg -i $input -s 320x240 -ar 44100 -r 12 $output";
   echo "$command<br />";
   shell_exec( $command );
   echo "Converted<br />";
}
?>
For some reason, it doesn't output anything.
What am I missing here?

ffmpeg
ffmpeg support (ffmpeg-php)     enabled
ffmpeg-php version              0.5.0
libavcodec version              Lavc51.32.0
libavformat version             Lavf51.8.0
Registered 7849 days, 19 hours, 32 minutes, 12 seconds ago.
Happy Birthday, WDZ

03-06-2007 07:42 PM
Profile PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: FFMPEG-PHP: converting videos
shell_exec() isn't supposed to output anything... try putting an echo in front of it. :p
03-06-2007 07:53 PM
Profile PM Web Find Quote Report
Weyzza
Veteran Member
*****

Avatar
SoCal sunset > *

Posts: 1170
Reputation: 29
– / Male / –
Joined: May 2003
O.P. RE: FFMPEG-PHP: converting videos
quote:
Originally posted by WDZ
shell_exec() isn't supposed to output anything... try putting an echo in front of it. :p
What I meant with "anything" was the output file :p

Anyways, I added an echo there, and it's still the same.
It even doesn't say whether the library/command is unavailable or something.

I have a strange feeling that I have to call it in another way (creating a new object, etc.).
Registered 7849 days, 19 hours, 32 minutes, 12 seconds ago.
Happy Birthday, WDZ

03-06-2007 08:03 PM
Profile PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: RE: FFMPEG-PHP: converting videos
quote:
Originally posted by Weyzza
What I meant with "anything" was the output file :p
I thought that might be the case, but still, there should be some kind of error message if it fails... :-/

quote:
Anyways, I added an echo there, and it's still the same.
It even doesn't say whether the library/command is unavailable or something.
:S

Try a simple test...
code:
<?php

$output = shell_exec("ffmpeg -formats");

echo "<pre>";
print_r($output);
echo "</pre>";

?>
If successful, that should display info about the formats FFmpeg supports, and confirm that you can run it. If it doesn't work, I'm not sure what the problem is... maybe you have to specify the absolute path to the FFmpeg binary or something.

quote:
I have a strange feeling that I have to call it in another way (creating a new object, etc.).
I doubt it... the ffmpeg-php extension is only "for accessing and retrieving information from video and audio files." It doesn't do conversion. Besides, that script I linked to in the shoutbox simply calls shell_exec()...
03-06-2007 08:38 PM
Profile PM Web Find Quote Report
Weyzza
Veteran Member
*****

Avatar
SoCal sunset > *

Posts: 1170
Reputation: 29
– / Male / –
Joined: May 2003
O.P. RE: RE: RE: FFMPEG-PHP: converting videos
quote:
Originally posted by WDZ
code:
<?php

$output = shell_exec("ffmpeg -formats");

echo "<pre>";
print_r($output);
echo "</pre>";

?>

I tried it earlier, and it printed nothing.
quote:
maybe you have to specify the absolute path to the FFmpeg binary or something.
Tried with /usr/local/bin/ffmpeg. It didn't work, either :p
I will confirm my hosting provider soon.
quote:
I doubt it... the ffmpeg-php extension is only "for accessing and retrieving information from video and audio files." It doesn't do conversion. Besides, that script I linked to in the shoutbox simply calls shell_exec()...

So FFMPEG-PHP is not the same as FFMPEG?
* Weyzza slaps himself around a bit with a large trout.
Registered 7849 days, 19 hours, 32 minutes, 12 seconds ago.
Happy Birthday, WDZ

03-06-2007 08:54 PM
Profile PM Find Quote Report
WDZ
Former Admin
*****

Avatar

Posts: 7106
Reputation: 107
– / Male / Flag
Joined: Mar 2002
RE: FFMPEG-PHP: converting videos
quote:
Originally posted by Weyzza
I will confirm my hosting provider soon.
k. :tongue:

quote:
So FFMPEG-PHP is not the same as FFMPEG?
Correct, ffmpeg is a command-line program that has nothing to do with PHP. ffmpeg-php is a PHP extension that incorporates some of the capabilities of ffmpeg.

Edit: I tested your convertToFlv() function on my localhost (Win32) and it worked fine. All I had to do was change the path to ffmpeg.exe.

This post was edited on 03-06-2007 at 09:37 PM by WDZ.
03-06-2007 09:11 PM
Profile PM Web Find Quote Report
mysoogal
New Member
*


Posts: 2
Joined: May 2009
RE: FFMPEG-PHP: converting videos
its 2009 ! lol

this is what i'm looking for but , i really hate flv ! flash now supports h264 !

how can i change this,
---------------------------------------------------------------------------------------
<?php
convertToFlv( "test.avi", "test.flv" );

function convertToFlv( $input, $output ) {
   echo "Converting $input to $output<br />";
   $command = "ffmpeg -i $input -s 320x240 -ar 44100 -r 12 $output";
   echo "$command<br />";
   shell_exec( $command );
   echo "Converted<br />";
}
?>

----------------------------------------------------------------------------------------------------------

to support this,

mencoder video.mpeg -o output.mp4 -af volume=10 -aspect 16:9 -of avi -noodml -ovc x264 -x264encopts bitrate=300:level_idc=41:bframes=3:frameref=2: nopsnr: nossim: pass=1: threads=auto -oac mp3lame

i'm not sure if mencoder can be called through like php. which runs with ffmpeg-php i believe.

i just want to encode to h264 video, mp3 audio, and output container to be ogg or ogm.

and yes i do notice this post was made years ago lol who knows maybe i get reply
05-03-2009 08:55 PM
Profile E-Mail PM Find Quote Report
Dr4g0n
Full Member
***

Avatar

Posts: 376
Reputation: 15
34 / Male / Flag
Joined: Nov 2003
RE: FFMPEG-PHP: converting videos
code:
<?php
convertToFlv( "test.avi", "test.flv" );

function convertToFlv( $input, $output ) {
   echo "Converting $input to $output<br />";
   $command = "mencoder $input -o $output -af volume=10 -aspect 16:9 -of avi -noodml -ovc x264 -x264encopts bitrate=300:level_idc=41:bframes=3:frameref=2: nopsnr: nossim: pass=1: threads=auto -oac mp3lame ";
   echo "$command<br />";
   shell_exec( $command );
   echo "Converted<br />";
}
?>

How about that? Uses the mencoder command you wanted.
05-09-2009 03:28 PM
Profile PM Web Find Quote Report
-dt-
Scripting Contest Winner
*****

Avatar
;o

Posts: 1819
Reputation: 74
36 / Male / Flag
Joined: Mar 2004
RE: FFMPEG-PHP: converting videos
also remember if you're passing an argument into the command line, use http://php.net/escapeshellarg to make it safeish ;>
[Image: dt2.0v2.png]      Happy Birthday, WDZ
05-09-2009 03:36 PM
Profile PM Web Find Quote Report
Dr4g0n
Full Member
***

Avatar

Posts: 376
Reputation: 15
34 / Male / Flag
Joined: Nov 2003
RE: FFMPEG-PHP: converting videos
quote:
Originally posted by -dt-
also remember if you're passing an argument into the command line, use http://php.net/escapeshellarg to make it safeish ;>

Yeah thanks dt, slipped my mind.

code:
<?php
convertToFlv( "test.avi", "test.flv" );

function convertToFlv( $input, $output ) {
   $input = escapeshellarg($input);
   $output = escapeshellarg($output);
   echo "Converting $input to $output<br />";
   $command = "mencoder $input -o $output -af volume=10 -aspect 16:9 -of avi -noodml -ovc x264 -x264encopts bitrate=300:level_idc=41:bframes=3:frameref=2: nopsnr: nossim: pass=1: threads=auto -oac mp3lame ";
   echo "$command<br />";
   shell_exec( $command );
   echo "Converted<br />";
}
?>
05-09-2009 03:42 PM
Profile PM Web Find Quote Report
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On