yapingcat / gomedia

golang library for rtmp, mpeg-ts,mpeg-ps,flv,mp4,ogg,rtsp
MIT License
386 stars 67 forks source link

Panic on writing frame in rtmp push client when video was encoded HVENC encoder #150

Closed kbats183 closed 1 week ago

kbats183 commented 2 weeks ago

I am getting panic when I publishing flv video to rtmp server using example example_rtmp_publish_client.

panic: OUT OF RANGE

goroutine 34 [running]:
github.com/yapingcat/gomedia/go-codec.(*BitStream).GetBit(...)
    .../github.com/yapingcat/gomedia@v0.0.0-20240725163034-902e6befb413/go-codec/bitstream.go:90
github.com/yapingcat/gomedia/go-codec.(*BitStream).ReadUE(0x18?)
    .../github.com/yapingcat/gomedia@v0.0.0-20240725163034-902e6befb413/go-codec/bitstream.go:152 +0xe5
github.com/yapingcat/gomedia/go-codec.(*H264HrdParameters).Decode(0xc0000459e8, 0xc000045a58)
    .../github.com/yapingcat/gomedia@v0.0.0-20240725163034-902e6befb413/go-codec/h264.go:569 +0xda
github.com/yapingcat/gomedia/go-codec.(*H264VuiParameters).Decode(0xc000045980, 0xc000045a58)
    .../github.com/yapingcat/gomedia@v0.0.0-20240725163034-902e6befb413/go-codec/h264.go:537 +0x265
github.com/yapingcat/gomedia/go-codec.(*SPS).Decode(0xc0000458b0, 0xc000045a58)
    .../github.com/yapingcat/gomedia@v0.0.0-20240725163034-902e6befb413/go-codec/h264.go:143 +0x85d
github.com/yapingcat/gomedia/go-codec.CreateH264AVCCExtradata({0xc000008078, 0x1, 0xc000045b50?}, {0xc000008090, 0x1, 0x27bbc4dc688?})
    .../github.com/yapingcat/gomedia@v0.0.0-20240725163034-902e6befb413/go-codec/h264.go:358 +0x696
github.com/yapingcat/gomedia/go-flv.(*AVCMuxer).Write(0xc000020120, {0xc00022a000?, 0x794945?, 0x27bbc4d0108?}, 0x43, 0x0)
    .../github.com/yapingcat/gomedia@v0.0.0-20240725163034-902e6befb413/go-flv/flv-muxer.go:137 +0x445
github.com/yapingcat/gomedia/go-rtmp.(*RtmpClient).WriteVideo(0xc00011e000, 0x24000?, {0xc00022a000, 0x2228e, 0x24000}, 0x43, 0x0)
    .../github.com/yapingcat/gomedia@v0.0.0-20240725163034-902e6befb413/go-rtmp/client.go:233 +0x2f2
main.publish.func1(0x32?, {0xc00022a000?, 0x2228e?, 0xc000020090?}, 0x22a000?, 0xc0?)
    .../example_rtmp_publish_client.go:24 +0x90
github.com/yapingcat/gomedia/go-flv.(*FlvReader).createVideoTagDemuxer.func1(0xc00007a000?, {0xc00022a000?, 0xc000045df8?, 0x0?}, 0x204?)
    .../github.com/yapingcat/gomedia@v0.0.0-20240725163034-902e6befb413/go-flv/flv-file.go:213 +0x31
github.com/yapingcat/gomedia/go-flv.(*AVCTagDemuxer).Decode(0xc000008018, {0xc000200000, 0x22261, 0x2a000})
    .../github.com/yapingcat/gomedia@v0.0.0-20240725163034-902e6befb413/go-flv/flv-demuxer.go:92 +0x86e
github.com/yapingcat/gomedia/go-flv.(*FlvReader).Input(0xc00005c0c0, {0xc000062000?, 0x1000?, 0x0?})
    .../github.com/yapingcat/gomedia@v0.0.0-20240725163034-902e6befb413/go-flv/flv-file.go:153 +0x346
main.publish({0x87b608, 0x13}, 0xc00011e000)
    .../example_rtmp_publish_client.go:42 +0x1ab
main.main.func3()
    .../example_rtmp_publish_client.go:84 +0x75
created by main.main in goroutine 1
    .../example_rtmp_publish_client.go:81 +0x291

This video was recorded in OBS with Video encoder Hardware (HVENC, H.264). Sample of file: test_hvenc_h264.zip.

If I use software encoder, all works fine, but hardware encoder based on Nvida GeForce causes an error. Can you help me?

kbats183 commented 2 weeks ago

Some updates. I found that there is no problem before merge #136

yapingcat commented 2 weeks ago

retry this case with the latest version?

yapingcat commented 1 week ago

I test this case with the latest version and it works fine f997303

kbats183 commented 1 week ago

Yes, it works. Thank you!