NetStream 信息返回 0(Icecast 流)

发布于 2024-12-19 20:13:38 字数 4888 浏览 3 评论 0原文

我已经四处寻找解决此问题的方法,但找不到任何关于为什么几乎所有属性都返回为 0 的信息。

我正在使用 FLV 包装从 Icecast 中提取实时音频流(自 Adob​​e 以来,15 年后) ,仍然没有解决他们的实时音频内存泄漏问题)。它工作得很好,一切都很完美。

但是,我想创建一个带宽监视器(用于我的 iPhone 端口和我的普通 Flash 播放器)...但是每当我检索 netStreamInfo 时,它都会返回 0 !对于 dataBytesPerSecondaudioBytesPerSecondbyteCountdataByteCount,几乎每个属性都返回 0 。我在 1 秒计时器上运行了这个。

以下是总信息输出:

currentBytesPerSecond=0 
byteCount=0 
maxBytesPerSecond=0 
audioBytesPerSecond=0 
audioByteCount=0 
videoBytesPerSecond=0 
videoByteCount=0 
dataBytesPerSecond=0
dataByteCount=0 
playbackBytesPerSecond=16296.296296296296 
droppedFrames=0 
audioBufferLength=0.072
videoBufferLength=0 
dataBufferLength=0 
audioBufferByteLength=1540 
videoBufferByteLength=0
dataBufferByteLength=0 
srtt=0 
audioLossRate=0 
videoLossRate=0 Data Bytes Per Second

该输出大约持续 5 分钟。我注意到 playBackBytesPerSecond 从未改变,并且 audioBufferByteLength 喜欢在 1540 和 23xx 之间随机切换。

有人可以帮我吗?

我的动作脚本:

package
{
    import flash.display.Sprite;
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.media.Video;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextField;
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.events.NetStatusEvent;
    import flash.utils.Timer;
    import flash.media.Sound;
    import flash.net.URLRequest;
    import flash.media.SoundChannel;
    import flash.media.SoundMixer;
    import flash.media.SoundTransform;
    import flash.display.Loader;
    import flash.errors.IOError;
    import flash.events.MouseEvent;
    import flash.geom.Rectangle;
    import flash.net.NetStreamInfo;
    import flash.utils.ByteArray;
    import flash.media.*

    public class soundContainer extends Sprite
    {
        public var slider:SliderMC = new SliderMC();
        private var _video:Video;
        private var _stream:NetStream;
        private var _playbackTime:TextField;
        private var _duration:uint;
        private var _timer:Timer;
        private var _soundChannel:SoundChannel;
        public var audioTransform:SoundTransform = new SoundTransform();
        public var _URL:String;
        public var flvUrl:String = "s";
        public var dragging:Boolean = false;
        public var rectangle:Rectangle = new Rectangle(0,0,100,0);
        private var ba:ByteArray;
        private var bn;


        public function soundContainer() {

            addEventListener(Event.ADDED_TO_STAGE, init);
        }

        public function init(e:Event):void
        {

            ba = new ByteArray();

            slider.x = 73.85;
            slider.y = 10.95;
            addChild(slider);

            slider.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragIt);
            stage.addEventListener(MouseEvent.MOUSE_UP, dropIt);


            _timer = new Timer(1000);
            _timer.addEventListener(TimerEvent.TIMER, onTimer);
            _timer.start();


        }

        public function dragIt(e:MouseEvent):void
        {
            slider.slider_mc.startDrag(false, rectangle);
            dragging = true;
            slider.slider_mc.addEventListener(Event.ENTER_FRAME, adjustVolume);
        }

        public function dropIt(e:MouseEvent = null):void
        {
            if (dragging)
            {
                slider.slider_mc.stopDrag();
                dragging = false;
            }
        }

        public function adjustVolume(e:Event):void
        {
            var vol:Number = slider.slider_mc.x / 100;
            var st:SoundTransform = new SoundTransform(vol);
            SoundMixer.soundTransform = st;

        }

        public function playMyFlv(flvUrl)
        {
            _URL = flvUrl;
            _video = new Video();

            var connection:NetConnection = new NetConnection();
            connection.connect(null);

            _stream = new NetStream(connection);
            _stream.soundTransform = audioTransform;
            _stream.play(flvUrl);

            var Client:Object = new Object();
            _stream.client = Client;
            _video.attachNetStream(_stream);

            addChild(_video);

        }



        public function stopMyFlv()
        {
            SoundMixer.stopAll();
            trace("stop");
            try
            {
                _stream.close();
            }
            catch (error:IOError)
            {
            }

        }




        private function onNetStatus(e:NetStatusEvent)
        {

        }

        private function onTimer(t:TimerEvent):Number
        {
            trace(_stream.info + " Data Bytes Per Second");
        }


        public function onIOError(e:IOError)
        {
            trace("Failed to load");
        }
    }
}

