vlc的流输出功能

来源:互联网 发布:手机ping命令测试网络 编辑:程序博客网 时间:2024/06/03 18:45
流输出功能,可以将vlc读取到的流,输出到文件或者通过网络发送,客户端可以使用http、rtp、rtsp等协议访问,还可以进行转码等操作。

参考http://wiki.videolan.org/Documentation:Streaming_HowTo

流输出语法
% vlc input_stream --sout "#module1{option1=parameter1{parameter-option1},option2=parameter2}:module2{option1=...,option2=...}:..."
也可以使用下面的语法 
% vlc input_stream --sout-module1-option1=... --sout-module1-option2=... --sout-module2-option1=... --sout-module2-option2=... ...
1.standard模块(std)
example:
vlc test.mp4 -vvv --loop --sout "#standard{access=http,mux=ts,dst=192.168.9.80:10086/stream}"
将文件使用http协议发送到网络,使用ts封装,客户端使用http://192.168.9.80:10086/stream访问

关于standard的必选项
access,输出的协议。file(保存到文件)、udp、http、https、mmsh(使用微软的mms协议,仅支持基于http的mms协议)
mux,输出复用器。支持ts、ps、mpeg1、ogg、asf、asfh、avi、mpjpeg
dst,输出目的地址,如果access=file,就是保存的文件路径及文件名

对于某些视频,使用上面示例中的命令参数时,vlc接收端只能听见音频,消息中显示的错误日志如下 :
ts error: MPEG-4 descriptor not foundpacketizer_mpeg4audio info: AAC channels: 2 samplerate: 44100avcodec info: obtained IDirect3DDeviceManager9avcodec info: DXVA2CreateVideoService Success!avcodec error: DxFindVideoServiceConversion failed
但是使用mux=asf后,却能够正常播放
vlc test.mp4 -vvv --loop --sout "#standard{access=http,mux=asf,dst=192.168.9.80:10086/stream}"
这个问题与mp4文件格式有关,待解决。
2.rtp模块
使用rtp协议发送数据,也支持rtsp
example:
1)生成sdp文件
vlc.exe test.mp4 -vvv  --loop --sout "#rtp{dst=192.168.9.80,sdp=file:///E:/stream.sdp}"
启动rtp传输,该命令生成一个sdp的描述文件stream.sdp,将其copy到客户机上,就可以使用vlc进行播放了,dst指定客户端的ip。

2)使用rtsp进行传输
vlc.exe test.mp4 -vvv  --loop --sout "#rtp{sdp=rtsp://192.168.9.80:10086/stream}"
客户端面直接使用rtsp://192.168.9.80:10086/stream即可访问
3.es模块
es模块可以从stream中分离出不同的elementary streams,保存为不同的文件或者发送到不同的目的地址。
example:
vlc.exe test.mp4 -vvv --no-loop  --sout "#es{access=file, dst-video=e:/video_%d.%c, dst-audio=e:/audio_%d.%c}"
提取文件中的音视频,并保存到文件中。--no-loop表示不用循环,%d代表流的track号,%c表示 编码的FOURCC。
4.transcode模块
transcode模块用于转码, 也可以完成一些附加的功能re-scaling, deinterlacing, resampling,crop等,除了音视频外还可以处理字幕,叠加图片到视频
支持的编码格式参考:http://www.videolan.org/streaming-features.html
example:
按指定参数进行音视频转码,并保存为avi文件,后面级联standard模块完成文件保存功能
vlc.exe test.mp4 -vvv --sout "#transcode{vcodec=h264, vb=300, venc=x264, fps=15, width=352, height=288, acodec=mp3, aenc=ffmpeg, samplerate=44100, threads=2}:standard{access=file,mux=avi,dst=e:/test.avi}
venc,指定视频编码器,支持ffmpeg、x264、theora,可以进一步指定编码的详细参数
aenc,指定音频编码器,支持ffmpeg、vorbis、speex
threads,指定编码时线程数据,多核时可以提高效率
5.duplicate模块
duplicate模块可以复制stream,以用于不同的chains。
example:
vlc.exe test.mp4 -vvv --sout "#duplicate{dst=standard{access=file,mux=avi,dst=e:/test.avi}, dst=rtp{dst=192.168.9.80,name=stream,sdp=rtsp://192.168.9.80:10086/stream}, dst=display}"
通过dumplicate模块得到3个输出,保存为*.avi、发送到rtsp server、本地显示
dumplicate还有一个select选项,用于选择处理的stream


其它说明:
1.默认情况下,vlc只会处理第一个音频和视频流,可以使用--sout-all选项,处理所有的流
2.--no-sout-audio,--no-sout-video选项可以禁止输出音频或者视频
3.更多示例见http://wiki.videolan.org/Documentation:Streaming_HowTo/Command_Line_Examples