FFMPEG-PHP: converting videos |
Author: |
Message: |
Weyzza
Veteran Member
SoCal sunset > *
Posts: 1170 Reputation: 29
– / / –
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 7853 days, 15 hours, 13 minutes, 40 seconds ago.
Happy Birthday, WDZ
|
|
03-06-2007 07:42 PM |
|
|
WDZ
Former Admin
Posts: 7106 Reputation: 107
– / /
Joined: Mar 2002
|
RE: FFMPEG-PHP: converting videos
shell_exec() isn't supposed to output anything... try putting an echo in front of it.
|
|
03-06-2007 07:53 PM |
|
|
Weyzza
Veteran Member
SoCal sunset > *
Posts: 1170 Reputation: 29
– / / –
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.
What I meant with "anything" was the output file
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 7853 days, 15 hours, 13 minutes, 40 seconds ago.
Happy Birthday, WDZ
|
|
03-06-2007 08:03 PM |
|
|
WDZ
Former Admin
Posts: 7106 Reputation: 107
– / /
Joined: Mar 2002
|
RE: RE: FFMPEG-PHP: converting videos
quote: Originally posted by Weyzza
What I meant with "anything" was the output file
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.
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 |
|
|
Weyzza
Veteran Member
SoCal sunset > *
Posts: 1170 Reputation: 29
– / / –
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
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 7853 days, 15 hours, 13 minutes, 40 seconds ago.
Happy Birthday, WDZ
|
|
03-06-2007 08:54 PM |
|
|
WDZ
Former Admin
Posts: 7106 Reputation: 107
– / /
Joined: Mar 2002
|
RE: FFMPEG-PHP: converting videos
quote: Originally posted by Weyzza
I will confirm my hosting provider soon.
k.
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 |
|
|
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 |
|
|
Dr4g0n
Full Member
Posts: 376 Reputation: 15
34 / /
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 |
|
|
-dt-
Scripting Contest Winner
;o
Posts: 1819 Reputation: 74
36 / /
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 ;>
Happy Birthday, WDZ
|
|
05-09-2009 03:36 PM |
|
|
Dr4g0n
Full Member
Posts: 376 Reputation: 15
34 / /
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 |
|
|
|