Can any one help me. I looking to convert a video file into flv using php and ffmpeg. I have tried some of the exi开发者_如何学JAVAsting solution on stackoverflow but with no luck.
exec('ffmpeg -i Videos/robot.avi -ab 96k -b 700k -ar 44100 -s 640x480 -acodec mp3 Videos/robot.flv');
This is my code nothing happens when I execute this.
I assume your ffmpeg command works from CLI OK. If not, get that working first.
If you are trying to output FLV created on-the-fly with PHP and ffmpeg, try this:
<?php
header("video/x-flv");
passthru('ffmpeg -i Videos/robot.avi -ab 96k -b 700k -ar 44100 -s 640x480 -acodec mp3 Videos/robot.flv');
?>
#### EDIT #####
Here is a link to ffmpeg documentation that talks about using STDOUT: http://www.ffmpeg.org/ffmpeg-doc.html#TOC41
I think you should be able to do this:
<?php
header("video/x-flv");
passthru('ffmpeg -i Videos/robot.avi -ab 96k -b 700k -ar 44100 -s 640x480 -acodec mp3 -f flv pipe:');
?>
Check out this example: https://trac.ffmpeg.org/wiki/PHP
You should get it running in your CLI first before writing a PHP script.
After reading the example it seems like you want to use
shell_exec("insert ffmpeg command here");
Here's an ffmpeg php class that might be helpful:
https://github.com/olaferlandsen/FFmpeg-PHP-Class
I needed 'sudo' to run it on my local machine. For video/x-flv you need: "Content-Type: video/x-flv". My code:
<?php
header("Content-Type: video/x-flv");
passthru('sudo ffmpeg -i Videos/robot.avi -ab 96k -b 700k -ar 44100 -s 640x480 -acodec mp3 -f flv pipe:');
?>
精彩评论