温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

How to publish and play a live stream (MPEG-TS based encoder)

发布时间:2020-08-05 13:31:23 来源:网络 阅读:2067 作者:fengjihu 栏目:移动开发

  1. 英文原版配置,最后有简单操作步骤

This tutorial provides the basic steps for using a live encoder that publishes a stream using the MPEG2 Transport Stream protocol (MPEG-TS). Follow these steps to setup an application named live to stream live content to Adobe Flash player, Microsoft Silverlight player, Apple iOS devices, and RTSP/RTP based players & devices.


Updated for Wowza Media Server 2.2.0 (19 November 2010)

  1. Create application folder [install-dir]/applications/live

  2. Create configuration folder [install-dir]/conf/live and copy [install-dir]/conf/Application.xml into this new folder

  3. Edit the newly copied Application.xml file and make the following changes (some of these settings may already be present):

  1. Set the Streams/StreamType property to: live
    Code:
    <StreamType>live</StreamType>

  2. Set the HTTPStreamers property to: cupertinostreaming, smoothstreaming, sanjosestreaming
    Code:
    <HTTPStreamers>cupertinostreaming,smoothstreaming,sanjosestreaming</HTTPStreamers>

  3. Set the Streams/LiveStreamPacketizers property to: cupertinostreamingpacketizer, smoothstreamingpacketizer, sanjosestreamingpacketizer:
    Code:
    <LiveStreamPacketizers>cupertinostreamingpacketizer, smoothstreamingpacketizer, sanjosestreamingpacketizer</LiveStreamPacketizers>
    Note cupertinostreamingpacketizer, smoothstreamingpacketizer, sanjosestreamingpacketizer are used for iOS, Silverlight and Flash HTTP clients. You can remove packetizers that you don't need.

  4. Set the RTP/Authentication/PlayMethod to: none
    Code:
    <PlayMethod>none</PlayMethod>
    Download: Right click Application.xml to download a pre-configured version of Application.xml.

  1. Using a text editor, create the file [install-dir]/content/mpegts.stream (有多个流的话此名称做如下变化test.stream test2.stream,mpegts可随意变化,stream不能变动)set the contents of this file to udp://0.0.0.0:10000 (if you are receiving a multicast stream, change the 0.0.0.0 part to the multicast address of the stream)(0.0.0.0可以设置成VLC的服务器IP,端口也可改变,但需要vlc也做相应改变)

  2. Using a text editor, edit the file [install-dir]/conf/admin.password and add a username and password that will be used to start and stop the publishing of the MPEG-TS stream (below is an example of the file with the username myuser and password mypassword):
    Code:
    # Admin password file (format [username][space][password])
    # username password
    myuser mypassword

  3. Start Wowza Media Server 2

  4. Configure the MPEG-TS based encoder to send a live stream to the IP address of the server running Wowza Server using port 10000

  5. Use the Stream Manager to start the MPEG-TS stream


  1. 在浏览器中打开 http://[wowza-address]:8086/streammanager,输入用户名、密码,做下面配置

  1. Open a web browser and enter the url: http://[wowza-address]:8086/streammanager

  2. Enter your admin username and password from above

  3. Click the [start-receiving-stream] link just below the live application folder

  4. Select the MediaCaster Type: rtp

  5. Enter mpegts.stream into the Stream Name field

  6. Click OK



Publishing:

  • Consult your encoder's documentation. Send the stream to the IP address of the server running Wowza Server and the port 10000.

