首页 > 解决方案 > 将 ffmpeg 命令输出存储到 aws s3

问题描述

我在下面运行的命令在本地文件系统中运行良好。

命令:

exec('ffmpeg -i '.config('medialibrary.s3.domain').'/listing_video/intro.mp4'.' -vf "drawtext=fontfile=' . storage_path('assets/video/FutuMd.ttf') . ': text=' . $request->get('intro_text') . ': x=300: y=450: fontsize=65: fontcolor=white: enable=\'between(t,2,5)\'" introfinal.mp4');

但我必须将文件直接存储到s3,所以我将存储文件的命令更改为s3,但文件大小为0B。

exec('ffmpeg -i '.config('medialibrary.s3.domain').'/listing_video/intro.mp4'.' -vf "drawtext=fontfile=' . storage_path('assets/video/FutuMd.ttf') . ': text=' . $request->get('intro_text') . ': x=300: y=450: fontsize=65: fontcolor=white: enable=\'between(t,2,5)\'" '.Storage::put('introfinal.mp4', '').'');

提前致谢!

标签: laravelamazon-web-servicesamazon-s3ffmpeg

解决方案


这个例子并不完美,但会为您指明正确的方向:

exec('ffmpeg -i '.config('medialibrary.s3.domain').'/listing_video/intro.mp4'.' -vf "drawtext=fontfile=' . storage_path('assets/video/FutuMd.ttf') . ': text=' . $request->get('intro_text') . ': x=300: y=450: fontsize=65: fontcolor=white: enable=\'between(t,2,5)\'" introfinal.mp4');

$contents = file_get_contents('introfinal.mp4');

$success = Storage::put('introfinal.mp4', $contents);

推荐阅读