写入未压缩的 AVI 视频
是否有任何简单且小型的库或代码示例可以用 C++ 编写未压缩的 avi 视频文件?
我找到的每个资源都使用 Windows 视频,我需要它是可移植的。
我尝试查看 AVI 容器文档,但它看起来确实很麻烦。
Is there any simple and small library or code sample to write uncompressed avi video files in c++?
Every resource I find uses video for windows, and I need this to be portable.
I tried looking at the AVI container documentation but it looks really cumbersome.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我自己没有这样做,但我建议使用
libavformat
,它是ffmpeg
的一部分 (LGPLv2.1/GPLv2+)。I haven't done it myself but I suggest using
libavformat
, part offfmpeg
(LGPLv2.1/GPLv2+).如果您想要超级简单的东西,那么将 BMP 作为编号序列写入磁盘,然后通过
system()
或类似的方法调用ffmpeg
或类似的东西:注意:
-r
参数表示您希望最终电影达到的帧速率。您可以通过调用 ffmpeg 所基于的 libavformat/libavcodec 库来实现相同的结果,但这可能不符合您的“小”和“简单”要求。
If you want something that is super easy, then write the BMPs to disk as a numbered sequence, then invoke
ffmpeg
viasystem()
or something similar like this:Note: the
-r
argument indicates the frame rate you want the final movie to be.You could achieve the same result by calling into the libavformat/libavcodec libs that ffmpeg is based on, but that may not fit the "small" and "simple" requirement you have.
总有 OpenCV,它是多平台的,并且相对容易将数据推送到其中。
或者 - 您始终可以将视频数据传输到另一个可执行文件。
例如,在 unix 中,您可以执行以下操作:
在您的程序中:
在运行程序的脚本中:
(请注意,这确实会压缩视频 - 未压缩只是更改 mencoder 命令行的问题)
我相信您也可以使用ffmpeg 这种方式,或 x264。您还可以从程序中启动编码器,然后写入管道(如果您使用库,则整个过程会变得简单) - 这应该适用于 Windows、Linux 或 Mac(对 mencoder 命令进行少量修改 -线)。
显然,也不存在许可问题(除了 mencoder 可执行文件的分发),因为您没有链接到任何代码或编译任何内容。
虽然不完全是您想要的,但它确实具有自动使用第二个处理器的优点用于编码。
There is always OpenCV, which is multiplatform and relatively easy to push data into.
OR - you can always pipe the video data to another executable.
For instance, in unix you can do:
In your program:
And in a script that runs your program:
(Note that this does compress the video - uncompressed is just a matter of changing the mencoder command-line)
I believe you can also use ffmpeg this way, or x264. You can also start the encoder from within your program, and write to a pipe (making the whole process as simple if you were using a library) - and this should work on Windows, Linux or Mac (with minor modifications to the mencoder command-line).
Obviously there are no licensing issues either (apart from distribution of the mencoder executable), as you are not linking to any code or compiling anything in.
While not quite what you want, it does have the advantage that a second processor will automatically be used for the encoding.