Playback:

  • To play using Adobe Flash player (RTMP)

    Double-click [install-dir]/examples/LiveVideoStreaming/client/live.html, enter the information below and click the Play button.

    Code:
    Server: rtmp://[wowza-address]/live
    Stream: mpegts.stream
    Note: If your application will only stream to Flash RTMP clients see note at bottom of this article: Optional Configuration for Flash RTMP Clients Only

  • To play using Adobe Flash player (San Jose/Flash HTTP)

    Double-click [install-dir]/examples/SimpleVideoStreaming/clientOSMF/bin-release/SimpleOSMFPlayer.html, enter the information below and click thePlay button.

    Code:
    Stream: http://[wowza-ip-address]:1935/live/mpegts.stream/manifest.f4m
    Note: The HTTP link above will not play directly in a browser. The stream can only be played from an OSMF based Flash player that is embedded in an HTML page. To play the stream from a remote system, copy the contents of the clientOSMF/bin-release folder to a web server.

  • To play using an Apple iOS device (Cupertino/Apple HTTP Live Streaming)

    Enter the following URL into the Safari web browser:
    Code:
    http://[wowza-address]:1935/live/mpegts.stream/playlist.m3u8
    Note: This stream can also be played using the Safari Browser or QuickTime 10.x on a computer running OSX version 10.6 or greater (Snow Leopard).
    Note: The iPhone 3GS and older, and iPod touch devices require video encoded using H.264 format, Baseline 3 profile, or lower, and AAC or MP3 stereo audio.

  • To play using Microsoft Silverlight (Smooth Streaming)

    Double-click [install-dir]/examples/LiveVideoStreaming/clientSilverlight/Default.html, enter the URL below and click the Play button.

    Code:
    http://[wowza-address]:1935/live/mpegts.stream/Manifest
    Note: The Silverlight player requires both audio and video to be present for playback. For live streaming only, the key frame frequency (which can be set directly in some encoders or is gop/fps), needs to be between 1 – 4 seconds. 2 seconds is recommended.

  • To play using RTSP/RTP player or device

    Enter the following URL into the RTSP/RTP player:
    Code:
    rtsp://[wowza-address]:1935/live/mpegts.stream
    See Also:
    Mobile streaming troubleshooting guide
    How to best setup an application for RTSP/RTP streaming
    How to configure QuickTime player ...
    How to configure VLC player ...

    Note: [wowza-address] is the IP address or domain name of the server running Wowza Server.

    Note: For Microsoft Silverlight playback, the key frame interval must be set to between 1 and 4 seconds. Anything greater than 4 seconds can cause playback to freeze.

    Note: The mpegts.stream file is to contain the address of the incoming UDP stream that is carrying the MPEG-TS packets. Most of the time it is sufficient to set this address to udp://0.0.0.0:[port] where [port] is the number of the UDP on which the stream is being published. The IP address 0.0.0.0 instructs Wowza to listen on all local IP addresses for the incoming stream. Sometimes if there are multiple network interfaces on the machine, this will not work properly. When this happens, it is best to specify the internal IP address of the stream. For example, to listen to the local loopback interface you might specifyudp://127.0.0.1:10000 or maybe the internal NAT address of the machine udp://192.168.1.1:10000.

    Note: RTSP/RTP streaming is the way to stream to Android and Blackberry mobile devices. Newer Android based phones also support Flash player 10.1 along with RTMP and Flash HTTP streaming.

    Note: It is very important to carefully follow the instructions provided in the Mobile streaming troubleshooting guide to properly configure Wowza Server forRTSP/RTP streaming.

    Note: To stream to RTSP/RTP be sure UDP ports 0-65535 are open and properly mapped to the server running Wowza Media Server.

    Note: Many text editors will append a .txt extension to the mpegts.stream filename. This will result in an error message similar to:
    Code:
    SDP file missing: c:/program files/wowzamediasystems/wowzamediaserver[version]/content/mpegts.stream
    To fix this, go to the folder [install-dir]/content and remove the .txt extension from the filename.

Multi-bitrate Live Streaming


Multi-bitrate live streaming to Flash, Apple iOS devices and Silverlight requires that you have an encoder that can generate multiple bitrate streams from the same source that are properly key-frame aligned. Once you have an encoder that can generate properly aligned streams then you need to create a Synchronized Multimedia Integration Language (SMIL) file that links the streams together for playback.


