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

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

问题描述

有没有人知道可靠的方式来创建一系列图像文件中的视频?在您发布问题之前,先拒绝找回答案,然后再点击使用FFMPEG之类的简单信息,然后再阅读本消息的其余部分。



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



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



我在StackOverflow上发现了一些类似的问题,并尝试了几个解决方案,都有不同程度的挫败感没有任何东西像成功。



FFMPEG看起来像一个伟大的程序。也许在Linux上。我下载的两个Windows版本已损坏。给定这个命令行:

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

其中一个构建读取图像,然后由于数据执行预防而崩溃。另一个读取第一个文件,然后吐出一个错误消息,说找不到合适的文件编解码器jpeg / image2.jpg。有帮助,那。在任何情况下,FFMPEG看起来像Windows下的非启动器。



以前发布的一个答案建议 Splicer 。看起来很好的代码我编译了样本并试图运行,但是有一些关于未找到文件的隐含错误信息。看起来COM类没有注册。我想我需要安装(DirectShow,也许,虽然我以为已经安装了)?根据需要而定,我可能很难在服务器上进行安装。 (什么?为什么你需要在服务器上?)



另一个答案建议 AviFile 库。这看起来很简单:围绕Windows AviFile子系统的包装。除了软件包创建的AVI文件看起来具有所有框架,但在Windows Media Player中播放AVI时,仅显示第一帧。那么,如果你试图创建一个压缩的视频,程序会抛出一个例外。



所以,我不知道是否有一个很好的,可靠的方式做我想要的:在Windows系统上,通过.NET API或使用外部程序从一系列映像创建AVI或其他通用视频文件格式。任何帮助?

解决方案

在使用它一段时间后,再看看x264和VideoLan,我回到了Splicer。事实证明,这个隐含的错误信息是由于我的代码中的错误。



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



感谢所有回覆者。


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.

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.

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.

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 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

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.

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?")

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.

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?

解决方案

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.

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

Thanks to all who responded.

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

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