Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

录制增加OPUS音频后,WriteTrailer报错 #139

Open
klk2x opened this issue Jun 19, 2024 · 1 comment
Open

录制增加OPUS音频后,WriteTrailer报错 #139

klk2x opened this issue Jun 19, 2024 · 1 comment

Comments

@klk2x
Copy link

klk2x commented Jun 19, 2024

我使用go-mp4模块,实现rtsp流的录制,单H264是正常录制的
增加同时录制opus音频后,WriteTrailer报错

这是我少写了什么吗,还是写入的数据不对?

这是报错日志:

2024/06/19 12:19:45 INF [RecordHandler] startRecord : path=live /Users/lele/WebstormProjects/2023/recordings/20240619/live/12-19-45-832900.mp4
2024/06/19 12:19:50 INF [RecordHandler] Recording Stop completeChan path=live
2024/06/19 12:19:50 INF [RecordHandler] stopRecord path=live %!s(bool=true)
2024/06/19 12:19:50 WAR [RecordHandler] write Stop
panic: runtime error: slice bounds out of range [:8] with capacity 0

goroutine 208 [running]:
github.com/yapingcat/gomedia/go-codec.(*OpusContext).ParseExtranData(0x394170?, {0x0?, 0xc000d355e0?, 0x10e01653b?})
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-codec/opus.go:352 +0x59c
github.com/yapingcat/gomedia/go-mp4.makeOpusSpecificBox({0x0?, 0x10f9b8d80?, 0x10f9738c0?})
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/dops-box.go:108 +0x51
github.com/yapingcat/gomedia/go-mp4.makeStsd(0xc0005a6a00, {0x73, 0x6f, 0x75, 0x6e})
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/stsd-box.go:334 +0xeb
github.com/yapingcat/gomedia/go-mp4.makeStblBox(0xc0005a6a00)
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/stbl-box.go:11 +0x68
github.com/yapingcat/gomedia/go-mp4.makeMinfBox(0xc0005a6a00)
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/minf-box.go:15 +0x75
github.com/yapingcat/gomedia/go-mp4.makeMdiaBox(0xc0005a6a00)
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/mdia-box.go:6 +0xa5
github.com/yapingcat/gomedia/go-mp4.makeTrak(0xc0005a6a00, 0xdd290?)
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/trak-box.go:16 +0x20a
github.com/yapingcat/gomedia/go-mp4.(*Movmuxer).writeMoov(0xc0008c79c0, {0x10f14d0e8, 0xc000573740})
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/mp4muxer.go:299 +0x1dc
github.com/yapingcat/gomedia/go-mp4.(*Movmuxer).WriteTrailer(0xc0008c79c0)
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/mp4muxer.go:224 +0x189
github.com/bluenviron/mediamtx/internal/core.(*mp4Muxer).WriteTrailer(0xc000ad0220?)

这是我增加的opus实现:

rtpDec, err := forma.CreateDecoder()
for _, pkt := range u.GetRTPPackets() {
      opkt, err := rtpDec.Decode(pkt)
      if err != nil {
	      continue
      }
      err = meidiaMuxer.Write(atid, opkt, uint64(int64(pts/time.Millisecond)), uint64(int64(pts/time.Millisecond)))
}
@ZSC714725
Copy link
Contributor

我使用go-mp4模块,实现rtsp流的录制,单H264是正常录制的 增加同时录制opus音频后,WriteTrailer报错

这是我少写了什么吗,还是写入的数据不对?

这是报错日志:

2024/06/19 12:19:45 INF [RecordHandler] startRecord : path=live /Users/lele/WebstormProjects/2023/recordings/20240619/live/12-19-45-832900.mp4
2024/06/19 12:19:50 INF [RecordHandler] Recording Stop completeChan path=live
2024/06/19 12:19:50 INF [RecordHandler] stopRecord path=live %!s(bool=true)
2024/06/19 12:19:50 WAR [RecordHandler] write Stop
panic: runtime error: slice bounds out of range [:8] with capacity 0

goroutine 208 [running]:
github.com/yapingcat/gomedia/go-codec.(*OpusContext).ParseExtranData(0x394170?, {0x0?, 0xc000d355e0?, 0x10e01653b?})
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-codec/opus.go:352 +0x59c
github.com/yapingcat/gomedia/go-mp4.makeOpusSpecificBox({0x0?, 0x10f9b8d80?, 0x10f9738c0?})
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/dops-box.go:108 +0x51
github.com/yapingcat/gomedia/go-mp4.makeStsd(0xc0005a6a00, {0x73, 0x6f, 0x75, 0x6e})
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/stsd-box.go:334 +0xeb
github.com/yapingcat/gomedia/go-mp4.makeStblBox(0xc0005a6a00)
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/stbl-box.go:11 +0x68
github.com/yapingcat/gomedia/go-mp4.makeMinfBox(0xc0005a6a00)
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/minf-box.go:15 +0x75
github.com/yapingcat/gomedia/go-mp4.makeMdiaBox(0xc0005a6a00)
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/mdia-box.go:6 +0xa5
github.com/yapingcat/gomedia/go-mp4.makeTrak(0xc0005a6a00, 0xdd290?)
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/trak-box.go:16 +0x20a
github.com/yapingcat/gomedia/go-mp4.(*Movmuxer).writeMoov(0xc0008c79c0, {0x10f14d0e8, 0xc000573740})
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/mp4muxer.go:299 +0x1dc
github.com/yapingcat/gomedia/go-mp4.(*Movmuxer).WriteTrailer(0xc0008c79c0)
	/Users/lele/go/pkg/mod/github.com/yapingcat/gomedia@v0.0.0-20240601043430-920523f8e5c7/go-mp4/mp4muxer.go:224 +0x189
github.com/bluenviron/mediamtx/internal/core.(*mp4Muxer).WriteTrailer(0xc000ad0220?)

这是我增加的opus实现:

rtpDec, err := forma.CreateDecoder()
for _, pkt := range u.GetRTPPackets() {
      opkt, err := rtpDec.Decode(pkt)
      if err != nil {
	      continue
      }
      err = meidiaMuxer.Write(atid, opkt, uint64(int64(pts/time.Millisecond)), uint64(int64(pts/time.Millisecond)))
}

你缺少extra data,就是类似于asc的东西

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants