go - 无法获取媒体统计信息VLC

标签 go vlc libvlc

我正在使用VLC的libvlc-dev库来获取视频的媒体统计信息,但无法获取有关该视频的信息。我正在使用Go的cgo功能与VLC(3.0.8)交互,出现以下错误-

fatal error: unexpected signal during runtime execution
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0x7fa0e03ad78f]

runtime stack:
runtime.throw(0x4ece85, 0x2a)
    /usr/local/go/src/runtime/panic.go:774 +0x72
runtime.sigpanic()
    /usr/local/go/src/runtime/signal_unix.go:378 +0x47c

goroutine 1 [syscall]:
runtime.cgocall(0x4ab660, 0xc000047e40, 0x45eeac)
...

我的vlc.go文件看起来像这样-

//#cgo LDFLAGS: -lvlc
//#include <vlc/vlc.h>
//#include <stdlib.h>
import "C"
import (
    "errors"
    "fmt"
    "os"
    "unsafe"
)

type Vlc struct {
    instance *C.libvlc_instance_t
    player   *C.libvlc_media_player_t
    media    *C.libvlc_media_t
}

type libvlc_media_stats_t struct {
    iReadBytes    int
    fInputBitrate float64
    iDemuxReadBytes     int
    fDemuxBitrate       float64
    iDemuxCorrupted     int
    iDemuxDiscontinuity int
    iDecodedVideo int
    iDecodedAudio int
    iDisplayedPictures int
    iLostPictures      int
    iPlayedAbuffers int
    iLostAbuffers   int
}

...

// Media stats.
func (vlc *Vlc) Stats() error {
    // fmt.Println("vlc")
    var stats *C.libvlc_media_stats_t
    err := C.libvlc_media_get_stats(vlc.media, stats)
    fmt.Println(err)
    return vlc.getLastErr()
}

如何获得媒体统计信息?

最佳答案

go-vlc具有相似的代码

func (this *Media) Stats() (*Stats, error) {
    if this.ptr == nil {
        return nil, os.EINVAL
    }

    var c C.libvlc_media_stats_t

    if C.libvlc_media_get_stats(this.ptr, &c) != 0 {
        return nil, checkError()
    }

    return &Stats{&c}, nil
}

stats.go的定义在这里https://github.com/egelmex/go-vlc/blob/master/stats.go

关于go - 无法获取媒体统计信息VLC,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60277877/

相关文章:

go - 从不同目录的多个文件创建插件

go - 如何从云功能中安排一些事情

kotlin - vlcj - 如何在播放前更改音频音量?

qt-creator - 对 libvlc 的 undefined reference

git - 无法从 git.videolan.org 运行 git clone

electron - WebChimera和wcjs没有在Ubuntu 16.04上预构建的视频输出

go - [golang]是否可以不用证书写TLS服务器?

json - 无法从帖子请求中解析 JSON

java - 在 vlcj 中播放实时 http 流

opencv - 如何将网络摄像头录制到 X11 之外的文件中?