Reputation: 691
OS: ubuntu 11.10 Webserver: Apache Code: PHP I am trying to display the output of command "ffmpeg -i " on the webpage using php. Required: The webpage should show the information about video (text). Whats happening: The webpage shows no text output on running the php code. If I was however doing system("ls") the code runs fine and outputs the list of files. Here's my code
<?php
echo "Details of video file:";
system('ffmpeg -i /home/atish/Videos/T2V0040006_Angled_ride_720x576i_FLDCMB.avi');
?>
The same command works fine on my shell, and my system has ffmpeg installed. Here's a snapshot of executing this command directly on shell:
ThinkPad-T420:~/Videos$ ffmpeg -i /home/xx/Videos/T2V0040006_Angled_ride_720x576i_FLDCMB.avi
ffmpeg version git-2012-01-10-7e2ba2d Copyright (c) 2000-2012 the FFmpeg developers
built on Jan 10 2012 12:01:19 with gcc 4.6.1
configuration: --enable-gpl --enable-libfaac --enable-libmp3lame --enable-libopencore- amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvorbis --enable-libx264 --enable-nonfree --enable-postproc --enable-version3 --enable-x11grab
libavutil 51. 34.100 / 51. 34.100
libavcodec 53. 54.100 / 53. 54.100
libavformat 53. 29.100 / 53. 29.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 58.100 / 2. 58.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 51. 2.100 / 51. 2.100
Input #0, avi, from '/home/atish/Videos/T2V0040006_Angled_ride_720x576i_FLDCMB.avi':
Metadata:
encoder : Lavf52.23.1
Duration: 00:00:29.00, start: 0.000000, bitrate: 124422 kb/s
Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 720x576, 25 tbr, 25 tbn, 25 tbc
At least one output file must be specified
I have tried appending "DISPLAY=:0" to my command and also done "xhost +" before running php code, but nothing is helping me out.
Thanks.
Upvotes: 0
Views: 1141
Reputation: 691
This link explains the how and why. Thanks for the replies folks.
This is the way to get the desired output:
echo exec('/usr/local/bin/ffmpeg -i input.mp4 2>&1', $output);
var_dump($output);
Upvotes: 1
Reputation: 12018
Have you tried exec() instead of system()? See here for a discussion of issues with PHP and ffmpeg as well as a method that uses proc_open().
Upvotes: 0
Reputation: 890
You need to use exec
instead, and pass an output parameter like so
$op = array();
exec('ffmpeg -i /home/atish/Videos/T2V0040006_Angled_ride_720x576i_FLDCMB.avi', $op)
REF: http://php.net/manual/en/function.exec.php
Upvotes: 0