简体   繁体   English

在 C++ 程序中包含 ffmpeg-command

[英]include ffmpeg-command in c++ program

I have a c++ program that reads rendered images from shared-memory and writes them into a pipe(mkfifo), so that I can capture them with ffmpeg and stream them as live-video over ffserver.我有一个 C++ 程序,它从共享内存读取渲染图像并将它们写入管道(mkfifo),这样我就可以用 ffmpeg 捕获它们并将它们作为实时视频通过 ffserver 流式传输。 For my stream to work I have to start the program and the ffmpeg-command seperately.为了让我的流工作,我必须分别启动程序和 ffmpeg 命令。 I asked myself if there isn't a possibility to include the ffmpeg into the program and avoid the pipe.我问自己是否有可能将 ffmpeg 包含到程序中并避免使用管道。

My ffmpeg command:我的 ffmpeg 命令:

ffmpeg -re -f -rawvideo -s 800x600 -pix_fmt rgb24 -i myfifo http://localhost:8090/feed1.ffm

My question is:我的问题是:

What would be the best way to include the ffmpeg-command into the c++-program?将 ffmpeg 命令包含到 c++ 程序中的最佳方法是什么? Is there some other idea to improve this solution?还有其他想法可以改进此解决方案吗?

Any help is greatly appreciated.任何帮助是极大的赞赏。 Thanks in advance.提前致谢。

There are two ways:有两种方式:

The easier is to use system(), assuming you are in Linux, and launch the ffmpeg command.更容易的是使用 system(),假设您在 Linux 中,然后启动 ffmpeg 命令。

if(system("ffmpeg -re -f -rawvideo -s 800x600 -pix_fmt rgb24 -i myfifo http://localhost:8090/feed1.ffm") != 0)
{
    cout << "ffmpeg failed..." << endl;
}

The difficult is to include the library in your project, and use it internally: Can FFmpeg be used as a library, instead of a standalone program?困难在于将库包含在您的项目中,并在内部使用它: FFmpeg 可以用作库,而不是独立程序吗? . .

To start check out https://trac.ffmpeg.org/wiki/Using%20libav *, where it describes how to use libav (internal library used by ffmpeg), and I would recommend to follow the tutorial http://dranger.com/ffmpeg/tutorial01.html要开始查看https://trac.ffmpeg.org/wiki/Using%20libav *,它描述了如何使用 libav(ffmpeg 使用的内部库),我建议遵循教程http://dranger。 com/ffmpeg/tutorial01.html

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

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