通过 FFmpeg 和 PHP 创建目录中所有文件的视频缩略图
我已经搜索遍了Google和StackOverFlow,但仍然没有找到解决方案。
我想生成目录中所有 mp4 视频文件的视频缩略图,并将缩略图命名为“filename.mp4”.jpg
我的服务器上安装了 ffmpeg 和 ffmpeg-php。我还成功地一次创建一个文件的缩略图。
所以情况就是这样,我有一个名为 uploads 的目录,其中有很多 mp4 视频。 现在,当我运行脚本时,应自动创建大小为 100x100 的缩略图并将其放置在另一个文件夹“skrin”中。例如: xxx.mp4 应该有 xxx.mp4.jpg 有拇指名称。
重要提示:我的文件名中包含空格、单引号、方括号等。所以脚本应该能够处理这个问题。
有人可以帮助我吗?我在 php 中使用以下 shell 命令,使用 exec 生成单个视频的缩略图。
exec("/usr/local/bin/ffmpeg -itsoffset -105 -i 'xxx haha.mp4' -vcodec mjpeg -vframes 1 -an -f rawvideo -s 100x100 'xxx haha.mp4.jpg'");
I have searched all over the Google and StackOverFlow, but still did not find a solution for this.
I want to generate video thumbnail of all mp4 video files in a directory and name the thumbnails as "filename.mp4".jpg
I have ffmpeg and ffmpeg-php installed on my server. I also succeeded in creating thumbnails of one file at a time.
So this is the situation, I have a directory named uploads which has lots of mp4 videos.
Now, when I run the script, thumbnail of size 100x100 shoud be created automatically and placed in another folder "skrin". Eg: xxx.mp4 should have xxx.mp4.jpg has the thumb name.
IMPORTANT: My filenames have spaces, single quotes, brackets etc in their file names. So the script should be able to handle this.
Could some one help me ? I use the following shell command in php using exec to generate thumb of an individual video.
exec("/usr/local/bin/ffmpeg -itsoffset -105 -i 'xxx haha.mp4' -vcodec mjpeg -vframes 1 -an -f rawvideo -s 100x100 'xxx haha.mp4.jpg'");
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这只是一个快速的:
It's just a quick one:
试试这个
try this