gpt4 book ai didi

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

转载 作者:太空宇宙 更新时间:2023-11-04 04:42:47 31 4
gpt4 key购买 nike

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

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com