【问题标题】:how to view stream sent by me libvlc C/C++如何查看我发送的流 libvlc C/C++
【发布时间】:2014-08-10 08:59:01
【问题描述】:

我在 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();
}

【问题讨论】:

  • 所以,我发现答案-堆栈溢出不会让我发布答案,因为我是新来的,所以它在 cmets 中!我应该在创建媒体时使用我的 IP 地址:media = libvlc_media_new_location(inst, "http://192.168.1.56:8080");(故意留出空间,以便论坛不会隐藏链接)效果很好!

标签: c++ c http stream libvlc


【解决方案1】:

所以,我找到了答案-堆栈溢出不会让我发布答案,因为我是新来的,所以它在 cmets 中!我应该在创建媒体时使用我的 IP 地址:media = libvlc_media_new_location(inst, "http://192.168.1.56:8080");(故意留出空间以便论坛不会隐藏链接)效果很好! -

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-07-27
    • 1970-01-01
    • 1970-01-01
    • 2020-07-28
    • 2018-01-19
    • 2014-05-17
    相关资源
    最近更新 更多