在 C# 中从图像制作视频的工作方法 [英] Working way to make video from images in C#

查看:17
本文介绍了在 C# 中从图像制作视频的工作方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有人有已知可靠的方法来从一系列图像文件创建视频?在你因为在发布问题之前没有搜索答案而让我失望之前,在你发出使用 FFMPEG"这样的简单消息之前,请阅读此消息的其余部分.

Does anybody have a known reliable way to create a video from a series of image files? Before you mod me down for not searching for the answer before posting the question, and before you fire off a simple message like "use FFMPEG," read the rest of this message.

我正在尝试从一系列图像(.jpg、.bmp 等)创建视频,只要它被广泛支持,什么格式都无所谓.我的平台是 Windows Server 2008,64 位.如果我可以在我的 C# 程序中制作视频,那就太好了,但我并不反对将一系列图像文件写入目录,然后启动外部程序以从这些图像制作视频.

I'm trying to create a video, it doesn't matter too much what format as long as it's widely supported, from a series of images (.jpg, .bmp, etc.). My platform is Windows Server 2008, 64-bit. If I can make the video from within my C# program, that's great, but I'm not averse to writing a series of image files to a directory and then firing off an external program to make a video from those images.

唯一的限制是:它必须在我的 Windows Server 2008 系统上运行,并且可以编写脚本.也就是说,没有需要操作员干预的 GUI 程序.

The only constraints are: it must work on my Windows Server 2008 system, and be scriptable. That is, no GUI programs that require operator intervention.

我在 StackOverflow 上发现了许多类似的问题,并尝试了几种解决方案,但都遇到了不同程度的挫败感,但都没有成功.

I found a number of similar questions on StackOverflow, and have tried several of the solutions, all with varying degrees of frustration and none with anything like success.

FFMPEG 看起来是一个很棒的程序.也许是,在 Linux 上.我下载的两个 Windows 版本都坏了.鉴于此命令行:

FFMPEG looks like a great program. Maybe it is, on Linux. The two Windows builds I downloaded are broken. Given this command line:

  ffmpeg -r 1 -f image2 -i jpeg*.jpg video.avi

其中一个构建读取图像,然后由于数据执行保护而崩溃.另一个读取第一个文件,然后吐出一条错误消息,指出找不到文件 jpeg/image2.jpg 的合适编解码器".有用,那个.无论如何,FFMPEG 在 Windows 下看起来都不是入门者.

One of the builds reads the images and then crashes due to data execution prevention. The other reads the first file and then spits out an error message that says "cannot find suitable codec for file jpeg/image2.jpg". Helpful, that. In any case, FFMPEG looks like a non-starter under Windows.

对之前推荐的帖子的一个答案 Splicer .看起来很不错的代码.我编译了示例并尝试运行,但收到​​了一些关于找不到文件的神秘错误消息.看起来 COM 类未注册.我想我需要安装一些东西(DirectShow,也许,虽然我认为已经安装了?).根据需要什么,我可能很难证明它在服务器上的安装是合理的.(什么?为什么你需要在服务器上使用它?")

One answer to a previous posting recommended Splicer . It looks like pretty good code. I compiled the samples and tried to run, but got some cryptic error message about a file not found. It looks like a COM class isn't registered. I suppose I need to install something (DirectShow, maybe, although I thought that was already installed?). Depending on what's required, I might have a difficult time justifying its installation on a server. ("What? Why do you need that on a server?")

另一个答案建议使用 Code Project 中的 AviFile 库.这看起来很简单:Windows AviFile 子系统的包装器.除了包创建的 AVI 文件似乎包含所有帧,但当我在 Windows Media Player 中播放 AVI 时只显示第一帧.好吧,如果您尝试创建压缩视频,程序会抛出异常.

Another answer suggested the AviFile library from Code Project. That looks simple enough: a wrapper around the Windows AviFile subsystem. Except that the AVI files the package creates appear to have all of the frames, but only the first frame shows when I play the AVI in Windows Media Player. Well, that and if you try to create a compressed video, the program throws an exception.

所以,我想知道是否有一种好的、可靠的方法来做我想做的事:在 Windows 系统上,通过 .NET API 从一系列图像创建 AVI 或其他常见的视频文件格式或使用外部程序.有什么帮助吗?

So, I'm left wondering if there is a good, reliable way to do what I want: on a Windows system, create an AVI or other common video file format from a series of images, either through a .NET API or using an external program. Any help?

推荐答案

在使用了一段时间并查看了 x264 和 VideoLan 之后,我又回到了 Splicer.事实证明,神秘的错误消息是由于我的代码中的错误造成的.

After working with it a while and taking a look at x264 and VideoLan, I went back to Splicer. It turns out that the cryptic error message was due to an error in my code.

看起来 Splicer 会做我想做的事:从一系列图像以编程方式创建视频.

It looks like Splicer will do what I want: programmatically create videos from a series of images.

感谢所有回复的人.

这篇关于在 C# 中从图像制作视频的工作方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