python 图像帧转视频
我正在编写一个 python/django 应用程序,它需要进行图像处理,然后将图像组合成视频(每个图像都是一帧)。图像处理很容易。我正在使用 PIL,但对于转换为视频部分,我陷入困境。我找到了 pyffmpeg,但这似乎只是将视频解码为帧,而不是相反。虽然我可能错过了一些东西。我还听说 pythonMagick (imagemagick 包装器)可以做到这一点,但我似乎在文档中找不到有关编码的任何内容。
它在 Linux 服务器上运行,并且必须是 python(因为应用程序就是在其中)。
我应该用什么?
I am writing a python/django application and it needs to do image manipulation and then combine the images into a video (each image is a frame). Image manipulation is easy. I'm using PIL, but for the convert to video part, I'm stuck. I've found pyffmpeg but that just seems to do decoding of videos to frames, not the other way around. Although I may have missed something. I've also heard that pythonMagick (imagemagick wrapper) can do this, but I can't seem to find anything about encoding in the docs.
This is running on a linux server and must be python (since that is what the application is in).
What should I use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
首先使用以下命令安装 ffmpeg: sudo apt install ffmpeg
详细信息:
上述代码从存储在 images 文件夹中的三个图像文件创建视频。每个图像在视频中播放 5 秒(由于参数:-r 1/5)。 images 文件夹中的三个文件名称分别为:“swissGenevaLake1.jpg”、“swissGenevaLake2.jpg”和“swissGenevaLake3.jpg”。
希望这有帮助。
First install ffmpeg using the following command: sudo apt install ffmpeg
Details:
The aforementioned code creates a video from three images file, stored in the images folder. Each image plays for 5 seconds in the video (because of the argument: -r 1/5). The three files names are: "swissGenevaLake1.jpg", "swissGenevaLake2.jpg" and "swissGenevaLake3.jpg" in images folder.
Hope this helps.
使用 OpenCV 和 python 绑定。有
cv.WriteFrame
函数。 类似问答Use OpenCV and python binding. There is
cv.WriteFrame
function. Similar question and answer您可以使用 Popen 只是在子进程中运行 ffmpeg。
You could use Popen just to run the ffmpeg in a subprocess.
如果您有一个要制作为视频的图像文件夹。您可以调整参数并以排序方式排列帧。
If u have a folder of images to be framed as video. You can tune the parameters and arrange the frames in sorted manner.