Answer the question
In order to leave comments, you need to log in
Why can't Monolog write the file?
I'm trying to run HLS stream via FFMpeg.
I use the library https://github.com/aminyazdanpanah/PHP-FFmpeg-vide... .
The code:
require '/phplibs/vendor/autoload.php'; // path to the autoload file
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
$config = [
'ffmpeg.binaries' => '/usr/bin/ffmpeg',
'ffprobe.binaries' => '/usr/bin/ffprobe',
'timeout' => 3600, // The timeout for the underlying process
'ffmpeg.threads' => 12, // The number of threads that FFmpeg should use
];
$log = new Logger('FFmpeg_Streaming');
$log->pushHandler(new StreamHandler('/var/log/ffmpeg-streaming.log')); // path to log file
$ffmpeg = Streaming\FFMpeg::create($config, $log);
$video = $ffmpeg->open('video.mp4');
$video->hls()
->x264()
->autoGenerateRepresentations([1080, 480, 240])
->save('hls-stream.m3u8');
[Thu Nov 11 17:20:48.713222 2021] [proxy_fcgi:error] [pid 10223] [client IP:52534] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught Streaming\\Exception\\RuntimeException: Unable to save the file in /phplibs/vendor/aminyazdanpanah/php-ffmpeg-video-streaming/src/File.php:68\nStack trace:\n#0 /phplibs/vendor/aminyazdanpanah/php-ffmpeg-video-streaming/src/HLSPlaylist.php(92): Streaming\\File::put()\n#1 /phplibs/vendor/aminyazdanpanah/php-ffmpeg-video-streaming/src/HLS.php(314): Streaming\\HLSPlaylist->save()\n#2 /phplibs/vendor/aminyazdanpanah/php-ffmpeg-video-streaming/src/HLS.php(303): Streaming\\HLS->savePlaylist()\n#3 /phplibs/vendor/aminyazdanpanah/php-ffmpeg-video-streaming/src/Stream.php(123): Streaming\\HLS->getPath()\n#4 /phplibs/vendor/aminyazdanpanah/php-ffmpeg-video-streaming/src/Stream.php(163): Streaming\\Stream->run()\n#5 /var/www/html/test-hls/hls.php(21): Streaming\\Stream->save()\n#6 {main}\n thrown in /phplibs/vendor/aminyazdanpanah/php-ffmpeg-video-streaming/src/File.php on line 68'
[Thu Nov 11 17:19:17.884360 2021] [proxy_fcgi:error] [pid 10221] [client IP:52527] AH01071: Got error 'PHP message: PHP Fatal error: Uncaught UnexpectedValueException: The stream or file "/var/log/ffmpeg-streaming.log" could not be opened in append mode: failed to open stream: Permission denied in /phplibs/vendor/monolog/monolog/src/Monolog/Handler/StreamHandler.php:146\nStack trace:\n#0 /phplibs/vendor/monolog/monolog/src/Monolog/Handler/AbstractProcessingHandler.php(48): Monolog\\Handler\\StreamHandler->write()\n#1 /phplibs/vendor/monolog/monolog/src/Monolog/Logger.php(327): Monolog\\Handler\\AbstractProcessingHandler->handle()\n#2 /phplibs/vendor/monolog/monolog/src/Monolog/Logger.php(526): Monolog\\Logger->addRecord()\n#3 /phplibs/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/ProcessRunner.php(60): Monolog\\Logger->info()\n#4 /phplibs/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php(207): Alchemy\\BinaryDriver\\ProcessRunner->run()\n#5 /phplibs/vendor/alchemy/binary-driver/src/Alchemy/BinaryDriver/AbstractBinary.php(136): Alchemy\\BinaryDriver\\AbstractBinary->run()\n#6 /phplibs/...'
Permission Denied, created a file in the specified location, set the rights to 777. Answer the question
In order to leave comments, you need to log in
It's all in the error messages.
The monologue cursed that he did not have enough rights to record. And I swore rightly, because writing application logs to /var/log is a very so-so idea.
And this amyazdanpapanah herself does not swear at anything, because its author is a moron.
For this
if (false === @file_put_contents($path, $content)) {
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question