Reputation: 567
I am trying to get ffmpeg to work using PHP, in its most basic format, just as a test before i develop my code further.
However i can not get it to work and get no error messages or indications to what is wrong :-(
i am trying:
echo exec("/usr/bin/ffmpeg -y -i /home/xxxxxx/public_html/videos/1746/0765916.avi /home/xxxxxx/public_html/videos/1746/test.mp4");
this is creating a 0kb file, but nothing else :-( i get no error message (or anything else!)
(i have error_reporting turned ON and nothing is displayed in browser or server logs)
if i add the below to get the codecs available:
echo exec("ffmpeg -formats");
this just outputs "worse."
I do not have access to command line, as i am using a shared hosting server.
I have had the host run the above from command line, and they say it says "codec not found" or words to the effect.
is there any way i can get any error output into my php file so i can see what is happening.
Also how do i go about installing codecs, if this is the problem (the host will install them, but have mentioned they have never installed a codec on a Linux box, so would be grateful if i could point them to any install info too)
Thanks in advance!
EDIT:
after adding in the code that @stewe suggests, this is the output when trying to convert to mp4
(i can convert to to other formats fine )
FFmpeg version SVN-r0.5.10-4:0.5.10-1, Copyright (c) 2000-2009 Fabrice
Bellard, et al. configuration: --extra-version=4:0.5.10-1
--prefix=/usr --enable-avfilter --enable-avfilter-lavf --enable-vdpau --enable-bzlib --enable-libdirac --enable-libgsm --enable-libopenjpeg --enable-libschroedinger --enable-libspeex --enable-libtheora --enable-libvorbis --enable-pthreads --enable-zlib --disable-stripping --disable-vhook --enable-runtime-cpudetect --enable-gpl --enable-postproc --enable-swscale --enable-x11grab --enable-libfaad --enable-libdc1394 --enable-shared --disable-static libavutil 49.15. 0 / 49.15. 0 libavcodec 52.20. 1 / 52.20. 1 libavformat 52.31. 0 /
52.31. 0 libavdevice 52. 1. 0 / 52. 1. 0 libavfilter 0. 4. 0 / 0. 4. 0 libswscale 0. 7. 1 / 0. 7. 1 libpostproc 51. 2. 0 / 51. 2. 0 built on
Feb 16 2013 10:07:01, gcc: 4.4.5 Input #0, avi, from
'/home/xxxxx/public_html/videos/1746/0765916.avi':
Duration: 00:01:37.56, start: 0.000000, bitrate: 868 kb/s Stream #0.0:
Video: mpeg4, yuv420p, 480x272 [PAR 1:1 DAR 30:17], 25 tbr, 25 tbn, 25
tbc Stream #0.1: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s Output
#0, mp4, to '/home/xxxxx/public_html/videos/1746/test.mp4':
Stream #0.0: Video: mpeg4, yuv420p, 480x272 [PAR 1:1 DAR 30:17],
q=2-31, 200 kb/s, 90k tbn, 25 tbc Stream #0.1: Audio: 0x0000, 48000
Hz, stereo, s16, 64 kb/s Stream mapping: Stream #0.0 -> #0.0 Stream
#0.1 -> #0.1 [mpeg4 @ 0x9fb7880]removing common factors from framerate Unsupported codec for output stream #0.1
If anyone can help as to how to fix this issue, as i would ideally like to convert to mp4
Upvotes: 0
Views: 195
Reputation: 133753
ffmpeg
is ancientFFmpeg development is very active, but you're using version SVN-r0.5.10-4:0.5.10-1. This is incredibly old and is unsupported by the FFmpeg project.
I'll bet once you get a recent version it will work as expected. Note that once you upgrade if your new build supports libx264, then it will encode H.264 video for MP4 output. Your current geriatric build is outputting MPEG-4 Part 2 video instead.
Note that you can't just "install a codec" and expect FFmpeg to work. Here are some methods to upgrade:
Download a build of ffmpeg
. Point your script to it. Simple and easy.
Compile ffmpeg
. Refer to a step-by-step compile guide. Should work on shared servers as long as they provide the proper packages needed to compile (gcc
and make
at a minimum).
Ask your host to upgrade. They may or may not know how to do this or they may only provide another ancient build.
Upvotes: 1
Reputation: 42632
You get the full output like this:
echo shell_exec("ffmpeg -formats 2>&1");
the 2>&1
part redirects the stderr to stdout, so you also get the error messages.
Upvotes: 1