如何查看由我libvlc C/ c++发送的流



我在Ubuntu 14.04上,我试图写一个程序,将我的桌面流,使用这个答案:libvlc流部分屏幕为例。但是,我没有另一台计算机可以随时看到流进行得很好,所以我如何在我的计算机上查看流呢?

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");(空间的目的是让论坛不隐藏链接)工作得很好!——

相关内容

  • 没有找到相关文章