监听FFmpeg/Libav中的端口
Listening to port in FFmpeg/Libav
在FFmpeg中,有一个参数"-listen"来监听指定的端口:
# Server side (receiving):
ffmpeg -listen 1 -enter code herei http://server:port -c copy somefile.ogg
https://www.ffmpeg.org/ffmpeg-protocols.html toc-http
我想在c++和Libav中使用这个命令(因为FFMpeg已经移动到Libav中)。
对于侦听端口,我需要使用哪种Libav方法?
我解决了这个问题:
void listen(const unsigned int port) {
const int TIMEOUT = 600000;
// check if webservice is already listening
if (!m_listening) {
m_listening = true;
// Format specification: tcp://hostname:port[?options]
// See: https://www.ffmpeg.org/ffmpeg-protocols.html#tcp
std::stringstream ss;
ss << "tcp://localhost:" << port << "?listen=1" << "?listen_timeout=" << TIMEOUT << "?timeout=" << TIMEOUT * 1000;
const std::string publishingPointURI = ss.str();
avformat_network_init();
if (avformat_open_input(&m_stream, publishingPointURI.c_str(), NULL, NULL) != 0) {
throw Exception(
"Unable to buffer stream received from " + publishingPointURI + "");
}
m_listening = false;
}
相关文章:
- FFmpeg:制作一个应用程序比直接使用ffmepg更好吗
- 使用FFMPEG将RGB图像序列保存到.mp4时出现问题
- FFMPEG配置文件级别id大小无效
- FFMpeg库:如何在音频文件中精确查找
- 如何使用libav编写.mov文件,如果文件未正确完成,则可以播放
- OpenCV RTP-Stream with FFMPEG
- FFmpeg——使用硬件加速进行视频解码
- 如何在 C/C++ 中使用 ffmpeg 的黑框 avfilter
- 在 GLFW 窗口中显示 FFMPEG 解码帧
- FFMPEG:sws_scale返回错误:切片参数 0, 2160 无效
- 为什么有些延迟加载 DLL 会立即使用 FFMPEG 卸载?
- 将FFMpeg AVFrame对象从C++应用程序流式传输到Python的最佳方法?
- 面临分段故障 使用 ffmpeg 读取视频时,因为"pFormatCtx-> streams [i]-> codecpar"的地址0x00
- 将 FFMPEG 帧写入 png/jpeg 文件
- FFMPEG,C++,内存泄漏,我做错了什么?
- Thread Safety of LibAv/FFMpeg?
- 使用 FFmpeg 库(不是 libav 分支)以编程方式捕获视频,在 C++ 中具有可变帧速率
- 使用libav*库的FFMPEG音频转码
- Windows中的ffmpeg/libav链接问题
- 监听FFmpeg/Libav中的端口