nareix / joy4

Golang audio/video library and streaming server
MIT License
2.68k stars 500 forks source link

Invalid memory address or nil pointer dereference in Transcoding example code #133

Open MoCuishle28 opened 1 year ago

MoCuishle28 commented 1 year ago

joy4 version: v0.0.0-20200507095837-05a4ffbb5369 ffmpeg version: N-109585-g379e43e6ec OS: Ubuntu 20.04

When I run Transcoding example code joy4/examples/transcode/main.go, I meet this panic:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x8 pc=0x53c700]

goroutine 1 [running]:
github.com/nareix/joy4/cgo/ffmpeg.(*AudioEncoder).SetSampleRate(0x585d3d?, 0xa?)
        /root/.gvm/pkgsets/go1.19/global/pkg/mod/github.com/nareix/joy4@v0.0.0-20200507095837-05a4ffbb5369/cgo/ffmpeg/audio.go:227
main.main.func1({0x5bb148, 0xc00002c0c0}, 0x2?)
        /root/codes/video/joy4-demo/transcode/main.go:24 +0x68
github.com/nareix/joy4/av/transcode.NewTranscoder({0xc00006c060, 0x2, 0x19?}, {0xc?})
        /root/.gvm/pkgsets/go1.19/global/pkg/mod/github.com/nareix/joy4@v0.0.0-20200507095837-05a4ffbb5369/av/transcode/transcode.go:44 +0x199
github.com/nareix/joy4/av/transcode.(*Demuxer).prepare(0xc00002c080)
        /root/.gvm/pkgsets/go1.19/global/pkg/mod/github.com/nareix/joy4@v0.0.0-20200507095837-05a4ffbb5369/av/transcode/transcode.go:207 +0x4d
github.com/nareix/joy4/av/transcode.(*Demuxer).Streams(0xc00002c080)
        /root/.gvm/pkgsets/go1.19/global/pkg/mod/github.com/nareix/joy4@v0.0.0-20200507095837-05a4ffbb5369/av/transcode/transcode.go:236 +0x25
github.com/nareix/joy4/av/avutil.CopyFile({0x7febbe0fe880?, 0xc00007e630}, {0x5ba998, 0xc00002c080})
        /root/.gvm/pkgsets/go1.19/global/pkg/mod/github.com/nareix/joy4@v0.0.0-20200507095837-05a4ffbb5369/av/avutil/avutil.go:296 +0x3a
main.main()
        /root/codes/video/joy4-demo/transcode/main.go:39 +0x112
exit status 2