mirror of
https://github.com/asticode/go-astiav.git
synced 2025-09-26 20:21:15 +08:00
Added links to C doc
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
# v0.25.0
|
||||
|
||||
- `CodecParameters`.`CodecType` and `CodecParameters`.`SetCodecType` have been removed, use `CodecParameters`.`MediaType` and `CodecParameters`.`SetMediaType` instead
|
||||
|
||||
# v0.24.0
|
||||
|
||||
- use `FilterGraph`.`NewBuffersinkFilterContext` and `FilterGraph`.`NewBuffersrcFilterContext` instead of `FilterGraph`.`NewFilterContext` when creating `buffersink` and `buffersrc` filter contexts and use `BuffersinkFilterContext`.`GetFrame` and `BuffersrcFilterContext`.`AddFrame` to manipulate them. Use `BuffersinkFilterContext`.`FilterContext` and `BuffersrcFilterContext`.`FilterContext` in `FilterInOut`.`SetFilterContext`.
|
||||
|
@@ -4,7 +4,7 @@ package astiav
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n7.0/libavutil/audio_fifo.c#L37
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVAudioFifo.html
|
||||
type AudioFifo struct {
|
||||
c *C.AVAudioFifo
|
||||
}
|
||||
@@ -16,22 +16,27 @@ func newAudioFifoFromC(c *C.AVAudioFifo) *AudioFifo {
|
||||
return &AudioFifo{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__audiofifo.html#ga9d792394f0615a329aec47847f8f8784
|
||||
func AllocAudioFifo(sampleFmt SampleFormat, channels int, nbSamples int) *AudioFifo {
|
||||
return newAudioFifoFromC(C.av_audio_fifo_alloc(C.enum_AVSampleFormat(sampleFmt), C.int(channels), C.int(nbSamples)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__audiofifo.html#ga27c1e16e5f09940d6016b1971c0b5742
|
||||
func (a *AudioFifo) Realloc(nbSamples int) error {
|
||||
return newError(C.av_audio_fifo_realloc(a.c, C.int(nbSamples)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__audiofifo.html#gaa0a4742ecac52a999e8b4478d27f3b9b
|
||||
func (a *AudioFifo) Size() int {
|
||||
return int(C.av_audio_fifo_size(a.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__audiofifo.html#ga2bed2f01fe34228ee8a73617b3177d00
|
||||
func (a *AudioFifo) Space() int {
|
||||
return int(C.av_audio_fifo_space(a.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__audiofifo.html#ga51d81a165872919bbfdee3f00f6d6530
|
||||
func (a *AudioFifo) Write(f *Frame) (int, error) {
|
||||
ret := C.av_audio_fifo_write(a.c, (*unsafe.Pointer)(unsafe.Pointer(&f.c.data[0])), C.int(f.NbSamples()))
|
||||
if err := newError(ret); err != nil {
|
||||
@@ -40,6 +45,7 @@ func (a *AudioFifo) Write(f *Frame) (int, error) {
|
||||
return int(ret), nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__audiofifo.html#ga5e2c87bbeefba0d229b4109b4b755529
|
||||
func (a *AudioFifo) Read(f *Frame) (int, error) {
|
||||
ret := C.av_audio_fifo_read(a.c, (*unsafe.Pointer)(unsafe.Pointer(&f.c.data[0])), C.int(f.NbSamples()))
|
||||
if err := newError(ret); err != nil {
|
||||
@@ -48,6 +54,7 @@ func (a *AudioFifo) Read(f *Frame) (int, error) {
|
||||
return int(ret), nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__audiofifo.html#ga74e029e47f7aa99217ad1f315c434875
|
||||
func (a *AudioFifo) Free() {
|
||||
C.av_audio_fifo_free(a.c)
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/release/5.1/libavcodec/bsf.h#L111
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVBitStreamFilter.html
|
||||
type BitStreamFilter struct {
|
||||
c *C.AVBitStreamFilter
|
||||
}
|
||||
@@ -19,12 +19,14 @@ func newBitStreamFilterFromC(c *C.AVBitStreamFilter) *BitStreamFilter {
|
||||
return &BitStreamFilter{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__bsf.html#gae491493190b45698ebd43db28c4e8fe9
|
||||
func FindBitStreamFilterByName(n string) *BitStreamFilter {
|
||||
cn := C.CString(n)
|
||||
defer C.free(unsafe.Pointer(cn))
|
||||
return newBitStreamFilterFromC(C.av_bsf_get_by_name(cn))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVBitStreamFilter.html#a33c3cb51bd13060da35481655b41e4e5
|
||||
func (bsf *BitStreamFilter) Name() string {
|
||||
return C.GoString(bsf.c.name)
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/release/5.1/libavcodec/bsf.h#L68
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVBSFContext.html
|
||||
type BitStreamFilterContext struct {
|
||||
c *C.AVBSFContext
|
||||
}
|
||||
@@ -23,6 +23,7 @@ func newBSFContextFromC(c *C.AVBSFContext) *BitStreamFilterContext {
|
||||
|
||||
var _ Classer = (*BitStreamFilterContext)(nil)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__bsf.html#ga7da65af303e20c9546e15ec266b182c1
|
||||
func AllocBitStreamFilterContext(f *BitStreamFilter) (*BitStreamFilterContext, error) {
|
||||
if f == nil {
|
||||
return nil, errors.New("astiav: bit stream filter must not be nil")
|
||||
@@ -36,14 +37,17 @@ func AllocBitStreamFilterContext(f *BitStreamFilter) (*BitStreamFilterContext, e
|
||||
return newBSFContextFromC(bsfc), nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVBSFContext.html#aa5d5018816daac804414c459ec8a1c5c
|
||||
func (bsfc *BitStreamFilterContext) Class() *Class {
|
||||
return newClassFromC(unsafe.Pointer(bsfc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__bsf.html#ga242529d54013acf87e94273d298a5ff2
|
||||
func (bsfc *BitStreamFilterContext) Initialize() error {
|
||||
return newError(C.av_bsf_init(bsfc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__bsf.html#gaada9ea8f08d3dcf23c14564dbc88992c
|
||||
func (bsfc *BitStreamFilterContext) SendPacket(p *Packet) error {
|
||||
var pc *C.AVPacket
|
||||
if p != nil {
|
||||
@@ -52,6 +56,7 @@ func (bsfc *BitStreamFilterContext) SendPacket(p *Packet) error {
|
||||
return newError(C.av_bsf_send_packet(bsfc.c, pc))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__bsf.html#ga7fffb6c87b91250956e7a2367af56b38
|
||||
func (bsfc *BitStreamFilterContext) ReceivePacket(p *Packet) error {
|
||||
if p == nil {
|
||||
return errors.New("astiav: packet must not be nil")
|
||||
@@ -59,6 +64,7 @@ func (bsfc *BitStreamFilterContext) ReceivePacket(p *Packet) error {
|
||||
return newError(C.av_bsf_receive_packet(bsfc.c, p.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__bsf.html#ga08d53431e76355f88e27763b1940df4f
|
||||
func (bsfc *BitStreamFilterContext) Free() {
|
||||
if bsfc.c != nil {
|
||||
// Make sure to clone the classer before freeing the object since
|
||||
@@ -73,14 +79,17 @@ func (bsfc *BitStreamFilterContext) Free() {
|
||||
}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVBSFContext.html#ad75adf988c00f89202099c87ea39f0db
|
||||
func (bsfc *BitStreamFilterContext) InputTimeBase() Rational {
|
||||
return newRationalFromC(bsfc.c.time_base_in)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVBSFContext.html#ad75adf988c00f89202099c87ea39f0db
|
||||
func (bsfc *BitStreamFilterContext) SetInputTimeBase(r Rational) {
|
||||
bsfc.c.time_base_in = r.c
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVBSFContext.html#a702ace639b8193475cf0a12ebdebd738
|
||||
func (bsfc *BitStreamFilterContext) InputCodecParameters() *CodecParameters {
|
||||
return newCodecParametersFromC(bsfc.c.par_in)
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavfilter/buffersink.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink.html#ga9453fc0e81d30237080b51575da0f0d8
|
||||
type BuffersinkFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/buffersink.h#L89
|
||||
const (
|
||||
BuffersinkFlagPeek = BuffersinkFlag(C.AV_BUFFERSINK_FLAG_PEEK)
|
||||
BuffersinkFlagNoRequest = BuffersinkFlag(C.AV_BUFFERSINK_FLAG_NO_REQUEST)
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavfilter/buffersrc.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersrc.html#gga9e9505a91a84992d04ba4e85217fb4e4a6efcf61145ec6d60d3a773fcd0797872
|
||||
type BuffersrcFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/buffersrc.h#L36
|
||||
const (
|
||||
BuffersrcFlagNoCheckFormat = BuffersrcFlag(C.AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT)
|
||||
BuffersrcFlagPush = BuffersrcFlag(C.AV_BUFFERSRC_FLAG_PUSH)
|
||||
|
@@ -6,7 +6,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/channel_layout.h#L90
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__audio__channels.html#ga855bb7dede67971e95bd09d8fcca7293
|
||||
var (
|
||||
ChannelLayoutMono = newChannelLayoutFromC(C.astiavChannelLayoutMono)
|
||||
ChannelLayoutStereo = newChannelLayoutFromC(C.astiavChannelLayoutStereo)
|
||||
@@ -46,6 +46,7 @@ var (
|
||||
ChannelLayout7Point1TopBack = newChannelLayoutFromC(C.astiavChannelLayout7Point1TopBack)
|
||||
)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVChannelLayout.html
|
||||
type ChannelLayout struct {
|
||||
c *C.AVChannelLayout
|
||||
}
|
||||
@@ -54,6 +55,7 @@ func newChannelLayoutFromC(c *C.AVChannelLayout) ChannelLayout {
|
||||
return ChannelLayout{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVChannelLayout.html#adfd3f460a8ea1575baa32852d9248d3c
|
||||
func (l ChannelLayout) Channels() int {
|
||||
if l.c == nil {
|
||||
return 0
|
||||
@@ -70,6 +72,7 @@ func (l ChannelLayout) String() string {
|
||||
return string(b[:n])
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__audio__channels.html#gacc7d7d1a280248aafb8f9196c9d4e24f
|
||||
func (l ChannelLayout) Describe(b []byte) (int, error) {
|
||||
if l.c == nil {
|
||||
return 0, nil
|
||||
@@ -84,6 +87,7 @@ func (l ChannelLayout) Describe(b []byte) (int, error) {
|
||||
return int(ret), nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__audio__channels.html#gad15a6bf80ee8551ee4a4789d970ccbea
|
||||
func (l ChannelLayout) Valid() bool {
|
||||
if l.c == nil {
|
||||
return false
|
||||
@@ -91,6 +95,7 @@ func (l ChannelLayout) Valid() bool {
|
||||
return C.av_channel_layout_check(l.c) > 0
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__audio__channels.html#ga5da99475fc07b778522974a2e0a1f58c
|
||||
func (l ChannelLayout) Compare(l2 ChannelLayout) (equal bool, err error) {
|
||||
if l.c == nil || l2.c == nil {
|
||||
return l.c == nil && l2.c == nil, nil
|
||||
@@ -107,6 +112,7 @@ func (l ChannelLayout) Equal(l2 ChannelLayout) bool {
|
||||
return v
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__audio__channels.html#gad36be43b2a1b14b66492b8025b82f886
|
||||
func (l ChannelLayout) copy(dst *C.AVChannelLayout) error {
|
||||
return newError(C.av_channel_layout_copy(dst, l.c))
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavutil/pixfmt.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/pixfmt.h#L616
|
||||
// https://ffmpeg.org/doxygen/7.0/pixfmt_8h.html#a1f86ed1b6a420faccacf77c98db6c1ff
|
||||
type ChromaLocation C.enum_AVChromaLocation
|
||||
|
||||
const (
|
||||
|
6
class.go
6
class.go
@@ -8,7 +8,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/log.h#L66
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVClass.html
|
||||
type Class struct {
|
||||
c *C.AVClass
|
||||
ptr unsafe.Pointer
|
||||
@@ -28,18 +28,22 @@ func newClassFromC(ptr unsafe.Pointer) *Class {
|
||||
}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVClass.html#a5fc161d93a0d65a608819da20b7203ba
|
||||
func (c *Class) Category() ClassCategory {
|
||||
return ClassCategory(C.astiavClassCategory(c.c, c.ptr))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVClass.html#ad763b2e6a0846234a165e74574a550bd
|
||||
func (c *Class) ItemName() string {
|
||||
return C.GoString(C.astiavClassItemName(c.c, c.ptr))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVClass.html#aa8883e113a3f2965abd008f7667db7eb
|
||||
func (c *Class) Name() string {
|
||||
return C.GoString(c.c.class_name)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVClass.html#a88948c8a7c6515181771615a54a808bf
|
||||
func (c *Class) Parent() *Class {
|
||||
return newClassFromC(unsafe.Pointer(C.astiavClassParent(c.c, c.ptr)))
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavutil/log.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/log.h#L28
|
||||
// https://ffmpeg.org/doxygen/7.0/log_8h.html#aeb1c06cc3e47a029ca6afeac782ac8f9
|
||||
type ClassCategory C.AVClassCategory
|
||||
|
||||
const (
|
||||
|
15
codec.go
15
codec.go
@@ -7,7 +7,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/codec.h#L202
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodec.html
|
||||
type Codec struct {
|
||||
c *C.AVCodec
|
||||
}
|
||||
@@ -19,6 +19,7 @@ func newCodecFromC(c *C.AVCodec) *Codec {
|
||||
return &Codec{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodec.html#ad3daa3e729850b573c139a83be8938ca
|
||||
func (c *Codec) Name() string {
|
||||
return C.GoString(c.c.name)
|
||||
}
|
||||
@@ -27,10 +28,12 @@ func (c *Codec) String() string {
|
||||
return c.Name()
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodec.html#a01a53d07936f4c7ee280444793b6967b
|
||||
func (c *Codec) ID() CodecID {
|
||||
return CodecID(c.c.id)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodec.html#a710e3bd3081124ef3364b0c520379dd8
|
||||
func (c *Codec) ChannelLayouts() (o []ChannelLayout) {
|
||||
if c.c.ch_layouts == nil {
|
||||
return nil
|
||||
@@ -46,14 +49,17 @@ func (c *Codec) ChannelLayouts() (o []ChannelLayout) {
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga6dc18eef1afca3610644a52565cf8a31
|
||||
func (c *Codec) IsDecoder() bool {
|
||||
return int(C.av_codec_is_decoder(c.c)) != 0
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga2b665824e4d9144f8d4f6c01e3e85aa3
|
||||
func (c *Codec) IsEncoder() bool {
|
||||
return int(C.av_codec_is_encoder(c.c)) != 0
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodec.html#ac2b97bd3c19686025e1b7d577329c250
|
||||
func (c *Codec) PixelFormats() (o []PixelFormat) {
|
||||
if c.c.pix_fmts == nil {
|
||||
return nil
|
||||
@@ -69,6 +75,7 @@ func (c *Codec) PixelFormats() (o []PixelFormat) {
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodec.html#aac19f4c45370f715412ad5c7b78daacf
|
||||
func (c *Codec) SampleFormats() (o []SampleFormat) {
|
||||
if c.c.sample_fmts == nil {
|
||||
return nil
|
||||
@@ -84,26 +91,31 @@ func (c *Codec) SampleFormats() (o []SampleFormat) {
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga51e35d01da2b3833b3afa839212c58fa
|
||||
func FindDecoder(id CodecID) *Codec {
|
||||
return newCodecFromC(C.avcodec_find_decoder((C.enum_AVCodecID)(id)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#gad4e08a758f3560006145db074d16cb47
|
||||
func FindDecoderByName(n string) *Codec {
|
||||
cn := C.CString(n)
|
||||
defer C.free(unsafe.Pointer(cn))
|
||||
return newCodecFromC(C.avcodec_find_decoder_by_name(cn))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga68e4b5f31de5e5fc25d5781a1be22331
|
||||
func FindEncoder(id CodecID) *Codec {
|
||||
return newCodecFromC(C.avcodec_find_encoder((C.enum_AVCodecID)(id)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga9fa02c1eae54a2ec67beb789c2688d6e
|
||||
func FindEncoderByName(n string) *Codec {
|
||||
cn := C.CString(n)
|
||||
defer C.free(unsafe.Pointer(cn))
|
||||
return newCodecFromC(C.avcodec_find_encoder_by_name(cn))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga4f80582a2ea9c0e141de5d6f6152008f
|
||||
func (c *Codec) HardwareConfigs() (configs []CodecHardwareConfig) {
|
||||
var i int
|
||||
for {
|
||||
@@ -117,6 +129,7 @@ func (c *Codec) HardwareConfigs() (configs []CodecHardwareConfig) {
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga7cd040fcc147340186deb0c54dc996b0
|
||||
func Codecs() (cs []*Codec) {
|
||||
var opq *C.void = nil
|
||||
for {
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/avcodec.h#L383
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html
|
||||
type CodecContext struct {
|
||||
c *C.AVCodecContext
|
||||
// We need to store this to unref it properly
|
||||
@@ -26,6 +26,7 @@ func newCodecContextFromC(c *C.AVCodecContext) *CodecContext {
|
||||
|
||||
var _ Classer = (*CodecContext)(nil)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#gae80afec6f26df6607eaacf39b561c315
|
||||
func AllocCodecContext(c *Codec) *CodecContext {
|
||||
var cc *C.AVCodec
|
||||
if c != nil {
|
||||
@@ -34,6 +35,7 @@ func AllocCodecContext(c *Codec) *CodecContext {
|
||||
return newCodecContextFromC(C.avcodec_alloc_context3(cc))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#gaf869d0829ed607cec3a4a02a1c7026b3
|
||||
func (cc *CodecContext) Free() {
|
||||
if cc.hdc != nil {
|
||||
C.av_buffer_unref(&cc.hdc.c)
|
||||
@@ -64,51 +66,63 @@ func (cc *CodecContext) String() string {
|
||||
return s
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a6b53fda85ad61baa345edbd96cb8a33c
|
||||
func (cc *CodecContext) BitRate() int64 {
|
||||
return int64(cc.c.bit_rate)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a6b53fda85ad61baa345edbd96cb8a33c
|
||||
func (cc *CodecContext) SetBitRate(bitRate int64) {
|
||||
cc.c.bit_rate = C.int64_t(bitRate)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a167ff73c67960acf2d5ca73d93e13f64
|
||||
func (cc *CodecContext) ChannelLayout() ChannelLayout {
|
||||
l, _ := newChannelLayoutFromC(&cc.c.ch_layout).clone()
|
||||
return l
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a167ff73c67960acf2d5ca73d93e13f64
|
||||
func (cc *CodecContext) SetChannelLayout(l ChannelLayout) {
|
||||
l.copy(&cc.c.ch_layout) //nolint: errcheck
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#ac60a0209642b5d74068cab0ac35a78b2
|
||||
func (cc *CodecContext) ChromaLocation() ChromaLocation {
|
||||
return ChromaLocation(cc.c.chroma_sample_location)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a90622d3af2a9abba986a1c9f7ca21b16
|
||||
func (cc *CodecContext) Class() *Class {
|
||||
return newClassFromC(unsafe.Pointer(cc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#adc5f65d6099fd8339c1580c091777223
|
||||
func (cc *CodecContext) CodecID() CodecID {
|
||||
return CodecID(cc.c.codec_id)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a3a41b3e5bde23b877799f6e72dac8ef3
|
||||
func (cc *CodecContext) ColorPrimaries() ColorPrimaries {
|
||||
return ColorPrimaries(cc.c.color_primaries)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a255bf7100a4ba6dcb6ee5d87740a4f35
|
||||
func (cc *CodecContext) ColorRange() ColorRange {
|
||||
return ColorRange(cc.c.color_range)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a8cd8caa7d40319324ce3d879a2edbd9f
|
||||
func (cc *CodecContext) ColorSpace() ColorSpace {
|
||||
return ColorSpace(cc.c.colorspace)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#ab649e8c599f5a0e2a30448e67a36deb6
|
||||
func (cc *CodecContext) ColorTransferCharacteristic() ColorTransferCharacteristic {
|
||||
return ColorTransferCharacteristic(cc.c.color_trc)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#abe964316aaaa61967b012efdcced79c4
|
||||
func (cc *CodecContext) ExtraData() []byte {
|
||||
return bytesFromC(func(size *C.size_t) *C.uint8_t {
|
||||
*size = C.size_t(cc.c.extradata_size)
|
||||
@@ -116,154 +130,192 @@ func (cc *CodecContext) ExtraData() []byte {
|
||||
})
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#abe964316aaaa61967b012efdcced79c4
|
||||
func (cc *CodecContext) SetExtraData(b []byte) error {
|
||||
return setBytesWithIntSizeInC(b, &cc.c.extradata, &cc.c.extradata_size)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#abb01e291550fa3fb96188af4d494587e
|
||||
func (cc *CodecContext) Flags() CodecContextFlags {
|
||||
return CodecContextFlags(cc.c.flags)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#abb01e291550fa3fb96188af4d494587e
|
||||
func (cc *CodecContext) SetFlags(fs CodecContextFlags) {
|
||||
cc.c.flags = C.int(fs)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a1944f9a4f8f2e123c087e1fe7613d571
|
||||
func (cc *CodecContext) Flags2() CodecContextFlags2 {
|
||||
return CodecContextFlags2(cc.c.flags2)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a1944f9a4f8f2e123c087e1fe7613d571
|
||||
func (cc *CodecContext) SetFlags2(fs CodecContextFlags2) {
|
||||
cc.c.flags2 = C.int(fs)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a4d08b297e97eefd66c714df4fff493c8
|
||||
func (cc *CodecContext) Framerate() Rational {
|
||||
return newRationalFromC(cc.c.framerate)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a4d08b297e97eefd66c714df4fff493c8
|
||||
func (cc *CodecContext) SetFramerate(f Rational) {
|
||||
cc.c.framerate = f.c
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#aec57f0d859a6df8b479cd93ca3a44a33
|
||||
func (cc *CodecContext) FrameSize() int {
|
||||
return int(cc.c.frame_size)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a9b6b3f1fcbdcc2ad9f4dbb4370496e38
|
||||
func (cc *CodecContext) GopSize() int {
|
||||
return int(cc.c.gop_size)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a9b6b3f1fcbdcc2ad9f4dbb4370496e38
|
||||
func (cc *CodecContext) SetGopSize(gopSize int) {
|
||||
cc.c.gop_size = C.int(gopSize)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363
|
||||
func (cc *CodecContext) Height() int {
|
||||
return int(cc.c.height)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a0449afd803eb107bd4dbc8b5ea22e363
|
||||
func (cc *CodecContext) SetHeight(height int) {
|
||||
cc.c.height = C.int(height)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a6927dc652ae6241f1dfdbad4e12d3a40
|
||||
func (cc *CodecContext) Level() Level {
|
||||
return Level(cc.c.level)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a6927dc652ae6241f1dfdbad4e12d3a40
|
||||
func (cc *CodecContext) SetLevel(l Level) {
|
||||
cc.c.level = C.int(l)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a3f99ca3115c44e6d7772c9384faf15e6
|
||||
func (cc *CodecContext) MediaType() MediaType {
|
||||
return MediaType(cc.c.codec_type)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a0425c77b3d06d71e5db88b1d7e1b37f2
|
||||
func (cc *CodecContext) PixelFormat() PixelFormat {
|
||||
return PixelFormat(cc.c.pix_fmt)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a0425c77b3d06d71e5db88b1d7e1b37f2
|
||||
func (cc *CodecContext) SetPixelFormat(pixFmt PixelFormat) {
|
||||
cc.c.pix_fmt = C.enum_AVPixelFormat(pixFmt)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a7abe7095de73df98df4895bf9e25fc6b
|
||||
func (cc *CodecContext) Profile() Profile {
|
||||
return Profile(cc.c.profile)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a7abe7095de73df98df4895bf9e25fc6b
|
||||
func (cc *CodecContext) SetProfile(p Profile) {
|
||||
cc.c.profile = C.int(p)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a3f63bc9141e25bf7f1cda0cef7cd4a60
|
||||
func (cc *CodecContext) Qmin() int {
|
||||
return int(cc.c.qmin)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a3f63bc9141e25bf7f1cda0cef7cd4a60
|
||||
func (cc *CodecContext) SetQmin(qmin int) {
|
||||
cc.c.qmin = C.int(qmin)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a5252d34fbce300228d4dbda19a8c3293
|
||||
func (cc *CodecContext) SampleAspectRatio() Rational {
|
||||
return newRationalFromC(cc.c.sample_aspect_ratio)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a5252d34fbce300228d4dbda19a8c3293
|
||||
func (cc *CodecContext) SetSampleAspectRatio(r Rational) {
|
||||
cc.c.sample_aspect_ratio = r.c
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a1bdba69ea111e2a9d03fdaa7a46a4c45
|
||||
func (cc *CodecContext) SampleFormat() SampleFormat {
|
||||
return SampleFormat(cc.c.sample_fmt)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a1bdba69ea111e2a9d03fdaa7a46a4c45
|
||||
func (cc *CodecContext) SetSampleFormat(f SampleFormat) {
|
||||
cc.c.sample_fmt = C.enum_AVSampleFormat(f)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0
|
||||
func (cc *CodecContext) SampleRate() int {
|
||||
return int(cc.c.sample_rate)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a8ff0b000c463361e234af48d03aadfc0
|
||||
func (cc *CodecContext) SetSampleRate(sampleRate int) {
|
||||
cc.c.sample_rate = C.int(sampleRate)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a3090804569341ca235e3adbdc03318d2
|
||||
func (cc *CodecContext) StrictStdCompliance() StrictStdCompliance {
|
||||
return StrictStdCompliance(cc.c.strict_std_compliance)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a3090804569341ca235e3adbdc03318d2
|
||||
func (cc *CodecContext) SetStrictStdCompliance(c StrictStdCompliance) {
|
||||
cc.c.strict_std_compliance = C.int(c)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589
|
||||
func (cc *CodecContext) TimeBase() Rational {
|
||||
return newRationalFromC(cc.c.time_base)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#ab7bfeb9fa5840aac090e2b0bd0ef7589
|
||||
func (cc *CodecContext) SetTimeBase(r Rational) {
|
||||
cc.c.time_base = r.c
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#aa852b6227d0778b62e9cc4034ad3720c
|
||||
func (cc *CodecContext) ThreadCount() int {
|
||||
return int(cc.c.thread_count)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#aa852b6227d0778b62e9cc4034ad3720c
|
||||
func (cc *CodecContext) SetThreadCount(threadCount int) {
|
||||
cc.c.thread_count = C.int(threadCount)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a7651614f4309122981d70e06a4b42fcb
|
||||
func (cc *CodecContext) ThreadType() ThreadType {
|
||||
return ThreadType(cc.c.thread_type)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a7651614f4309122981d70e06a4b42fcb
|
||||
func (cc *CodecContext) SetThreadType(t ThreadType) {
|
||||
cc.c.thread_type = C.int(t)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a0d8f46461754e8abea0847dcbc41b956
|
||||
func (cc *CodecContext) Width() int {
|
||||
return int(cc.c.width)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a0d8f46461754e8abea0847dcbc41b956
|
||||
func (cc *CodecContext) SetWidth(width int) {
|
||||
cc.c.width = C.int(width)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga11f785a188d7d9df71621001465b0f1d
|
||||
func (cc *CodecContext) Open(c *Codec, d *Dictionary) error {
|
||||
var dc **C.AVDictionary
|
||||
if d != nil {
|
||||
@@ -272,6 +324,7 @@ func (cc *CodecContext) Open(c *Codec, d *Dictionary) error {
|
||||
return newError(C.avcodec_open2(cc.c, c.c, dc))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__decoding.html#ga5b8eff59cf259747cf0b31563e38ded6
|
||||
func (cc *CodecContext) ReceivePacket(p *Packet) error {
|
||||
var pc *C.AVPacket
|
||||
if p != nil {
|
||||
@@ -280,6 +333,7 @@ func (cc *CodecContext) ReceivePacket(p *Packet) error {
|
||||
return newError(C.avcodec_receive_packet(cc.c, pc))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__decoding.html#ga58bc4bf1e0ac59e27362597e467efff3
|
||||
func (cc *CodecContext) SendPacket(p *Packet) error {
|
||||
var pc *C.AVPacket
|
||||
if p != nil {
|
||||
@@ -288,6 +342,7 @@ func (cc *CodecContext) SendPacket(p *Packet) error {
|
||||
return newError(C.avcodec_send_packet(cc.c, pc))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__decoding.html#ga11e6542c4e66d3028668788a1a74217c
|
||||
func (cc *CodecContext) ReceiveFrame(f *Frame) error {
|
||||
var fc *C.AVFrame
|
||||
if f != nil {
|
||||
@@ -296,6 +351,7 @@ func (cc *CodecContext) ReceiveFrame(f *Frame) error {
|
||||
return newError(C.avcodec_receive_frame(cc.c, fc))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__decoding.html#ga9395cb802a5febf1f00df31497779169
|
||||
func (cc *CodecContext) SendFrame(f *Frame) error {
|
||||
var fc *C.AVFrame
|
||||
if f != nil {
|
||||
@@ -312,6 +368,7 @@ func (cc *CodecContext) FromCodecParameters(cp *CodecParameters) error {
|
||||
return cp.ToCodecContext(cc)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#acf8113e490f9e7b57465e65af9c0c75c
|
||||
func (cc *CodecContext) SetHardwareDeviceContext(hdc *HardwareDeviceContext) {
|
||||
if cc.hdc != nil {
|
||||
C.av_buffer_unref(&cc.hdc.c)
|
||||
@@ -322,6 +379,7 @@ func (cc *CodecContext) SetHardwareDeviceContext(hdc *HardwareDeviceContext) {
|
||||
}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a3bac44bb0b016ab838780cc19ac277d6
|
||||
func (cc *CodecContext) SetHardwareFrameContext(hfc *HardwareFrameContext) {
|
||||
if cc.hfc != nil {
|
||||
C.av_buffer_unref(&cc.hfc.c)
|
||||
@@ -332,10 +390,12 @@ func (cc *CodecContext) SetHardwareFrameContext(hfc *HardwareFrameContext) {
|
||||
}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#ad2f772bd948d8f3be4d674a3a52ee00e
|
||||
func (cc *CodecContext) ExtraHardwareFrames() int {
|
||||
return int(cc.c.extra_hw_frames)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#ad2f772bd948d8f3be4d674a3a52ee00e
|
||||
func (cc *CodecContext) SetExtraHardwareFrames(n int) {
|
||||
cc.c.extra_hw_frames = C.int(n)
|
||||
}
|
||||
@@ -351,6 +411,7 @@ var (
|
||||
codecContextPixelFormatCallbacksMutex = &sync.Mutex{}
|
||||
)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecContext.html#a360a2b8508a67c4234d97f4c13ba1bb5
|
||||
func (cc *CodecContext) SetPixelFormatCallback(c CodecContextPixelFormatCallback) {
|
||||
// Lock
|
||||
codecContextPixelFormatCallbacksMutex.Lock()
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavcodec/avcodec.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#gaa52d62f5dbfc4529388f0454ae671359
|
||||
type CodecContextFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/avcodec.h#L206
|
||||
const (
|
||||
CodecContextFlagUnaligned = CodecContextFlag(C.AV_CODEC_FLAG_UNALIGNED)
|
||||
CodecContextFlagQscale = CodecContextFlag(C.AV_CODEC_FLAG_QSCALE)
|
||||
@@ -28,7 +28,7 @@ const (
|
||||
|
||||
type CodecContextFlag2 int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/avcodec.h#L287
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga1a6a486e686ab6c581ffffcb88cb31b3
|
||||
const (
|
||||
CodecFlag2Fast = CodecContextFlag2(C.AV_CODEC_FLAG2_FAST)
|
||||
CodecFlag2NoOutput = CodecContextFlag2(C.AV_CODEC_FLAG2_NO_OUTPUT)
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavcodec/avcodec.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/codec.h#L460
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecHWConfig.html
|
||||
type CodecHardwareConfig struct {
|
||||
c *C.AVCodecHWConfig
|
||||
}
|
||||
@@ -12,14 +12,17 @@ func newCodecHardwareConfigFromC(c *C.AVCodecHWConfig) CodecHardwareConfig {
|
||||
return CodecHardwareConfig{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecHWConfig.html#a1474cb73c1f41e377dc5070ae373ac40
|
||||
func (chc CodecHardwareConfig) HardwareDeviceType() HardwareDeviceType {
|
||||
return HardwareDeviceType(chc.c.device_type)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecHWConfig.html#a208c924c3f626b01bf2020eef9eb4905
|
||||
func (chc CodecHardwareConfig) MethodFlags() CodecHardwareConfigMethodFlags {
|
||||
return CodecHardwareConfigMethodFlags(chc.c.methods)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecHWConfig.html#a9352b11d6d6b315fe3c61b65447d5174
|
||||
func (chc CodecHardwareConfig) PixelFormat() PixelFormat {
|
||||
return PixelFormat(chc.c.pix_fmt)
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavcodec/avcodec.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/codec.h#L420
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#gga9334a5b9057f32da96db9b5c6a045d67a680870b80f0ed65e9ba97ea0905eb2fa
|
||||
type CodecHardwareConfigMethodFlag int64
|
||||
|
||||
const (
|
||||
|
@@ -4,7 +4,7 @@ package astiav
|
||||
//#include <libavformat/avformat.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/codec_id.h#L47
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#gaadca229ad2c20e060a14fec08a5cc7ce
|
||||
type CodecID C.enum_AVCodecID
|
||||
|
||||
const (
|
||||
|
@@ -3,11 +3,12 @@ package astiav
|
||||
//#include <libavcodec/avcodec.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/codec_par.h#L52
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html
|
||||
type CodecParameters struct {
|
||||
c *C.AVCodecParameters
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga647755ab2252e93221bb345f3d5e414f
|
||||
func AllocCodecParameters() *CodecParameters {
|
||||
return newCodecParametersFromC(C.avcodec_parameters_alloc())
|
||||
}
|
||||
@@ -19,75 +20,83 @@ func newCodecParametersFromC(c *C.AVCodecParameters) *CodecParameters {
|
||||
return &CodecParameters{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga950c8da55b8112077e640b6a0cb8cf36
|
||||
func (cp *CodecParameters) Free() {
|
||||
C.avcodec_parameters_free(&cp.c)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a5268fcf4ae8ed27edef54f836b926d93
|
||||
func (cp *CodecParameters) BitRate() int64 {
|
||||
return int64(cp.c.bit_rate)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a4d581c205b18108a4f00e8fb3a2b26f9
|
||||
func (cp *CodecParameters) ChannelLayout() ChannelLayout {
|
||||
l, _ := newChannelLayoutFromC(&cp.c.ch_layout).clone()
|
||||
return l
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a4d581c205b18108a4f00e8fb3a2b26f9
|
||||
func (cp *CodecParameters) SetChannelLayout(l ChannelLayout) {
|
||||
l.copy(&cp.c.ch_layout) //nolint: errcheck
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a9f76f2475ef24ff4c9771dd53072d040
|
||||
func (cp *CodecParameters) CodecID() CodecID {
|
||||
return CodecID(cp.c.codec_id)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a9f76f2475ef24ff4c9771dd53072d040
|
||||
func (cp *CodecParameters) SetCodecID(i CodecID) {
|
||||
cp.c.codec_id = uint32(i)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a9b6f7d220d100ba73defab295623356b
|
||||
func (cp *CodecParameters) CodecTag() CodecTag {
|
||||
return CodecTag(cp.c.codec_tag)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a9b6f7d220d100ba73defab295623356b
|
||||
func (cp *CodecParameters) SetCodecTag(t CodecTag) {
|
||||
cp.c.codec_tag = C.uint(t)
|
||||
}
|
||||
|
||||
func (cp *CodecParameters) CodecType() MediaType {
|
||||
return MediaType(cp.c.codec_type)
|
||||
}
|
||||
|
||||
func (cp *CodecParameters) SetCodecType(t MediaType) {
|
||||
cp.c.codec_type = int32(t)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#ae4c7ac718a75adb31b5f2076a02fdedf
|
||||
func (cp *CodecParameters) ChromaLocation() ChromaLocation {
|
||||
return ChromaLocation(cp.c.chroma_location)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#aa884cae3fd16b30c61201a686664f96b
|
||||
func (cp *CodecParameters) ColorPrimaries() ColorPrimaries {
|
||||
return ColorPrimaries(cp.c.color_primaries)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#afa6744d9b8766db47a5ff7bddf0f2404
|
||||
func (cp *CodecParameters) ColorRange() ColorRange {
|
||||
return ColorRange(cp.c.color_range)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#afa6744d9b8766db47a5ff7bddf0f2404
|
||||
func (cp *CodecParameters) SetColorRange(r ColorRange) {
|
||||
cp.c.color_range = C.enum_AVColorRange(r)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a020398a4963e932853cefc169d90456d
|
||||
func (cp *CodecParameters) ColorSpace() ColorSpace {
|
||||
return ColorSpace(cp.c.color_space)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a020398a4963e932853cefc169d90456d
|
||||
func (cp *CodecParameters) SetColorSpace(s ColorSpace) {
|
||||
cp.c.color_space = C.enum_AVColorSpace(s)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#ac25ed8394e1efdbbcf28932ff0020893
|
||||
func (cp *CodecParameters) ColorTransferCharacteristic() ColorTransferCharacteristic {
|
||||
return ColorTransferCharacteristic(cp.c.color_trc)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a9befe0b86412646017afb0051d144d13
|
||||
func (cp *CodecParameters) ExtraData() []byte {
|
||||
return bytesFromC(func(size *C.size_t) *C.uint8_t {
|
||||
*size = C.size_t(cp.c.extradata_size)
|
||||
@@ -95,102 +104,127 @@ func (cp *CodecParameters) ExtraData() []byte {
|
||||
})
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a9befe0b86412646017afb0051d144d13
|
||||
func (cp *CodecParameters) SetExtraData(b []byte) error {
|
||||
return setBytesWithIntSizeInC(b, &cp.c.extradata, &cp.c.extradata_size)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a0ce9631123719789e4c7b0c23c66d534
|
||||
func (cp *CodecParameters) FrameSize() int {
|
||||
return int(cp.c.frame_size)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a0ce9631123719789e4c7b0c23c66d534
|
||||
func (cp *CodecParameters) SetFrameSize(i int) {
|
||||
cp.c.frame_size = C.int(i)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a1ec57ee84f19cf65d00eaa4d2a2253ce
|
||||
func (cp *CodecParameters) Height() int {
|
||||
return int(cp.c.height)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a1ec57ee84f19cf65d00eaa4d2a2253ce
|
||||
func (cp *CodecParameters) SetHeight(h int) {
|
||||
cp.c.height = C.int(h)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a26ae48eeaf8b315eca03b207e11edc7c
|
||||
func (cp *CodecParameters) Level() Level {
|
||||
return Level(cp.c.level)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a26ae48eeaf8b315eca03b207e11edc7c
|
||||
func (cp *CodecParameters) SetLevel(l Level) {
|
||||
cp.c.level = C.int(l)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a58369c3a8a986935b572df5aa6361ce2
|
||||
func (cp *CodecParameters) MediaType() MediaType {
|
||||
return MediaType(cp.c.codec_type)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a58369c3a8a986935b572df5aa6361ce2
|
||||
func (cp *CodecParameters) SetMediaType(t MediaType) {
|
||||
cp.c.codec_type = C.enum_AVMediaType(t)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#abee943e65d98f9763fa6602a356e774f
|
||||
func (cp *CodecParameters) PixelFormat() PixelFormat {
|
||||
return PixelFormat(cp.c.format)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#abee943e65d98f9763fa6602a356e774f
|
||||
func (cp *CodecParameters) SetPixelFormat(f PixelFormat) {
|
||||
cp.c.format = C.int(f)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a6b13b8a226ed923085718cd1323bfcb5
|
||||
func (cp *CodecParameters) Profile() Profile {
|
||||
return Profile(cp.c.profile)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a6b13b8a226ed923085718cd1323bfcb5
|
||||
func (cp *CodecParameters) SetProfile(p Profile) {
|
||||
cp.c.profile = C.int(p)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a7d6ef91120ffe80040c699e747a1ad68
|
||||
func (cp *CodecParameters) SampleAspectRatio() Rational {
|
||||
return newRationalFromC(cp.c.sample_aspect_ratio)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a7d6ef91120ffe80040c699e747a1ad68
|
||||
func (cp *CodecParameters) SetSampleAspectRatio(r Rational) {
|
||||
cp.c.sample_aspect_ratio = r.c
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#ad54da9241deabb3601e6e0e8fa832c19
|
||||
func (cp *CodecParameters) SideData() *PacketSideData {
|
||||
return newPacketSideDataFromC(&cp.c.coded_side_data, &cp.c.nb_coded_side_data)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#abee943e65d98f9763fa6602a356e774f
|
||||
func (cp *CodecParameters) SampleFormat() SampleFormat {
|
||||
return SampleFormat(cp.c.format)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#abee943e65d98f9763fa6602a356e774f
|
||||
func (cp *CodecParameters) SetSampleFormat(f SampleFormat) {
|
||||
cp.c.format = C.int(f)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#abfc9b0aa975206f7e77a125e6b78536e
|
||||
func (cp *CodecParameters) SampleRate() int {
|
||||
return int(cp.c.sample_rate)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#abfc9b0aa975206f7e77a125e6b78536e
|
||||
func (cp *CodecParameters) SetSampleRate(r int) {
|
||||
cp.c.sample_rate = C.int(r)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a51639f88aef9f4f283f538a0c033fbb8
|
||||
func (cp *CodecParameters) Width() int {
|
||||
return int(cp.c.width)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVCodecParameters.html#a51639f88aef9f4f283f538a0c033fbb8
|
||||
func (cp *CodecParameters) SetWidth(w int) {
|
||||
cp.c.width = C.int(w)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga506c1c185ac48bb0086c61e267fc085c
|
||||
func (cp *CodecParameters) FromCodecContext(cc *CodecContext) error {
|
||||
return newError(C.avcodec_parameters_from_context(cp.c, cc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga8a4998c9d1695abb01d379539d313227
|
||||
func (cp *CodecParameters) ToCodecContext(cc *CodecContext) error {
|
||||
return newError(C.avcodec_parameters_to_context(cc.c, cp.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__core.html#ga6d02e640ccc12c783841ce51d09b9fa7
|
||||
func (cp *CodecParameters) Copy(dst *CodecParameters) error {
|
||||
return newError(C.avcodec_parameters_copy(dst.c, cp.c))
|
||||
}
|
||||
|
@@ -76,8 +76,6 @@ func TestCodecParameters(t *testing.T) {
|
||||
require.Equal(t, ColorRangeJpeg, cp6.ColorRange())
|
||||
cp6.SetColorSpace(ColorSpaceBt709)
|
||||
require.Equal(t, ColorSpaceBt709, cp6.ColorSpace())
|
||||
cp6.SetCodecType(MediaTypeAudio)
|
||||
require.Equal(t, MediaTypeAudio, cp6.CodecType())
|
||||
cp6.SetFrameSize(1)
|
||||
require.Equal(t, 1, cp6.FrameSize())
|
||||
cp6.SetHeight(1)
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavutil/pixfmt.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/pixfmt.h#L469
|
||||
// https://ffmpeg.org/doxygen/7.0/pixfmt_8h.html#ad384ee5a840bafd73daef08e6d9cafe7
|
||||
type ColorPrimaries C.enum_AVColorPrimaries
|
||||
|
||||
const (
|
||||
|
@@ -4,7 +4,7 @@ package astiav
|
||||
//#include <libavutil/pixfmt.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/pixfmt.h#L562
|
||||
// https://ffmpeg.org/doxygen/7.0/pixfmt_8h.html#a3da0bf691418bc22c4bcbe6583ad589a
|
||||
type ColorRange C.enum_AVColorRange
|
||||
|
||||
const (
|
||||
@@ -14,6 +14,11 @@ const (
|
||||
ColorRangeNb = ColorRange(C.AVCOL_RANGE_NB)
|
||||
)
|
||||
|
||||
func (r ColorRange) String() string {
|
||||
// https://ffmpeg.org/doxygen/7.0/pixdesc_8c.html#a590decf389632dd3af095f3096a92caf
|
||||
func (r ColorRange) Name() string {
|
||||
return C.GoString(C.av_color_range_name(C.enum_AVColorRange(r)))
|
||||
}
|
||||
|
||||
func (r ColorRange) String() string {
|
||||
return r.Name()
|
||||
}
|
||||
|
@@ -7,5 +7,6 @@ import (
|
||||
)
|
||||
|
||||
func TestColorRange(t *testing.T) {
|
||||
require.Equal(t, "tv", ColorRangeMpeg.Name())
|
||||
require.Equal(t, "tv", ColorRangeMpeg.String())
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ package astiav
|
||||
//#include <libavutil/pixfmt.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/pixfmt.h#L523
|
||||
// https://ffmpeg.org/doxygen/7.0/pixfmt_8h.html#aff71a069509a1ad3ff54d53a1c894c85
|
||||
type ColorSpace C.enum_AVColorSpace
|
||||
|
||||
const (
|
||||
@@ -27,6 +27,11 @@ const (
|
||||
ColorSpaceNb = ColorSpace(C.AVCOL_SPC_NB)
|
||||
)
|
||||
|
||||
func (s ColorSpace) String() string {
|
||||
// https://ffmpeg.org/doxygen/7.0/pixdesc_8c.html#a7a5b3f4d128f0a0112b4a91f75055339
|
||||
func (s ColorSpace) Name() string {
|
||||
return C.GoString(C.av_color_space_name(C.enum_AVColorSpace(s)))
|
||||
}
|
||||
|
||||
func (s ColorSpace) String() string {
|
||||
return s.Name()
|
||||
}
|
||||
|
@@ -7,5 +7,6 @@ import (
|
||||
)
|
||||
|
||||
func TestColorSpace(t *testing.T) {
|
||||
require.Equal(t, "bt709", ColorSpaceBt709.Name())
|
||||
require.Equal(t, "bt709", ColorSpaceBt709.String())
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavutil/pixfmt.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/pixfmt.h#L494
|
||||
// https://ffmpeg.org/doxygen/7.0/pixfmt_8h.html#ad4791ea14975f098b649db7fcd731ce6
|
||||
type ColorTransferCharacteristic C.enum_AVColorTransferCharacteristic
|
||||
|
||||
const (
|
||||
|
@@ -3,6 +3,7 @@ package astiav
|
||||
//#include <libavdevice/avdevice.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavd.html#ga7c90a3585267b55941ae2f7388c006b6
|
||||
func RegisterAllDevices() {
|
||||
C.avdevice_register_all()
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/dict.h#L84
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVDictionary.html
|
||||
type Dictionary struct {
|
||||
c *C.AVDictionary
|
||||
}
|
||||
@@ -24,6 +24,7 @@ func newDictionaryFromC(c *C.AVDictionary) *Dictionary {
|
||||
return &Dictionary{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__dict.html#ga8d9c2de72b310cef8e6a28c9cd3acbbe
|
||||
func (d *Dictionary) Set(key, value string, flags DictionaryFlags) error {
|
||||
ck := C.CString(key)
|
||||
defer C.free(unsafe.Pointer(ck))
|
||||
@@ -32,6 +33,7 @@ func (d *Dictionary) Set(key, value string, flags DictionaryFlags) error {
|
||||
return newError(C.av_dict_set(&d.c, ck, cv, C.int(flags)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__dict.html#gaca5ff7c251e60bd13164d13c82f21b79
|
||||
func (d *Dictionary) ParseString(i, keyValSep, pairsSep string, flags DictionaryFlags) error {
|
||||
ci := C.CString(i)
|
||||
defer C.free(unsafe.Pointer(ci))
|
||||
@@ -42,6 +44,7 @@ func (d *Dictionary) ParseString(i, keyValSep, pairsSep string, flags Dictionary
|
||||
return newError(C.av_dict_parse_string(&d.c, ci, ck, cp, C.int(flags)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__dict.html#gae67f143237b2cb2936c9b147aa6dfde3
|
||||
func (d *Dictionary) Get(key string, prev *DictionaryEntry, flags DictionaryFlags) *DictionaryEntry {
|
||||
ck := C.CString(key)
|
||||
defer C.free(unsafe.Pointer(ck))
|
||||
@@ -55,16 +58,19 @@ func (d *Dictionary) Get(key string, prev *DictionaryEntry, flags DictionaryFlag
|
||||
return nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__dict.html#ga1bafd682b1fbb90e48a4cc3814b820f7
|
||||
func (d *Dictionary) Free() {
|
||||
C.av_dict_free(&d.c)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet.html#ga2d2c8e143a2c98cf0aa31b072c286186
|
||||
func (d *Dictionary) Pack() []byte {
|
||||
return bytesFromC(func(size *C.size_t) *C.uint8_t {
|
||||
return C.av_packet_pack_dictionary(d.c, size)
|
||||
})
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet.html#gaae45c29cb3a29dc80b0b8f4ee9724492
|
||||
func (d *Dictionary) Unpack(b []byte) error {
|
||||
return bytesToC(b, func(b *C.uint8_t, size C.size_t) error {
|
||||
return newError(C.av_packet_unpack_dictionary(b, size, &d.c))
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavutil/dict.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/dict.h#L79
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVDictionaryEntry.html
|
||||
type DictionaryEntry struct {
|
||||
c *C.AVDictionaryEntry
|
||||
}
|
||||
@@ -12,10 +12,12 @@ func newDictionaryEntryFromC(c *C.AVDictionaryEntry) *DictionaryEntry {
|
||||
return &DictionaryEntry{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVDictionaryEntry.html#a38fc80176f8f839282bb61c03392e194
|
||||
func (e DictionaryEntry) Key() string {
|
||||
return C.GoString(e.c.key)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVDictionaryEntry.html#aa38678f2cad36f120d42e56449c5edb4
|
||||
func (e DictionaryEntry) Value() string {
|
||||
return C.GoString(e.c.value)
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavutil/dict.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__dict.html#gad9cbc53cec515b72ae7caa2e194c6bc0
|
||||
type DictionaryFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/dict.h#L67
|
||||
const (
|
||||
DictionaryFlagMatchCase = DictionaryFlag(C.AV_DICT_MATCH_CASE)
|
||||
DictionaryFlagIgnoreSuffix = DictionaryFlag(C.AV_DICT_IGNORE_SUFFIX)
|
||||
|
@@ -8,6 +8,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__video__display.html
|
||||
type DisplayMatrix [9]uint32
|
||||
|
||||
func NewDisplayMatrixFromBytes(b []byte) (m *DisplayMatrix, err error) {
|
||||
@@ -27,6 +28,7 @@ func NewDisplayMatrixFromBytes(b []byte) (m *DisplayMatrix, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__video__display.html#ga5964303bfe085ad33683bc2454768d4a
|
||||
func NewDisplayMatrixFromRotation(angle float64) *DisplayMatrix {
|
||||
m := &DisplayMatrix{}
|
||||
C.av_display_rotation_set((*C.int32_t)(unsafe.Pointer(&m[0])), C.double(angle))
|
||||
@@ -42,6 +44,7 @@ func (m DisplayMatrix) Bytes() []byte {
|
||||
}
|
||||
|
||||
// Rotation is a clockwise angle
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__video__display.html#gaac2ea94d3f66496c758349450b5b0217
|
||||
func (m DisplayMatrix) Rotation() float64 {
|
||||
return -float64(C.av_display_rotation_get((*C.int32_t)(unsafe.Pointer(&m[0]))))
|
||||
}
|
||||
|
3
error.go
3
error.go
@@ -4,9 +4,9 @@ package astiav
|
||||
//#include <errno.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__error.html#ga586e134e9dad8f57a218b2cd8734b601
|
||||
type Error int
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/error.h#L51
|
||||
const (
|
||||
ErrBsfNotFound = Error(C.AVERROR_BSF_NOT_FOUND)
|
||||
ErrBufferTooSmall = Error(C.AVERROR_BUFFER_TOO_SMALL)
|
||||
@@ -51,6 +51,7 @@ func newError(ret C.int) error {
|
||||
return Error(i)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__error.html#ga5792b4a2d18d7d9cb0efbcfc335dce24
|
||||
func (e Error) Error() string {
|
||||
s, _ := stringFromC(255, func(buf *C.char, size C.size_t) error {
|
||||
return newError(C.av_strerror(C.int(e), buf, size))
|
||||
|
@@ -6,7 +6,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/avfilter.h#L165
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilter.html
|
||||
type Filter struct {
|
||||
c *C.AVFilter
|
||||
}
|
||||
@@ -18,12 +18,14 @@ func newFilterFromC(c *C.AVFilter) *Filter {
|
||||
return &Filter{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#gadd774ec49e50edf00158248e1bfe4ae6
|
||||
func FindFilterByName(n string) *Filter {
|
||||
cn := C.CString(n)
|
||||
defer C.free(unsafe.Pointer(cn))
|
||||
return newFilterFromC(C.avfilter_get_by_name(cn))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilter.html#a28a4776f344f91055f42a4c2a1b15c0c
|
||||
func (f *Filter) Name() string {
|
||||
return C.GoString(f.c.name)
|
||||
}
|
||||
@@ -32,14 +34,17 @@ func (f *Filter) String() string {
|
||||
return f.Name()
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilter.html#a04e408702054370fbe35c8d5b49f68cb
|
||||
func (f *Filter) NbInputs() int {
|
||||
return int(f.c.nb_inputs)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilter.html#abb166cb2c9349de54d24aefb879608f4
|
||||
func (f *Filter) NbOutputs() int {
|
||||
return int(f.c.nb_outputs)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilter.html#ad311151fe6e8c87a89f895bef7c8b98b
|
||||
func (f *Filter) Inputs() (ps []*FilterPad) {
|
||||
for idx := 0; idx < f.NbInputs(); idx++ {
|
||||
ps = append(ps, newFilterPad(MediaType(C.avfilter_pad_get_type(f.c.inputs, C.int(idx)))))
|
||||
@@ -47,6 +52,7 @@ func (f *Filter) Inputs() (ps []*FilterPad) {
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilter.html#ad0608786fa3e1ca6e4cc4b67039f77d7
|
||||
func (f *Filter) Outputs() (ps []*FilterPad) {
|
||||
for idx := 0; idx < f.NbOutputs(); idx++ {
|
||||
ps = append(ps, newFilterPad(MediaType(C.avfilter_pad_get_type(f.c.outputs, C.int(idx)))))
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n7.0/libavfilter/avfilter.h#L1142
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterChain.html
|
||||
type FilterChain struct {
|
||||
c *C.AVFilterChain
|
||||
}
|
||||
@@ -19,6 +19,7 @@ func newFilterChainFromC(c *C.AVFilterChain) *FilterChain {
|
||||
return &FilterChain{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterChain.html#aedebb337fac024e27b499fb3a0321f3e
|
||||
func (fc *FilterChain) Filters() (fs []*FilterParams) {
|
||||
fcs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.AVFilterParams)(nil))](*C.AVFilterParams))(unsafe.Pointer(fc.c.filters))
|
||||
for i := 0; i < fc.NbFilters(); i++ {
|
||||
@@ -27,6 +28,7 @@ func (fc *FilterChain) Filters() (fs []*FilterParams) {
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterChain.html#abacf5280bd6db0d37a304b0dd0b6c54d
|
||||
func (fc *FilterChain) NbFilters() int {
|
||||
return int(fc.c.nb_filters)
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavfilter/avfilter.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#gace41bae000b621fc8804a93ce9f2d6e9
|
||||
type FilterCommandFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/avfilter.h#L739
|
||||
const (
|
||||
FilterCommandFlagOne = FilterCommandFlag(C.AVFILTER_CMD_FLAG_ONE)
|
||||
FilterCommandFlagFast = FilterCommandFlag(C.AVFILTER_CMD_FLAG_FAST)
|
||||
|
@@ -9,7 +9,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/avfilter.h#L67
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterContext.html
|
||||
type FilterContext struct {
|
||||
c *C.AVFilterContext
|
||||
}
|
||||
@@ -25,6 +25,7 @@ func newFilterContext(c *C.AVFilterContext) *FilterContext {
|
||||
|
||||
var _ Classer = (*FilterContext)(nil)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#ga0ea7664a3ce6bb677a830698d358a179
|
||||
func (fc *FilterContext) Free() {
|
||||
// Make sure to clone the classer before freeing the object since
|
||||
// the C free method may reset the pointer
|
||||
@@ -37,6 +38,7 @@ func (fc *FilterContext) Free() {
|
||||
}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterContext.html#a00ac82b13bb720349c138310f98874ca
|
||||
func (fc *FilterContext) Class() *Class {
|
||||
return newClassFromC(unsafe.Pointer(fc.c))
|
||||
}
|
||||
@@ -49,16 +51,19 @@ func newBuffersinkFilterContext(fc *FilterContext) *BuffersinkFilterContext {
|
||||
return &BuffersinkFilterContext{fc: fc}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink__accessors.html#gaad918036937648701c09f9612f42706e
|
||||
func (bfc *BuffersinkFilterContext) ChannelLayout() ChannelLayout {
|
||||
var cl C.AVChannelLayout
|
||||
C.av_buffersink_get_ch_layout(bfc.fc.c, &cl)
|
||||
return newChannelLayoutFromC(&cl)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink__accessors.html#gab80976e506ab88d23d94bb6d7a4051bd
|
||||
func (bfc *BuffersinkFilterContext) ColorRange() ColorRange {
|
||||
return ColorRange(C.av_buffersink_get_color_range(bfc.fc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink__accessors.html#gaad817cdcf5493c385126e8e17c5717f2
|
||||
func (bfc *BuffersinkFilterContext) ColorSpace() ColorSpace {
|
||||
return ColorSpace(C.av_buffersink_get_colorspace(bfc.fc.c))
|
||||
}
|
||||
@@ -67,10 +72,12 @@ func (bfc *BuffersinkFilterContext) FilterContext() *FilterContext {
|
||||
return bfc.fc
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink__accessors.html#ga55614fd28de2fa05b04f427390061d5b
|
||||
func (bfc *BuffersinkFilterContext) FrameRate() Rational {
|
||||
return newRationalFromC(C.av_buffersink_get_frame_rate(bfc.fc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink.html#ga71ae9c529c8da51681e12faa37d1a395
|
||||
func (bfc *BuffersinkFilterContext) GetFrame(f *Frame, fs BuffersinkFlags) error {
|
||||
var cf *C.AVFrame
|
||||
if f != nil {
|
||||
@@ -79,34 +86,42 @@ func (bfc *BuffersinkFilterContext) GetFrame(f *Frame, fs BuffersinkFlags) error
|
||||
return newError(C.av_buffersink_get_frame_flags(bfc.fc.c, cf, C.int(fs)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink__accessors.html#ga955ecf3680e71e10429d7500343be25c
|
||||
func (bfc *BuffersinkFilterContext) Height() int {
|
||||
return int(C.av_buffersink_get_h(bfc.fc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink__accessors.html#ga1eb8bbf583ffb7cc29aaa1944b1e699c
|
||||
func (bfc *BuffersinkFilterContext) MediaType() MediaType {
|
||||
return MediaType(C.av_buffersink_get_type(bfc.fc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink__accessors.html#ga402ddbef6f7347869725696846ac81eb
|
||||
func (bfc *BuffersinkFilterContext) PixelFormat() PixelFormat {
|
||||
return PixelFormat(C.av_buffersink_get_format(bfc.fc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink__accessors.html#gaa38ee33e1c7f6f7cb190bd2330e5f848
|
||||
func (bfc *BuffersinkFilterContext) SampleAspectRatio() Rational {
|
||||
return newRationalFromC(C.av_buffersink_get_sample_aspect_ratio(bfc.fc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink__accessors.html#ga402ddbef6f7347869725696846ac81eb
|
||||
func (bfc *BuffersinkFilterContext) SampleFormat() SampleFormat {
|
||||
return SampleFormat(C.av_buffersink_get_format(bfc.fc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink__accessors.html#ga2af714e82f48759551acdbc4488ded4a
|
||||
func (bfc *BuffersinkFilterContext) SampleRate() int {
|
||||
return int(C.av_buffersink_get_sample_rate(bfc.fc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink__accessors.html#gabc82f65ec7f4fa47c5216260639258a1
|
||||
func (bfc *BuffersinkFilterContext) TimeBase() Rational {
|
||||
return newRationalFromC(C.av_buffersink_get_time_base(bfc.fc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersink__accessors.html#gac8c86515d2ef56090395dfd74854c835
|
||||
func (bfc *BuffersinkFilterContext) Width() int {
|
||||
return int(C.av_buffersink_get_w(bfc.fc.c))
|
||||
}
|
||||
@@ -119,6 +134,7 @@ func newBuffersrcFilterContext(fc *FilterContext) *BuffersrcFilterContext {
|
||||
return &BuffersrcFilterContext{fc: fc}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi__buffersrc.html#ga73ed90c3c3407f36e54d65f91faaaed9
|
||||
func (bfc *BuffersrcFilterContext) AddFrame(f *Frame, fs BuffersrcFlags) error {
|
||||
var cf *C.AVFrame
|
||||
if f != nil {
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/avfilter.h#L861
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterGraph.html
|
||||
type FilterGraph struct {
|
||||
c *C.AVFilterGraph
|
||||
// We need to store filter contexts to clean classer once filter graph is freed
|
||||
@@ -25,10 +25,12 @@ func newFilterGraphFromC(c *C.AVFilterGraph) *FilterGraph {
|
||||
|
||||
var _ Classer = (*FilterGraph)(nil)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#ga6c778454b86f845805ffd814b4ce51d4
|
||||
func AllocFilterGraph() *FilterGraph {
|
||||
return newFilterGraphFromC(C.avfilter_graph_alloc())
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#ga871684449dac05050df238a18d0d493b
|
||||
func (g *FilterGraph) Free() {
|
||||
if g.c != nil {
|
||||
// Make sure to clone the classer before freeing the object since
|
||||
@@ -52,26 +54,32 @@ func (g *FilterGraph) Free() {
|
||||
}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#gadb442aca4e5a8c3ba740f6049f0a288b
|
||||
func (g *FilterGraph) String() string {
|
||||
return C.GoString(C.avfilter_graph_dump(g.c, nil))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterGraph.html#af00925dd69b474fac48887efc0e1ac94
|
||||
func (g *FilterGraph) Class() *Class {
|
||||
return newClassFromC(unsafe.Pointer(g.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterGraph.html#ac28dcbf76e6fdd800295a2738d41660e
|
||||
func (g *FilterGraph) ThreadCount() int {
|
||||
return int(g.c.nb_threads)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterGraph.html#ac28dcbf76e6fdd800295a2738d41660e
|
||||
func (g *FilterGraph) SetThreadCount(threadCount int) {
|
||||
g.c.nb_threads = C.int(threadCount)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterGraph.html#a7fd96bbd6d1a3b730681dc0bf5107a5e
|
||||
func (g *FilterGraph) ThreadType() ThreadType {
|
||||
return ThreadType(g.c.thread_type)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterGraph.html#a7fd96bbd6d1a3b730681dc0bf5107a5e
|
||||
func (g *FilterGraph) SetThreadType(t ThreadType) {
|
||||
g.c.thread_type = C.int(t)
|
||||
}
|
||||
@@ -86,6 +94,7 @@ func (args FilterArgs) String() string {
|
||||
return strings.Join(ss, ":")
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#gac0788a9ab6966dba9318b5d5c7524fea
|
||||
func (g *FilterGraph) NewFilterContext(f *Filter, name string, args FilterArgs) (*FilterContext, error) {
|
||||
ca := (*C.char)(nil)
|
||||
if len(args) > 0 {
|
||||
@@ -119,6 +128,7 @@ func (g *FilterGraph) NewBuffersrcFilterContext(f *Filter, name string, args Fil
|
||||
return newBuffersrcFilterContext(fc), nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#ga34f4ff420bd58da6747a3ff1fbedd001
|
||||
func (g *FilterGraph) Parse(content string, inputs, outputs *FilterInOut) error {
|
||||
cc := C.CString(content)
|
||||
defer C.free(unsafe.Pointer(cc))
|
||||
@@ -133,6 +143,7 @@ func (g *FilterGraph) Parse(content string, inputs, outputs *FilterInOut) error
|
||||
return newError(C.avfilter_graph_parse_ptr(g.c, cc, ic, oc, nil))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#ga2ecfd3667219b6cd1e37b7047cc0ef2b
|
||||
func (g *FilterGraph) ParseSegment(content string) (*FilterGraphSegment, error) {
|
||||
cc := C.CString(content)
|
||||
defer C.free(unsafe.Pointer(cc))
|
||||
@@ -143,10 +154,12 @@ func (g *FilterGraph) ParseSegment(content string) (*FilterGraphSegment, error)
|
||||
return newFilterGraphSegmentFromC(cs), nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#ga1896c46b7bc6ff1bdb1a4815faa9ad07
|
||||
func (g *FilterGraph) Configure() error {
|
||||
return newError(C.avfilter_graph_config(g.c, nil))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#gaaad7850fb5fe26d35e5d371ca75b79e1
|
||||
func (g *FilterGraph) SendCommand(target, cmd, args string, f FilterCommandFlags) (response string, err error) {
|
||||
targetc := C.CString(target)
|
||||
defer C.free(unsafe.Pointer(targetc))
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n7.0/libavfilter/avfilter.h#L1156
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterGraphSegment.html
|
||||
type FilterGraphSegment struct {
|
||||
c *C.AVFilterGraphSegment
|
||||
}
|
||||
@@ -19,10 +19,12 @@ func newFilterGraphSegmentFromC(c *C.AVFilterGraphSegment) *FilterGraphSegment {
|
||||
return &FilterGraphSegment{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#ga51283edd8f3685e1f33239f360e14ae8
|
||||
func (fgs *FilterGraphSegment) Free() {
|
||||
C.avfilter_graph_segment_free(&fgs.c)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterGraphSegment.html#ad5a2779af221d1520490fe2719f9e39a
|
||||
func (fgs *FilterGraphSegment) Chains() (cs []*FilterChain) {
|
||||
ccs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.AVFilterChain)(nil))](*C.AVFilterChain))(unsafe.Pointer(fgs.c.chains))
|
||||
for i := 0; i < fgs.NbChains(); i++ {
|
||||
@@ -31,6 +33,7 @@ func (fgs *FilterGraphSegment) Chains() (cs []*FilterChain) {
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterGraphSegment.html#ab7563eca151d89e693f6258de5ce0214
|
||||
func (fgs *FilterGraphSegment) NbChains() int {
|
||||
return int(fgs.c.nb_chains)
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavfilter/avfilter.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavfilter/avfilter.h#L1021
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterInOut.html
|
||||
type FilterInOut struct {
|
||||
c *C.AVFilterInOut
|
||||
}
|
||||
@@ -15,26 +15,32 @@ func newFilterInOutFromC(c *C.AVFilterInOut) *FilterInOut {
|
||||
return &FilterInOut{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#ga6e1c2931e15eb4283c59c6ccc8b83919
|
||||
func AllocFilterInOut() *FilterInOut {
|
||||
return newFilterInOutFromC(C.avfilter_inout_alloc())
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavfi.html#ga294500a9856260eb1552354fd9d9a6c4
|
||||
func (i *FilterInOut) Free() {
|
||||
C.avfilter_inout_free(&i.c)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterInOut.html#a88afecac258f51aab7e9a9db9e7a4d58
|
||||
func (i *FilterInOut) SetName(n string) {
|
||||
i.c.name = C.CString(n)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterInOut.html#a3227857d0b955b639f4950d13e4e6f40
|
||||
func (i *FilterInOut) SetFilterContext(c *FilterContext) {
|
||||
i.c.filter_ctx = (*C.AVFilterContext)(c.c)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterInOut.html#a386ff90d40aa22f5612dd5eca734ed48
|
||||
func (i *FilterInOut) SetPadIdx(idx int) {
|
||||
i.c.pad_idx = C.int(idx)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterInOut.html#af8c8cf9ffb650974d19e791f5bb7cf33
|
||||
func (i *FilterInOut) SetNext(n *FilterInOut) {
|
||||
var nc *C.AVFilterInOut
|
||||
if n != nil {
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavfilter/avfilter.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n7.0/libavfilter/avfilter.h#L1075
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterParams.html
|
||||
type FilterParams struct {
|
||||
c *C.AVFilterParams
|
||||
}
|
||||
@@ -15,6 +15,7 @@ func newFilterParamsFromC(c *C.AVFilterParams) *FilterParams {
|
||||
return &FilterParams{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFilterParams.html#a90edb3817b62f2ca70ea70001b84d001
|
||||
func (fp *FilterParams) FilterName() string {
|
||||
return C.GoString(fp.c.filter_name)
|
||||
}
|
||||
|
@@ -8,7 +8,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L1202
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html
|
||||
type FormatContext struct {
|
||||
c *C.AVFormatContext
|
||||
}
|
||||
@@ -24,10 +24,12 @@ func newFormatContextFromC(c *C.AVFormatContext) *FormatContext {
|
||||
|
||||
var _ Classer = (*FormatContext)(nil)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__core.html#gac7a91abf2f59648d995894711f070f62
|
||||
func AllocFormatContext() *FormatContext {
|
||||
return newFormatContextFromC(C.avformat_alloc_context())
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avformat_8h.html#af5930942120e38a4766dc0bb9e4cae74
|
||||
func AllocOutputFormatContext(of *OutputFormat, formatName, filename string) (*FormatContext, error) {
|
||||
fonc := (*C.char)(nil)
|
||||
if len(formatName) > 0 {
|
||||
@@ -50,6 +52,7 @@ func AllocOutputFormatContext(of *OutputFormat, formatName, filename string) (*F
|
||||
return newFormatContextFromC(fcc), nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__core.html#gac2990b13b68e831a408fce8e1d0d6445
|
||||
func (fc *FormatContext) Free() {
|
||||
// Make sure to clone the classer before freeing the object since
|
||||
// the C free method may reset the pointer
|
||||
@@ -62,56 +65,69 @@ func (fc *FormatContext) Free() {
|
||||
}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a972a02b9e3b542a426e323a8f8e3ea41
|
||||
func (fc *FormatContext) BitRate() int64 {
|
||||
return int64(fc.c.bit_rate)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a0c396740b9a2487aa57d4352d2dc1687
|
||||
func (fc *FormatContext) Class() *Class {
|
||||
return newClassFromC(unsafe.Pointer(fc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a4e6076343df1ffc2e16cedbba3f3f397
|
||||
func (fc *FormatContext) CtxFlags() FormatContextCtxFlags {
|
||||
return FormatContextCtxFlags(fc.c.ctx_flags)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#ad0ea78ac48f5bb0a15a15c1c472744d9
|
||||
func (fc *FormatContext) Duration() int64 {
|
||||
return int64(fc.c.duration)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a0302506d4b3434da77b8b3db43821aa0
|
||||
func (fc *FormatContext) EventFlags() FormatEventFlags {
|
||||
return FormatEventFlags(fc.c.event_flags)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a32379cc371463b235d54235d4af06a15
|
||||
func (fc *FormatContext) Flags() FormatContextFlags {
|
||||
return FormatContextFlags(fc.c.flags)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a32379cc371463b235d54235d4af06a15
|
||||
func (fc *FormatContext) SetFlags(f FormatContextFlags) {
|
||||
fc.c.flags = C.int(f)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a5b37acfe4024d92ee510064e80920b40
|
||||
func (fc *FormatContext) SetInterruptCallback() IOInterrupter {
|
||||
i := newDefaultIOInterrupter()
|
||||
fc.c.interrupt_callback = i.c
|
||||
return i
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a6c01f25ef062e0398b0b55dd337246ed
|
||||
func (fc *FormatContext) InputFormat() *InputFormat {
|
||||
return newInputFormatFromC(fc.c.iformat)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a5e6814c9de3c272396f07e2ff18c7b27
|
||||
func (fc *FormatContext) IOFlags() IOContextFlags {
|
||||
return IOContextFlags(fc.c.avio_flags)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a4d860662c014f88277c8f20e238fa694
|
||||
func (fc *FormatContext) MaxAnalyzeDuration() int64 {
|
||||
return int64(fc.c.max_analyze_duration)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a3019a56080ed2e3297ff25bc2ff88adf
|
||||
func (fc *FormatContext) Metadata() *Dictionary {
|
||||
return newDictionaryFromC(fc.c.metadata)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a3019a56080ed2e3297ff25bc2ff88adf
|
||||
func (fc *FormatContext) SetMetadata(d *Dictionary) {
|
||||
if d == nil {
|
||||
fc.c.metadata = nil
|
||||
@@ -120,18 +136,39 @@ func (fc *FormatContext) SetMetadata(d *Dictionary) {
|
||||
}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a58c8c4d0ea974e0fcb0ce06fb1174f9f
|
||||
func (fc *FormatContext) NbPrograms() int {
|
||||
return int(fc.c.nb_programs)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a4c2c5a4c758966349ff513e95154d062
|
||||
func (fc *FormatContext) Programs() (ps []*Program) {
|
||||
pcs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.AVProgram)(nil))](*C.AVProgram))(unsafe.Pointer(fc.c.programs))
|
||||
for i := 0; i < fc.NbPrograms(); i++ {
|
||||
ps = append(ps, newProgramFromC(pcs[i], fc))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a0b748d924898b08b89ff4974afd17285
|
||||
func (fc *FormatContext) NbStreams() int {
|
||||
return int(fc.c.nb_streams)
|
||||
}
|
||||
|
||||
func (fc *FormatContext) Streams() (ss []*Stream) {
|
||||
scs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.AVStream)(nil))](*C.AVStream))(unsafe.Pointer(fc.c.streams))
|
||||
for i := 0; i < fc.NbStreams(); i++ {
|
||||
ss = append(ss, newStreamFromC(scs[i]))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a37ba86cd5630097cdae01afbc2b40743
|
||||
func (fc *FormatContext) OutputFormat() *OutputFormat {
|
||||
return newOutputFormatFromC(fc.c.oformat)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a1e7324262b6b78522e52064daaa7bc87
|
||||
func (fc *FormatContext) Pb() *IOContext {
|
||||
// If the io context has been created using the format context's OpenInput() method, we need to
|
||||
// make sure to return the same go struct as the one stored in classers
|
||||
@@ -143,38 +180,27 @@ func (fc *FormatContext) Pb() *IOContext {
|
||||
return newIOContextFromC(fc.c.pb)
|
||||
}
|
||||
|
||||
func (fc *FormatContext) Programs() (ps []*Program) {
|
||||
pcs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.AVProgram)(nil))](*C.AVProgram))(unsafe.Pointer(fc.c.programs))
|
||||
for i := 0; i < fc.NbPrograms(); i++ {
|
||||
ps = append(ps, newProgramFromC(pcs[i], fc))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a1e7324262b6b78522e52064daaa7bc87
|
||||
func (fc *FormatContext) SetPb(i *IOContext) {
|
||||
fc.c.pb = i.c
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a2590129e00adfa726ab2033a10e905e9
|
||||
func (fc *FormatContext) StartTime() int64 {
|
||||
return int64(fc.c.start_time)
|
||||
}
|
||||
|
||||
func (fc *FormatContext) Streams() (ss []*Stream) {
|
||||
scs := (*[(math.MaxInt32 - 1) / unsafe.Sizeof((*C.AVStream)(nil))](*C.AVStream))(unsafe.Pointer(fc.c.streams))
|
||||
for i := 0; i < fc.NbStreams(); i++ {
|
||||
ss = append(ss, newStreamFromC(scs[i]))
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a5017684cf0a84c990f60c8d50adec144
|
||||
func (fc *FormatContext) StrictStdCompliance() StrictStdCompliance {
|
||||
return StrictStdCompliance(fc.c.strict_std_compliance)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a5017684cf0a84c990f60c8d50adec144
|
||||
func (fc *FormatContext) SetStrictStdCompliance(strictStdCompliance StrictStdCompliance) {
|
||||
fc.c.strict_std_compliance = C.int(strictStdCompliance)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__decoding.html#gac05d61a2b492ae3985c658f34622c19d
|
||||
func (fc *FormatContext) OpenInput(url string, fmt *InputFormat, d *Dictionary) error {
|
||||
var urlc *C.char
|
||||
if url != "" {
|
||||
@@ -198,6 +224,7 @@ func (fc *FormatContext) OpenInput(url string, fmt *InputFormat, d *Dictionary)
|
||||
return nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__decoding.html#gae804b99aec044690162b8b9b110236a4
|
||||
func (fc *FormatContext) CloseInput() {
|
||||
if fc.c != nil {
|
||||
// Make sure to clone the classer before freeing the object since
|
||||
@@ -219,10 +246,12 @@ func (fc *FormatContext) CloseInput() {
|
||||
}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__core.html#gab31f7c7c99dcadead38e8e83e0fdb828
|
||||
func (fc *FormatContext) NewProgram(id int) *Program {
|
||||
return newProgramFromC(C.av_new_program(fc.c, C.int(id)), fc)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__core.html#gaf2c94216a6a19144e86cac843a0a4409
|
||||
func (fc *FormatContext) NewStream(c *Codec) *Stream {
|
||||
var cc *C.AVCodec
|
||||
if c != nil {
|
||||
@@ -231,6 +260,7 @@ func (fc *FormatContext) NewStream(c *Codec) *Stream {
|
||||
return newStreamFromC(C.avformat_new_stream(fc.c, cc))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__decoding.html#gad42172e27cddafb81096939783b157bb
|
||||
func (fc *FormatContext) FindStreamInfo(d *Dictionary) error {
|
||||
var dc **C.AVDictionary
|
||||
if d != nil {
|
||||
@@ -239,6 +269,7 @@ func (fc *FormatContext) FindStreamInfo(d *Dictionary) error {
|
||||
return newError(C.avformat_find_stream_info(fc.c, dc))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__decoding.html#ga4fdb3084415a82e3810de6ee60e46a61
|
||||
func (fc *FormatContext) ReadFrame(p *Packet) error {
|
||||
var pc *C.AVPacket
|
||||
if p != nil {
|
||||
@@ -247,14 +278,17 @@ func (fc *FormatContext) ReadFrame(p *Packet) error {
|
||||
return newError(C.av_read_frame(fc.c, pc))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__decoding.html#gaa23f7619d8d4ea0857065d9979c75ac8
|
||||
func (fc *FormatContext) SeekFrame(streamIndex int, timestamp int64, f SeekFlags) error {
|
||||
return newError(C.av_seek_frame(fc.c, C.int(streamIndex), C.int64_t(timestamp), C.int(f)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__decoding.html#gaa03a82c5fd4fe3af312d229ca94cd6f3
|
||||
func (fc *FormatContext) Flush() error {
|
||||
return newError(C.avformat_flush(fc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__encoding.html#ga18b7b10bb5b94c4842de18166bc677cb
|
||||
func (fc *FormatContext) WriteHeader(d *Dictionary) error {
|
||||
var dc **C.AVDictionary
|
||||
if d != nil {
|
||||
@@ -263,6 +297,7 @@ func (fc *FormatContext) WriteHeader(d *Dictionary) error {
|
||||
return newError(C.avformat_write_header(fc.c, dc))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__encoding.html#gaa85cc1774f18f306cd20a40fc50d0b36
|
||||
func (fc *FormatContext) WriteFrame(p *Packet) error {
|
||||
var pc *C.AVPacket
|
||||
if p != nil {
|
||||
@@ -271,6 +306,7 @@ func (fc *FormatContext) WriteFrame(p *Packet) error {
|
||||
return newError(C.av_write_frame(fc.c, pc))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__encoding.html#ga37352ed2c63493c38219d935e71db6c1
|
||||
func (fc *FormatContext) WriteInterleavedFrame(p *Packet) error {
|
||||
var pc *C.AVPacket
|
||||
if p != nil {
|
||||
@@ -279,10 +315,12 @@ func (fc *FormatContext) WriteInterleavedFrame(p *Packet) error {
|
||||
return newError(C.av_interleaved_write_frame(fc.c, pc))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__encoding.html#ga7f14007e7dc8f481f054b21614dfec13
|
||||
func (fc *FormatContext) WriteTrailer() error {
|
||||
return newError(C.av_write_trailer(fc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__misc.html#gafa6fbfe5c1bf6792fd6e33475b6056bd
|
||||
func (fc *FormatContext) GuessSampleAspectRatio(s *Stream, f *Frame) Rational {
|
||||
var cf *C.AVFrame
|
||||
if f != nil {
|
||||
@@ -291,6 +329,7 @@ func (fc *FormatContext) GuessSampleAspectRatio(s *Stream, f *Frame) Rational {
|
||||
return newRationalFromC(C.av_guess_sample_aspect_ratio(fc.c, s.c, cf))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__misc.html#ga698e6aa73caa9616851092e2be15875d
|
||||
func (fc *FormatContext) GuessFrameRate(s *Stream, f *Frame) Rational {
|
||||
var cf *C.AVFrame
|
||||
if f != nil {
|
||||
@@ -299,16 +338,10 @@ func (fc *FormatContext) GuessFrameRate(s *Stream, f *Frame) Rational {
|
||||
return newRationalFromC(C.av_guess_frame_rate(fc.c, s.c, cf))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__misc.html#gaa2a7353a6bb0c8726797abd56b176af0
|
||||
func (fc *FormatContext) SDPCreate() (string, error) {
|
||||
return sdpCreate([]*FormatContext{fc})
|
||||
}
|
||||
|
||||
func sdpCreate(fcs []*FormatContext) (string, error) {
|
||||
return stringFromC(1024, func(buf *C.char, size C.size_t) error {
|
||||
fccs := []*C.AVFormatContext{}
|
||||
for _, fc := range fcs {
|
||||
fccs = append(fccs, fc.c)
|
||||
}
|
||||
return newError(C.av_sdp_create(&fccs[0], C.int(len(fcs)), buf, C.int(size)))
|
||||
fccs := []*C.AVFormatContext{fc.c}
|
||||
return newError(C.av_sdp_create(&fccs[0], C.int(len(fccs)), buf, C.int(size)))
|
||||
})
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavformat/avformat.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avformat_8h.html#a42e3c3d72e561fdc501613962fccc4aa
|
||||
type FormatContextCtxFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L1153
|
||||
const (
|
||||
FormatContextCtxFlagNoHeader = FormatContextCtxFlag(C.AVFMTCTX_NOHEADER)
|
||||
FormatContextCtxFlagUnseekable = FormatContextCtxFlag(C.AVFMTCTX_UNSEEKABLE)
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavformat/avformat.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avformat_8h.html#a69e2c8bc119c0245ff6092f9db4d12ae
|
||||
type FormatContextFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L1321
|
||||
const (
|
||||
FormatContextFlagGenPts = FormatContextFlag(C.AVFMT_FLAG_GENPTS)
|
||||
FormatContextFlagIgnidx = FormatContextFlag(C.AVFMT_FLAG_IGNIDX)
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavformat/avformat.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avformat_8h.html#a19485b8b52e579db560875e9a1e44e7a
|
||||
type FormatEventFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L1519
|
||||
const (
|
||||
FormatEventFlagMetadataUpdated = FormatEventFlag(C.AVFMT_EVENT_FLAG_METADATA_UPDATED)
|
||||
)
|
||||
|
52
frame.go
52
frame.go
@@ -11,9 +11,10 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/frame_8h.html#add80189702cf0f5ea82718576fb43201
|
||||
const NumDataPointers = uint(C.AV_NUM_DATA_POINTERS)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/frame.h#L317
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html
|
||||
type Frame struct {
|
||||
c *C.AVFrame
|
||||
}
|
||||
@@ -25,67 +26,83 @@ func newFrameFromC(c *C.AVFrame) *Frame {
|
||||
return &Frame{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__frame.html#gac700017c5270c79c1e1befdeeb008b2f
|
||||
func AllocFrame() *Frame {
|
||||
return newFrameFromC(C.av_frame_alloc())
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__frame.html#gac700017c5270c79c1e1befdeeb008b2f
|
||||
func (f *Frame) AllocBuffer(align int) error {
|
||||
return newError(C.av_frame_get_buffer(f.c, C.int(align)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/hwcontext_8c.html#adfa5aaa3a4f69b163ea30cadc6d663dc
|
||||
func (f *Frame) AllocHardwareBuffer(hfc *HardwareFrameContext) error {
|
||||
return newError(C.av_hwframe_get_buffer(hfc.c, f.c, 0))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__picture.html#ga841e0a89a642e24141af1918a2c10448
|
||||
func (f *Frame) AllocImage(align int) error {
|
||||
return newError(C.av_image_alloc(&f.c.data[0], &f.c.linesize[0], f.c.width, f.c.height, (C.enum_AVPixelFormat)(f.c.format), C.int(align)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__sampmanip.html#ga4db4c77f928d32c7d8854732f50b8c04
|
||||
func (f *Frame) AllocSamples(align int) error {
|
||||
return newError(C.av_samples_alloc(&f.c.data[0], &f.c.linesize[0], f.c.ch_layout.nb_channels, f.c.nb_samples, (C.enum_AVSampleFormat)(f.c.format), C.int(align)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#ae291cdec7758599e765bc9e3edbb3065
|
||||
func (f *Frame) ChannelLayout() ChannelLayout {
|
||||
l, _ := newChannelLayoutFromC(&f.c.ch_layout).clone()
|
||||
return l
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#ae291cdec7758599e765bc9e3edbb3065
|
||||
func (f *Frame) SetChannelLayout(l ChannelLayout) {
|
||||
l.copy(&f.c.ch_layout) //nolint: errcheck
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a853afbad220bbc58549b4860732a3aa5
|
||||
func (f *Frame) ColorRange() ColorRange {
|
||||
return ColorRange(f.c.color_range)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a853afbad220bbc58549b4860732a3aa5
|
||||
func (f *Frame) SetColorRange(r ColorRange) {
|
||||
f.c.color_range = C.enum_AVColorRange(r)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a9262c231f1f64869439b4fe587fe1710
|
||||
func (f *Frame) ColorSpace() ColorSpace {
|
||||
return ColorSpace(f.c.colorspace)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a9262c231f1f64869439b4fe587fe1710
|
||||
func (f *Frame) SetColorSpace(s ColorSpace) {
|
||||
f.c.colorspace = C.enum_AVColorSpace(s)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a1d0f65014a8d1bf78cec8cbed2304992
|
||||
func (f *Frame) Data() *FrameData {
|
||||
return newFrameData(newFrameDataFrame(f))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a3f89733f429c98ba5bc64373fb0a3f13
|
||||
func (f *Frame) Height() int {
|
||||
return int(f.c.height)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a3f89733f429c98ba5bc64373fb0a3f13
|
||||
func (f *Frame) SetHeight(h int) {
|
||||
f.c.height = C.int(h)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#afe0345882416bbb9d3a86720dcaa9252
|
||||
func (f *Frame) KeyFrame() bool {
|
||||
return int(f.c.key_frame) > 0
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#afe0345882416bbb9d3a86720dcaa9252
|
||||
func (f *Frame) SetKeyFrame(k bool) {
|
||||
i := 0
|
||||
if k {
|
||||
@@ -94,6 +111,7 @@ func (f *Frame) SetKeyFrame(k bool) {
|
||||
f.c.key_frame = C.int(i)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__picture.html#ga24a67963c3ae0054a2a4bab35930e694
|
||||
func (f *Frame) ImageBufferSize(align int) (int, error) {
|
||||
ret := C.av_image_get_buffer_size((C.enum_AVPixelFormat)(f.c.format), f.c.width, f.c.height, C.int(align))
|
||||
if err := newError(ret); err != nil {
|
||||
@@ -102,6 +120,7 @@ func (f *Frame) ImageBufferSize(align int) (int, error) {
|
||||
return int(ret), nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__picture.html#ga6f8576f1ef0c2d9a9f7c5ac7f9a28c52
|
||||
func (f *Frame) ImageCopyToBuffer(b []byte, align int) (int, error) {
|
||||
ret := C.av_image_copy_to_buffer((*C.uint8_t)(unsafe.Pointer(&b[0])), C.int(len(b)), &f.c.data[0], &f.c.linesize[0], (C.enum_AVPixelFormat)(f.c.format), f.c.width, f.c.height, C.int(align))
|
||||
if err := newError(ret); err != nil {
|
||||
@@ -110,6 +129,7 @@ func (f *Frame) ImageCopyToBuffer(b []byte, align int) (int, error) {
|
||||
return int(ret), nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__picture.html#ga3fa8e484cc214e8c7b9026825b5f4078
|
||||
func (f *Frame) ImageFillBlack() error {
|
||||
linesize := [NumDataPointers]C.ptrdiff_t{}
|
||||
for i := 0; i < int(NumDataPointers); i++ {
|
||||
@@ -118,6 +138,7 @@ func (f *Frame) ImageFillBlack() error {
|
||||
return newError(C.av_image_fill_black(&f.c.data[0], &linesize[0], (C.enum_AVPixelFormat)(f.c.format), (C.enum_AVColorRange)(f.c.color_range), f.c.width, f.c.height))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__sampfmts.html#gaa7368bc4e3a366b688e81938ed55eb06
|
||||
func (f *Frame) SamplesBufferSize(align int) (int, error) {
|
||||
ret := C.av_samples_get_buffer_size(nil, f.c.ch_layout.nb_channels, f.c.nb_samples, (C.enum_AVSampleFormat)(f.c.format), C.int(align))
|
||||
if err := newError(ret); err != nil {
|
||||
@@ -134,10 +155,12 @@ func (f *Frame) SamplesCopyToBuffer(b []byte, align int) (int, error) {
|
||||
return int(ret), nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__sampmanip.html#gabcb166e22938c7d93c2d609529c458bb
|
||||
func (f *Frame) SamplesFillSilence() error {
|
||||
return newError(C.av_samples_set_silence(&f.c.data[0], 0, f.c.nb_samples, f.c.ch_layout.nb_channels, (C.enum_AVSampleFormat)(f.c.format)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#aa52bfc6605f6a3059a0c3226cc0f6567
|
||||
func (f *Frame) Linesize() [NumDataPointers]int {
|
||||
o := [NumDataPointers]int{}
|
||||
for i := 0; i < int(NumDataPointers); i++ {
|
||||
@@ -146,102 +169,127 @@ func (f *Frame) Linesize() [NumDataPointers]int {
|
||||
return o
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a02f45ab8191aea1660159f1e464237ea
|
||||
func (f *Frame) NbSamples() int {
|
||||
return int(f.c.nb_samples)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a02f45ab8191aea1660159f1e464237ea
|
||||
func (f *Frame) SetNbSamples(n int) {
|
||||
f.c.nb_samples = C.int(n)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#af9920fc3fbfa347b8943ae461b50d18b
|
||||
func (f *Frame) PictureType() PictureType {
|
||||
return PictureType(f.c.pict_type)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#af9920fc3fbfa347b8943ae461b50d18b
|
||||
func (f *Frame) SetPictureType(t PictureType) {
|
||||
f.c.pict_type = C.enum_AVPictureType(t)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#aed14fa772ce46881020fd1545c86432c
|
||||
func (f *Frame) PixelFormat() PixelFormat {
|
||||
return PixelFormat(f.c.format)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#aed14fa772ce46881020fd1545c86432c
|
||||
func (f *Frame) SetPixelFormat(pf PixelFormat) {
|
||||
f.c.format = C.int(pf)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#aa52951f35ec9e303d3dfeb4b3e44248a
|
||||
func (f *Frame) PktDts() int64 {
|
||||
return int64(f.c.pkt_dts)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a0452833e3ab6ddd7acbf82817a7818a4
|
||||
func (f *Frame) Pts() int64 {
|
||||
return int64(f.c.pts)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a0452833e3ab6ddd7acbf82817a7818a4
|
||||
func (f *Frame) SetPts(i int64) {
|
||||
f.c.pts = C.int64_t(i)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a62f9c20541a83d37db7072126ff0060d
|
||||
func (f *Frame) SampleAspectRatio() Rational {
|
||||
return newRationalFromC(f.c.sample_aspect_ratio)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a62f9c20541a83d37db7072126ff0060d
|
||||
func (f *Frame) SetSampleAspectRatio(r Rational) {
|
||||
f.c.sample_aspect_ratio = r.c
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#aed14fa772ce46881020fd1545c86432c
|
||||
func (f *Frame) SampleFormat() SampleFormat {
|
||||
return SampleFormat(f.c.format)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#aed14fa772ce46881020fd1545c86432c
|
||||
func (f *Frame) SetSampleFormat(sf SampleFormat) {
|
||||
f.c.format = C.int(sf)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#ac85daa1316e1f47e78da0ca19b7c60e6
|
||||
func (f *Frame) SampleRate() int {
|
||||
return int(f.c.sample_rate)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#ac85daa1316e1f47e78da0ca19b7c60e6
|
||||
func (f *Frame) SetSampleRate(r int) {
|
||||
f.c.sample_rate = C.int(r)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__frame.html#gae05843b941b79e56b955674e581a8262
|
||||
func (f *Frame) NewSideData(t FrameSideDataType, size uint64) *FrameSideData {
|
||||
return newFrameSideDataFromC(C.av_frame_new_side_data(f.c, (C.enum_AVFrameSideDataType)(t), C.size_t(size)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__frame.html#gadec0efb470b1eead6a979333d9deca0c
|
||||
func (f *Frame) SideData(t FrameSideDataType) *FrameSideData {
|
||||
return newFrameSideDataFromC(C.av_frame_get_side_data(f.c, (C.enum_AVFrameSideDataType)(t)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a1e71ce60cedd5f3b6811714a9f7f9e0a
|
||||
func (f *Frame) Width() int {
|
||||
return int(f.c.width)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrame.html#a1e71ce60cedd5f3b6811714a9f7f9e0a
|
||||
func (f *Frame) SetWidth(w int) {
|
||||
f.c.width = C.int(w)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/hwcontext_8c.html#abf1b1664b8239d953ae2cac8b643815a
|
||||
func (f *Frame) TransferHardwareData(dst *Frame) error {
|
||||
return newError(C.av_hwframe_transfer_data(dst.c, f.c, 0))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__frame.html#ga979d73f3228814aee56aeca0636e37cc
|
||||
func (f *Frame) Free() {
|
||||
C.av_frame_free(&f.c)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__frame.html#ga88b0ecbc4eb3453eef3fbefa3bddeb7c
|
||||
func (f *Frame) Ref(src *Frame) error {
|
||||
return newError(C.av_frame_ref(f.c, src.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__frame.html#ga46d6d32f6482a3e9c19203db5877105b
|
||||
func (f *Frame) Clone() *Frame {
|
||||
return newFrameFromC(C.av_frame_clone(f.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__frame.html#ga0a2b687f9c1c5ed0089b01fd61227108
|
||||
func (f *Frame) Unref() {
|
||||
C.av_frame_unref(f.c)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__frame.html#ga709e62bc2917ffd84c5c0f4e1dfc48f7
|
||||
func (f *Frame) MoveRef(src *Frame) {
|
||||
C.av_frame_move_ref(f.c, src.c)
|
||||
}
|
||||
@@ -250,10 +298,12 @@ func (f *Frame) UnsafePointer() unsafe.Pointer {
|
||||
return unsafe.Pointer(f.c)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__frame.html#ga3ba755bada5c3c8883361ef43fb5fb7a
|
||||
func (f *Frame) IsWritable() bool {
|
||||
return C.av_frame_is_writable(f.c) > 0
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__frame.html#gadd5417c06f5a6b419b0dbd8f0ff363fd
|
||||
func (f *Frame) MakeWritable() error {
|
||||
return newError(C.av_frame_make_writable(f.c))
|
||||
}
|
||||
|
@@ -362,7 +362,7 @@ func (f *frameDataFrame) planes(b []byte, align int) ([]frameDataPlane, error) {
|
||||
planeSizes[i] = int(cLinesize)
|
||||
}
|
||||
case MediaTypeVideo:
|
||||
// Below is mostly inspired by https://github.com/FFmpeg/FFmpeg/blob/n5.1.2/libavutil/imgutils.c#L466
|
||||
// Below is mostly inspired by https://ffmpeg.org/doxygen/7.0/group__lavu__picture.html#ga24a67963c3ae0054a2a4bab35930e694
|
||||
|
||||
// Get linesize
|
||||
var cLinesizes [8]C.int
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/frame.h#L223
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrameSideData.html
|
||||
type FrameSideData struct {
|
||||
c *C.AVFrameSideData
|
||||
}
|
||||
@@ -19,6 +19,7 @@ func newFrameSideDataFromC(c *C.AVFrameSideData) *FrameSideData {
|
||||
return &FrameSideData{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrameSideData.html#a76937ad48652a5a0cc4bff65fc6c886e
|
||||
func (d *FrameSideData) Data() []byte {
|
||||
return bytesFromC(func(size *C.size_t) *C.uint8_t {
|
||||
*size = d.c.size
|
||||
@@ -26,10 +27,12 @@ func (d *FrameSideData) Data() []byte {
|
||||
})
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrameSideData.html#a76937ad48652a5a0cc4bff65fc6c886e
|
||||
func (d *FrameSideData) SetData(b []byte) {
|
||||
C.memcpy(unsafe.Pointer(d.c.data), unsafe.Pointer(&b[0]), C.size_t(math.Min(float64(len(b)), float64(d.c.size))))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVFrameSideData.html#a07ff3499827c124591ff4bae6f68eec0
|
||||
func (d *FrameSideData) Type() FrameSideDataType {
|
||||
return FrameSideDataType(d.c._type)
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavutil/frame.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/frame.h#L48
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__frame.html#gae01fa7e427274293aacdf2adc17076bc
|
||||
type FrameSideDataType C.enum_AVFrameSideDataType
|
||||
|
||||
const (
|
||||
|
@@ -7,11 +7,12 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/hwcontext.h#L61
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVHWDeviceContext.html
|
||||
type HardwareDeviceContext struct {
|
||||
c *C.AVBufferRef
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/hwcontext_8c.html#a21fbd088225e4e25c4d9a01b3f5e8c51
|
||||
func CreateHardwareDeviceContext(t HardwareDeviceType, device string, options *Dictionary, flags int) (*HardwareDeviceContext, error) {
|
||||
hdc := HardwareDeviceContext{}
|
||||
deviceC := (*C.char)(nil)
|
||||
|
@@ -6,7 +6,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/hwcontext.h#L27
|
||||
// https://ffmpeg.org/doxygen/7.0/hwcontext_8h.html#acf25724be4b066a51ad86aa9214b0d34
|
||||
type HardwareDeviceType C.enum_AVHWDeviceType
|
||||
|
||||
const (
|
||||
@@ -24,10 +24,16 @@ const (
|
||||
HardwareDeviceTypeVulkan = HardwareDeviceType(C.AV_HWDEVICE_TYPE_VULKAN)
|
||||
)
|
||||
|
||||
func (t HardwareDeviceType) String() string {
|
||||
// https://ffmpeg.org/doxygen/7.0/hwcontext_8h.html#afb2b99a15f3fdde25a2fd19353ac5a67
|
||||
func (t HardwareDeviceType) Name() string {
|
||||
return C.GoString(C.av_hwdevice_get_type_name((C.enum_AVHWDeviceType)(t)))
|
||||
}
|
||||
|
||||
func (t HardwareDeviceType) String() string {
|
||||
return t.Name()
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/hwcontext_8h.html#a541943ddced791765349645a30adfa4d
|
||||
func FindHardwareDeviceTypeByName(n string) HardwareDeviceType {
|
||||
cn := C.CString(n)
|
||||
defer C.free(unsafe.Pointer(cn))
|
||||
|
@@ -7,6 +7,7 @@ import (
|
||||
)
|
||||
|
||||
func TestHardwareDeviceType(t *testing.T) {
|
||||
require.Equal(t, "cuda", HardwareDeviceTypeCUDA.Name())
|
||||
require.Equal(t, "cuda", HardwareDeviceTypeCUDA.String())
|
||||
require.Equal(t, FindHardwareDeviceTypeByName("cuda"), HardwareDeviceTypeCUDA)
|
||||
}
|
||||
|
@@ -6,7 +6,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n7.0/libavutil/hwcontext.h#L115
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVHWFramesContext.html
|
||||
type HardwareFrameContext struct {
|
||||
c *C.struct_AVBufferRef
|
||||
}
|
||||
@@ -18,6 +18,7 @@ func newHardwareFrameContextFromC(c *C.struct_AVBufferRef) *HardwareFrameContext
|
||||
return &HardwareFrameContext{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/hwcontext_8c.html#ac45a7c039eb4e084b692f69ff5f2e217
|
||||
func AllocHardwareFrameContext(hdc *HardwareDeviceContext) *HardwareFrameContext {
|
||||
return newHardwareFrameContextFromC(C.av_hwframe_ctx_alloc(hdc.c))
|
||||
}
|
||||
@@ -26,26 +27,32 @@ func (hfc *HardwareFrameContext) data() *C.AVHWFramesContext {
|
||||
return (*C.AVHWFramesContext)(unsafe.Pointer((hfc.c.data)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVHWFramesContext.html#a9e6f29d0f744930cdd0e8bdff8771520
|
||||
func (hfc *HardwareFrameContext) SetWidth(width int) {
|
||||
hfc.data().width = C.int(width)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVHWFramesContext.html#ae61bbe1d8645a0c573085e29f1d0a58f
|
||||
func (hfc *HardwareFrameContext) SetHeight(height int) {
|
||||
hfc.data().height = C.int(height)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVHWFramesContext.html#a045bc1713932804f6ceef170a5578e0e
|
||||
func (hfc *HardwareFrameContext) SetPixelFormat(format PixelFormat) {
|
||||
hfc.data().format = C.enum_AVPixelFormat(format)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVHWFramesContext.html#a663a9aceca97aa7b2426c9aba6543e4a
|
||||
func (hfc *HardwareFrameContext) SetSoftwarePixelFormat(swFormat PixelFormat) {
|
||||
hfc.data().sw_format = C.enum_AVPixelFormat(swFormat)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVHWFramesContext.html#a9c3a94dcd9c96e19059b56a6bae9c764
|
||||
func (hfc *HardwareFrameContext) SetInitialPoolSize(initialPoolSize int) {
|
||||
hfc.data().initial_pool_size = C.int(initialPoolSize)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/hwcontext_8c.html#a66a7e1ebc7e459ce07d3de6639ac7e38
|
||||
func (hfc *HardwareFrameContext) Initialize() error {
|
||||
return newError(C.av_hwframe_ctx_init(hfc.c))
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ package astiav
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L650
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVInputFormat.html
|
||||
type InputFormat struct {
|
||||
c *C.AVInputFormat
|
||||
}
|
||||
@@ -16,21 +16,24 @@ func newInputFormatFromC(c *C.AVInputFormat) *InputFormat {
|
||||
return &InputFormat{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__decoding.html#ga40034b6d64d372e1c989e16dde4b459a
|
||||
func FindInputFormat(name string) *InputFormat {
|
||||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
return newInputFormatFromC(C.av_find_input_format(cname))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVInputFormat.html#a1b30f6647d0c2faf38ba8786d7c3a838
|
||||
func (f *InputFormat) Flags() IOFormatFlags {
|
||||
return IOFormatFlags(f.c.flags)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVInputFormat.html#a850db3eb225e22b64f3304d72134ca0c
|
||||
func (f *InputFormat) Name() string {
|
||||
return C.GoString(f.c.name)
|
||||
}
|
||||
|
||||
// LongName Description of the format, meant to be more human-readable than Name.
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVInputFormat.html#a1f67064a527941944017f1dfe65d3aa9
|
||||
func (f *InputFormat) LongName() string {
|
||||
return C.GoString(f.c.long_name)
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ package astiav
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avr32_2intreadwrite_8h.html#ace46e41b9bd6cac88fb7109ffd657f9a
|
||||
func RL32(i []byte) uint32 {
|
||||
if len(i) == 0 {
|
||||
return 0
|
||||
@@ -11,6 +12,7 @@ func RL32(i []byte) uint32 {
|
||||
return uint32(C.astiavRL32((*C.uint8_t)(unsafe.Pointer(&i[0]))))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avr32_2intreadwrite_8h.html#ace46e41b9bd6cac88fb7109ffd657f9a
|
||||
func RL32WithOffset(i []byte, offset uint) uint32 {
|
||||
if len(i) == 0 {
|
||||
return 0
|
||||
|
@@ -11,7 +11,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avio.h#L161
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVIOContext.html
|
||||
type IOContext struct {
|
||||
c *C.AVIOContext
|
||||
handlerID unsafe.Pointer
|
||||
@@ -34,6 +34,7 @@ type IOContextSeekFunc func(offset int64, whence int) (n int64, err error)
|
||||
|
||||
type IOContextWriteFunc func(b []byte) (n int, err error)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avio_8h.html#a50c588d3c44707784f3afde39e1c181c
|
||||
func AllocIOContext(bufferSize int, writable bool, readFunc IOContextReadFunc, seekFunc IOContextSeekFunc, writeFunc IOContextWriteFunc) (ic *IOContext, err error) {
|
||||
// Invalid buffer size
|
||||
if bufferSize <= 0 {
|
||||
@@ -107,6 +108,7 @@ func AllocIOContext(bufferSize int, writable bool, readFunc IOContextReadFunc, s
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avio_8c.html#ab1b99c5b70aa59f15ab7cd4cbb40381e
|
||||
func OpenIOContext(filename string, flags IOContextFlags) (*IOContext, error) {
|
||||
cfi := C.CString(filename)
|
||||
defer C.free(unsafe.Pointer(cfi))
|
||||
@@ -121,6 +123,7 @@ func (ic *IOContext) Class() *Class {
|
||||
return newClassFromC(unsafe.Pointer(ic.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avio_8c.html#ae118a1f37f1e48617609ead9910aac15
|
||||
func (ic *IOContext) Close() error {
|
||||
if ic.c != nil {
|
||||
// Make sure to clone the classer before freeing the object since
|
||||
@@ -138,6 +141,7 @@ func (ic *IOContext) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avio_8h.html#ad1baf8cd6711f05a45d0339cafe2d21d
|
||||
func (ic *IOContext) Free() {
|
||||
if ic.c != nil {
|
||||
if ic.c.buffer != nil {
|
||||
@@ -160,6 +164,7 @@ func (ic *IOContext) Free() {
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avio_8h.html#a53843d2cbe6282d994fcf59c03d59294
|
||||
func (ic *IOContext) Read(b []byte) (n int, err error) {
|
||||
// Nothing to read
|
||||
if b == nil || len(b) <= 0 {
|
||||
@@ -189,6 +194,7 @@ func (ic *IOContext) Read(b []byte) (n int, err error) {
|
||||
return
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avio_8h.html#a03e23bf0144030961c34e803c71f614f
|
||||
func (ic *IOContext) Seek(offset int64, whence int) (int64, error) {
|
||||
ret := C.avio_seek(ic.c, C.int64_t(offset), C.int(whence))
|
||||
if err := newError(C.int(ret)); err != nil {
|
||||
@@ -197,6 +203,7 @@ func (ic *IOContext) Seek(offset int64, whence int) (int64, error) {
|
||||
return int64(ret), nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avio_8h.html#acc3626afc6aa3964b75d02811457164e
|
||||
func (ic *IOContext) Write(b []byte) {
|
||||
// Nothing to write
|
||||
if b == nil || len(b) <= 0 {
|
||||
@@ -207,6 +214,7 @@ func (ic *IOContext) Write(b []byte) {
|
||||
C.avio_write(ic.c, (*C.uchar)(unsafe.Pointer(&b[0])), C.int(len(b)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avio_8h.html#ad88b866a118c17c95663f7782b2e8946
|
||||
func (ic *IOContext) Flush() {
|
||||
C.avio_flush(ic.c)
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavformat/avformat.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avio_8h.html#a21e61cb486bd1588eb7f775998cf8c77
|
||||
type IOContextFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avio.h#L621
|
||||
const (
|
||||
IOContextFlagRead = IOContextFlag(C.AVIO_FLAG_READ)
|
||||
IOContextFlagWrite = IOContextFlag(C.AVIO_FLAG_WRITE)
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavformat/avformat.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avformat_8h.html#a752cce390d480521919aa5d8be24ac0b
|
||||
type IOFormatFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L464
|
||||
const (
|
||||
IOFormatFlagNofile = IOFormatFlag(C.AVFMT_NOFILE)
|
||||
IOFormatFlagNeednumber = IOFormatFlag(C.AVFMT_NEEDNUMBER)
|
||||
|
2
level.go
2
level.go
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavcodec/avcodec.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avcodec_8h.html#a84a993ea19afa2cbda45b3283a598fe6
|
||||
type Level int
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/avcodec.h#L1652
|
||||
const (
|
||||
LevelUnknown = Level(C.FF_LEVEL_UNKNOWN)
|
||||
)
|
||||
|
7
log.go
7
log.go
@@ -8,9 +8,9 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__log__constants.html#ga11e329935b59b83ca722b66674f37fd4
|
||||
type LogLevel int
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/log.h#L162
|
||||
const (
|
||||
LogLevelQuiet = LogLevel(C.AV_LOG_QUIET)
|
||||
LogLevelPanic = LogLevel(C.AV_LOG_PANIC)
|
||||
@@ -22,10 +22,12 @@ const (
|
||||
LogLevelDebug = LogLevel(C.AV_LOG_DEBUG)
|
||||
)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__log.html#ga1fd32c74db581e3e2e7f35d277bb1e24
|
||||
func SetLogLevel(l LogLevel) {
|
||||
C.av_log_set_level(C.int(l))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__log.html#gae8ada5cc5722548d8698650b05207904
|
||||
func GetLogLevel() LogLevel {
|
||||
return LogLevel(C.av_log_get_level())
|
||||
}
|
||||
@@ -34,6 +36,7 @@ type LogCallback func(c Classer, l LogLevel, fmt, msg string)
|
||||
|
||||
var logCallback LogCallback
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__log.html#ga14034761faf581a8b9ed6ef19b313708
|
||||
func SetLogCallback(c LogCallback) {
|
||||
logCallback = c
|
||||
C.astiavSetLogCallback()
|
||||
@@ -59,10 +62,12 @@ func goAstiavLogCallback(ptr unsafe.Pointer, level C.int, fmt, msg *C.char) {
|
||||
logCallback(c, LogLevel(level), C.GoString(fmt), C.GoString(msg))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__log.html#ga5bd132d2e4ac6f9843ef6d8e3c05050a
|
||||
func ResetLogCallback() {
|
||||
C.astiavResetLogCallback()
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__log.html#gabd386ffd4b27637cf34e98d5d1a6e8ae
|
||||
func Log(c Classer, l LogLevel, fmt string, args ...string) {
|
||||
fmtc := C.CString(fmt)
|
||||
defer C.free(unsafe.Pointer(fmtc))
|
||||
|
@@ -3,10 +3,12 @@ package astiav
|
||||
//#include <libavutil/mathematics.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__math.html#gaf02994a8bbeaa91d4757df179cbe567f
|
||||
func RescaleQ(a int64, b Rational, c Rational) int64 {
|
||||
return int64(C.av_rescale_q(C.int64_t(a), b.c, c.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__math.html#gab706bfec9bf56534e02ca9564cb968f6
|
||||
func RescaleQRnd(a int64, b Rational, c Rational, r Rounding) int64 {
|
||||
return int64(C.av_rescale_q_rnd(C.int64_t(a), b.c, c.c, C.enum_AVRounding(r)))
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ package astiav
|
||||
//#include <libavutil/avutil.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/avutil.h#L199
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__misc.html#ga9a84bba4713dfced21a1a56163be1f48
|
||||
type MediaType C.enum_AVMediaType
|
||||
|
||||
const (
|
||||
@@ -17,6 +17,7 @@ const (
|
||||
MediaTypeVideo = MediaType(C.AVMEDIA_TYPE_VIDEO)
|
||||
)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__misc.html#gaf21645cfa855b2caf9699d7dc7b2d08e
|
||||
func (t MediaType) String() string {
|
||||
return C.GoString(C.av_get_media_type_string((C.enum_AVMediaType)(t)))
|
||||
}
|
||||
|
@@ -4,7 +4,7 @@ package astiav
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L503
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVOutputFormat.html
|
||||
type OutputFormat struct {
|
||||
c *C.AVOutputFormat
|
||||
}
|
||||
@@ -16,21 +16,24 @@ func newOutputFormatFromC(c *C.AVOutputFormat) *OutputFormat {
|
||||
return &OutputFormat{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavf__encoding.html#ga00bceb049f2b20716e2f36ebc990a350
|
||||
func FindOutputFormat(name string) *OutputFormat {
|
||||
cname := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cname))
|
||||
return newOutputFormatFromC(C.av_guess_format(cname, nil, nil))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVOutputFormat.html#aad55a00e728a020c1dcfaaf695320445
|
||||
func (f *OutputFormat) Flags() IOFormatFlags {
|
||||
return IOFormatFlags(f.c.flags)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVOutputFormat.html#ac3abc5f47f3465b6b7eec89c9476351c
|
||||
func (f *OutputFormat) Name() string {
|
||||
return C.GoString(f.c.name)
|
||||
}
|
||||
|
||||
// LongName Description of the format, meant to be more human-readable than Name.
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVOutputFormat.html#a4ff98d90aac0047a204a35a758a363fc
|
||||
func (f *OutputFormat) LongName() string {
|
||||
return C.GoString(f.c.long_name)
|
||||
}
|
||||
|
27
packet.go
27
packet.go
@@ -7,7 +7,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/packet.h#L350
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html
|
||||
type Packet struct {
|
||||
c *C.AVPacket
|
||||
}
|
||||
@@ -19,10 +19,12 @@ func newPacketFromC(c *C.AVPacket) *Packet {
|
||||
return &Packet{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet.html#gaaf85aa950695631e0217a16062289b66
|
||||
func AllocPacket() *Packet {
|
||||
return newPacketFromC(C.av_packet_alloc())
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#aaf4fe58dfcc7c232c1f2268b539d8367
|
||||
func (p *Packet) Data() []byte {
|
||||
if p.c.data == nil {
|
||||
return nil
|
||||
@@ -33,94 +35,117 @@ func (p *Packet) Data() []byte {
|
||||
})
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#a85dbbd306b44b02390cd91c45e6a0f76
|
||||
func (p *Packet) Dts() int64 {
|
||||
return int64(p.c.dts)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#a85dbbd306b44b02390cd91c45e6a0f76
|
||||
func (p *Packet) SetDts(v int64) {
|
||||
p.c.dts = C.int64_t(v)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#a622e758be29fd500aed0ffdc069550f7
|
||||
func (p *Packet) Duration() int64 {
|
||||
return int64(p.c.duration)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#a622e758be29fd500aed0ffdc069550f7
|
||||
func (p *Packet) SetDuration(d int64) {
|
||||
p.c.duration = C.int64_t(d)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#a437be96a9da675f12caa228a9c81bd82
|
||||
func (p *Packet) Flags() PacketFlags {
|
||||
return PacketFlags(p.c.flags)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#a437be96a9da675f12caa228a9c81bd82
|
||||
func (p *Packet) SetFlags(f PacketFlags) {
|
||||
p.c.flags = C.int(f)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#ab5793d8195cf4789dfb3913b7a693903
|
||||
func (p *Packet) Pos() int64 {
|
||||
return int64(p.c.pos)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#ab5793d8195cf4789dfb3913b7a693903
|
||||
func (p *Packet) SetPos(v int64) {
|
||||
p.c.pos = C.int64_t(v)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#a73bde0a37f3b1efc839f11295bfbf42a
|
||||
func (p *Packet) Pts() int64 {
|
||||
return int64(p.c.pts)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#a73bde0a37f3b1efc839f11295bfbf42a
|
||||
func (p *Packet) SetPts(v int64) {
|
||||
p.c.pts = C.int64_t(v)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#ac55bfef91c33f02704ba76518d0f294c
|
||||
func (p *Packet) SideData() *PacketSideData {
|
||||
return newPacketSideDataFromC(&p.c.side_data, &p.c.side_data_elems)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#a4d1ea19f63eb107111fd650ca514d1f4
|
||||
func (p *Packet) Size() int {
|
||||
return int(p.c.size)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#a4d1ea19f63eb107111fd650ca514d1f4
|
||||
func (p *Packet) SetSize(s int) {
|
||||
p.c.size = C.int(s)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49
|
||||
func (p *Packet) StreamIndex() int {
|
||||
return int(p.c.stream_index)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacket.html#a0d1cb9b5a32b00fb6edc81ea3aae2a49
|
||||
func (p *Packet) SetStreamIndex(i int) {
|
||||
p.c.stream_index = C.int(i)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet.html#ga1066464e7cdd1f215df6940db94e5d8e
|
||||
func (p *Packet) Free() {
|
||||
C.av_packet_free(&p.c)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet.html#gacbe3e51cf411a7003d706127dc48cbb1
|
||||
func (p *Packet) Clone() *Packet {
|
||||
return newPacketFromC(C.av_packet_clone(p.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet.html#gadfa708660b85a56749c753124de2da7d
|
||||
func (p *Packet) AllocPayload(s int) error {
|
||||
return newError(C.av_new_packet(p.c, C.int(s)))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet.html#gadb05d71fa2ea7b7fd3e8cfc6d9065a47
|
||||
func (p *Packet) Ref(src *Packet) error {
|
||||
return newError(C.av_packet_ref(p.c, src.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet.html#ga63d5a489b419bd5d45cfd09091cbcbc2
|
||||
func (p *Packet) Unref() {
|
||||
C.av_packet_unref(p.c)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet.html#ga91dbb1359f99547adb544ee96a406b21
|
||||
func (p *Packet) MoveRef(src *Packet) {
|
||||
C.av_packet_move_ref(p.c, src.c)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet.html#gae5c86e4d93f6e7aa62ef2c60763ea67e
|
||||
func (p *Packet) RescaleTs(src, dst Rational) {
|
||||
C.av_packet_rescale_ts(p.c, src.c, dst.c)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet.html#ga7ca877e1f0ded89a27199b65e9a077dc
|
||||
func (p *Packet) FromData(data []byte) (err error) {
|
||||
// Create buf
|
||||
buf := (*C.uint8_t)(C.av_malloc(C.size_t(len(data))))
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavcodec/avcodec.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet.html#ga75603d7c2b8adf5829f4fd2fb860168f
|
||||
type PacketFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/packet.h#L428
|
||||
const (
|
||||
PacketFlagCorrupt = PacketFlag(C.AV_PKT_FLAG_CORRUPT)
|
||||
PacketFlagDiscard = PacketFlag(C.AV_PKT_FLAG_DISCARD)
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n6.1.1/libavcodec/packet.h#L342
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVPacketSideData.html
|
||||
type PacketSideData struct {
|
||||
sd **C.AVPacketSideData
|
||||
size *C.int
|
||||
@@ -20,6 +20,7 @@ func newPacketSideDataFromC(sd **C.AVPacketSideData, size *C.int) *PacketSideDat
|
||||
}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet__side__data.html#gad208a666db035802403ea994912a83db
|
||||
func (d *PacketSideData) Add(t PacketSideDataType, b []byte) error {
|
||||
if len(b) == 0 {
|
||||
return nil
|
||||
@@ -34,6 +35,7 @@ func (d *PacketSideData) Add(t PacketSideDataType, b []byte) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet__side__data.html#ga61a3a0fba92a308208c8ab957472d23c
|
||||
func (d *PacketSideData) Get(t PacketSideDataType) []byte {
|
||||
return bytesFromC(func(size *C.size_t) *C.uint8_t {
|
||||
if d.sd == nil || d.size == nil {
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavcodec/avcodec.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/packet.h#L40
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet__side__data.html#ga9a80bfcacc586b483a973272800edb97
|
||||
type PacketSideDataType C.enum_AVPacketSideDataType
|
||||
|
||||
const (
|
||||
@@ -37,6 +37,7 @@ const (
|
||||
PacketSideDataTypeWebvttSettings = PacketSideDataType(C.AV_PKT_DATA_WEBVTT_SETTINGS)
|
||||
)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavc__packet__side__data.html#ga78c05e43a5d021eb10e63b28a541bce3
|
||||
func (t PacketSideDataType) Name() string {
|
||||
return C.GoString(C.av_packet_side_data_name((C.enum_AVPacketSideDataType)(t)))
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavutil/avutil.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/avutil.h#L272
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__picture.html#gae6cbcab1f70d8e476757f1c1f5a0a78e
|
||||
type PictureType C.enum_AVPictureType
|
||||
|
||||
const (
|
||||
@@ -17,6 +17,7 @@ const (
|
||||
PictureTypeBi = PictureType(C.AV_PICTURE_TYPE_BI)
|
||||
)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__picture.html#gacbf2ea8b2b89924c890ef8ec10a3d922
|
||||
func (t PictureType) String() string {
|
||||
return string(rune(C.av_get_picture_type_char((C.enum_AVPictureType)(t))))
|
||||
}
|
||||
|
@@ -7,7 +7,7 @@ package astiav
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/pixfmt.h#L64
|
||||
// https://ffmpeg.org/doxygen/7.0/pixfmt_8h.html#a9a8e335cf3be472042bc9f0cf80cd4c5
|
||||
type PixelFormat C.enum_AVPixelFormat
|
||||
|
||||
const (
|
||||
@@ -202,6 +202,7 @@ const (
|
||||
PixelFormatYvyu422 = PixelFormat(C.AV_PIX_FMT_YVYU422)
|
||||
)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/pixdesc_8c.html#ab92e2a8a9b58c982560c49df9f01e47e
|
||||
func (f PixelFormat) Name() string {
|
||||
return C.GoString(C.av_get_pix_fmt_name((C.enum_AVPixelFormat)(f)))
|
||||
}
|
||||
@@ -210,6 +211,7 @@ func (f PixelFormat) String() string {
|
||||
return f.Name()
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/pixdesc_8c.html#a925ef18d69c24c3be8c53d5a7dc0660e
|
||||
func FindPixelFormatByName(name string) PixelFormat {
|
||||
cn := C.CString(name)
|
||||
defer C.free(unsafe.Pointer(cn))
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavcodec/avcodec.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avcodec_8h.html#a1d8d03f5be975b8a728574cbdb00c896
|
||||
type Profile int
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/avcodec.h#L1526
|
||||
const (
|
||||
ProfileAacEld = Profile(C.FF_PROFILE_AAC_ELD)
|
||||
ProfileAacHe = Profile(C.FF_PROFILE_AAC_HE)
|
||||
|
15
program.go
15
program.go
@@ -6,7 +6,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n7.0/libavformat/avformat.h#L1181
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVProgram.html
|
||||
type Program struct {
|
||||
c *C.AVProgram
|
||||
fc *FormatContext
|
||||
@@ -22,22 +22,27 @@ func newProgramFromC(c *C.AVProgram, fc *FormatContext) *Program {
|
||||
}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avformat_8c.html#ae1eb83cf16060217c805e61f0f62fa4e
|
||||
func (p *Program) AddStream(s *Stream) {
|
||||
C.av_program_add_stream_index(p.fc.c, p.c.id, C.uint(s.c.index))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a10cc799a98b37335e820b0bdb386eb95
|
||||
func (p *Program) ID() int {
|
||||
return int(p.c.id)
|
||||
}
|
||||
|
||||
func (p *Program) NbStreams() int {
|
||||
return int(p.c.nb_stream_indexes)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a10cc799a98b37335e820b0bdb386eb95
|
||||
func (p *Program) SetID(i int) {
|
||||
p.c.id = C.int(i)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a136cf29d2aa5b0e4c6d743406c5e39d1
|
||||
func (p *Program) NbStreams() int {
|
||||
return int(p.c.nb_stream_indexes)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVProgram.html#a7967d41af4812ed61a28762e988c7a02
|
||||
func (p *Program) Streams() (ss []*Stream) {
|
||||
is := make(map[int]bool)
|
||||
for _, idx := range unsafe.Slice(p.c.stream_index, p.c.nb_stream_indexes) {
|
||||
|
@@ -4,7 +4,7 @@ package astiav
|
||||
import "C"
|
||||
import "strconv"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/rational.h#L58
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVRational.html
|
||||
type Rational struct {
|
||||
c C.AVRational
|
||||
}
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavutil/mathematics.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/mathematics.h#L79
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__math.html#ga921d656eaf2c4d6800a734a13af021d0
|
||||
type Rounding C.enum_AVRounding
|
||||
|
||||
const (
|
||||
|
@@ -3,7 +3,7 @@ package astiav
|
||||
//#include <libavutil/samplefmt.h>
|
||||
import "C"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavutil/samplefmt.h#L58
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__sampfmts.html#gaf9a51ca15301871723577c730b5865c5
|
||||
type SampleFormat C.enum_AVSampleFormat
|
||||
|
||||
const (
|
||||
@@ -23,6 +23,7 @@ const (
|
||||
SampleFormatU8P = SampleFormat(C.AV_SAMPLE_FMT_U8P)
|
||||
)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__sampfmts.html#ga31b9d149b2de9821a65f4f5612970838
|
||||
func (f SampleFormat) Name() string {
|
||||
return C.GoString(C.av_get_sample_fmt_name((C.enum_AVSampleFormat)(f)))
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavformat/avformat.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avformat_8h.html#ac736f8f4afc930ca1cda0b43638cc678
|
||||
type SeekFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L2277
|
||||
const (
|
||||
SeekFlagAny = SeekFlag(C.AVSEEK_FLAG_ANY)
|
||||
SeekFlagBackward = SeekFlag(C.AVSEEK_FLAG_BACKWARD)
|
||||
|
@@ -7,7 +7,7 @@ import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libswscale/swscale_internal.h#L300
|
||||
// https://ffmpeg.org/doxygen/7.0/structSwsContext.html
|
||||
type SoftwareScaleContext struct {
|
||||
c *C.struct_SwsContext
|
||||
// We need to store attributes in GO since C attributes are internal and therefore not accessible
|
||||
@@ -30,6 +30,7 @@ type softwareScaleContextUpdate struct {
|
||||
srcW *int
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__libsws.html#gaf360d1a9e0e60f906f74d7d44f9abfdd
|
||||
func CreateSoftwareScaleContext(srcW, srcH int, srcFormat PixelFormat, dstW, dstH int, dstFormat PixelFormat, flags SoftwareScaleContextFlags) (*SoftwareScaleContext, error) {
|
||||
ssc := &SoftwareScaleContext{
|
||||
dstFormat: C.enum_AVPixelFormat(dstFormat),
|
||||
@@ -59,6 +60,7 @@ func CreateSoftwareScaleContext(srcW, srcH int, srcFormat PixelFormat, dstW, dst
|
||||
return ssc, nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__libsws.html#gad3af0ca76f071dbe0173444db9882932
|
||||
func (ssc *SoftwareScaleContext) Free() {
|
||||
// Make sure to clone the classer before freeing the object since
|
||||
// the C free method may reset the pointer
|
||||
@@ -73,10 +75,12 @@ func (ssc *SoftwareScaleContext) Free() {
|
||||
|
||||
var _ Classer = (*SoftwareScaleContext)(nil)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structSwsContext.html#a6866f52574bc730833d2580abc806261
|
||||
func (ssc *SoftwareScaleContext) Class() *Class {
|
||||
return newClassFromC(unsafe.Pointer(ssc.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__libsws.html#ga1c72fcf83bd57aea72cf3dadfcf02541
|
||||
func (ssc *SoftwareScaleContext) ScaleFrame(src, dst *Frame) error {
|
||||
return newError(C.sws_scale_frame(ssc.c, dst.c, src.c))
|
||||
}
|
||||
@@ -144,34 +148,42 @@ func (ssc *SoftwareScaleContext) update(u softwareScaleContextUpdate) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structSwsContext.html#a4bad42bdd38e916f045956efe81039bf
|
||||
func (ssc *SoftwareScaleContext) Flags() SoftwareScaleContextFlags {
|
||||
return SoftwareScaleContextFlags(ssc.flags)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structSwsContext.html#a4bad42bdd38e916f045956efe81039bf
|
||||
func (ssc *SoftwareScaleContext) SetFlags(swscf SoftwareScaleContextFlags) error {
|
||||
return ssc.update(softwareScaleContextUpdate{flags: &swscf})
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structSwsContext.html#a0bf831c04c58c12ea7aef32e0ffb2f6d
|
||||
func (ssc *SoftwareScaleContext) DestinationWidth() int {
|
||||
return int(ssc.dstW)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structSwsContext.html#a0bf831c04c58c12ea7aef32e0ffb2f6d
|
||||
func (ssc *SoftwareScaleContext) SetDestinationWidth(i int) error {
|
||||
return ssc.update(softwareScaleContextUpdate{dstW: &i})
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structSwsContext.html#a195564564eff11e1ee181999c13b9a22
|
||||
func (ssc *SoftwareScaleContext) DestinationHeight() int {
|
||||
return int(ssc.dstH)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structSwsContext.html#a195564564eff11e1ee181999c13b9a22
|
||||
func (ssc *SoftwareScaleContext) SetDestinationHeight(i int) error {
|
||||
return ssc.update(softwareScaleContextUpdate{dstH: &i})
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structSwsContext.html#a66adb1238b56e3539ad1145c146348e2
|
||||
func (ssc *SoftwareScaleContext) DestinationPixelFormat() PixelFormat {
|
||||
return PixelFormat(ssc.dstFormat)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structSwsContext.html#a66adb1238b56e3539ad1145c146348e2
|
||||
func (ssc *SoftwareScaleContext) SetDestinationPixelFormat(p PixelFormat) error {
|
||||
return ssc.update(softwareScaleContextUpdate{dstFormat: &p})
|
||||
}
|
||||
@@ -184,26 +196,32 @@ func (ssc *SoftwareScaleContext) SetDestinationResolution(w int, h int) error {
|
||||
return ssc.update(softwareScaleContextUpdate{dstW: &w, dstH: &h})
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structSwsContext.html#a1e1455f5d751e9ca639bf8afbda25646
|
||||
func (ssc *SoftwareScaleContext) SourceWidth() int {
|
||||
return int(ssc.srcW)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structSwsContext.html#a1e1455f5d751e9ca639bf8afbda25646
|
||||
func (ssc *SoftwareScaleContext) SetSourceWidth(i int) error {
|
||||
return ssc.update(softwareScaleContextUpdate{srcW: &i})
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygensrcH/7.0/structSwsContext.html#a195564564eff11e1ee181999c13b9a22
|
||||
func (ssc *SoftwareScaleContext) SourceHeight() int {
|
||||
return int(ssc.srcH)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygensrcH/7.0/structSwsContext.html#a195564564eff11e1ee181999c13b9a22
|
||||
func (ssc *SoftwareScaleContext) SetSourceHeight(i int) error {
|
||||
return ssc.update(softwareScaleContextUpdate{srcH: &i})
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygensrcH/7.0/structSwsContext.html#a195564564eff11e1ee181999c13b9a22
|
||||
func (ssc *SoftwareScaleContext) SourcePixelFormat() PixelFormat {
|
||||
return PixelFormat(ssc.srcFormat)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygensrcH/7.0/structSwsContext.html#a195564564eff11e1ee181999c13b9a22
|
||||
func (ssc *SoftwareScaleContext) SetSourcePixelFormat(p PixelFormat) error {
|
||||
return ssc.update(softwareScaleContextUpdate{srcFormat: &p})
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libswscale/swscale.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/group__libsws.html#ga6110064d9edfbec77ca5c3279cb75c31
|
||||
type SoftwareScaleContextFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libswscale/swscale.h#L59
|
||||
const (
|
||||
SoftwareScaleContextFlagArea = SoftwareScaleContextFlag(C.SWS_AREA)
|
||||
SoftwareScaleContextFlagBicubic = SoftwareScaleContextFlag(C.SWS_BICUBIC)
|
||||
|
26
stream.go
26
stream.go
@@ -2,8 +2,9 @@ package astiav
|
||||
|
||||
//#include <libavformat/avformat.h>
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L937
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html
|
||||
type Stream struct {
|
||||
c *C.AVStream
|
||||
}
|
||||
@@ -15,74 +16,97 @@ func newStreamFromC(c *C.AVStream) *Stream {
|
||||
return &Stream{c: c}
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a946e1e9b89eeeae4cab8a833b482c1ad
|
||||
func (s *Stream) AvgFrameRate() Rational {
|
||||
return newRationalFromC(s.c.avg_frame_rate)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a946e1e9b89eeeae4cab8a833b482c1ad
|
||||
func (s *Stream) SetAvgFrameRate(r Rational) {
|
||||
s.c.avg_frame_rate = r.c
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a4737d8b012827558f55a6f559b253496
|
||||
func (s *Stream) Class() *Class {
|
||||
return newClassFromC(unsafe.Pointer(s.c))
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a12826d21779289356722971d362c583c
|
||||
func (s *Stream) CodecParameters() *CodecParameters {
|
||||
return newCodecParametersFromC(s.c.codecpar)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a4e04af7a5a4d8298649850df798dd0bc
|
||||
func (s *Stream) Duration() int64 {
|
||||
return int64(s.c.duration)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#ab76e176c2a1d1ff09ec9c0bb88dc25e9
|
||||
func (s *Stream) EventFlags() StreamEventFlags {
|
||||
return StreamEventFlags(s.c.event_flags)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a6873ed62f196c24e8bf282609231786f
|
||||
func (s *Stream) ID() int {
|
||||
return int(s.c.id)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a6873ed62f196c24e8bf282609231786f
|
||||
func (s *Stream) SetID(i int) {
|
||||
s.c.id = C.int(i)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a6ca823054632821e085377f7d371a2d1
|
||||
func (s *Stream) Index() int {
|
||||
return int(s.c.index)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a6ca823054632821e085377f7d371a2d1
|
||||
func (s *Stream) SetIndex(i int) {
|
||||
s.c.index = C.int(i)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html
|
||||
func (s *Stream) Metadata() *Dictionary {
|
||||
return newDictionaryFromC(s.c.metadata)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a4382c3064df1c9eb232ac198dec067f9
|
||||
func (s *Stream) NbFrames() int64 {
|
||||
return int64(s.c.nb_frames)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#ad63fb11cc1415e278e09ddc676e8a1ad
|
||||
func (s *Stream) RFrameRate() Rational {
|
||||
return newRationalFromC(s.c.r_frame_rate)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#ad63fb11cc1415e278e09ddc676e8a1ad
|
||||
func (s *Stream) SetRFrameRate(r Rational) {
|
||||
s.c.r_frame_rate = r.c
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a3f19c60ac6da237cd10e4d97150c118e
|
||||
func (s *Stream) SampleAspectRatio() Rational {
|
||||
return newRationalFromC(s.c.sample_aspect_ratio)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a3f19c60ac6da237cd10e4d97150c118e
|
||||
func (s *Stream) SetSampleAspectRatio(r Rational) {
|
||||
s.c.sample_aspect_ratio = r.c
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a7c67ae70632c91df8b0f721658ec5377
|
||||
func (s *Stream) StartTime() int64 {
|
||||
return int64(s.c.start_time)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6
|
||||
func (s *Stream) TimeBase() Rational {
|
||||
return newRationalFromC(s.c.time_base)
|
||||
}
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/structAVStream.html#a9db755451f14e2bf590d4b85d82b32e6
|
||||
func (s *Stream) SetTimeBase(r Rational) {
|
||||
s.c.time_base = r.c
|
||||
}
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavformat/avformat.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avformat_8h.html#ab3a5958310f614671f5030ed10753ba9
|
||||
type StreamEventFlag int64
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavformat/avformat.h#L1070
|
||||
const (
|
||||
StreamEventFlagMetadataUpdated = StreamEventFlag(C.AVSTREAM_EVENT_FLAG_METADATA_UPDATED)
|
||||
)
|
||||
|
@@ -25,6 +25,9 @@ func TestStream(t *testing.T) {
|
||||
require.Equal(t, NewRational(1, 1), s1.SampleAspectRatio())
|
||||
require.Equal(t, int64(0), s1.StartTime())
|
||||
require.Equal(t, NewRational(1, 12288), s1.TimeBase())
|
||||
cl := s1.Class()
|
||||
require.NotNil(t, cl)
|
||||
require.Equal(t, "AVStream", cl.Name())
|
||||
|
||||
require.Equal(t, 1, s2.Index())
|
||||
require.Equal(t, int64(240640), s2.Duration())
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavcodec/avcodec.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/defs_8h.html#a96808e3862c53c7edb4ace1b2f3e544f
|
||||
type StrictStdCompliance int
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/avcodec.h#L1281
|
||||
const (
|
||||
StrictStdComplianceVeryStrict = StrictStdCompliance(C.FF_COMPLIANCE_VERY_STRICT)
|
||||
StrictStdComplianceStrict = StrictStdCompliance(C.FF_COMPLIANCE_STRICT)
|
||||
|
@@ -3,9 +3,9 @@ package astiav
|
||||
//#include <libavcodec/avcodec.h>
|
||||
import "C"
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/avcodec_8h.html#a116c7fb56ac57ccca3e08b80467b2a40
|
||||
type ThreadType int
|
||||
|
||||
// https://github.com/FFmpeg/FFmpeg/blob/n5.0/libavcodec/avcodec.h#L1451
|
||||
const (
|
||||
ThreadTypeFrame = ThreadType(C.FF_THREAD_FRAME)
|
||||
ThreadTypeSlice = ThreadType(C.FF_THREAD_SLICE)
|
||||
|
6
time.go
6
time.go
@@ -5,14 +5,18 @@ package astiav
|
||||
import "C"
|
||||
|
||||
const (
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__time.html#ga2eaefe702f95f619ea6f2d08afa01be1
|
||||
NoPtsValue = int64(C.AV_NOPTS_VALUE)
|
||||
TimeBase = int(C.AV_TIME_BASE)
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__time.html#gaa11ed202b70e1f52bac809811a910e2a
|
||||
TimeBase = int(C.AV_TIME_BASE)
|
||||
)
|
||||
|
||||
var (
|
||||
// https://ffmpeg.org/doxygen/7.0/group__lavu__time.html#gafd07a13a4ddaa6015275cad6022d9ee3
|
||||
TimeBaseQ = newRationalFromC(C.AV_TIME_BASE_Q)
|
||||
)
|
||||
|
||||
// https://ffmpeg.org/doxygen/7.0/time_8c.html#adf0e36df54426fa167e3cc5a3406f3b7
|
||||
func RelativeTime() int64 {
|
||||
return int64(C.av_gettime_relative())
|
||||
}
|
||||
|
Reference in New Issue
Block a user