nicholasstephan Posted November 21, 2008 Share Posted November 21, 2008 Hey, I'm trying to encode some video using php and ffmpeg. I'm new ffmpeg and calling command line tools using php in general, so I don't even know where to start looking for problems here. I've got some code that puts together the following ffmpeg calls for an uploaded movie: /usr/local/bin/ffmpeg -i /tmp/phpKSRTnC -f mpg -b 1500k -ab 64k -ac 2 -ar 44100 -r 25 -s 667x500 -title test -author test351 -comment test userVideo/mpg/test351492701c2c521a.mpg /usr/local/bin/ffmpeg -i /tmp/phpKSRTnC -f flv -b 900k -ab 64k -ac 1 -ar 44100 -r 25 -s 300x225 -title test -author test351 -comment test userVideo/flv/test351492701c2c521a.flv and /usr/local/bin/ffmpeg -i /tmp/phpKSRTnC -f flv -b 100k -ab 32k -ac 1 -ar 44100 -r 25 -s 67x50 -title test -author test351 -comment test userVideo/thumbs/test351492701c2c521a.flv ... which when I call with exec() seems to do nothing. I get a blank array for the &$output, and 1 in &$return_var, but no movies come out the other end. I've looked into all the usual newb problems like permissions and ini memory limites, etc... but I can't even get it to give me an error. I then found a piece of code online: function runExternal( $cmd, &$code ) { $descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 => array("pipe", "w") // stderr is a file to write to ); $pipes= array(); $process = proc_open($cmd, $descriptorspec, $pipes); $output= ""; if (!is_resource($process)) return false; //close child's input imidiately fclose($pipes[0]); stream_set_blocking($pipes[1],false); stream_set_blocking($pipes[2],false); $todo= array($pipes[1],$pipes[2]); while( true ) { $read = array(); if(!feof($pipes[1])) $read[]= $pipes[1]; if(!feof($pipes[2])) $read[]= $pipes[2]; if (!$read) break; $ready= stream_select($read, $write=NULL, $ex= NULL, 2); if ($ready === false) { break; //should never happen - something died } foreach ($read as $r) { $s= fread($r,1024); $output.= $s; } } fclose($pipes[1]); fclose($pipes[2]); $code= proc_close($process); return $output; } about which I'm completely clueless, but it seems to run through cleanly, but still no movies on the other end. Once, an flv showed up in the thumbs directory, but it was massive (15000xsomething) instead of the 67x50 specified by -s, which makes me think it's my ffmpeg call that's to blame. Anybody done this before? Any gems of wisdom for me? Thanks Link to comment https://forums.phpfreaks.com/topic/133690-php-ffmpeg/ Share on other sites More sharing options...
nicholasstephan Posted November 21, 2008 Author Share Posted November 21, 2008 ok - I've built a very simple html form that shunts to the input into a php exec... it seems my ffmpeg call works perfectly... until I add the -s WxH option, which give me a return_var of 1, and nothing come out the other side. Any thoughts? Link to comment https://forums.phpfreaks.com/topic/133690-php-ffmpeg/#findComment-695666 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.