For example, let's say we have three live streams encoded at three different bitrates myStream_700.stream (700kbps total bitrate), myStream_350.stream(350kbps total bitrate) and myStream_200.stream (200kbps total bitrate). Using a text editor, create a SMIL file in the [install-dir]/content folder with the namemyStream.smil with the following content:


Code:

<smil>
       <head>
       </head>
       <body>
               <switch>
                       <video src="myStream_700.stream" system-bitrate="700000"/>
                       <video src="myStream_350.stream" system-bitrate="350000"/>
                       <video src="myStream_200.stream" system-bitrate="200000"/>
               </switch>
       </body>
</smil>

You can see that there is a <video> entry in the <switch> container for each rendition of the stream. The system-bitrate value is set to the total bitrate in bits-per-second for that stream.

  • To play using Adobe Flash player (San Jose/Flash HTTP)

    Double-click [install-dir]/examples/SimpleVideoStreaming/clientOSMF/bin-release/SimpleOSMFPlayer.html, enter the information below and click thePlay button.

    Code:
    Stream: http://[wowza-ip-address]:1935/vod/smil:myStream.smil/manifest.f4m

  • To play using an Apple iOS device (Cupertino/Apple HTTP Live Streaming)

    Enter the following URL into the Safari web browser on the device:

    Code:
    http://[wowza-address]:1935/vod/smil:myStream.smil/playlist.m3u8

  • To play using Microsoft Silverlight (Smooth Streaming)

    Double-click [install-dir]/examples/SimpleVideoStreaming/clientSilverlight/Default.html, enter the URL below and click the Play button.

    Code:
    http://[wowza-address]:1935/vod/smil:myStream.smil/Manifest

  • To play using Adobe Flash player (RTMP)

    Dynamic Streaming to the Flash player requires a fair amount of work on the client-side. These articles cover the details of how to achieve dynamic streaming in Flash:

    Dynamic streaming in Flash (part 1)
    Dynamic streaming in Flash (part 2)
    Dynamic streaming in Flash (part 3)


Note: Silverlight Smooth Streaming will only switch between the video portion of the streams. The audio track of the first stream listed in the <switch> container will be used. If you want to use a stream other then the first stream for the audio track, add an <audio> entry to the <switch> container for that item. The <audio>item will be ignored when streaming using San Jose or Cupertino streaming. For example:


Code:

<smil>
       <head>
       </head>
       <body>
               <switch>
                       <video src="myStream_700.sdp" system-bitrate="700000"/>
                       <video src="myStream_350.sdp" system-bitrate="350000"/>
                       <video src="myStream_200.sdp" system-bitrate="200000"/>
                       <audio src="myStream_200.sdp" system-bitrate="96000"/>
               </switch>
       </body>
</smil>

Note: By default Silverlight Smooth Streaming will calculate video and audio bitrates for the Manifest data on the fly by inspecting the file. If you would like to instruct Wowza Server to use the bitrates in the SMIL file, add the following property to the HTTPStreams/Properties <Properties> container in [install-dir]/conf/[application]/Application.xml (be sure to get the correct properties container - there are several in the Application.xml file). When running in this mode, Wowza will assume the video and audio system-bitrate values are only for the video and audio data only:


Code:

<Property>
       <Name>smoothStreamingUseSMILBitrates</Name>
       <Value>true</Value>
       <Type>Boolean</Type>
</Property>

Note: When streaming out using RTSP/RTP you can force the output to MPEG-TS (which is needed by many set-top boxes) by adding the following two properties to the RTP/Properties (be sure to get the correct <Properties> container) in [install-dir]/conf/[application]/Application.xml:

Code:

<Property>
       <Name>forceMPEGTSOut</Name>
       <Value>true</Value>
       <Type>Boolean</Type>
</Property>
<Property>
       <Name>rtpWrapMPEGTS</Name>
       <Value>true</Value>
       <Type>Boolean</Type>
</Property>

Note: Wowza Server can output AAC audio using two different packetization methods; mpeg4-generic and mp4a-latm (3gpp). The default packetization method ismpeg4-generic. To switch to mp4a-latm (3gpp) add the following property to the RTP/Properties container in [install-dir]/[application]/Application.xml (be sure to get the correct Properties container - there are several in Application.xml):


