zhangpeihao / gortmp

Implement RTMP protocol by golang
MIT License
523 stars 162 forks source link

Publish rtmp stream fails [rtmp to rtmp] #38

Open pavan4 opened 7 years ago

pavan4 commented 7 years ago

I am using rtmp_player to read a rtmp stream and publish it to another RTMP server using rtmp_publish

What to pass as argument to stream.PublishData(tagHeader.TagType, data, deltaTimestamp) ?

I receive the rtmp stream with Message struct from OnReceived(rconn rtmp.Conn, message *rtmp.Message)

type Message struct {
    ChunkStreamID     uint32
    Timestamp         uint32
    Size              uint32
    Type              uint8
    StreamID          uint32
    Buf               *bytes.Buffer
    IsInbound         bool
    AbsoluteTimestamp uint32
}

When I publish directly with stream.PublishData(msg.Type,msg.Buf.Bytes(),msg.Timestamp)

The rtmp stream is automatically closed just after the stream is accepted.

Simple steps to reproduce this : (I am doing it live by establishing a tcp socket and forwarding the packets, the same behavior is exhibited when I save to file and use the file to publish)

./player -URL rtmp://188.138.17.8:1935/albuk -Stream albuk.stream -DumpFLV ./demo.flv

./publish -URL rtmp://myserver:1935/<path>/ -Stream <name> -FLV ./demo.flv I get the following output

to dial
a
b
to connect
c
@@@@@@@@@@@@@status: 3, err: <nil>
ReceviedRtmpCommand: &{IsFlex:false Name:_result TransactionID:1 Objects:[map[fmsVer:FMS/3,0,1,123 capabilities:31] map[code:NetConnection.Connect.Success description:Connection succeeded. objectEncoding:0 level:status]]}
@@@@@@@@@@@@@status: 5, err: <nil>
Stream created: 1
ReceviedRtmpCommand: &{IsFlex:false Name:_result TransactionID:2 Objects:[<nil> 1]}
1
2
3
3333@@@@@@@@@@@@@@diff1 header(&{TagType:18 DataSize:40 Timestamp:0}), startTs: 0
18 40 0 0
3333@@@@@@@@@@@@@@diff1 header(&{TagType:9 DataSize:44 Timestamp:0}), startTs: 0
9 44 0 0
3333@@@@@@@@@@@@@@diff1 header(&{TagType:9 DataSize:2 Timestamp:0}), startTs: 0
9 2 0 0
3333@@@@@@@@@@@@@@diff1 header(&{TagType:9 DataSize:23332 Timestamp:0}), startTs: 0
9 23332 0 0
3333@@@@@@@@@@@@@@diff1 header(&{TagType:9 DataSize:55 Timestamp:0}), startTs: 0
9 55 0 0
3333@@@@@@@@@@@@@@diff1 header(&{TagType:9 DataSize:5658 Timestamp:0}), startTs: 0
9 5658 0 0
3333@@@@@@@@@@@@@@diff1 header(&{TagType:9 DataSize:120 Timestamp:0}), startTs: 0
9 120 0 0
3333@@@@@@@@@@@@@@diff1 header(&{TagType:9 DataSize:5334 Timestamp:0}), startTs: 0
9 5334 0 0
.
.
.
9 47 200 204
8 554 209 213
9 7857 220 224
8 555 231 235
@@@@@@@@@@@@@status: 0, err: <nil>
@@@@@@@@@@@@@Closed
Audio size: 6494 bytes; Vedio size: 380281 bytes
Audio size: 6494 bytes; Vedio size: 380281 bytes

There is no video stream running.