I’m trying to convert avi file to flv format using FFMPEG on server, but its giving me problems. On conversion, the file is converted to flv format but no data (0 kb size file). Tried debugging the code but could not. The FFMPEG is installed in CentOS, in path /usr/bin/ffmpeg, and i’m using following command for conversion:
$srcFile = "/home/mydomain/public_html/demo/test/sample.avi"; $destFile = "/home/mydomain/public_html/demo/test/sample_again.flv"; $ffmpegPath = "/usr/bin/ffmpeg"; $flvtool2Path = "/usr/local/bin/flvtool2"; $command = $ffmpegPath . " -y -i " . $srcFile . " -ar 32000 -ab 32000 -f flv -s 320x240 ". $destFile . " | " . $flvtool2Path . " -U stdin " . $destFile; exec($command, $output); print_r($output);
I tried doing:
exec("which ffmpeg");
And it gave me the path /usr/bin/ffmpeg, but get following error when i execute the code:
Array ( [0] => ERROR: undefined method `timestamp' for nil:NilClass [1] => ERROR: /usr/local/cpffmpeg/lib/ruby/site_ruby/1.8/flv/stream.rb:285:in `lasttimestamp' [2] => ERROR: /usr/local/cpffmpeg/lib/ruby/site_ruby/1.8/flv/stream.rb:274:in `duration' [3] => ERROR: /usr/local/cpffmpeg/lib/ruby/site_ruby/1.8/flvtool2/base.rb:181:in `add_meta_data_tag' [4] => ERROR: /usr/local/cpffmpeg/lib/ruby/site_ruby/1.8/flvtool2/base.rb:137:in `update' [5] => ERROR: /usr/local/cpffmpeg/lib/ruby/site_ruby/1.8/flvtool2/base.rb:47:in `send' [6] => ERROR: /usr/local/cpffmpeg/lib/ruby/site_ruby/1.8/flvtool2/base.rb:47:in `execute!' [7] => ERROR: /usr/local/cpffmpeg/lib/ruby/site_ruby/1.8/flvtool2/base.rb:46:in `each' [8] => ERROR: /usr/local/cpffmpeg/lib/ruby/site_ruby/1.8/flvtool2/base.rb:46:in `execute!' [9] => ERROR: /usr/local/cpffmpeg/lib/ruby/site_ruby/1.8/flvtool2/base.rb:206:in `process_files' [10] => ERROR: /usr/local/cpffmpeg/lib/ruby/site_ruby/1.8/flvtool2/base.rb:44:in `execute!' [11] => ERROR: /usr/local/cpffmpeg/lib/ruby/site_ruby/1.8/flvtool2.rb:168:in `execute!' [12] => ERROR: /usr/local/cpffmpeg/lib/ruby/site_ruby/1.8/flvtool2.rb:228 [13] => ERROR: /usr/local/bin/flvtool2:2:in `require' [14] => ERROR: /usr/local/bin/flvtool2:2 )
What could be the problem. Is this the problem of Flvtool2, if yes then what is it. Please suggest something
Can you var_dump($command) then run that command in the shell (as the user that apache is running under) ?