[FMS]FMS音频质量的稍微提高
[FMS]FMS 音频质量的稍微提高,fms音频,fms配置
直接贴出部分源码:
- package
- {
- import flash.display.Sprite;
- import flash.events.NetStatusEvent;
- import flash.net.NetConnection;
- import flash.net.NetStream;
- import flash.media.Microphone;
- import flash.media.SoundCodec;
- public class Main extends Sprite
- {
- private var nc:NetConnection;
- private var nsAudio:NetStream;
- private var nsVideo:NetStream;
- private var nsPlayVideo:NetStream;
- private var nsPlayAudio:NetStream;
- public function Main():void
- {
- nc=new NetConnection();
- nc.client = this;
- nc.addEventListener(NetStatusEvent.NET_STATUS,netStatusHandler);
- nc.connect("rtmp://localhost/TestAudioMore","我心空");
- }
- private function netStatusHandler(e:NetStatusEvent)
- {
- var code:String = e.info.code;
- switch (code)
- {
- case "NetConnection.Connect.Success" :
- publishAudio(0);
- break;
- default :
- break;
- }
- }
- //分别发布音频,视频
- private function publishAudio(id)
- {
- if (nsAudio==null)
- {
- nsAudio = new NetStream(nc);
- nsAudio.client = this;
- nsAudio.bufferTime = 2;
- var mic:Microphone = Microphone.getMicrophone();
- if (mic!=null)
- {
- mic.codec = SoundCodec.SPEEX;
- mic.encodeQuality = 4;
- mic.noiseSuppressionLevel = 0;
- mic.setSilenceLevel(10,1000);
- mic.setUseEchoSuppression(true);
- mic.setLoopBack(false);
- mic.gain = 50;
- nsAudio.attachAudio(mic);
- }
- nsAudio.publish("audio"+id,"live");
- }
- }
- private function publishVideo(id)
- {
- if (nsVideo==null)
- {
- nsVideo=new NetStream();
- nsVideo.client = this;
- nsVideo.bufferTime = 2;
- var cam:Camera = Camera.getCamera();
- if (cam!=null)
- {
- cam.setQuality(0,80);
- cam.setMode(160,130,7);
- nsVideo.attachCamera(cam);
- }
- nsVideo.publish("video"+id,"live");
- }
- }
- //分别播放视频音频
- private function playVideo(id)
- {
- clearVideoStream();
- nsPlayVideo=new NetStream(nc);
- var vid:Video=new Video();
- vid.attachNetStream(nsPlayVideo);
- vid.width=240;
- vid.height=150;
- addChild(vid);
- nsPlayVideo.play("video"+id);
- }
- /**
- *清除视频
- */
- private function clearVideoStream(clearPublish:Boolean=false)
- {
- if (nsPlayVideo)
- {
- nsPlayVideo.close();
- nsPlayVideo = null;
- }
- if (nsVideo&&clearPublish)
- {
- nsVideo.close();
- nsVideo = null;
- }
- }
- /**
- *清除音频
- */
- private function clearAudioStream(clearPublish:Boolean=false)
- {
- if (nsPlayAudio)
- {
- nsPlayAudio.close();
- nsPlayAudio = null;
- }
- if (nsAudio&&clearPublish)
- {
- nsAudio.close();
- nsAudio = null;
- }
- }
- public function Welcome(str)
- {
- trace(str,",欢迎你的到来。义无反顾,彻底的放下心扉");
- }
- }
- }
通讯文件main.asc
- application.onConnect=function(newClient,aname)
- {
- application.acceptConnection(newClient);
- newClient.call("Welcome",null,aname);
- }
热门文章推荐
- [FMS]adobe FMS配置实现(FMS/HLS/HDS)功能经验
- [HLS]HTTP Live Streaming流与TS流比较
- [FMS]adobe FMS(flash media server )服务器安装过程
- [FMS]fms5.0的hls(HTTP Live Streaming)技术实现跨平台点播与
- [FMS]FMS之HTTP Live Streaming (HLS)视频直播技术
- [hls]m3u8视频如何处理成加密?
- [海康]视频监控环境中配置组播模式
- [FMS]基于fms搭建在线hls跨平台直播环境(组图)
请稍候...