[英]Encoding failed during converting and saving video using php-ffmpeg in laravel
我正在使用https://github.com/PHP-FFMpeg/PHP-FFMpeg package 将用户视频上传转换为mp4
格式,请注意我正在使用ZA5C95B86291EA299ZFCBE644 框架进行开发。
但是我正面临这个错误,我不确定我做错了什么,因为它所说的只是编码失败。 我附上了下面的错误图片,您可以在底部看到它。
这是我的 function 处理用户上传:
public function upload()
{
$this->putVideoIntoStorage();
$this->ffmpeg->saveVideo($this->storageManager->getAbsolutePathOf($this->video->getClientOriginalName()));
return $this->saveVideoIntoDatabase();
}
这是 function 处理使用php-ffmpeg
将视频保存和转换为mp4
public function saveVideo(String $path)
{
$ffmpeg = FFMpeg::create([
'ffmpeg.binaries' => config('services.ffmpeg.ffmpeg_path'),
'ffprobe.binaries' => config('services.ffmpeg.ffprobe_path'),
'timeout' => 3600, // The timeout for the underlying process
'ffmpeg.threads' => 12, // The number of threads that FFMpeg should use
]);
$video = $ffmpeg->open($path);
$video->save(new X264(), 'video.mp4');
}
这是我得到的错误:错误图像
如果您需要问我,我可以提供更多详细信息,如果有人可以帮助我解决这个问题,我将非常高兴。
这是正确的方法:
$format = new FFMpeg\Format\Video\X264();
$format->setAudioCodec("libmp3lame");
$video->save($format, '/path/to/new/file');
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.