HLS

hankyulee·2022년 12월 25일
0

이글을 먼저 읽고 시작하세요: https://www.wowza.com/blog/converting-rtmp-to-hls#rtmp

Apple provides several frameworks that support HTTP Live Streaming, including AVKit, AVFoundation, and WebKit.

media 파일들을 포함한 index file이 web server에 개시되고 이를 Client가 요청한다. (URL을 통해서)
No custom server modules are required to deliver the content, and typically very little configuration is needed on the web server. To actually deploy HTTP Live Streaming, you need to create either an HTML page for browsers or a client app to act as a receiver. You also need the use of a web server and a way to encode live streams as fragmented MPEG-4 media files containing HEVC or H.264 video, and AAC or AC-3 audio.

  • distribution파트에서는 You also need the use of a web server and a way to encode live streams as fragmented MPEG-4 media files containing HEVC or H.264 video, and AAC or AC-3 audio.

  • a way to break the encoded media into segments and save them as files = 인코드된 미디어를 segments로 쪼갠다.

    -> IOS가 관심 있는 부분은 Distribution 파트에서 segmented files들을 관리하는 index 파일들(m3u8)을 요청하는 부분.

    master playlist: hsl에서 index 파일
    각각에서 잘려진 비디오를 관리하는 파일리스트: 미디어 플레이리스트
    우리는 마스터플레이리스트에 요청.
    -> 요청시 반응이 온다. 태그같은 것과.
    그 다음 미디어 플레이리스트에 대해 요청한다.
    -> 역시 요청시 반응 온다. 위와 조금 다른 모양.

    • VOD Type, Event type. 이벤트 타입은 라이브 스트리밍.
  • The index file, in turn, specifies the location of the available media files, decryption keys, and any alternate streams available

네트워크 상황 안좋아지면, 저화질의 미디어플레이리스트 다운 받는다.

라이브스트리밍의 지속: This process continues until the client encounters the EXT-X-ENDLIST tag in the index file. If no EXT-X-ENDLIST tag is present, the index file is part of an ongoing broadcast. During ongoing broadcasts, the client loads a new version of the index file periodically. The client looks for new media files and encryption keys in the updated index and adds these URLs to its queue.

https://developer.apple.com/documentation/http_live_streaming/understanding_the_http_live_streaming_architecture

The mediastreamvalidator tool is a command-line utility for validating HLS streams and servers. See Using Apple's HTTP Live Streaming (HLS) Tools for details on obtaining the tool.

이것은 무엇인가. Fairplay. streaming: https://developer.apple.com/streaming/fps/

The current recommendation for encrypting media while minimizing overhead is to change the key every 3 to 4 hours and change the initialization vector after every 50 Mb of data.

Even with restricted access to keys, it’s possible for an eavesdropper to obtain copies of the key files if they’re sent over HTTP. One solution to this problem is to send the keys securely over HTTPS.

AVFoundation: play HLS streams, and build powerful media functionality into your apps.

애플 Developer: https://developer.apple.com/videos/all-videos/?q=live%20streaming

공부:
1. HLS(이준원) https://www.youtube.com/watch?v=Z3eRwICG4OU - 19분 부터 성능 측정 보기
3. 래이웬더리치(원하던 것 아님)
4. 애플디벨로퍼 영상(wwdc에 좋은것잇음)

URI 변경시(인터넷 상태가 안좋아질때 저화질 다운으로 바뀔때) 새로운 accessLogEvent 인스턴스 생성
중요: AVPlayerItemAccessLog 성능측정시, 매우중요

HaishinKit

Apple does not allow video recording in the background, which means that the library cannot send video fragments to the server. On the server side, it causes crashes and stream interruptions.

To fix this, we decided to add more functionality to the library for sending a static image in the background. Our version of the library can be taken from our project on GitHub.
출처:https://gcore.com/blog/how-to-create-a-mobile-streaming-app-on-ios/

HLS 받기

HaishinKit은 HLS를 받는 부분은 포함하지 않는다:
(https://github.com/shogo4405/HaishinKit.swift/issues/351 에서 작자가 말하고있다.) -> HaishinKit에서 HLS부분은 송신하는 부분이었다. 그리고 아래와 같이 주소를 입력하는 부분에 IP주소는 local이 아닌 terminal 에서 ifconfig | grep inet 시 출력 되는 부분을 넣어야한다. 그러면 아래와 같이 web에서 확인 할 수 있다.


위에서 HLS로 비디오를 송신하고 HLS를 get하는 앱을 통해서 아래와 같이 확인 할 수 있다. 그 앱의 github는 아래에 있다.(chrome 말고 safari 사용하자)


wowza를 이용한 HLS get

wowza에서 webRTC를 선택해서 웹방송을 한 뒤, 아래 사이트를 통해서 HLS를 get할 수 있다.

https://github.com/yunihuang1112/HLS_demo
HLS Test 사이트: https://www.theoplayer.com/test-your-stream-hls-dash-hesp

RTMP

Just to hammer this home, if all you have is an RTMP URL and you want to find a player online so you can watch it, it’s not going to happen anymore. Blame Adobe. it no longer makes sense on the publishing end of a workflow.
출처: https://www.wowza.com/blog/test-players-rtmp-hls-rtsp-dash

RTMP to HLS with either Wowza Streaming Engine
출처: https://www.wowza.com/blog/converting-rtmp-to-hls

Because RTMP sits on top of the Transmission Control Protocol (TCP)...
For this reason, RTMP is quite reliable.

우리가 필요한 서버

Live Streaming Server Solution 필요하다.
A media server is an absolute necessity.

참고:
https://www.createwithswift.com/hls-for-live-and-on-demand-audio-and-video/

0개의 댓글