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

标签 c++ c http stream libvlc

我在 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/

相关文章:

c++ - 标识符 "do"未定义

c - Makefile 产生错误但构建正常?

c - 归并排序: need of copying elements from temporary array

C 程序并发与 pthread

html - HTML 片段的内容类型

php - 在 PHP 上使用 curl 为 Web API 设置路径 HTTP GET 请求

java - 当数据存在时,http 响应使用分块编码

c++ - 使用 jsoncpp 将字符串映射转换为 json

c++ - 指针值的严格弱排序

c++ - Fortran 中的 STL 类似物