I've searched high and low for a fix to this issue, but cannot find ANYTHING on why almost all the properties are being returned as 0.

I am using FLV wrapping to pull a live audio stream from Icecast (since Adobe, 15 years later, still haven't fixed their live audio memory leak issue). It works great, everything functions perfectly.

However, I'm wanting to create a bandwidth monitor (for my iPhone port, and for my normal Flash player)... But whenever I retrieve netStreamInfo it returns as 0! For dataBytesPerSecond, audioBytesPerSecond, byteCount, dataByteCount, nearly EVERY SINGLE PROPERTY returns 0. I have this run on a 1-second timer.

Here's the total info output:

currentBytesPerSecond=0 
byteCount=0 
maxBytesPerSecond=0 
audioBytesPerSecond=0 
audioByteCount=0 
videoBytesPerSecond=0 
videoByteCount=0 
dataBytesPerSecond=0
dataByteCount=0 
playbackBytesPerSecond=16296.296296296296 
droppedFrames=0 
audioBufferLength=0.072
videoBufferLength=0 
dataBufferLength=0 
audioBufferByteLength=1540 
videoBufferByteLength=0
dataBufferByteLength=0 
srtt=0 
audioLossRate=0 
videoLossRate=0 Data Bytes Per Second

That output was about 5 minutes in. I noted the playBackBytesPerSecond never changed, and the audioBufferByteLength liked to switch between 1540 and 23xx randomly.

Can anyone pleaaase help me out here?

My actionscript:

package
{
    import flash.display.Sprite;
    import flash.net.NetConnection;
    import flash.net.NetStream;
    import flash.media.Video;
    import flash.text.TextFieldAutoSize;
    import flash.text.TextField;
    import flash.events.Event;
    import flash.events.TimerEvent;
    import flash.events.NetStatusEvent;
    import flash.utils.Timer;
    import flash.media.Sound;
    import flash.net.URLRequest;
    import flash.media.SoundChannel;
    import flash.media.SoundMixer;
    import flash.media.SoundTransform;
    import flash.display.Loader;
    import flash.errors.IOError;
    import flash.events.MouseEvent;
    import flash.geom.Rectangle;
    import flash.net.NetStreamInfo;
    import flash.utils.ByteArray;
    import flash.media.*

    public class soundContainer extends Sprite
    {
        public var slider:SliderMC = new SliderMC();
        private var _video:Video;
        private var _stream:NetStream;
        private var _playbackTime:TextField;
        private var _duration:uint;
        private var _timer:Timer;
        private var _soundChannel:SoundChannel;
        public var audioTransform:SoundTransform = new SoundTransform();
        public var _URL:String;
        public var flvUrl:String = "s";
        public var dragging:Boolean = false;
        public var rectangle:Rectangle = new Rectangle(0,0,100,0);
        private var ba:ByteArray;
        private var bn;


        public function soundContainer() {

            addEventListener(Event.ADDED_TO_STAGE, init);
        }

        public function init(e:Event):void
        {

            ba = new ByteArray();

            slider.x = 73.85;
            slider.y = 10.95;
            addChild(slider);

            slider.slider_mc.addEventListener(MouseEvent.MOUSE_DOWN, dragIt);
            stage.addEventListener(MouseEvent.MOUSE_UP, dropIt);


            _timer = new Timer(1000);
            _timer.addEventListener(TimerEvent.TIMER, onTimer);
            _timer.start();


        }

        public function dragIt(e:MouseEvent):void
        {
            slider.slider_mc.startDrag(false, rectangle);
            dragging = true;
            slider.slider_mc.addEventListener(Event.ENTER_FRAME, adjustVolume);
        }

        public function dropIt(e:MouseEvent = null):void
        {
            if (dragging)
            {
                slider.slider_mc.stopDrag();
                dragging = false;
            }
        }

        public function adjustVolume(e:Event):void
        {
            var vol:Number = slider.slider_mc.x / 100;
            var st:SoundTransform = new SoundTransform(vol);
            SoundMixer.soundTransform = st;

        }

        public function playMyFlv(flvUrl)
        {
            _URL = flvUrl;
            _video = new Video();

            var connection:NetConnection = new NetConnection();
            connection.connect(null);

            _stream = new NetStream(connection);
            _stream.soundTransform = audioTransform;
            _stream.play(flvUrl);

            var Client:Object = new Object();
            _stream.client = Client;
            _video.attachNetStream(_stream);

            addChild(_video);

        }



        public function stopMyFlv()
        {
            SoundMixer.stopAll();
            trace("stop");
            try
            {
                _stream.close();
            }
            catch (error:IOError)
            {
            }

        }




        private function onNetStatus(e:NetStatusEvent)
        {

        }

        private function onTimer(t:TimerEvent):Number
        {
            trace(_stream.info + " Data Bytes Per Second");
        }


        public function onIOError(e:IOError)
        {
            trace("Failed to load");
        }
    }
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文