我在Ubuntu 14.04上写了一个程序,这个程序可以让我的桌面流化,比如:libvlc stream part of screen。然而,我没有另一台计算机可以随时看到流的进展顺利,所以我如何才能在我的计算机上查看流?

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=:8080/stream}",
5, params, 1, 0)

我的程序不会抛出任何错误,并将此写入
[0x7f0118000e18] x264 encoder: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX

[0x7f0118000e18] x264 encoder: profile High, level 3.0

[0x7f0118000e18] x264 encoder: final ratefactor: 25.54

[0x7f0118000e18] x264 encoder: using SAR=1/1

[0x7f0118000e18] x264 encoder: using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX

[0x7f0118000e18] x264 encoder: profile High, level 2.2

所以在我看来,一切都很好。但是,我不知道如何从我的计算机上查看该流-如果我打开vlc并尝试打开网络流,使用http://@:7777(专用空间,网站不允许发布此类链接)我会在其日志中收到无效主机错误。这可能是我的一个愚蠢的错误,但任何帮助都将不胜感激!
如果有人需要,这是我的全部代码(我使用的是QT 4.8.6):
#include <QCoreApplication>
#include <iostream>
#include <vlc/vlc.h>
#include <X11/Xlib.h>
// #include <QDebug>

using namespace std;

bool ended;

void playerEnded(const libvlc_event_t* event, void *ptr);
libvlc_media_list_t * subitems;
libvlc_instance_t * inst;
libvlc_media_player_t *mp;
libvlc_media_t *media;
libvlc_media_t * stream;

int main(int argc, char *argv[])
{
    XInitThreads();
    QCoreApplication::setAttribute(Qt::AA_X11InitThreads);
    ended = false;




    QCoreApplication a(argc, argv);
  // the array with parameters
            const char* params[] = {"screen-top=0",
                                    "screen-left=0",
                                    "screen-width=640",
                                    "screen-height=480",
                                    "screen-fps=10"};

        // Load the VLC engine */
           inst = libvlc_new (0, NULL);

           if(!inst)
               std::cout << "Can't load video player plugins" << std::endl;

           cout<< "add broacast: " <<
                  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=:8080/stream}",
                       5, params, // <= 5 == sizeof(params) == count of parameters
                       1, 0)<< '\n';
               cout<< "poczatek broacastu: " <<libvlc_vlm_play_media(inst, "mybroad")<< '\n';
               media = libvlc_media_new_location(inst,http://@:8080/stream");
           // Create a media player playing environment
               mp = libvlc_media_player_new (inst);
               libvlc_media_player_play (mp);
 cout<<"szatan!!!"<<endl;
        int e;
        cin>>e;
        /* Stop playing */
           libvlc_media_player_stop (mp);
        /* Free the media_player */
           libvlc_media_player_release (mp);
           libvlc_release (inst);
       return a.exec();
}

最佳答案

所以,我发现答案堆栈溢出不会让我发布答案,因为我是新来的,所以在评论!我应该在创建媒体时使用我的IP地址:media=libvlc_media_new_location(inst,“http://192.168.1.56:8080”);(有目的的空间,这样论坛就不会隐藏链接)很好!–

关于c++ - 如何查看我发送的流libvlc C/C++,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/24313085/

10-09 01:27