Code:

<Property>
       <Name>audioPacketizerAAC</Name>
       <Value>com.wowza.wms.rtp.packetizer.RTPPacketizerMPEG4LATM</Value>
</Property>

Note: Some MPEG-TS based encoders send out video and audio in such a way that the media frames are not aligned on PES packet boundaries. This will cause the video and audio to not play. Wowza Server can re-aligned unaligned streams but it requires a property be added to [install-dir]/conf/[application]/Application.xml to enable this feature.


To turn on the code to fix audio alignment, add the following property to the RTP/Properties container in [install-dir]/[application]/Application.xml (be sure to get the correct Properties container - there are several in Application.xml):


Code:

<Property>
               <Name>audioIsAligned</Name>
               <Value>false</Value>
               <Type>Boolean</Type>
</Property>

To turn on the code to fix video alignment, add the following property to the RTP/Properties container in [install-dir]/[application]/Application.xml (be sure to get the correct Properties container - there are several in Application.xml) (Wowza Media Server 3 or greater is required):


Code:

<Property>
               <Name>videoIsAligned</Name>
               <Value>false</Value>
               <Type>Boolean</Type>
</Property>

Note: Some (not many) MPEG-TS encoders send do not properly align TS packets in UDP packets. When this happens you will see lots of the following warning messages in the logs:


Code:

RTPDePacketizerMPEGTS.handleRTPPacket: Out of sync: 0x[nn]

Add the following property to the RTP/Properties container in [install-dir]/[application]/Application.xml (be sure to get the correct Properties container - there are several in Application.xml):


Code:

<Property>
       <Name>rtpDePacketizerWrapper</Name>
       <Value>com.wowza.wms.rtp.depacketizer.RTPDePacketizerWrapperReChunkMPEGTS</Value>
</Property>

Wowza Server only allows a single rtpDePacketizerWrapper value. If you have setup a jitter buffer or packet recorder that uses the samertpDePacketizerWrapper they must be removed.


Optional Configuration for Flash RTMP Clients Only


If your application will only stream to Flash RTMP clients you can, optionally, change StreamType "rtp-live", then you will not need to use StreamManager (steps 8a-f above). The first Flash client that plays the stream will trigger Wowza to start re-streaming.

Code:

<StreamType>rtp-live</StreamType>

Also make the /conf/[app-name]/Application.xml /Streams /LiveStreamPacketizers empty:


Code:

<LiveStreamPacketizers></LiveStreamPacketizers>

  • Click here, if you are having problems or would like to discuss this article.

  • Leave a comment below, if there is some aspect of this article you would like to see changed or improved.


源文档 <http://www.wowza.com/forums/content.php?37>

  1. 简单中文操作步骤参考

第一步:建立发布点applicationconf目录下建立发布点live

第二步:修改conf/live下的Applicationxml

第三步:在content下建立mpegts.stream(流),mpegts可以随意修改,stream不可修改。修改文件内容为udp://0.0.0.0:10000(地址和端口都是vlc的)

第四步:打开http://wowzaip:8086/streammanager 添加rtp流,流名称填写mpegts.stream(或自定义的流名称)

第五步:播放,rtmp://wowzaip:1935/live/mpegts.stream

<<Application.xml>>

<<vlc.txt>>



VLC编码配置

vlc -vvv "mms://lmdb.nbradio.com/jjpd" --sout

"#transcode{venc=x2

64{keyint=60,profile=baseline,level=3.0,nocabac},vcodec=x264,vb=150,scale=0.5,acodec=mp4a,ab=96,channels=2,samplerate=48000}:rtp{dst=192.168.0.52,port=10000,mux=ts}"


dst=192.168.0.52指wowza服务器IP

port=10000 指端口,可进行变化,变化收[wowza-install]/content/mpegts.stream 中的端口也需要变化。


向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI