博客
关于我
用vlc搭建简单流媒体服务器(UDP和TCP方式)
阅读量:491 次
发布时间:2019-03-07

本文共 1378 字,大约阅读时间需要 4 分钟。

简介

VLC不仅是一款优秀的媒体播放器,同样可以用作流媒体服务器。以下将介绍如何利用VLC搭建基于UDP和TCP的流媒体服务器。

基于UDP的流媒体服务器

1. 传统UDP模式

以下是操作流程:

打开VLC的“媒体”菜单,进入“流媒体”选项:

点击“添加”按钮,选择需要流媒体的文件,然后点击“串流”按钮:

在目标设置中选择“UDP (legacy)”,并填写目标IP地址和端口:

在转码选项中选择合适的编码格式:

完成这些设置后,点击“串流”按钮即可实现流媒体。

在客户端,打开“媒体——打开网络串流”,输入“udp://@1234”,点击“播放”开始接收流媒体内容:

除了图形界面操作,还可以用命令行工具进行:

服务端:vlc -vvv sample1.avi --sout udp:172.16.1.100:1234 --ttl 10

客户端:vlc udp://@:1234

2. RTP协议

RTP流媒体也是基于UDP协议,操作方式与传统UDP类似,但目标设置需要选择“RTP / MPEG Transport Stream”:

填写目标IP地址和端口:

点击“串流”按钮即可完成流媒体设置:

客户端打开 VLC,输入RTP地址进行播放:

命令行设置:

服务端:vlc -vvv sample1.avi --sout "#transcode{vcodec=h264,vb=0,scale=0,acodec=mpga,ab=128,channels=2,samplerate=44100}:rtp{dst=172.16.1.100,port=5004,mux=ts,ttl=10}"

客户端:vlc rtp://@:5004

3. RTSP协议

RTSP是一种常见的流媒体控制协议,操作方式类似于RTP:

服务端需要在transcode选项中添加RTSP地址:

客户端可以直接使用rtsp://地址播放内容:

命令行设置:

服务端:vlc -vvv sample1.avi --sout "#transcode{vcodec=h264,vb=0,scale=0,acodec=mpga,ab=128,channels=2,samplerate=44100}:rtp{sdp=rtsp://:8554/test}"

客户端:vlc rtsp://172.16.1.1:8554/test

基于TCP的流媒体服务器

HTTP方式

HTTP流媒体服务器基于TCP协议,操作方式与RTSP类似:

服务端通过VLC的转码功能将流媒体内容转为HTTP格式:

命令行设置:

服务端:vlc -vvv sample1.avi --sout "#transcode{vcodec=h264,vb=0,scale=0,acodec=mpga,ab=128,channels=2,samplerate=44100}:http{mux=ffmpeg{mux=flv},dst=:8080/test}"

客户端:vlc http://172.16.1.1:8080/test

总结

VLC提供了多种流媒体协议的实现,包括UDP、RTP和HTTP。无论是通过图形界面还是命令行工具,都可以轻松搭建流媒体服务器。此外,VLC的灵活性和可定制性使其成为流媒体开发和部署的理想选择。

转载地址:http://zsedz.baihongyu.com/

你可能感兴趣的文章
Orderer节点启动报错解决方案:Not bootstrapping because of 3 existing channels
查看>>
org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Unexpected subelement profile
查看>>
sql查询中 查询字段数据类型 int 与 String 出现问题
查看>>
org.apache.commons.beanutils.BasicDynaBean cannot be cast to ...
查看>>
org.apache.dubbo.common.serialize.SerializationException: com.alibaba.fastjson2.JSONException: not s
查看>>
sqlserver学习笔记(三)—— 为数据库添加新的用户
查看>>
org.apache.http.conn.HttpHostConnectException: Connection to refused
查看>>
org.apache.ibatis.binding.BindingException: Invalid bound statement错误一例
查看>>
org.apache.ibatis.exceptions.PersistenceException:
查看>>
org.apache.ibatis.exceptions.TooManyResultsException: Expected one result (or null) to be returned
查看>>
org.apache.ibatis.type.TypeException: Could not resolve type alias 'xxxx'异常
查看>>
org.apache.poi.hssf.util.Region
查看>>
org.apache.xmlbeans.XmlOptions.setEntityExpansionLimit(I)Lorg/apache/xmlbeans/XmlOptions;
查看>>
org.apache.zookeeper.KeeperException$ConnectionLossException: KeeperErrorCode = ConnectionLoss for /
查看>>
org.hibernate.HibernateException: Unable to get the default Bean Validation factory
查看>>
org.hibernate.ObjectNotFoundException: No row with the given identifier exists:
查看>>
org.springframework.boot:spring boot maven plugin丢失---SpringCloud Alibaba_若依微服务框架改造_--工作笔记012
查看>>
SQL-CLR 类型映射 (LINQ to SQL)
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
查看>>