Use a variety of streaming playlists instead of a single stream of code. The HLS client can dynamically change the stream based on the bandwidth situation, providing the user with the best user experience. (This argument is more idealized, personally think that as long as you can provide a variety of code flow to the user to choose, the app in the start video, according to the bandwidth to select the use of the stream) need to consider the following issues:
1. Coding Equipment and budgetingYou need to consider whether the device can generate multiple encodings, and for real-time video If you use a CDN, you also need to consider the number of streams and users and calculate the cost.
2. Bitstream switchingNeed to detect the interval between different streams, and note whether the client can switch between multiple streams
3. Device functionNeed to understand the capabilities of the application device, such as: resolution, the description level of H. Different devices require a different playlist: a. Device resolution: Due to the different resolution of the device, it is necessary to include in the main playlist
RESOLUTION
Properties, such as:
#EXT-X-STREAM-INF:BANDWIDTH=1280000,RESOLUTION=640x360
#EXT-X-STREAM-INF:BANDWIDTH=1700000,RESOLUTION=1280x720
#EXT-X-STREAM-INF:BANDWIDTH=3500000,RESOLUTION=1920x1080
If there is no selectable resolution, video playback with a higher than the current screen resolution appears, wasting user bandwidth. B. Device code: Due to the difference in the description level of the set, you need to join
CODECSproperty, which allows the client to filter to get its supporting features, such as:
#EXT-X-STREAM-INF:BANDWIDTH=1280000,CODECS="avc1.42001e" // 基线
#EXT-X-STREAM-INF:BANDWIDTH=1280000,CODECS="avc1.4d001f" // 主要
#EXT-X-STREAM-INF:BANDWIDTH=1280000,CODECS="avc1.64001f" // 高
The device can select the appropriate playback content based on the playlist C. Type of setting: You can choose which playlists to use based on the device type, for example: In Safari, you can get the device type based on the user-agent in the HTTP header (recommended for server implementation )
通过Safari来访问服务器
Mozilla/5.0 (iPhone; CPU iPhone OS 5_1_1 like Mac OS X) AppleWebKit/ 534.46
(KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3
Mozilla/5.0 (iPad; CPU OS 5_1_1 like Mac OS X) AppleWebKit/534.46
(KHTML, like Gecko) Version/5.1 Mobile/9B206 Safari/7534.48.3
App gets device type
AppleCoreMedia/1.0.0.9B176 (iPhone; U; CPU OS 5_1 like Mac OS X; en_us)
AppleCoreMedia/1.0.0.9B176 (iPad; U; CPU OS 5_1 like Mac OS X; en_us)
4. Network FunctionsFirst determine the network type, then select the appropriate playlist. This can either use a different URL interface request or you can use additional parameters, and the server returns the appropriate playlist based on the situation.
5. Code Flow recommendations Some playlist selection code stream suggestions: a. The code that can be accepted by the primary client is exiled to the first line of the playlist, even if you use multiple playlists. mobile network: 150Kbps video streaming   &NBS P wifi: 440kbps video streaming b. Provide as many streams as possible, and these streams refer to the best quality of the stream at a specific bandwidth. For example: 64 kbps, up to 1500 kbps, Kbps, 550 Kbps kbps C. Audio/video Streaming considerations videos must Use the same screen aspect ratio, but can consider different sizes, recommended: screen crossbar &N BSP, size 16:9 &NBS P 416x234 &NBSp 4:3 400x300 d. Adjacent streams should be between 1.5 and twice times the relationship adjacent streams too close, wasted bands Width, effect is not obvious The adjacent code stream too far, should not be suitable for the client, and jump too big & nbsp e. KeyFrames (IDR frames) Each video clip has at least one keyframe, much better. If there is only one keyframe in the video clip, it must be placed at the beginning. f. Do not lower the stream in the main playlist, The maximum stream peak of the video should be placed in the playlist instead of the average, otherwise the delay (bitstream and bandwidth mismatch) will occur.
6. Special Considerations for mobile networksIf you are developing an iOS app, you must be aware of the following requirements or the app will be rejected. A. Providing a 192kbps stream or lower bandwidth audio stream, where you can add pictures, you must note that 192kbps is the peak, not the average, which includes video and audio B. You cannot use video clips in your app Note: iOS submitted for review, you need to provide a 192kbps URL to the tester, otherwise whether you can pass it is not good to say
7. Encoding Format video format: H. Baseline Profile Level 3.0 (Iphone/ipod Touch), & nbsp Main profile level 3.1 (i PAD), and nbsp High Profiles Level 4.1 (new IPad), &NBSP ; MPEG-4 Simple profile (iphone/ipod touch/ipad), motion JPE G (m-jpeg) (IPod Touch 4th Gen, IPhone 4, IPad) audio format: HE-AAC or AAC-LC max 48 khz, stereo mp3 8 khz To-KHz, Stereo code format: MPEG-2 TS &N Bsp Note: iOS devices do not support interlaced video
8. Recommended code Stream ConfigurationDuration: 10 seconds Video Coding recommendation table:
How to choose HLS Video stream