mirror of
https://github.com/giorgisio/goav.git
synced 2024-04-21 12:31:56 +00:00
Working tutorial; More hooks to libav API; removes debbuging print
Missing constants, additional functions, remove errors
This commit is contained in:
+24
-10
@@ -20,6 +20,9 @@ package avformat
|
||||
import "C"
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/giorgisio/goav/avcodec"
|
||||
"github.com/giorgisio/goav/avutil"
|
||||
)
|
||||
|
||||
type (
|
||||
@@ -35,10 +38,8 @@ type (
|
||||
AvProgram C.struct_AVProgram
|
||||
AvChapter C.struct_AVChapter
|
||||
AvPacketList C.struct_AVPacketList
|
||||
Packet C.struct_AVPacket
|
||||
CodecParserContext C.struct_AVCodecParserContext
|
||||
AvIOContext C.struct_AVIOContext
|
||||
Rational C.struct_AVRational
|
||||
AvCodec C.struct_AVCodec
|
||||
AvCodecTag C.struct_AVCodecTag
|
||||
Class C.struct_AVClass
|
||||
@@ -57,13 +58,17 @@ type (
|
||||
type File C.FILE
|
||||
|
||||
//Allocate and read the payload of a packet and initialize its fields with default values.
|
||||
func (ctxt *AvIOContext) AvGetPacket(pkt *Packet, s int) int {
|
||||
return int(C.av_get_packet((*C.struct_AVIOContext)(ctxt), (*C.struct_AVPacket)(pkt), C.int(s)))
|
||||
func (ctxt *AvIOContext) AvGetPacket(pkt *avcodec.Packet, s int) int {
|
||||
return int(C.av_get_packet((*C.struct_AVIOContext)(ctxt), toCPacket(pkt), C.int(s)))
|
||||
}
|
||||
|
||||
//Read data and append it to the current content of the Packet.
|
||||
func (ctxt *AvIOContext) AvAppendPacket(pkt *Packet, s int) int {
|
||||
return int(C.av_append_packet((*C.struct_AVIOContext)(ctxt), (*C.struct_AVPacket)(pkt), C.int(s)))
|
||||
func (ctxt *AvIOContext) AvAppendPacket(pkt *avcodec.Packet, s int) int {
|
||||
return int(C.av_append_packet((*C.struct_AVIOContext)(ctxt), toCPacket(pkt), C.int(s)))
|
||||
}
|
||||
|
||||
func (ctxt *AvIOContext) Close() error {
|
||||
return avutil.ErrorFromCode(int(C.avio_close((*C.AVIOContext)(unsafe.Pointer(ctxt)))))
|
||||
}
|
||||
|
||||
func (f *InputFormat) AvRegisterInputFormat() {
|
||||
@@ -190,13 +195,13 @@ func AvHexDumpLog(a, l int, b *uint8, s int) {
|
||||
}
|
||||
|
||||
//Send a nice dump of a packet to the specified file stream.
|
||||
func AvPktDump2(f *File, pkt *Packet, dp int, st *Stream) {
|
||||
C.av_pkt_dump2((*C.FILE)(f), (*C.struct_AVPacket)(pkt), C.int(dp), (*C.struct_AVStream)(st))
|
||||
func AvPktDump2(f *File, pkt *avcodec.Packet, dp int, st *Stream) {
|
||||
C.av_pkt_dump2((*C.FILE)(f), toCPacket(pkt), C.int(dp), (*C.struct_AVStream)(st))
|
||||
}
|
||||
|
||||
//Send a nice dump of a packet to the log.
|
||||
func AvPktDumpLog2(a int, l int, pkt *Packet, dp int, st *Stream) {
|
||||
C.av_pkt_dump_log2(unsafe.Pointer(&a), C.int(l), (*C.struct_AVPacket)(pkt), C.int(dp), (*C.struct_AVStream)(st))
|
||||
func AvPktDumpLog2(a int, l int, pkt *avcodec.Packet, dp int, st *Stream) {
|
||||
C.av_pkt_dump_log2(unsafe.Pointer(&a), C.int(l), toCPacket(pkt), C.int(dp), (*C.struct_AVStream)(st))
|
||||
}
|
||||
|
||||
//enum CodecId av_codec_get_id (const struct AvCodecTag *const *tags, unsigned int tag)
|
||||
@@ -273,3 +278,12 @@ func AvformatGetMovVideoTags() *AvCodecTag {
|
||||
func AvformatGetMovAudioTags() *AvCodecTag {
|
||||
return (*AvCodecTag)(C.avformat_get_mov_audio_tags())
|
||||
}
|
||||
|
||||
func AvIOOpen(url string, flags int) (res *AvIOContext, err error) {
|
||||
urlStr := C.CString(url)
|
||||
defer C.free(unsafe.Pointer(urlStr))
|
||||
|
||||
err = avutil.ErrorFromCode(int(C.avio_open((**C.AVIOContext)(unsafe.Pointer(&res)), urlStr, C.int(flags))))
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
@@ -0,0 +1,150 @@
|
||||
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
|
||||
// Giorgis (habtom@giorgis.io)
|
||||
|
||||
//Package avformat provides some generic global options, which can be set on all the muxers and demuxers.
|
||||
//In addition each muxer or demuxer may support so-called private options, which are specific for that component.
|
||||
//Supported formats (muxers and demuxers) provided by the libavformat library
|
||||
package avformat
|
||||
|
||||
//#cgo pkg-config: libavformat libavcodec libavutil libavdevice libavfilter libswresample libswscale
|
||||
//#include <stdio.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <inttypes.h>
|
||||
//#include <stdint.h>
|
||||
//#include <string.h>
|
||||
//#include <libavformat/avformat.h>
|
||||
//#include <libavcodec/avcodec.h>
|
||||
import "C"
|
||||
import (
|
||||
"reflect"
|
||||
"unsafe"
|
||||
|
||||
"github.com/giorgisio/goav/avcodec"
|
||||
)
|
||||
|
||||
func (cctxt *CodecContext) Type() MediaType {
|
||||
return MediaType(cctxt.codec_type)
|
||||
}
|
||||
|
||||
func (cctxt *CodecContext) SetBitRate(br int64) {
|
||||
cctxt.bit_rate = C.int64_t(br)
|
||||
}
|
||||
|
||||
func (cctxt *CodecContext) GetCodecId() CodecId {
|
||||
return CodecId(cctxt.codec_id)
|
||||
}
|
||||
|
||||
func (cctxt *CodecContext) SetCodecId(codecId CodecId) {
|
||||
cctxt.codec_id = C.enum_AVCodecID(codecId)
|
||||
}
|
||||
|
||||
func (cctxt *CodecContext) GetCodecType() MediaType {
|
||||
return MediaType(cctxt.codec_type)
|
||||
}
|
||||
|
||||
func (cctxt *CodecContext) SetCodecType(ctype MediaType) {
|
||||
cctxt.codec_type = C.enum_AVMediaType(ctype)
|
||||
}
|
||||
|
||||
func (cctxt *CodecContext) GetTimeBase() avcodec.Rational {
|
||||
return newRational(cctxt.time_base)
|
||||
}
|
||||
|
||||
func (cctxt *CodecContext) SetTimeBase(timeBase avcodec.Rational) {
|
||||
cctxt.time_base.num = C.int(timeBase.Num())
|
||||
cctxt.time_base.den = C.int(timeBase.Den())
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) GetWidth() int {
|
||||
return int(cctx.width)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) SetWidth(w int) {
|
||||
cctx.width = C.int(w)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) GetHeight() int {
|
||||
return int(cctx.height)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) SetHeight(h int) {
|
||||
cctx.height = C.int(h)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) GetPixelFormat() avcodec.PixelFormat {
|
||||
return avcodec.PixelFormat(C.int(cctx.pix_fmt))
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) SetPixelFormat(fmt avcodec.PixelFormat) {
|
||||
cctx.pix_fmt = C.enum_AVPixelFormat(C.int(fmt))
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) GetFlags() int {
|
||||
return int(cctx.flags)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) SetFlags(flags int) {
|
||||
cctx.flags = C.int(flags)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) GetMeRange() int {
|
||||
return int(cctx.me_range)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) SetMeRange(r int) {
|
||||
cctx.me_range = C.int(r)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) GetMaxQDiff() int {
|
||||
return int(cctx.max_qdiff)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) SetMaxQDiff(v int) {
|
||||
cctx.max_qdiff = C.int(v)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) GetQMin() int {
|
||||
return int(cctx.qmin)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) SetQMin(v int) {
|
||||
cctx.qmin = C.int(v)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) GetQMax() int {
|
||||
return int(cctx.qmax)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) SetQMax(v int) {
|
||||
cctx.qmax = C.int(v)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) GetQCompress() float32 {
|
||||
return float32(cctx.qcompress)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) SetQCompress(v float32) {
|
||||
cctx.qcompress = C.float(v)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) GetExtraData() []byte {
|
||||
header := reflect.SliceHeader{
|
||||
Data: uintptr(unsafe.Pointer(cctx.extradata)),
|
||||
Len: int(cctx.extradata_size),
|
||||
Cap: int(cctx.extradata_size),
|
||||
}
|
||||
|
||||
return *((*[]byte)(unsafe.Pointer(&header)))
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) SetExtraData(data []byte) {
|
||||
header := (*reflect.SliceHeader)(unsafe.Pointer(&data))
|
||||
|
||||
cctx.extradata = (*C.uint8_t)(unsafe.Pointer(header.Data))
|
||||
cctx.extradata_size = C.int(header.Len)
|
||||
}
|
||||
|
||||
func (cctx *CodecContext) Release() {
|
||||
C.avcodec_close((*C.struct_AVCodecContext)(unsafe.Pointer(cctx)))
|
||||
C.av_freep(unsafe.Pointer(cctx))
|
||||
}
|
||||
+14
-15
@@ -10,8 +10,7 @@ import (
|
||||
"time"
|
||||
"unsafe"
|
||||
|
||||
"github.com/selfmodify/goav/avcodec"
|
||||
"github.com/selfmodify/goav/common"
|
||||
"github.com/giorgisio/goav/avcodec"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -106,7 +105,7 @@ func AvFindBestStream(ic *Context, t MediaType, ws, rs int, c **AvCodec, f int)
|
||||
|
||||
//Return the next frame of a stream.
|
||||
func (s *Context) AvReadFrame(pkt *avcodec.Packet) int {
|
||||
return int(C.av_read_frame((*C.struct_AVFormatContext)(unsafe.Pointer(s)), (*C.struct_AVPacket)(unsafe.Pointer(pkt))))
|
||||
return int(C.av_read_frame((*C.struct_AVFormatContext)(unsafe.Pointer(s)), toCPacket(pkt)))
|
||||
}
|
||||
|
||||
//Seek to the keyframe at timestamp.
|
||||
@@ -116,8 +115,8 @@ func (s *Context) AvSeekFrame(st int, t int64, f int) int {
|
||||
|
||||
// AvSeekFrameTime seeks to a specified time location.
|
||||
// |timebase| is codec specific and can be obtained by calling AvCodecGetPktTimebase2
|
||||
func (s *Context) AvSeekFrameTime(st int, at time.Duration, timebase common.AVRational) int {
|
||||
t2 := C.double(C.double(at.Seconds())*C.double(timebase.Den)) / (C.double(timebase.Num))
|
||||
func (s *Context) AvSeekFrameTime(st int, at time.Duration, timebase avcodec.Rational) int {
|
||||
t2 := C.double(C.double(at.Seconds())*C.double(timebase.Den())) / (C.double(timebase.Num()))
|
||||
// log.Printf("Seeking to time :%v TimebaseTime:%v ActualTimebase:%v", at, t2, timebase)
|
||||
return int(C.av_seek_frame((*C.struct_AVFormatContext)(s), C.int(st), C.int64_t(t2), AvseekFlagBackward))
|
||||
}
|
||||
@@ -139,7 +138,7 @@ func (s *Context) AvReadPause() int {
|
||||
|
||||
//Close an opened input Context.
|
||||
func (s *Context) AvformatCloseInput() {
|
||||
C.avformat_close_input((**C.struct_AVFormatContext)(unsafe.Pointer(s)))
|
||||
C.avformat_close_input((**C.struct_AVFormatContext)(unsafe.Pointer(&s)))
|
||||
}
|
||||
|
||||
//Allocate the stream private data and write the stream header to an output media file.
|
||||
@@ -148,13 +147,13 @@ func (s *Context) AvformatWriteHeader(o **Dictionary) int {
|
||||
}
|
||||
|
||||
//Write a packet to an output media file.
|
||||
func (s *Context) AvWriteFrame(pkt *Packet) int {
|
||||
return int(C.av_write_frame((*C.struct_AVFormatContext)(s), (*C.struct_AVPacket)(pkt)))
|
||||
func (s *Context) AvWriteFrame(pkt *avcodec.Packet) int {
|
||||
return int(C.av_write_frame((*C.struct_AVFormatContext)(s), toCPacket(pkt)))
|
||||
}
|
||||
|
||||
//Write a packet to an output media file ensuring correct interleaving.
|
||||
func (s *Context) AvInterleavedWriteFrame(pkt *Packet) int {
|
||||
return int(C.av_interleaved_write_frame((*C.struct_AVFormatContext)(s), (*C.struct_AVPacket)(pkt)))
|
||||
func (s *Context) AvInterleavedWriteFrame(pkt *avcodec.Packet) int {
|
||||
return int(C.av_interleaved_write_frame((*C.struct_AVFormatContext)(s), toCPacket(pkt)))
|
||||
}
|
||||
|
||||
//Write a uncoded frame to an output media file.
|
||||
@@ -192,13 +191,13 @@ func (s *Context) AvDumpFormat(i int, url string, io int) {
|
||||
}
|
||||
|
||||
//Guess the sample aspect ratio of a frame, based on both the stream and the frame aspect ratio.
|
||||
func (s *Context) AvGuessSampleAspectRatio(st *Stream, fr *Frame) Rational {
|
||||
return (Rational)(C.av_guess_sample_aspect_ratio((*C.struct_AVFormatContext)(s), (*C.struct_AVStream)(st), (*C.struct_AVFrame)(fr)))
|
||||
func (s *Context) AvGuessSampleAspectRatio(st *Stream, fr *Frame) avcodec.Rational {
|
||||
return newRational(C.av_guess_sample_aspect_ratio((*C.struct_AVFormatContext)(s), (*C.struct_AVStream)(st), (*C.struct_AVFrame)(fr)))
|
||||
}
|
||||
|
||||
//Guess the frame rate, based on both the container and codec information.
|
||||
func (s *Context) AvGuessFrameRate(st *Stream, fr *Frame) Rational {
|
||||
return (Rational)(C.av_guess_frame_rate((*C.struct_AVFormatContext)(s), (*C.struct_AVStream)(st), (*C.struct_AVFrame)(fr)))
|
||||
func (s *Context) AvGuessFrameRate(st *Stream, fr *Frame) avcodec.Rational {
|
||||
return newRational(C.av_guess_frame_rate((*C.struct_AVFormatContext)(s), (*C.struct_AVStream)(st), (*C.struct_AVFrame)(fr)))
|
||||
}
|
||||
|
||||
//Check if the stream st contained in s is matched by the stream specifier spec.
|
||||
@@ -212,7 +211,7 @@ func (s *Context) AvformatQueueAttachedPictures() int {
|
||||
|
||||
func (s *Context) AvformatNewStream2(c *AvCodec) *Stream {
|
||||
stream := (*Stream)(C.avformat_new_stream((*C.struct_AVFormatContext)(s), (*C.struct_AVCodec)(c)))
|
||||
stream.codec.pix_fmt = int32(common.AV_PIX_FMT_YUV)
|
||||
stream.codec.pix_fmt = int32(avcodec.AV_PIX_FMT_YUV)
|
||||
stream.codec.width = 640
|
||||
stream.codec.height = 480
|
||||
stream.time_base.num = 1
|
||||
|
||||
@@ -7,6 +7,7 @@ package avformat
|
||||
//#include <libavformat/avformat.h>
|
||||
import "C"
|
||||
import (
|
||||
"reflect"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
@@ -42,12 +43,24 @@ func (ctxt *Context) InterruptCallback() AvIOInterruptCB {
|
||||
return AvIOInterruptCB(ctxt.interrupt_callback)
|
||||
}
|
||||
|
||||
func (ctxt *Context) Programs() **AvProgram {
|
||||
return (**AvProgram)(unsafe.Pointer(ctxt.programs))
|
||||
func (ctxt *Context) Programs() []*AvProgram {
|
||||
header := reflect.SliceHeader{
|
||||
Data: uintptr(unsafe.Pointer(ctxt.programs)),
|
||||
Len: int(ctxt.NbPrograms()),
|
||||
Cap: int(ctxt.NbPrograms()),
|
||||
}
|
||||
|
||||
return *((*[]*AvProgram)(unsafe.Pointer(&header)))
|
||||
}
|
||||
|
||||
func (ctxt *Context) Streams() *Stream {
|
||||
return (*Stream)(unsafe.Pointer(*ctxt.streams))
|
||||
func (ctxt *Context) Streams() []*Stream {
|
||||
header := reflect.SliceHeader{
|
||||
Data: uintptr(unsafe.Pointer(ctxt.streams)),
|
||||
Len: int(ctxt.NbStreams()),
|
||||
Cap: int(ctxt.NbStreams()),
|
||||
}
|
||||
|
||||
return *((*[]*Stream)(unsafe.Pointer(&header)))
|
||||
}
|
||||
|
||||
func (ctxt *Context) Filename() string {
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
|
||||
// Giorgis (habtom@giorgis.io)
|
||||
|
||||
//Package avformat provides some generic global options, which can be set on all the muxers and demuxers.
|
||||
//In addition each muxer or demuxer may support so-called private options, which are specific for that component.
|
||||
//Supported formats (muxers and demuxers) provided by the libavformat library
|
||||
package avformat
|
||||
|
||||
//#cgo pkg-config: libavformat libavcodec libavutil libavdevice libavfilter libswresample libswscale
|
||||
//#include <stdio.h>
|
||||
//#include <stdlib.h>
|
||||
//#include <inttypes.h>
|
||||
//#include <stdint.h>
|
||||
//#include <string.h>
|
||||
//#include <libavformat/avformat.h>
|
||||
//#include <libavformat/avio.h>
|
||||
import "C"
|
||||
|
||||
const (
|
||||
AVIO_FLAG_READ = int(C.AVIO_FLAG_READ)
|
||||
AVIO_FLAG_WRITE = int(C.AVIO_FLAG_WRITE)
|
||||
AVIO_FLAG_READ_WRITE = int(C.AVIO_FLAG_READ_WRITE)
|
||||
)
|
||||
@@ -0,0 +1,17 @@
|
||||
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
|
||||
|
||||
package avformat
|
||||
|
||||
//#cgo pkg-config: libavutil
|
||||
//#include <libavutil/avutil.h>
|
||||
import "C"
|
||||
|
||||
const (
|
||||
AVMEDIA_TYPE_UNKNOWN = C.AVMEDIA_TYPE_UNKNOWN
|
||||
AVMEDIA_TYPE_VIDEO = C.AVMEDIA_TYPE_VIDEO
|
||||
AVMEDIA_TYPE_AUDIO = C.AVMEDIA_TYPE_AUDIO
|
||||
AVMEDIA_TYPE_DATA = C.AVMEDIA_TYPE_DATA
|
||||
AVMEDIA_TYPE_SUBTITLE = C.AVMEDIA_TYPE_SUBTITLE
|
||||
AVMEDIA_TYPE_ATTACHMENT = C.AVMEDIA_TYPE_ATTACHMENT
|
||||
AVMEDIA_TYPE_NB = C.AVMEDIA_TYPE_NB
|
||||
)
|
||||
@@ -0,0 +1,21 @@
|
||||
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
|
||||
// Giorgis (habtom@giorgis.io)
|
||||
|
||||
package avformat
|
||||
|
||||
//#cgo pkg-config: libavformat
|
||||
//#include <libavformat/avformat.h>
|
||||
import "C"
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/giorgisio/goav/avcodec"
|
||||
)
|
||||
|
||||
func toCPacket(pkt *avcodec.Packet) *C.struct_AVPacket {
|
||||
return (*C.struct_AVPacket)(unsafe.Pointer(pkt))
|
||||
}
|
||||
|
||||
func fromCPacket(pkt *C.struct_AVPacket) *avcodec.Packet {
|
||||
return (*avcodec.Packet)(unsafe.Pointer(pkt))
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
// Use of this source code is governed by a MIT license that can be found in the LICENSE file.
|
||||
// Giorgis (habtom@giorgis.io)
|
||||
|
||||
package avformat
|
||||
|
||||
//#cgo pkg-config: libavutil
|
||||
//#include <libavutil/avutil.h>
|
||||
import "C"
|
||||
import "github.com/giorgisio/goav/avcodec"
|
||||
|
||||
func newRational(r C.struct_AVRational) avcodec.Rational {
|
||||
return avcodec.NewRational(int(r.num), int(r.den))
|
||||
}
|
||||
+12
-4
@@ -6,15 +6,23 @@ package avformat
|
||||
//#cgo pkg-config: libavformat
|
||||
//#include <libavformat/avformat.h>
|
||||
import "C"
|
||||
import (
|
||||
"github.com/giorgisio/goav/avcodec"
|
||||
)
|
||||
|
||||
//Rational av_stream_get_r_frame_rate (const Stream *s)
|
||||
func (s *Stream) AvStreamGetRFrameRate() Rational {
|
||||
return (Rational)(C.av_stream_get_r_frame_rate((*C.struct_AVStream)(s)))
|
||||
func (s *Stream) AvStreamGetRFrameRate() avcodec.Rational {
|
||||
return newRational(C.av_stream_get_r_frame_rate((*C.struct_AVStream)(s)))
|
||||
}
|
||||
|
||||
//void av_stream_set_r_frame_rate (Stream *s, Rational r)
|
||||
func (s *Stream) AvStreamSetRFrameRate(r Rational) {
|
||||
C.av_stream_set_r_frame_rate((*C.struct_AVStream)(s), (C.struct_AVRational)(r))
|
||||
func (s *Stream) AvStreamSetRFrameRate(r avcodec.Rational) {
|
||||
rat := C.struct_AVRational{
|
||||
num: C.int(r.Num()),
|
||||
den: C.int(r.Den()),
|
||||
}
|
||||
|
||||
C.av_stream_set_r_frame_rate((*C.struct_AVStream)(s), rat)
|
||||
}
|
||||
|
||||
//struct CodecParserContext * av_stream_get_parser (const Stream *s)
|
||||
|
||||
+20
-10
@@ -8,8 +8,14 @@ package avformat
|
||||
import "C"
|
||||
import (
|
||||
"unsafe"
|
||||
|
||||
"github.com/giorgisio/goav/avcodec"
|
||||
)
|
||||
|
||||
func (avs *Stream) CodecParameters() *avcodec.AvCodecParameters {
|
||||
return (*avcodec.AvCodecParameters)(unsafe.Pointer(avs.codecpar))
|
||||
}
|
||||
|
||||
func (avs *Stream) Codec() *CodecContext {
|
||||
return (*CodecContext)(unsafe.Pointer(avs.codec))
|
||||
}
|
||||
@@ -22,8 +28,8 @@ func (avs *Stream) IndexEntries() *AvIndexEntry {
|
||||
return (*AvIndexEntry)(unsafe.Pointer(avs.index_entries))
|
||||
}
|
||||
|
||||
func (avs *Stream) AttachedPic() Packet {
|
||||
return Packet(avs.attached_pic)
|
||||
func (avs *Stream) AttachedPic() avcodec.Packet {
|
||||
return *fromCPacket(&avs.attached_pic)
|
||||
}
|
||||
|
||||
func (avs *Stream) SideData() *AvPacketSideData {
|
||||
@@ -34,24 +40,24 @@ func (avs *Stream) ProbeData() AvProbeData {
|
||||
return AvProbeData(avs.probe_data)
|
||||
}
|
||||
|
||||
func (avs *Stream) AvgFrameRate() Rational {
|
||||
return Rational(avs.avg_frame_rate)
|
||||
func (avs *Stream) AvgFrameRate() avcodec.Rational {
|
||||
return newRational(avs.avg_frame_rate)
|
||||
}
|
||||
|
||||
// func (avs *Stream) DisplayAspectRatio() *Rational {
|
||||
// return (*Rational)(unsafe.Pointer(avs.display_aspect_ratio))
|
||||
// }
|
||||
|
||||
func (avs *Stream) RFrameRate() Rational {
|
||||
return Rational(avs.r_frame_rate)
|
||||
func (avs *Stream) RFrameRate() avcodec.Rational {
|
||||
return newRational(avs.r_frame_rate)
|
||||
}
|
||||
|
||||
func (avs *Stream) SampleAspectRatio() Rational {
|
||||
return Rational(avs.sample_aspect_ratio)
|
||||
func (avs *Stream) SampleAspectRatio() avcodec.Rational {
|
||||
return newRational(avs.sample_aspect_ratio)
|
||||
}
|
||||
|
||||
func (avs *Stream) TimeBase() Rational {
|
||||
return Rational(avs.time_base)
|
||||
func (avs *Stream) TimeBase() avcodec.Rational {
|
||||
return newRational(avs.time_base)
|
||||
}
|
||||
|
||||
// func (avs *Stream) RecommendedEncoderConfiguration() string {
|
||||
@@ -225,3 +231,7 @@ func (avs *Stream) PtsReorderErrorCount() uint8 {
|
||||
func (avs *Stream) IndexEntriesAllocatedSize() uint {
|
||||
return uint(avs.index_entries_allocated_size)
|
||||
}
|
||||
|
||||
func (avs *Stream) Free() {
|
||||
C.av_freep(unsafe.Pointer(avs))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user