欢迎来到HugNew-拥抱变化,扫一扫右边二维码关注微信订阅号:Martin说 或 加QQ群:427697041互相交流,Stay hungry, Stay foolish.

VLC使用总结

随笔 jim 4325℃ 1评论

VLC使用总结

关键字: VLC, streaming server, VOD server, media trascoding, streaming media player, audio broadcasting over IP, 音频广播 在线广播 Live radio broadcast

VLC是一个跨平台的多媒体框架,可以作为(流)媒体播放器,VOD服务器,流媒体服务器,multicast RTP多播音频服务器,媒体文件转码等功能。
同时在使用方面提供了HTTP REST API,telnet,命令行,图形界面,VLM配置文件的方式。

编程方面有libVLC可供使用,提供多种binding方式,不过本文主要关于命令行下面的简单操作与使用,算是对官方VLC howto的一个验证(官方文档有一些都跑不起来,需要理解相关的原理,可以作为深入理解VLC的参考资料)

使用环境:ubuntu 14.04下面apt-get install VLC相应的版本

1. 命令行下VLC 将一个AMR文件转码成MP3

cvlc –play-and-exit bb.amr –sout ‘#transcode{acodec=mp3,ab=128}:standard{access=file,mux=dummy,dst=cc.mp3}’

vlc -I dummy –play-and-exit bb.amr –sout ‘#transcode{acodec=mp3,ab=128}:standard{access=file,mux=dummy,dst=cc.mp3}’

vlc -I dummy bb.amr –sout ‘#transcode{acodec=mp3,ab=128}:standard{access=file,mux=dummy,dst=dd.3}’ vlc://quit

vlc -I dummy bb.amr –sout ‘#transcode{acodec=mp3,ab=128}:standard{access=file,mux=mp3,dst=ee.mp3}’ vlc://quit

2. 调整MP3音频文件的音量

vlc -I dummy ee.mp3 –sout ‘#transcode{acodec=mp3,afilter=compressor}:standard{access=file,mux=raw,dst=ff.mp3}’ –compressor-makeup-gain=20 vlc://quit

3. Streaming howto

关于串流方式,可以先使用GUI界面去做,最后一步会有相关的命令行选项,然后再更改一下相关选项适应自己的需求

3.1) 使用RTP,可以有三种方式
下面假设 Server:192.168.208.188, Client:192.168.208.58
1) RTP A/V profile方式,需要SDP文件,不过这个SDP文件VLC会自动产生,需要添加vlc -vvv 选项

#Server:
vlc -vvv alsa://plughw:0,0 –sout ‘#transcode{vcodec=none,acodec=ulaw,ab=64,channels=2,samplerate=8000}:rtp{dst=192.168.208.58,port=5004,sap,name=aaaa,raw,chaching=100}’ –sout-rtp-caching 100 –sout-mux-caching 100

#Client:
vlc test3.sdp –network-caching=0

On Server:
# MIC unicast
vlc -vvv alsa://plughw:0,0 –sout ‘#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:rtp{dst=192.168.208.58,port=5004,sap,name=aaaa}’

# internet radio transcode and unicast
vlc -vvv mms://enmms.chinabroadcast.cn/fm91.5 –sout ‘#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:rtp{dst=192.168.208.58,port=5004,sap,name=aaaa}’

## duplicate stream to local
vlc -vvv mms://enmms.chinabroadcast.cn/fm91.5 –sout ‘#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:duplicate{dst=rtp{dst=192.168.208.58,port=5004,mux=ts,sap,name=aaaa},dst=display}’ –sout-keep

## multicast to a specified multicast ip
vlc -vvv mms://enmms.chinabroadcast.cn/fm91.5 –sout ‘#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:duplicate{dst=rtp{dst=238.44.44.44.44,port=5004,mux=ts,sap,name=aaaa},dst=display}’ –sout-keep

# mp3 unicast
vlc -vvv aaa.mp3 –sout ‘#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:rtp{dst=192.168.208.58,port=5004,sap,name=aaaa}’

### transcode file
“c:\vlc\vlc.exe” Myaudio.amr –sout=#transcode{acodec=mp3,ab=128}:standard{access=file,mux=dummy,dst=”myusableaudio.mp3″}
##########
On client:

vlc -vvv test3.sdp

test3.sdp:
v=0
o=- 15591613938679319692 15591613938679319692 IN IP4 centling-ThinkPad-R400
s=aaaaaaaaa
i=N/A
c=IN IP4 192.168.208.58
t=0 0
a=tool:vlc 2.1.4
a=recvonly
a=type:broadcast
a=charset:UTF-8
m=audio 5004 RTP/AVP 14
b=AS:128
b=RR:0
a=rtpmap:14 MPA/90000/2

2) RTP MPEG TRANSPORT STREAM
On server:
vlc -vvv aaa.mp3 –sout ‘#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:rtp{dst=192.168.208.58,port=5004,mux=ts,sap,name=aaaa}’
On Client:
vlc.exe rtp://@192.168.208.58:5004
vlc.exe rtp://192.168.208.58:5004

3) RTSP
On server:
vlc -vvv aaa.mp3 –sout ‘#transcode{vcodec=none,acodec=mp3,ab=128,channels=2,samplerate=44100}:rtp{sdp=rtsp://:8554/mytest}’ –sout-keep

On Client:
vlc.exe rtsp://192.168.208.188:8554/mytest

4. VOD server
需要使用VLM方式, 或者用远程管理(telnet)VLC daemon,下放一些命令。
通过 telnet连接到vlc上,就可以创建各种channel,可以播放媒体等。

参考资料:
http://www.videolan.org/doc/play-howto/en/index.html
http://www.videolan.org/doc/vlc-user-guide/en/ch04.html
http://www.videolan.org/doc/videolan-howto/en/ch09.html
https://www.videolan.org/doc/streaming-howto/en/ch04.html
https://wiki.videolan.org/Streaming/
https://wiki.videolan.org/Documentation:Streaming_HowTo/
https://wiki.videolan.org/Transcode/
https://wiki.videolan.org/Documentation:Streaming_HowTo/
http://www.videolan.org/streaming-features.html
https://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples/
https://wiki.videolan.org/Documentation:Streaming_HowTo/Advanced_Streaming_Using_the_Command_Line#vfilter
https://wiki.videolan.org/Documentation:Streaming_HowTo/Streaming,_Muxers_and_Codecs/
https://wiki.videolan.org/Knowledge_Base/
http://discerning.com/topics/audiovideo/video_encoding.html
https://wiki.videolan.org/Documentation:Streaming_HowTo/Stream_from_Encoding_Cards_and_Other_Capture_Devices/
https://wiki.videolan.org/Documentation:Streaming_HowTo/Streaming_for_the_iPhone/

转载请注明:HugNew » VLC使用总结

喜欢 (3)or分享 (0)
发表我的评论
取消评论

表情
(1)个小伙伴在吐槽
  1. 赞一个,感谢jim哥的share 😀
    Martin2015-01-24 06:24 回复