国产精品久久久久久2021,日韩精品无码av中文无码版,亚洲精品久久久午夜麻豆,无码成人精品日本动漫纯h

010-68421378
當(dāng)前您所在的位置:首頁(yè)>新聞中心>新品發(fā)布

如何用Wowza自定義模塊計(jì)算一個(gè)RTMP輸入流的幀率?

發(fā)布時(shí)間:2021/04/28 瀏覽量:4081
如何開(kāi)發(fā)一個(gè)自定義模塊(Module)來(lái)檢測(cè)RTMP輸入流

這篇文章介紹了如何開(kāi)發(fā)一個(gè)自定義模塊(Module)來(lái)檢測(cè)RTMP輸入流,并計(jì)算它的視頻幀率。

 

 

請(qǐng)參考下面的代碼:

注意: 這個(gè)例子中用到的API只能在Wowza Streaming Engine™ 4.0 及以上版本使用。

packagecom.wowza.wms.example;

 

importcom.wowza.wms.amf.AMFDataList;

import com.wowza.wms.amf.AMFPacket;

importcom.wowza.wms.application.IApplicationInstance;

importcom.wowza.wms.client.IClient;

importcom.wowza.wms.module.ModuleBase;

importcom.wowza.wms.request.RequestFunction;

importcom.wowza.wms.stream.IMediaStream;

import com.wowza.wms.stream.IMediaStreamLivePacketNotify;

 

public classModuleLiveFrameRate extends ModuleBase

{

        class PacketListener implementsIMediaStreamLivePacketNotify

        {

               /**

               * onLivePacket is called forevery packet that is received for the live stream before the packet isprocessed for playback.

               * It is very important that thismethod returns quickly and is not delayed in any way.

               */

               @Override

               public voidonLivePacket(IMediaStream stream, AMFPacket packet)

               {

                       if (packet.isVideo())

                       {

                               //packet.getTimecode(); returns the elapsed time, in milliseconds, between thispacket and the last packet of the same type.

                               double fps =(double)1000 / packet.getTimecode();

                               stream.getProperties().setProperty("currentFPS",new Double(fps));

                       }

               }

 

        }

 

        private PacketListener packetListener =new PacketListener();

        private IApplicationInstanceappInstance;

 

        public voidonAppStart(IApplicationInstance appInstance)

        {

               this.appInstance = appInstance;

        }

 

        public void onStreamCreate(IMediaStreamstream)

        {

               stream.addLivePacketListener(packetListener);

        }

 

        public void onStreamDestroy(IMediaStreamstream)

        {

               stream.removeLivePacketListener(packetListener);

        }

 

        public void getCurrentFPS(IClientclient, RequestFunction function, AMFDataList params)

        {

               double fps = 0;

               String streamName =getParamString(params, PARAM1);

               if (streamName != null)

               {

                       fps =getCurrentFPS(streamName);

               }

 

               sendResult(client, params, fps);

        }

 

        public double getCurrentFPS(StringstreamName)

        {

               double fps = 0;

               IMediaStream stream =appInstance.getStreams().getStream(streamName);

               if (stream != null)

               {

                       fps =stream.getProperties().getPropertyDouble("currentFPS", fps);

                }

               return fps;

        }

}

 

Wowza Streaming Engine 4是業(yè)界功能強(qiáng)大、API接口豐富的流媒體Server產(chǎn)品,采用它作為流媒體服務(wù)器產(chǎn)品的案例很多,直播、在線教育、IPTV都有它的用武之地。 

下一篇:ASN.1 查看器/編輯器 :用于分析和編輯使用ASN.1編碼規(guī)則的編碼數(shù)據(jù)
上一篇:Splashtop :網(wǎng)絡(luò)安全領(lǐng)導(dǎo)者:Mark Lee 對(duì)話 Sramana Mitra

                               

 京ICP備09015132號(hào)-996 | 違法和不良信息舉報(bào)電話:4006561155

                                   © Copyright 2000-2026 北京哲想軟件有限公司版權(quán)所有 | 地址:北京市海淀區(qū)西三環(huán)北路50號(hào)豪柏大廈C2座11層1105室

                         北京哲想軟件集團(tuán)旗下網(wǎng)站:哲想軟件 | 哲想動(dòng)畫

                            華滋生物