zoukankan      html  css  js  c++  java
  • 关于ios对rtsp格式的流媒体支持的一些官方说明

    ios明确不支持rtsp格式的流媒体,基于rtsp/rtp对通用性和防炎墙以及需要开新端口等额外影响稳定性和通用性的原因。

    而对http流的视频支持是最好的。虽然有第三方的方式配合ffmpeg库,实现了rtsp的流内容播放,但效果很一般。

    如果架构的条件不是那么苛刻,不如直接选择http流提供给app去播放呈现。

    具体官方说明:

    Frequently Asked Questions

    1. What kinds of encoders are supported?

      The protocol specification does not limit the encoder selection. However, the current Apple implementation should interoperate with encoders that produce MPEG-2 Transport Streams containing H.264 video and AAC audio (HE-AAC or AAC-LC). Encoders that are capable of broadcasting the output stream over UDP should also be compatible with the current implementation of the Apple provided segmenter software.

    2. What are the specifics of the video and audio formats supported?

      Although the protocol specification does not limit the video and audio formats, the current Apple implementation supports the following formats:

      • Video:

        • H.264 Baseline Level 3.0, Baseline Level 3.1, Main Level 3.1, and High Profile Level 4.1.

      • Audio:

        • HE-AAC or AAC-LC up to 48 kHz, stereo audio

        • MP3 (MPEG-1 Audio Layer 3) 8 kHz to 48 kHz, stereo audio

        • AC-3 (for Apple TV, in pass-through mode only)

        Note: iPad, iPhone 3G, and iPod touch (2nd generation and later) support H.264 Baseline 3.1. If your app runs on older versions of iPhone or iPod touch, however, you should use H.264 Baseline 3.0 for compatibility. If your content is intended solely for iPad, Apple TV, iPhone 4 and later, and Mac OS X computers, you should use Main Level 3.1.

    3. What duration should media files be?

      The main point to consider is that shorter segments result in more frequent refreshes of the index file, which might create unnecessary network overhead for the client. Longer segments will extend the inherent latency of the broadcast and initial startup time. A duration of 10 seconds of media per file seems to strike a reasonable balance for most broadcast content.

    4. How many files should be listed in the index file during a continuous, ongoing session?

      The normal recommendation is 3, but the optimum number may be larger.

      The important point to consider when choosing the optimum number is that the number of files available during a live session constrains the client's behavior when doing play/pause and seeking operations. The more files in the list, the longer the client can be paused without losing its place in the broadcast, the further back in the broadcast a new client begins when joining the stream, and the wider the time range within which the client can seek. The trade-off is that a longer index file adds to network overhead—during live broadcasts, the clients are all refreshing the index file regularly, so it does add up, even though the index file is typically small.

    5. What data rates are supported?

      The data rate that a content provider chooses for a stream is most influenced by the target client platform and the expected network topology. The streaming protocol itself places no limitations on the data rates that can be used. The current implementation has been tested using audio-video streams with data rates as low as 64 Kbps and as high as 3 Mbps to iPhone. Audio-only streams at 64 Kbps are recommended as alternates for delivery over slow cellular connections.

      For recommended data rates, see Preparing Media for Delivery to iOS-Based Devices.

      Note: If the data rate exceeds the available bandwidth, there is more latency before startup and the client may have to pause to buffer more data periodically. If a broadcast uses an index file that provides a moving window into the content, the client will eventually fall behind in such cases, causing one or more segments to be dropped. In the case of VOD, no segments are lost, but inadequate bandwidth does cause slower startup and periodic stalling while data buffers.

    6. What is a .ts file?

      .ts file contains an MPEG-2 Transport Stream. This is a file format that encapsulates a series of encoded media samples—typically audio and video. The file format supports a variety of compression formats, including MP3 audio, AAC audio, H.264 video, and so on. Not all compression formats are currently supported in the Apple HTTP Live Streaming implementation, however. (For a list of currently supported formats, see Media Encoder.

      MPEG-2 Transport Streams are containers, and should not be confused with MPEG-2 compression.

    7. What is an .M3U8 file?

      An .M3U8 file is a extensible playlist file format. It is an m3u playlist containing UTF-8 encoded text. The m3u file format is a de facto standard playlist format suitable for carrying lists of media file URLs. This is the format used as the index file for HTTP Live Streaming. For details, see IETF Internet-Draft of the HTTP Live Streaming specification.

    8. How does the client software determine when to switch streams?

      The current implementation of the client observes the effective bandwidth while playing a stream. If a higher-quality stream is available and the bandwidth appears sufficient to support it, the client switches to a higher quality. If a lower-quality stream is available and the current bandwidth appears insufficient to support the current stream, the client switches to a lower quality.

      Note: For seamless transitions between alternate streams, the audio portion of the stream should be identical in all versions.

    9. Where can I find a copy of the media stream segmenter from Apple?

      The media stream segmenter, file stream segmenter, and other tools are frequently updated, so you should download the current version of the HTTP Live Streaming Tools from the Apple Developer website. See Download the Tools for details.

    10. What settings are recommended for a typical HTTP stream, with alternates, for use with the media segmenter from Apple?

      See Preparing Media for Delivery to iOS-Based Devices.

      These settings are the current recommendations. There are also certain requirements. The current mediastreamsegmenter tool works only with MPEG-2 Transport Streams as defined in ISO/IEC 13818. The transport stream must contain H.264 (MPEG-4, part 10) video and AAC or MPEG audio. If AAC audio is used, it must have ADTS headers. H.264 video access units must use Access Unit Delimiter NALs, and must be in unique PES packets.

      The segmenter also has a number of user-configurable settings. You can obtain a list of the command line arguments and their meanings by typingman mediastreamsegmenter from the Terminal application. A target duration (length of the media segments) of 10 seconds is recommended, and is the default if no target duration is specified.

    11. How can I specify what codecs or H.264 profile are required to play back my stream?

      Use the CODECS attribute of the EXT-X-STREAM-INF tag. When this attribute is present, it must include all codecs and profiles required to play back the stream. The following values are currently recognized:

      AAC-LC

      "mp4a.40.2"

      HE-AAC

      "mp4a.40.5"

      MP3

      "mp4a.40.34"

      H.264 Baseline Profile level 3.0

      "avc1.42001e" or "avc1.66.30"

      Note: Use "avc1.66.30" for compatibility with iOS versions 3.0 to 3.1.2.

      H.264 Baseline Profile level 3.1

      "avc1.42001f"

      H.264 Main Profile level 3.0

      "avc1.4d001e" or "avc1.77.30"

      Note: Use "avc1.77.30" for compatibility with iOS versions 3.0 to 3.12.

      H.264 Main Profile level 3.1

      "avc1.4d001f"

      H.264 Main Profile level 4.0

      "avc1.4d0028"

      H.264 High Profile level 3.1

      "avc1.64001f"

      H.264 High Profile level 4.0

      "avc1.640028"

      H.264 High Profile level 4.1

      "avc1.640028"

      The attribute value must be in quotes. If multiple values are specified, one set of quotes is used to contain all values, and the values are separated by commas. An example follows.

      #EXTM3U
      #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=500000, RESOLUTION=720x480
      mid_video_index.M3U8
      #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=800000, RESOLUTION=1280x720
      wifi_video_index.M3U8
      #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=3000000, CODECS="avc1.4d001e,mp4a.40.5", RESOLUTION=1920x1080
      h264main_heaac_index.M3U8
      #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=64000, CODECS="mp4a.40.5"
      aacaudio_index.M3U8
    12. How can I create an audio-only stream from audio/video input?

      Add the -audio-only argument when invoking the stream or files segmenter.

    13. How can I add a still image to an audio-only stream?

      Use the -meta-file argument when invoking the stream or file segmenter with -meta-type=picture to add an image to every segment. For example, this would add an image named poster.jpg to every segment of an audio stream created from the file track01.mp3:

      mediafilesegmenter -f /Dir/outputFile -a --meta-file=poster.jpg --meta-type=picture track01.mp3

      Remember that the image is typically resent every ten seconds, so it’s best to keep the file size small.

    14. How can I specify an audio-only alternate to an audio-video stream?

      Use the CODECS and BANDWIDTH attributes of the EXT-X-STREAM-INF tag together.

      The BANDWIDTH attribute specifies the bandwidth required for each alternate stream. If the available bandwidth is enough for the audio alternate, but not enough for the lowest video alternate, the client switches to the audio stream.

      If the CODECS attribute is included, it must list all codecs required to play the stream. If only an audio codec is specified, the stream is identified as audio-only. Currently, it is not required to specify that a stream is audio-only, so use of the CODECS attribute is optional.

      The following is an example that specifies video streams at 500 Kbps for fast connections, 150 Kbps for slower connections, and an audio-only stream at 64 Kbps for very slow connections. All the streams should use the same 64 Kbps audio to allow transitions between streams without an audible disturbance.

      #EXTM3U
      #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=500000, RESOLUTION=1920x1080
      mid_video_index.M3U8
      #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=150000, RESOLUTION=720x480
      3g_video_index.M3U8
      #EXT-X-STREAM-INF:PROGRAM-ID=1, BANDWIDTH=64000, CODECS="mp4a.40.5"
      aacaudio_index.M3U8
    15. What are the hardware requirements or recommendations for servers?

      See question #1 for encoder hardware recommendations.

      The Apple stream segmenter is capable of running on any Intel-based Mac. We recommend using a Mac with two Ethernet network interfaces, such as a Mac Pro or an XServe. One network interface can be used to obtain the encoded stream from the local network, while the second network interface can provide access to a wider network.

    16. Does the Apple implementation of HTTP Live Streaming support DRM?

      No. However, media can be encrypted, and key access can be limited by requiring authentication when the client retrieves the key from your HTTPS server.

    17. What client platforms are supported?

      iPhone, iPad, and iPod touch (requires iOS version 3.0 or later), Apple TV (version 2 and later), and Mac OS X computers.

    18. Is the protocol specification available?

      Yes. The protocol specification is an IETF Internet-Draft, at http://tools.ietf.org/html/draft-pantos-http-live-streaming.

    19. Does the client cache content?

      The index file can contain an instruction to the client that content should not be cached. Otherwise, the client may cache data for performance optimization when seeking within the media.

    20. Is this a real-time delivery system?

      No. It has inherent latency corresponding to the size and duration of the media files containing stream segments. At least one segment must fully download before it can be viewed by the client, and two may be required to ensure seamless transitions between segments. In addition, the encoder and segmenter must create a file from the input; the duration of this file is the minimum latency before media is available for download. Typical latency with recommended settings is in the neighborhood of 30 seconds.

    21. What is the latency?

      Approximately 30 seconds, with recommended settings. See question #15.

    22. Do I need to use a hardware encoder?

      No. Using the protocol specification, it is possible to implement a software encoder.

    23. What advantages does this approach have over RTP/RTSP?

      HTTP is less likely to be disallowed by routers, NAT, or firewall settings. No ports need to be opened that are commonly closed by default. Content is therefore more likely to get through to the client in more locations and without special settings. HTTP is also supported by more content-distribution networks, which can affect cost in large distribution models. In general, more available hardware and software works unmodified and as intended with HTTP than with RTP/RTSP. Expertise in customizing HTTP content delivery using tools such as PHP is also more widespread.

      Also, HTTP Live Streaming is supported in Safari and the media player framework on iOS. RTSP streaming is not supported.

    24. Why is my stream’s overall bit rate higher than the sum of the audio and video bitrates?

      MPEG-2 transport streams can include substantial overhead. They utilize fixed packet sizes that are padded when the packet contents are smaller than the default packet size. Encoder and multiplexer implementations vary in their efficiency at packing media data into these fixed packet sizes. The amount of padding can vary with frame rate, sample rate, and resolution.

    25. How can I reduce the overhead and bring the bit rate down?

      Using a more efficient encoder can reduce the amount of overhead, as can tuning the encoder settings.

    26. Do all media files have to be part of the same MPEG-2 Transport Stream?

      No. You can mix media files from different transport streams, as long as they are separated by EXT-X-DISCONTINUITY tags. See the protocol specification for more detail. For best results, however, all video media files should have the same height and width dimensions in pixels.

    27. Where can I get help or advice on setting up an HTTP audio/video server?

      You can visit the Apple Developer Forum at http://devforums.apple.com/.

      Also, check out Best Practices for Creating and Deploying HTTP Live Streaming Media for the iPhone and iPad.

  • 相关阅读:
    django-JWT的原理
    python-路由Routers-SimpleRouter-DefaultRouter的使用
    深入理解单例模式
    ArrayList
    队列----java实现
    栈--链表实现
    开发中CollectionUtils处理集合
    NullPointerException-----开发中遇到的空指针异常
    查询部门----返回给前台TreeView数据格式的数据
    git使用命令记录
  • 原文地址:https://www.cnblogs.com/killiancheung/p/4646097.html
Copyright © 2011-2022 走看看