简体   繁体   English

使用 C++ 的视频流

[英]Video streaming using c++

I'm going to build an application in c++ that creates stream of photos and then sends them as video stream to another application.我将在 C++ 中构建一个应用程序,该应用程序创建照片流,然后将它们作为视频流发送到另一个应用程序。 any ideas about how can i start?关于如何开始的任何想法? what I mean is, what libraries should i use and what the encoding?我的意思是,我应该使用哪些库以及编码是什么? I'm thinking about MJPEG, and UDP or RTP as protocol.... any help would be greatly appreciated.我正在考虑将 MJPEG、UDP 或 RTP 作为协议......任何帮助将不胜感激。

If your input data is just a bunch of random images, not video, you're not going to do "video streaming".如果您的输入数据只是一堆随机图像,而不是视频,那么您就不会进行“视频流”。 You're just going to be sending a bunch of full images.你只是要发送一堆完整的图像。 No need to involve video encoding technology, just do the simplest possible transmission of images.无需涉及视频编码技术,只做最简单的图像传输。 Video encoders rely on each frame having various relationships to the previous, as is common in actual video.视频编码器依赖于与前一帧具有各种关系的每一帧,这在实际视频中很常见。 For inputs of random images, they're not going to be able to compress that much, and single-frame compression (eg JPEG/PNG/whatever) is very likely already going to be applied to your input data.对于随机图像的输入,它们将无法压缩那么多,并且单帧压缩(例如 JPEG/PNG/任何格式)很可能已经应用于您的输入数据。

Probably easiest to send the contents of each file, together with the original filename, and have the receiving client re-create the file on disk, and use existing disk-oriented libraries to open and decode the image.可能最容易发送每个文件的内容以及原始文件名,并让接收客户端在磁盘上重新创建文件,并使用现有的面向磁盘的库来打开和解码图像。

You should probably just use TCP for this, nothing in your requirements that indicate you need to use the more complicated and error-prone UDP/RTP-based solutions.您可能应该为此使用 TCP,您的要求中没有任何内容表明您需要使用更复杂且容易出错的基于 UDP/RTP 的解决方案。

For the streaming part you can use Live555 .对于流媒体部分,您可以使用Live555 It should cover all you need.它应该涵盖您需要的所有内容。 That still leaves the problem of generating an MJpeg Stream.这仍然存在生成 MJpeg 流的问题。 I can only guess here, FFMpeg might be what you are looking for (as I see it also covers streaming, so you might only need this one).我只能在这里猜测, FFMpeg可能是您正在寻找的(因为我看到它也涵盖了流媒体,所以您可能只需要这个)。 I think that MJpeg is very suited for you application.我认为 MJpeg 非常适合您的应用程序。 As for the TCP or UDP, that depends on how you want to use it.至于 TCP 或 UDP,那取决于您想如何使用它。 UDP makes sense if you want to make your stream Multicast, otherwise I would prefer TCP, because it is more reliable.如果你想让你的流多播,UDP 是有意义的,否则我更喜欢 TCP,因为它更可靠。

Hope these are some useful hints.希望这些是一些有用的提示。

使用 ffmpeg 库对您的流进行编码,并使用 RTP/RTSP 堆栈来流式传输它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM