最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to extract stream key from incoming RTMP stream after handshake? - Stack Overflow

programmeradmin5浏览0评论

I am currently trying to get the stream key from an incoming stream but strangely enough if I turn the entire incoming bytes into a string it does not show the stream key anywhere.

For example, when implementing in Go all I get is this info:

nonprivatflashVer☻▼FMLE/3.0 (compatible; FMSc/1.0)♠swfUrl☻↨rtmp://127.0.0.1/stream♣tcUrl☻↨rtmp://127.0.0.1/stream

Which I can interpret using the RTMP spec based on message size and type, but where is the stream key? For example, my local stream key to test with is:

d319637b-ac26-4fbf-b90d-4d2ea4c4d21f

I was assuming streaming clients would all have the stream key decodable in a similar matter? Where should I look in RTMP spec?

// Read RTMP "connect" message and extract stream key
func ReadRTMPStreamKey(conn net.Conn) (string, error) {
    buffer := make([]byte, 4096)
    n, err := conn.Read(buffer)
    if err != nil {
        return "", err
    }

    // Ensure we only parse the bytes read
    data := buffer[:n]

    // Debug: Print the raw packet data
    fmt.Printf("Raw RTMP Packet: %v\n", data)

    stringifiedData := string(data)

    fmt.Printf("Stringified Data %v", stringifiedData)


    return "asda", nil
}
发布评论

评论列表(0)

  1. 暂无评论