diff --git a/format.go b/format.go index 8e52b0d..c2d1c2f 100644 --- a/format.go +++ b/format.go @@ -49,6 +49,7 @@ import "C" import ( "errors" "fmt" + "io" "os" "syscall" "time" @@ -358,6 +359,9 @@ func (this *FmtCtx) GetNextPacket() (*Packet, error) { time.Sleep(10000 * time.Microsecond) continue } + if ret == AVERROR_EOF { + return nil, io.EOF + } if ret < 0 { return nil, AvError(ret) } @@ -420,7 +424,7 @@ func (this *FmtCtx) StreamsCnt() int { } func (this *FmtCtx) GetStream(idx int) (*Stream, error) { - if idx > this.StreamsCnt() || this.StreamsCnt() == 0 { + if idx > this.StreamsCnt()-1 || this.StreamsCnt() == 0 { return nil, errors.New(fmt.Sprintf("Stream index '%d' is out of range. There is only '%d' streams.", idx, this.StreamsCnt())) } @@ -566,6 +570,10 @@ func (this *FmtCtx) SetProbeSize(v int64) { this.avCtx.probesize = C.int64_t(v) } +func (this *FmtCtx) GetProbeSize() int64 { + return int64(this.avCtx.probesize) +} + type OutputFmt struct { Filename string avOutputFmt *C.struct_AVOutputFormat diff --git a/stream.go b/stream.go index 3a9d0ee..0040a3c 100644 --- a/stream.go +++ b/stream.go @@ -14,12 +14,15 @@ import ( ) type Stream struct { - avStream *C.struct_AVStream - cc *CodecCtx - SwsCtx *SwsCtx - SwrCtx *SwrCtx - AvFifo *AVAudioFifo - DstFrame *Frame + avStream *C.struct_AVStream + cc *CodecCtx + SwsCtx *SwsCtx + SwrCtx *SwrCtx + AvFifo *AVAudioFifo + DstFrame *Frame + Pts int64 + Resampler func(*Stream, []*Frame, bool) []*Frame + Rescaler func(*Stream, []*Frame) []*Frame CgoMemoryManage }