I wrote few lines of codes today to create an video from an image with ffmpeg.
the command works well directly on my server and the file is saved at the good place, but when running it from PHP, the process goes, but the file won't save for some reason.
Here is the code I use :
$ffmpegcmd= "/usr/bin/ffmpeg -loop 1 -y -i /home/mysite/www/forwork/simpletext.jpg -c:v libx264 -t 30 -pix_fmt yuv420p /home/mysite/www/forwork/movie.avi 2>&1";
exec($ffmpegcmd, $output);
print_r($output);
And here is the answer I get :
Array ( [0] => ffmpeg version git-2015-09-06-db18b3d Copyright (c) 2000-2015 the FFmpeg developers
[1] => built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-16)
[2] => configuration: --prefix=/usr/ffmpeg_build --extra-cflags=-I/usr/ffmpeg_build/include --extra-ldflags=-L/usr/ffmpeg_build/lib --bindir=/usr/bin --pkg-config-flags=--static --enable-gpl --enable-nonfree --enable-libfdk-aac --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265
[3] => libavutil 55. 0.100 / 55. 0.100
[4] => libavcodec 57. 0.100 / 57. 0.100
[5] => libavformat 57. 0.100 / 57. 0.100
[6] => libavdevice 57. 0.100 / 57. 0.100
[7] => libavfilter 6. 0.100 / 6. 0.100
[8] => libswscale 4. 0.100 / 4. 0.100
[9] => libswresample 2. 0.100 / 2. 0.100
[10] => libpostproc 54. 0.100 / 54. 0.100
[11] => Input #0, image2, from '/home/mysite/www/forwork/simpletext.jpg':
[12] => Duration: 00:00:00.04, start: 0.000000, bitrate: 10414 kb/s
[13] => Stream #0:0: Video: mjpeg, yuvj420p(pc, bt470bg/unknown/unknown), 1280x720 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn, 25 tbc
[14] => /home/mysite/www/forwork/movie.avi: Permission denied )
I chmod the forwork directory to 755 but it won't change anything.
help troubleshooting this would be greatly appreciate. Thanks
chmod -R 755 /home/mysite/www/forwork/? If the file has different permissions that could be an issue. Also remember php runs a different user to you...movie.avi(might not solve your question but a worthwhile thing to check.