0

I'm working on a upload script where users can upload videos however I'm having an issue with FFMPEG-PHP : The converted videos don't work on mobiles while they are working fine on desktop.

//FFMPEG Instance
require_once '/root/vendor/autoload.php';
$ffmpeg = FFMpeg\FFMpeg::create();
$video = $ffmpeg->open($temp_path);

//WEBM Convert
$format_webm = new FFMpeg\Format\Video\WebM();
$video->save($format_webm, 'video.webm');

//MP4 Convert
$format_mp4 = new FFMpeg\Format\Video\X264();
$format_mp4->setAudioCodec("libmp3lame");
$video->save($format_mp4, 'video.mp4');

Fatal error: Uncaught Alchemy\BinaryDriver\Exception\ExecutionFailureException: ffmpeg failed to execute command '/usr/bin/ffmpeg' '-y' '-i' '/var/www/html/v/temp/13759.mp4' '-vcodec' 'libx264' '-acodec' 'aac' '-b:v' '1000k' '-refs' '6' '-coder' '1' '-sc_threshold' '40' '-flags' '+loop' '-me_range' '16' '-subq' '7' '-i_qfactor' '0.71' '-qcomp' '0.6' '-qdiff' '4' '-trellis' '1' '-b:a' '128k' '-pass' '1' '-passlogfile' '/tmp/ffmpeg-passes5ad4e29d1b71e6oveh/pass-5ad4e29d1b7b2' '/var/www/html/v/13759.mp4' in /root/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php:100\nStack trace:\n#0 /root/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php(72): Alchemy\BinaryDriver\ProcessRunner->doExecutionFailure(''/usr/bin/ffmpe...')\n#1 /root/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php(209): Alchemy\BinaryDriver\ProcessRunner->run(Object(Symfony\Component\Process\Process), Object(SplObjectStorage), false) in /root/vendor/php-ffmpeg/php-ffmpeg/src/FFMpeg/Media/Video.php on line 109

Any help ?

casusbelli
  • 463
  • 1
  • 5
  • 22
  • 1
    I'm going to guess you mean the MP4 files specifically. Try `aac` instead of `libmp3lame`. – llogan Apr 16 '18 at 17:28
  • @LordNeckbeard Fatal error: Uncaught Alchemy\BinaryDriver\Exception\ExecutionFailureException: ffmpeg failed to execute command .... – casusbelli Apr 16 '18 at 17:55
  • If this is just a wrapper for the `ffmpeg` command-line tool then I need to see the actual `ffmpeg` command being executed and the complete log/console output from that command to make any suggestions. Otherwise it's a guessing game. Current guess is that your `ffmpeg` is very old and requires `-strict experimental` to use the AAC encoder. – llogan Apr 16 '18 at 17:58
  • I recommend you [edit] your question to add this info: you will have more room and you can format it better. The log from `ffmpeg` itself is missing. The log is required. Your input is already MP4. Do you need to re-encode it to MP4? Your `ffmpeg` command looks like it is from 2006. A modern command could look like: `ffmpeg -i input -c:v libx264 -preset medium -crf 23 -c:a aac -movflags +faststart output.mp4` See [FFmpeg Wiki: H.264](https://trac.ffmpeg.org/wiki/Encode/H.264). – llogan Apr 16 '18 at 18:28
  • @LordNeckbeard Where can I get the error logs from ffmpeg? If I understand your advice I shouldn't use ffmpeg-php but ffmpeg exec() commands? – casusbelli Apr 16 '18 at 18:48
  • I don't know your system, your code, or the language so I don't have any specific suggestions (`ffmpeg` outputs to stderr). As a last resort you can attempt to add the `-report` option to `ffmpeg` to create a log file in the current directory, but it makes an overly verbose output. If you want to use a PHP wrapper for ffmpeg feel free to do so but it may complicate fixing of problems and some of the wrappers are very old and outdated. I'm not sure which one you are using and there are some wrappers that have the same or very similar names (see [tag:ffmpeg-php] and [tag:php-ffmpeg]). – llogan Apr 16 '18 at 19:05

0 Answers0