C++ 屏幕的libvlc流部分

C++ 屏幕的libvlc流部分,c++,streaming,vlc,libvlc,C++,Streaming,Vlc,Libvlc,我想使用vlc库对屏幕的一部分进行流式处理。我写了一个小例子: #include <iostream> #include <cstdlib> #include <vlc/vlc.h> int main(int argc, char**argv) { libvlc_instance_t * inst = libvlc_new(argc, argv); libvlc_vlm_add_broadcast(inst, "mybroad",

我想使用vlc库对屏幕的一部分进行流式处理。我写了一个小例子:

#include <iostream>
#include <cstdlib>

#include <vlc/vlc.h>


int main(int argc, char**argv)
{
    libvlc_instance_t * inst = libvlc_new(argc, argv);
    libvlc_vlm_add_broadcast(inst, "mybroad",
            "screen://", "#transcode{vcodec=h264, venc=x264,vb=0,scale=0, acodec=mpga,ab=128,channels=2, samplerate=44100}:http{mux=ffmpeg{mux=flv}, dst=:7777/}",
            0, NULL, 1, 0);
    libvlc_vlm_play_media(inst, "mybroad");
    std::cout << "ready" << std::endl;
    // next two lines - it just for waitint
    int i;
    std::cin >> i;
    // omit the code that frees libvlc
    return 0;
}
我试图通过修改一行代码来实现这一点:

libvlc_vlm_add_broadcast(inst, "mybroad",
                "screen:// :screen-fps=24 :screen-top=0 :screen-left=0 :screen-width=320 :screen-height=240", 
               "#transcode{vcodec=h264,venc=x264, vb=0,scale=0,acodec=mpga,ab=128,channels=2, samplerate=44100}:http{mux=ffmpeg{mux=flv},dst=:7777/}",
                0, NULL, 1, 0);
但这一修改并没有改变什么

老实说,我想从一个监视器(我有两个监视器)传输数据,但我可以计算监视器的边界。

我找到了解决方案

#include <iostream>
#include <cstdlib>

#include <vlc/vlc.h>


int main(int argc, char**argv)
{
    // the array with parameters
    const char* params[] = {"screen-top=0", 
                            "screen-left=0",
                            "screen-width=640", 
                            "screen-height=480", 
                            "screen-fps=10"}; 
    libvlc_instance_t * inst = libvlc_new(argc, argv);
    libvlc_vlm_add_broadcast(inst, "mybroad",
            "screen://", 
            "#transcode{vcodec=h264,vb=800,scale=1,acodec=mpga,ab=128,channels=2,samplerate=44100}:http{mux=ts,dst=:7777/}",
            5, params, // <= 5 == sizeof(params) == count of parameters
            1, 0);
    libvlc_vlm_play_media(inst, "mybroad");
    std::cout << "ready" << std::endl;
    int i;
    std::cin >> i;
    return 0;
}
#包括
#包括
#包括
int main(int argc,字符**argv)
{
//带参数的数组
常量字符*参数[]={“屏幕顶部=0”,
“屏幕左=0”,
“屏幕宽度=640”,
“屏幕高度=480”,
“屏幕fps=10”};
libvlc_instance_t*inst=libvlc_new(argc,argv);
libvlc_vlm_添加_广播(inst,“mybroad”,
“屏幕:/”,
“#转码{vcodec=h264,vb=800,scale=1,acodec=mpga,ab=128,channels=2,samplerate=44100}:http{mux=ts,dst=:7777/}”,

5,params,//不应该
params
(在
const char*params[……
)是
param
?为什么在运行此程序时会得到“main vlm daemon error:invalid media description”?
#include <iostream>
#include <cstdlib>

#include <vlc/vlc.h>


int main(int argc, char**argv)
{
    // the array with parameters
    const char* params[] = {"screen-top=0", 
                            "screen-left=0",
                            "screen-width=640", 
                            "screen-height=480", 
                            "screen-fps=10"}; 
    libvlc_instance_t * inst = libvlc_new(argc, argv);
    libvlc_vlm_add_broadcast(inst, "mybroad",
            "screen://", 
            "#transcode{vcodec=h264,vb=800,scale=1,acodec=mpga,ab=128,channels=2,samplerate=44100}:http{mux=ts,dst=:7777/}",
            5, params, // <= 5 == sizeof(params) == count of parameters
            1, 0);
    libvlc_vlm_play_media(inst, "mybroad");
    std::cout << "ready" << std::endl;
    int i;
    std::cin >> i;
    return 0;
}