mirror of
https://github.com/qrtc/ffmpeg-dev-go.git
synced 2025-09-27 04:06:10 +08:00
2023-10-13 20:52:26 CST W41D5
This commit is contained in:
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
# If you prefer the allow list template instead of the deny list, see community template:
|
||||
# https://github.com/github/gitignore/blob/main/community/Golang/Go.AllowList.gitignore
|
||||
#
|
||||
# Binaries for programs and plugins
|
||||
*.exe
|
||||
*.exe~
|
||||
*.dll
|
||||
*.so
|
||||
*.dylib
|
||||
|
||||
# Test binary, built with `go test -c`
|
||||
*.test
|
||||
|
||||
# Output of the go coverage tool, specifically when used with LiteIDE
|
||||
*.out
|
||||
|
||||
# Dependency directories (remove the comment below to include it)
|
||||
# vendor/
|
||||
|
||||
# Go workspace file
|
||||
go.work
|
||||
|
||||
# Examples
|
||||
/examples/*/*
|
||||
!/examples/*/*.go
|
62
README.md
62
README.md
@@ -1,2 +1,64 @@
|
||||
# ffmpeg-dev-go
|
||||
Go bindings for FFmpeg.
|
||||
|
||||
## How to use
|
||||
|
||||
### Step 1: Prepare
|
||||
|
||||
- macOS
|
||||
|
||||
```shell
|
||||
brew install ffmpeg
|
||||
```
|
||||
- Debian
|
||||
|
||||
```shell
|
||||
apt install \
|
||||
libavdevice-dev libavformat-dev libavfilter-dev \
|
||||
libavresample-dev libavcodec-dev libpostproc-dev \
|
||||
libswscale-dev libswresample-dev libavutil-dev
|
||||
```
|
||||
- Custom
|
||||
|
||||
```shell
|
||||
export PKG_CONFIG_PATH="<CUSTOM_FFMPEG_LIBRARY_PATH>/lib/pkgconfig"
|
||||
```
|
||||
|
||||
### Step 2: Detecte FFmpeg version
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
/*
|
||||
#cgo pkg-config: libavutil
|
||||
#include <libavutil/ffversion.h>
|
||||
*/
|
||||
import "C"
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
fmt.Println(string(C.FFMPEG_VERSION)[:3])
|
||||
}
|
||||
```
|
||||
|
||||
### Step 3: Get ffmpeg-go-dev
|
||||
|
||||
```shell
|
||||
go get github.com/qrtc/ffmpeg-dev-go@4.4
|
||||
```
|
||||
|
||||
### Step 4: Verify
|
||||
|
||||
```go
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/qrtc/ffmpeg-dev-go"
|
||||
)
|
||||
|
||||
func main() {
|
||||
fmt.Println(ffmpeg.AvVersionInfo())
|
||||
}
|
||||
```
|
3736
avcodec.go
Normal file
3736
avcodec.go
Normal file
File diff suppressed because it is too large
Load Diff
12
avcodec_ac3_parser.go
Normal file
12
avcodec_ac3_parser.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavcodec/ac3_parser.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
// AvAc3ParseHeader extracts the bitstream ID and the frame size from AC-3 data.
|
||||
func AvAc3ParseHeader(buf *uint8, size uint, bitstreamID *uint8, frameSize *uint16) int32 {
|
||||
return (int32)(C.av_ac3_parse_header((*C.uint8_t)(buf), (C.size_t)(size),
|
||||
(*C.uint8_t)(bitstreamID), (*C.uint16_t)(frameSize)))
|
||||
}
|
16
avcodec_adts_parser.go
Normal file
16
avcodec_adts_parser.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavcodec/adts_parser.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
AV_AAC_ADTS_HEADER_SIZE = C.AV_AAC_ADTS_HEADER_SIZE
|
||||
)
|
||||
|
||||
// AvAdtsHeaderParse extracts the number of samples and frames from AAC data.
|
||||
func AvAdtsHeaderParse(buf *uint8, sample *uint32, frame *uint8) int32 {
|
||||
return (int32)(C.av_adts_header_parse((*C.uint8_t)(buf),
|
||||
(*C.uint32_t)(sample), (*C.uint8_t)(frame)))
|
||||
}
|
23
avcodec_avdct.go
Normal file
23
avcodec_avdct.go
Normal file
@@ -0,0 +1,23 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavcodec/avdct.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
type AvDCT C.struct_AVDCT
|
||||
|
||||
// AvCodecDctAlloc allocates a AVDCT context.
|
||||
func AvCodecDctAlloc() *AvDCT {
|
||||
return (*AvDCT)(C.avcodec_dct_alloc())
|
||||
}
|
||||
|
||||
// AvCodecDctInit
|
||||
func AvCodecDctInit(dct *AvDCT) int32 {
|
||||
return (int32)(C.avcodec_dct_init((*C.struct_AVDCT)(dct)))
|
||||
}
|
||||
|
||||
// AvCodecDctGetClass
|
||||
func AvCodecDctGetClass() *AvClass {
|
||||
return (*AvClass)(C.avcodec_dct_get_class())
|
||||
}
|
114
avcodec_avfft.go
Normal file
114
avcodec_avfft.go
Normal file
@@ -0,0 +1,114 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavcodec/avfft.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
type FftSample C.FFTSample
|
||||
|
||||
type FftComplex C.struct_FFTComplex
|
||||
|
||||
type FftContext C.struct_FFTContext
|
||||
|
||||
// AvFftInit sets up a complex FFT.
|
||||
func AvFftInit(nbits, inverse int32) *FftContext {
|
||||
return (*FftContext)(C.av_fft_init((C.int)(nbits), (C.int)(inverse)))
|
||||
}
|
||||
|
||||
// AvFftPermute does the permutation needed BEFORE calling FfFftCalc().
|
||||
func AvFftPermute(s *FftContext, z *FftComplex) {
|
||||
C.av_fft_permute((*C.struct_FFTContext)(s), (*C.struct_FFTComplex)(z))
|
||||
}
|
||||
|
||||
// FfFftCalc does a complex FFT with the parameters defined in AvFftInit().
|
||||
func FfFftCalc(s *FftContext, z *FftComplex) {
|
||||
C.av_fft_calc((*C.struct_FFTContext)(s), (*C.struct_FFTComplex)(z))
|
||||
}
|
||||
|
||||
// AvFftEnd
|
||||
func AvFftEnd(s *FftContext) {
|
||||
C.av_fft_end((*C.struct_FFTContext)(s))
|
||||
}
|
||||
|
||||
// AvMdctInit
|
||||
func AvMdctInit(nbits, inverse int32, scale float64) *FftContext {
|
||||
return (*FftContext)(C.av_mdct_init((C.int)(nbits), (C.int)(inverse), (C.double)(scale)))
|
||||
}
|
||||
|
||||
// AvImdctCalc
|
||||
func AvImdctCalc(s *FftContext, output, input *FftSample) {
|
||||
C.av_imdct_calc((*C.struct_FFTContext)(s),
|
||||
(*C.FFTSample)(output), (*C.FFTSample)(input))
|
||||
}
|
||||
|
||||
// AvImdctHalf
|
||||
func AvImdctHalf(s *FftContext, output, input *FftSample) {
|
||||
C.av_imdct_half((*C.struct_FFTContext)(s),
|
||||
(*C.FFTSample)(output), (*C.FFTSample)(input))
|
||||
}
|
||||
|
||||
// AvMdctCalc
|
||||
func AvMdctCalc(s *FftContext, output, input *FftSample) {
|
||||
C.av_mdct_calc((*C.struct_FFTContext)(s),
|
||||
(*C.FFTSample)(output), (*C.FFTSample)(input))
|
||||
}
|
||||
|
||||
// AvMdctEnd
|
||||
func AvMdctEnd(s *FftContext) {
|
||||
C.av_mdct_end((*C.struct_FFTContext)(s))
|
||||
}
|
||||
|
||||
type RDFTransformType int32
|
||||
|
||||
const (
|
||||
DFT_R2C = RDFTransformType(C.DFT_R2C)
|
||||
IDFT_C2R = RDFTransformType(C.IDFT_C2R)
|
||||
IDFT_R2C = RDFTransformType(C.IDFT_R2C)
|
||||
DFT_C2R = RDFTransformType(C.DFT_C2R)
|
||||
)
|
||||
|
||||
type RDFTContext C.struct_RDFTContext
|
||||
|
||||
// AvRdftInit
|
||||
func AvRdftInit(nbits int32, trans RDFTransformType) *RDFTContext {
|
||||
return (*RDFTContext)(C.av_rdft_init((C.int)(nbits),
|
||||
(C.enum_RDFTransformType)(trans)))
|
||||
}
|
||||
|
||||
// AvRdftCalc
|
||||
func AvRdftCalc(r *RDFTContext, data *FftSample) {
|
||||
C.av_rdft_calc((*C.struct_RDFTContext)(r), (*C.FFTSample)(data))
|
||||
}
|
||||
|
||||
// AvRdftEnd
|
||||
func AvRdftEnd(r *RDFTContext) {
|
||||
C.av_rdft_end((*C.struct_RDFTContext)(r))
|
||||
}
|
||||
|
||||
type DCTContext C.struct_DCTContext
|
||||
|
||||
type DCTTransformType int32
|
||||
|
||||
const (
|
||||
DCT_II = DCTTransformType(C.DCT_II)
|
||||
DCT_III = DCTTransformType(C.DCT_III)
|
||||
DCT_I = DCTTransformType(C.DCT_I)
|
||||
DST_I = DCTTransformType(C.DST_I)
|
||||
)
|
||||
|
||||
// AvDctInit
|
||||
func AvDctInit(nbits int32, _type RDFTransformType) *DCTContext {
|
||||
return (*DCTContext)(C.av_dct_init((C.int)(nbits),
|
||||
(C.enum_RDFTransformType)(_type)))
|
||||
}
|
||||
|
||||
// AvDctCalc
|
||||
func AvDctCalc(d *DCTContext, data *FftSample) {
|
||||
C.av_dct_calc((*C.struct_DCTContext)(d), (*C.FFTSample)(data))
|
||||
}
|
||||
|
||||
// AvDctEnd
|
||||
func AvDctEnd(d *DCTContext) {
|
||||
C.av_dct_end((*C.struct_DCTContext)(d))
|
||||
}
|
112
avcodec_bsf.go
Normal file
112
avcodec_bsf.go
Normal file
@@ -0,0 +1,112 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavcodec/bsf.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// AvBSFInternal
|
||||
type AvBSFInternal C.struct_AVBSFInternal
|
||||
|
||||
// AvBSFContext
|
||||
type AvBSFContext C.struct_AVBSFContext
|
||||
|
||||
// AvBitStreamFilter
|
||||
type AvBitStreamFilter C.struct_AVBitStreamFilter
|
||||
|
||||
// AvBsfGetByName returns a bitstream filter with the specified name or NULL if no such
|
||||
// bitstream filter exists.
|
||||
func AvBsfGetByName(name string) *AvBitStreamFilter {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (*AvBitStreamFilter)(C.av_bsf_get_by_name((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvBsfIterate iterates over all registered bitstream filters.
|
||||
func AvBsfIterate(opaque *unsafe.Pointer) *AvBitStreamFilter {
|
||||
return (*AvBitStreamFilter)(C.av_bsf_iterate(opaque))
|
||||
}
|
||||
|
||||
// AvBsfAlloc allocates a context for a given bitstream filter.
|
||||
func AvBsfAlloc(filter *AvBitStreamFilter, ctx **AvBSFContext) int32 {
|
||||
return (int32)(C.av_bsf_alloc((*C.struct_AVBitStreamFilter)(filter),
|
||||
(**C.struct_AVBSFContext)(unsafe.Pointer(ctx))))
|
||||
}
|
||||
|
||||
// AvBsfInit prepares the filter for use, after all the parameters and options have been set.
|
||||
func AvBsfInit(ctx *AvBSFContext) int32 {
|
||||
return (int32)(C.av_bsf_init((*C.struct_AVBSFContext)(ctx)))
|
||||
}
|
||||
|
||||
// AvBsfSendPacket submits a packet for filtering.
|
||||
func AvBsfSendPacket(ctx *AvBSFContext, pkt *AvPacket) int32 {
|
||||
return (int32)(C.av_bsf_send_packet((*C.struct_AVBSFContext)(ctx),
|
||||
(*C.struct_AVPacket)(pkt)))
|
||||
}
|
||||
|
||||
// AvBsfReceivePacket retrieves a filtered packet.
|
||||
func AvBsfReceivePacket(ctx *AvBSFContext, pkt *AvPacket) int32 {
|
||||
return (int32)(C.av_bsf_receive_packet((*C.struct_AVBSFContext)(ctx),
|
||||
(*C.struct_AVPacket)(pkt)))
|
||||
}
|
||||
|
||||
// AvBsfFlush resets the internal bitstream filter state. Should be called e.g. when seeking.
|
||||
func AvBsfFlush(ctx *AvBSFContext) {
|
||||
C.av_bsf_flush((*C.struct_AVBSFContext)(ctx))
|
||||
}
|
||||
|
||||
// AvBsfFree frees a bitstream filter context.
|
||||
func AvBsfFree(ctx **AvBSFContext) {
|
||||
C.av_bsf_free((**C.struct_AVBSFContext)(unsafe.Pointer(ctx)))
|
||||
}
|
||||
|
||||
// AvBsfGetClass gets the AVClass for AVBSFContext.
|
||||
func AvBsfGetClass() *AvClass {
|
||||
return (*AvClass)(C.av_bsf_get_class())
|
||||
}
|
||||
|
||||
type AvBSFList C.struct_AVBSFList
|
||||
|
||||
// AvBsfListAlloc allocates empty list of bitstream filters.
|
||||
func AvBsfListAlloc() *AvBSFList {
|
||||
return (*AvBSFList)(C.av_bsf_list_alloc())
|
||||
}
|
||||
|
||||
// AvBsfListFree frees list of bitstream filters.
|
||||
func AvBsfListFree(lst **AvBSFList) {
|
||||
C.av_bsf_list_free((**C.struct_AVBSFList)(unsafe.Pointer(lst)))
|
||||
}
|
||||
|
||||
// AvBsfListAppend appends bitstream filter to the list of bitstream filters.
|
||||
func AvBsfListAppend(lst *AvBSFList, bsf *AvBSFContext) {
|
||||
C.av_bsf_list_append((*C.struct_AVBSFList)(lst),
|
||||
(*C.struct_AVBSFContext)(bsf))
|
||||
}
|
||||
|
||||
// AvBsfListAppend2
|
||||
func AvBsfListAppend2(lst *AvBSFList, bsfName string, options **AvDictionary) {
|
||||
bsfNamePtr, bsfNameFunc := StringCasting(bsfName)
|
||||
defer bsfNameFunc()
|
||||
C.av_bsf_list_append2((*C.struct_AVBSFList)(lst),
|
||||
(*C.char)(bsfNamePtr), (**C.struct_AVDictionary)(unsafe.Pointer(options)))
|
||||
}
|
||||
|
||||
// AvBsfListFinalize finalizes list of bitstream filters.
|
||||
func AvBsfListFinalize(lst **AvBSFList, bsf **AvBSFContext) int32 {
|
||||
return (int32)(C.av_bsf_list_finalize((**C.struct_AVBSFList)(unsafe.Pointer(lst)),
|
||||
(**C.struct_AVBSFContext)(unsafe.Pointer(bsf))))
|
||||
}
|
||||
|
||||
// AvBsfListParseStr parses string describing list of bitstream filters and creates single
|
||||
// AVBSFContext describing the whole chain of bitstream filters.
|
||||
func AvBsfListParseStr(str string, bsf **AvBSFContext) {
|
||||
strPtr, strFunc := StringCasting(str)
|
||||
defer strFunc()
|
||||
C.av_bsf_list_parse_str((*C.char)(strPtr), (**C.struct_AVBSFContext)(unsafe.Pointer(bsf)))
|
||||
}
|
||||
|
||||
// AvBsfGetNullFilter gets null/pass-through bitstream filter.
|
||||
func AvBsfGetNullFilter(bsf **AvBSFContext) int32 {
|
||||
return (int32)(C.av_bsf_get_null_filter((**C.struct_AVBSFContext)(unsafe.Pointer(bsf))))
|
||||
}
|
221
avcodec_codec.go
Normal file
221
avcodec_codec.go
Normal file
@@ -0,0 +1,221 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavcodec/codec.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
const (
|
||||
AV_CODEC_CAP_DRAW_HORIZ_BAND = C.AV_CODEC_CAP_DRAW_HORIZ_BAND
|
||||
AV_CODEC_CAP_DR1 = C.AV_CODEC_CAP_DR1
|
||||
AV_CODEC_CAP_TRUNCATED = C.AV_CODEC_CAP_TRUNCATED
|
||||
AV_CODEC_CAP_DELAY = C.AV_CODEC_CAP_DELAY
|
||||
AV_CODEC_CAP_SMALL_LAST_FRAME = C.AV_CODEC_CAP_SMALL_LAST_FRAME
|
||||
AV_CODEC_CAP_SUBFRAMES = C.AV_CODEC_CAP_SUBFRAMES
|
||||
AV_CODEC_CAP_EXPERIMENTAL = C.AV_CODEC_CAP_EXPERIMENTAL
|
||||
AV_CODEC_CAP_CHANNEL_CONF = C.AV_CODEC_CAP_CHANNEL_CONF
|
||||
AV_CODEC_CAP_FRAME_THREADS = C.AV_CODEC_CAP_FRAME_THREADS
|
||||
AV_CODEC_CAP_SLICE_THREADS = C.AV_CODEC_CAP_SLICE_THREADS
|
||||
AV_CODEC_CAP_PARAM_CHANGE = C.AV_CODEC_CAP_PARAM_CHANGE
|
||||
AV_CODEC_CAP_OTHER_THREADS = C.AV_CODEC_CAP_OTHER_THREADS
|
||||
AV_CODEC_CAP_AUTO_THREADS = C.AV_CODEC_CAP_AUTO_THREADS
|
||||
AV_CODEC_CAP_VARIABLE_FRAME_SIZE = C.AV_CODEC_CAP_VARIABLE_FRAME_SIZE
|
||||
AV_CODEC_CAP_AVOID_PROBING = C.AV_CODEC_CAP_AVOID_PROBING
|
||||
AV_CODEC_CAP_INTRA_ONLY = C.AV_CODEC_CAP_INTRA_ONLY
|
||||
AV_CODEC_CAP_LOSSLESS = C.AV_CODEC_CAP_LOSSLESS
|
||||
AV_CODEC_CAP_HARDWARE = C.AV_CODEC_CAP_HARDWARE
|
||||
AV_CODEC_CAP_HYBRID = C.AV_CODEC_CAP_HYBRID
|
||||
AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE = C.AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE
|
||||
AV_CODEC_CAP_ENCODER_FLUSH = C.AV_CODEC_CAP_ENCODER_FLUSH
|
||||
)
|
||||
|
||||
// AvProfile
|
||||
type AvProfile C.struct_AVProfile
|
||||
|
||||
// Custom: GetProfile gets `AVProfile.profile` value.
|
||||
func (p *AvProfile) GetProfile() int32 {
|
||||
return (int32)(p.profile)
|
||||
}
|
||||
|
||||
// Custom: GetName gets `AVProfile.name` value.
|
||||
func (p *AvProfile) GetName() string {
|
||||
return C.GoString(p.name)
|
||||
}
|
||||
|
||||
// AvCodec
|
||||
type AvCodec C.struct_AVCodec
|
||||
|
||||
// Custom: GetName gets `AVCodec.name` value.
|
||||
func (codec *AvCodec) GetName() string {
|
||||
return C.GoString(codec.name)
|
||||
}
|
||||
|
||||
// Custom: GetLongName gets `AVCodec.long_name` value.
|
||||
func (codec *AvCodec) GetLongName() string {
|
||||
return C.GoString(codec.long_name)
|
||||
}
|
||||
|
||||
// Custom: GetType gets `AVCodec.type` value.
|
||||
func (codec *AvCodec) GetType() AvMediaType {
|
||||
return (AvMediaType)(codec._type)
|
||||
}
|
||||
|
||||
// Custom: GetType gets `AVCodec.id` value.
|
||||
func (codec *AvCodec) GetID() AvCodecID {
|
||||
return (AvCodecID)(codec.id)
|
||||
}
|
||||
|
||||
// Custom: GetCapabilities gets `AVCodec.capabilities` value.
|
||||
func (codec *AvCodec) GetCapabilities() int32 {
|
||||
return (int32)(codec.capabilities)
|
||||
}
|
||||
|
||||
// Custom: GetSupportedFramerates gets `AVCodec.supportedFramerates` value.
|
||||
func (codec *AvCodec) GetSupportedFramerates() (v []AvRational) {
|
||||
if codec.supported_framerates == nil {
|
||||
return v
|
||||
}
|
||||
zeroQ := AvMakeQ(0, 0)
|
||||
ptr := (*AvRational)(codec.supported_framerates)
|
||||
for AvCmpQ(zeroQ, *ptr) != 0 {
|
||||
v = append(v, *ptr)
|
||||
ptr = (*AvRational)(unsafe.Pointer(uintptr(unsafe.Pointer(ptr)) +
|
||||
uintptr(unsafe.Sizeof(*ptr))))
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Custom: GetPixFmts gets `AVCodec.pix_fmts` value.
|
||||
func (codec *AvCodec) GetPixFmts() (v []AvPixelFormat) {
|
||||
if codec.pix_fmts == nil {
|
||||
return v
|
||||
}
|
||||
ptr := (*AvPixelFormat)(codec.pix_fmts)
|
||||
for *ptr != AV_PIX_FMT_NONE {
|
||||
v = append(v, *ptr)
|
||||
ptr = (*AvPixelFormat)(unsafe.Pointer(uintptr(unsafe.Pointer(ptr)) +
|
||||
uintptr(unsafe.Sizeof(*ptr))))
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Custom: GetSupportedSamplerates gets `AVCodec.supported_samplerates` value.
|
||||
func (codec *AvCodec) GetSupportedSamplerates() (v []int32) {
|
||||
if codec.supported_samplerates == nil {
|
||||
return v
|
||||
}
|
||||
ptr := (*int32)(codec.supported_samplerates)
|
||||
for *ptr != 0 {
|
||||
v = append(v, *ptr)
|
||||
ptr = (*int32)(unsafe.Pointer(uintptr(unsafe.Pointer(ptr)) +
|
||||
uintptr(unsafe.Sizeof(*ptr))))
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Custom: GetSampleFmts gets `AVCodec.sample_fmts` value.
|
||||
func (codec *AvCodec) GetSampleFmts() (v []AvSampleFormat) {
|
||||
if codec.sample_fmts == nil {
|
||||
return v
|
||||
}
|
||||
ptr := (*AvSampleFormat)(codec.sample_fmts)
|
||||
for *ptr != AV_SAMPLE_FMT_NONE {
|
||||
v = append(v, *ptr)
|
||||
ptr = (*AvSampleFormat)(unsafe.Pointer(uintptr(unsafe.Pointer(ptr)) +
|
||||
uintptr(unsafe.Sizeof(*ptr))))
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Custom: GetChannelLayouts gets `AVCodec.channel_layouts` value.
|
||||
func (codec *AvCodec) GetChannelLayouts() (v []uint64) {
|
||||
if codec.channel_layouts == nil {
|
||||
return v
|
||||
}
|
||||
ptr := (*uint64)(codec.channel_layouts)
|
||||
for *ptr != 0 {
|
||||
v = append(v, *ptr)
|
||||
ptr = (*uint64)(unsafe.Pointer(uintptr(unsafe.Pointer(ptr)) +
|
||||
uintptr(unsafe.Sizeof(*ptr))))
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Custom: GetMaxLowres gets `AVCodec.max_lowres` value.
|
||||
func (codec *AvCodec) GetMaxLowres() uint8 {
|
||||
return (uint8)(codec.max_lowres)
|
||||
}
|
||||
|
||||
// Custom: GetProfiles gets `AVCodec.profiles` value.
|
||||
func (codec *AvCodec) GetProfiles() (v []AvProfile) {
|
||||
if codec.profiles == nil {
|
||||
return v
|
||||
}
|
||||
ptr := (*AvProfile)(codec.profiles)
|
||||
for ptr.GetProfile() != FF_PROFILE_UNKNOWN {
|
||||
v = append(v, *ptr)
|
||||
ptr = (*AvProfile)(unsafe.Pointer(uintptr(unsafe.Pointer(ptr)) +
|
||||
uintptr(unsafe.Sizeof(*ptr))))
|
||||
}
|
||||
return v
|
||||
}
|
||||
|
||||
// Custom: GetWrapperName gets `AVCodec.wrapper_name` value.
|
||||
func (codec *AvCodec) GetWrapperName() string {
|
||||
return C.GoString(codec.wrapper_name)
|
||||
}
|
||||
|
||||
// AvCodecIterate iterates over all registered codecs.
|
||||
func AvCodecIterate(opaque *unsafe.Pointer) *AvCodec {
|
||||
return (*AvCodec)(C.av_codec_iterate(opaque))
|
||||
}
|
||||
|
||||
// AvCodecFindDecoder finds a registered decoder with a matching codec ID.
|
||||
func AvCodecFindDecoder(id AvCodecID) *AvCodec {
|
||||
return (*AvCodec)(C.avcodec_find_decoder((C.enum_AVCodecID)(id)))
|
||||
}
|
||||
|
||||
// AvCodecFindDecoderByName finds a registered decoder with the specified name.
|
||||
func AvCodecFindDecoderByName(name string) *AvCodec {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (*AvCodec)(C.avcodec_find_decoder_by_name((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvCodecFindEncoder finds a registered encoder with a matching codec ID.
|
||||
func AvCodecFindEncoder(id AvCodecID) *AvCodec {
|
||||
return (*AvCodec)(C.avcodec_find_encoder((C.enum_AVCodecID)(id)))
|
||||
}
|
||||
|
||||
// AvCodecFindEncoderByName finds a registered encoder with the specified name.
|
||||
func AvCodecFindEncoderByName(name string) *AvCodec {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (*AvCodec)(C.avcodec_find_encoder_by_name((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvCodecIsEncoder returns a non-zero number if codec is an encoder, zero otherwise
|
||||
func AvCodecIsEncoder(codec *AvCodec) int32 {
|
||||
return (int32)(C.av_codec_is_encoder((*C.struct_AVCodec)(codec)))
|
||||
}
|
||||
|
||||
// AvCodecIsDecoder returns a non-zero number if codec is an decoder, zero otherwise
|
||||
func AvCodecIsDecoder(codec *AvCodec) int32 {
|
||||
return (int32)(C.av_codec_is_decoder((*C.struct_AVCodec)(codec)))
|
||||
}
|
||||
|
||||
const (
|
||||
AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX = int32(C.AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX)
|
||||
AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX = int32(C.AV_CODEC_HW_CONFIG_METHOD_HW_FRAMES_CTX)
|
||||
AV_CODEC_HW_CONFIG_METHOD_INTERNAL = int32(C.AV_CODEC_HW_CONFIG_METHOD_INTERNAL)
|
||||
AV_CODEC_HW_CONFIG_METHOD_AD_HOC = int32(C.AV_CODEC_HW_CONFIG_METHOD_AD_HOC)
|
||||
)
|
||||
|
||||
// AvCodecHWConfig
|
||||
type AvCodecHWConfig C.struct_AVCodecHWConfig
|
||||
|
||||
// AvCodecGetHwConfig retrieves supported hardware configurations for a codec.
|
||||
func AvCodecGetHwConfig(codec *AvCodec, index int32) *AvCodecHWConfig {
|
||||
return (*AvCodecHWConfig)(C.avcodec_get_hw_config((*C.struct_AVCodec)(codec), (C.int)(index)))
|
||||
}
|
36
avcodec_codec_desc.go
Normal file
36
avcodec_codec_desc.go
Normal file
@@ -0,0 +1,36 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavcodec/codec_desc.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
// AvCodecDescriptor
|
||||
type AvCodecDescriptor C.struct_AVCodecDescriptor
|
||||
|
||||
const (
|
||||
AV_CODEC_PROP_INTRA_ONLY = C.AV_CODEC_PROP_INTRA_ONLY
|
||||
AV_CODEC_PROP_LOSSY = C.AV_CODEC_PROP_LOSSY
|
||||
AV_CODEC_PROP_LOSSLESS = C.AV_CODEC_PROP_LOSSLESS
|
||||
AV_CODEC_PROP_REORDER = C.AV_CODEC_PROP_REORDER
|
||||
AV_CODEC_PROP_BITMAP_SUB = C.AV_CODEC_PROP_BITMAP_SUB
|
||||
AV_CODEC_PROP_TEXT_SUB = C.AV_CODEC_PROP_TEXT_SUB
|
||||
)
|
||||
|
||||
// AvCodecDescriptorGet returns descriptor for given codec ID or NULL if no descriptor exists.
|
||||
func AvCodecDescriptorGet(id AvCodecID) *AvCodecDescriptor {
|
||||
return (*AvCodecDescriptor)(C.avcodec_descriptor_get((C.enum_AVCodecID)(id)))
|
||||
}
|
||||
|
||||
// AvCodecDescriptorNext iterates over all codec descriptors known to libavcodec.
|
||||
func AvCodecDescriptorNext(prev *AvCodecDescriptor) *AvCodecDescriptor {
|
||||
return (*AvCodecDescriptor)(C.avcodec_descriptor_next((*C.struct_AVCodecDescriptor)(prev)))
|
||||
}
|
||||
|
||||
// AvCodecDescriptorGetByName returns codec descriptor with the given name or NULL
|
||||
// if no such descriptor exists.
|
||||
func AvCodecDescriptorGetByName(name string) *AvCodecDescriptor {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (*AvCodecDescriptor)(C.avcodec_descriptor_get_by_name((*C.char)(namePtr)))
|
||||
}
|
551
avcodec_codec_id.go
Normal file
551
avcodec_codec_id.go
Normal file
@@ -0,0 +1,551 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavcodec/codec_id.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
// AvCodecID
|
||||
type AvCodecID int32
|
||||
|
||||
const (
|
||||
AV_CODEC_ID_NONE = AvCodecID(C.AV_CODEC_ID_NONE)
|
||||
|
||||
// video codecs
|
||||
AV_CODEC_ID_MPEG1VIDEO = AvCodecID(C.AV_CODEC_ID_MPEG1VIDEO)
|
||||
AV_CODEC_ID_MPEG2VIDEO = AvCodecID(C.AV_CODEC_ID_MPEG2VIDEO)
|
||||
AV_CODEC_ID_H261 = AvCodecID(C.AV_CODEC_ID_H261)
|
||||
AV_CODEC_ID_H263 = AvCodecID(C.AV_CODEC_ID_H263)
|
||||
AV_CODEC_ID_RV10 = AvCodecID(C.AV_CODEC_ID_RV10)
|
||||
AV_CODEC_ID_RV20 = AvCodecID(C.AV_CODEC_ID_RV20)
|
||||
AV_CODEC_ID_MJPEG = AvCodecID(C.AV_CODEC_ID_MJPEG)
|
||||
AV_CODEC_ID_MJPEGB = AvCodecID(C.AV_CODEC_ID_MJPEGB)
|
||||
AV_CODEC_ID_LJPEG = AvCodecID(C.AV_CODEC_ID_LJPEG)
|
||||
AV_CODEC_ID_SP5X = AvCodecID(C.AV_CODEC_ID_SP5X)
|
||||
AV_CODEC_ID_JPEGLS = AvCodecID(C.AV_CODEC_ID_JPEGLS)
|
||||
AV_CODEC_ID_MPEG4 = AvCodecID(C.AV_CODEC_ID_MPEG4)
|
||||
AV_CODEC_ID_RAWVIDEO = AvCodecID(C.AV_CODEC_ID_RAWVIDEO)
|
||||
AV_CODEC_ID_MSMPEG4V1 = AvCodecID(C.AV_CODEC_ID_MSMPEG4V1)
|
||||
AV_CODEC_ID_MSMPEG4V2 = AvCodecID(C.AV_CODEC_ID_MSMPEG4V2)
|
||||
AV_CODEC_ID_MSMPEG4V3 = AvCodecID(C.AV_CODEC_ID_MSMPEG4V3)
|
||||
AV_CODEC_ID_WMV1 = AvCodecID(C.AV_CODEC_ID_WMV1)
|
||||
AV_CODEC_ID_WMV2 = AvCodecID(C.AV_CODEC_ID_WMV2)
|
||||
AV_CODEC_ID_H263P = AvCodecID(C.AV_CODEC_ID_H263P)
|
||||
AV_CODEC_ID_H263I = AvCodecID(C.AV_CODEC_ID_H263I)
|
||||
AV_CODEC_ID_FLV1 = AvCodecID(C.AV_CODEC_ID_FLV1)
|
||||
AV_CODEC_ID_SVQ1 = AvCodecID(C.AV_CODEC_ID_SVQ1)
|
||||
AV_CODEC_ID_SVQ3 = AvCodecID(C.AV_CODEC_ID_SVQ3)
|
||||
AV_CODEC_ID_DVVIDEO = AvCodecID(C.AV_CODEC_ID_DVVIDEO)
|
||||
AV_CODEC_ID_HUFFYUV = AvCodecID(C.AV_CODEC_ID_HUFFYUV)
|
||||
AV_CODEC_ID_CYUV = AvCodecID(C.AV_CODEC_ID_CYUV)
|
||||
AV_CODEC_ID_H264 = AvCodecID(C.AV_CODEC_ID_H264)
|
||||
AV_CODEC_ID_INDEO3 = AvCodecID(C.AV_CODEC_ID_INDEO3)
|
||||
AV_CODEC_ID_VP3 = AvCodecID(C.AV_CODEC_ID_VP3)
|
||||
AV_CODEC_ID_THEORA = AvCodecID(C.AV_CODEC_ID_THEORA)
|
||||
AV_CODEC_ID_ASV1 = AvCodecID(C.AV_CODEC_ID_ASV1)
|
||||
AV_CODEC_ID_ASV2 = AvCodecID(C.AV_CODEC_ID_ASV2)
|
||||
AV_CODEC_ID_FFV1 = AvCodecID(C.AV_CODEC_ID_FFV1)
|
||||
AV_CODEC_ID_4XM = AvCodecID(C.AV_CODEC_ID_4XM)
|
||||
AV_CODEC_ID_VCR1 = AvCodecID(C.AV_CODEC_ID_VCR1)
|
||||
AV_CODEC_ID_CLJR = AvCodecID(C.AV_CODEC_ID_CLJR)
|
||||
AV_CODEC_ID_MDEC = AvCodecID(C.AV_CODEC_ID_MDEC)
|
||||
AV_CODEC_ID_ROQ = AvCodecID(C.AV_CODEC_ID_ROQ)
|
||||
AV_CODEC_ID_INTERPLAY_VIDEO = AvCodecID(C.AV_CODEC_ID_INTERPLAY_VIDEO)
|
||||
AV_CODEC_ID_XAN_WC3 = AvCodecID(C.AV_CODEC_ID_XAN_WC3)
|
||||
AV_CODEC_ID_XAN_WC4 = AvCodecID(C.AV_CODEC_ID_XAN_WC4)
|
||||
AV_CODEC_ID_RPZA = AvCodecID(C.AV_CODEC_ID_RPZA)
|
||||
AV_CODEC_ID_CINEPAK = AvCodecID(C.AV_CODEC_ID_CINEPAK)
|
||||
AV_CODEC_ID_WS_VQA = AvCodecID(C.AV_CODEC_ID_WS_VQA)
|
||||
AV_CODEC_ID_MSRLE = AvCodecID(C.AV_CODEC_ID_MSRLE)
|
||||
AV_CODEC_ID_MSVIDEO1 = AvCodecID(C.AV_CODEC_ID_MSVIDEO1)
|
||||
AV_CODEC_ID_IDCIN = AvCodecID(C.AV_CODEC_ID_IDCIN)
|
||||
AV_CODEC_ID_8BPS = AvCodecID(C.AV_CODEC_ID_8BPS)
|
||||
AV_CODEC_ID_SMC = AvCodecID(C.AV_CODEC_ID_SMC)
|
||||
AV_CODEC_ID_FLIC = AvCodecID(C.AV_CODEC_ID_FLIC)
|
||||
AV_CODEC_ID_TRUEMOTION1 = AvCodecID(C.AV_CODEC_ID_TRUEMOTION1)
|
||||
AV_CODEC_ID_VMDVIDEO = AvCodecID(C.AV_CODEC_ID_VMDVIDEO)
|
||||
AV_CODEC_ID_MSZH = AvCodecID(C.AV_CODEC_ID_MSZH)
|
||||
AV_CODEC_ID_ZLIB = AvCodecID(C.AV_CODEC_ID_ZLIB)
|
||||
AV_CODEC_ID_QTRLE = AvCodecID(C.AV_CODEC_ID_QTRLE)
|
||||
AV_CODEC_ID_TSCC = AvCodecID(C.AV_CODEC_ID_TSCC)
|
||||
AV_CODEC_ID_ULTI = AvCodecID(C.AV_CODEC_ID_ULTI)
|
||||
AV_CODEC_ID_QDRAW = AvCodecID(C.AV_CODEC_ID_QDRAW)
|
||||
AV_CODEC_ID_VIXL = AvCodecID(C.AV_CODEC_ID_VIXL)
|
||||
AV_CODEC_ID_QPEG = AvCodecID(C.AV_CODEC_ID_QPEG)
|
||||
AV_CODEC_ID_PNG = AvCodecID(C.AV_CODEC_ID_PNG)
|
||||
AV_CODEC_ID_PPM = AvCodecID(C.AV_CODEC_ID_PPM)
|
||||
AV_CODEC_ID_PBM = AvCodecID(C.AV_CODEC_ID_PBM)
|
||||
AV_CODEC_ID_PGM = AvCodecID(C.AV_CODEC_ID_PGM)
|
||||
AV_CODEC_ID_PGMYUV = AvCodecID(C.AV_CODEC_ID_PGMYUV)
|
||||
AV_CODEC_ID_PAM = AvCodecID(C.AV_CODEC_ID_PAM)
|
||||
AV_CODEC_ID_FFVHUFF = AvCodecID(C.AV_CODEC_ID_FFVHUFF)
|
||||
AV_CODEC_ID_RV30 = AvCodecID(C.AV_CODEC_ID_RV30)
|
||||
AV_CODEC_ID_RV40 = AvCodecID(C.AV_CODEC_ID_RV40)
|
||||
AV_CODEC_ID_VC1 = AvCodecID(C.AV_CODEC_ID_VC1)
|
||||
AV_CODEC_ID_WMV3 = AvCodecID(C.AV_CODEC_ID_WMV3)
|
||||
AV_CODEC_ID_LOCO = AvCodecID(C.AV_CODEC_ID_LOCO)
|
||||
AV_CODEC_ID_WNV1 = AvCodecID(C.AV_CODEC_ID_WNV1)
|
||||
AV_CODEC_ID_AASC = AvCodecID(C.AV_CODEC_ID_AASC)
|
||||
AV_CODEC_ID_INDEO2 = AvCodecID(C.AV_CODEC_ID_INDEO2)
|
||||
AV_CODEC_ID_FRAPS = AvCodecID(C.AV_CODEC_ID_FRAPS)
|
||||
AV_CODEC_ID_TRUEMOTION2 = AvCodecID(C.AV_CODEC_ID_TRUEMOTION2)
|
||||
AV_CODEC_ID_BMP = AvCodecID(C.AV_CODEC_ID_BMP)
|
||||
AV_CODEC_ID_CSCD = AvCodecID(C.AV_CODEC_ID_CSCD)
|
||||
AV_CODEC_ID_MMVIDEO = AvCodecID(C.AV_CODEC_ID_MMVIDEO)
|
||||
AV_CODEC_ID_ZMBV = AvCodecID(C.AV_CODEC_ID_ZMBV)
|
||||
AV_CODEC_ID_AVS = AvCodecID(C.AV_CODEC_ID_AVS)
|
||||
AV_CODEC_ID_SMACKVIDEO = AvCodecID(C.AV_CODEC_ID_SMACKVIDEO)
|
||||
AV_CODEC_ID_NUV = AvCodecID(C.AV_CODEC_ID_NUV)
|
||||
AV_CODEC_ID_KMVC = AvCodecID(C.AV_CODEC_ID_KMVC)
|
||||
AV_CODEC_ID_FLASHSV = AvCodecID(C.AV_CODEC_ID_FLASHSV)
|
||||
AV_CODEC_ID_CAVS = AvCodecID(C.AV_CODEC_ID_CAVS)
|
||||
AV_CODEC_ID_JPEG2000 = AvCodecID(C.AV_CODEC_ID_JPEG2000)
|
||||
AV_CODEC_ID_VMNC = AvCodecID(C.AV_CODEC_ID_VMNC)
|
||||
AV_CODEC_ID_VP5 = AvCodecID(C.AV_CODEC_ID_VP5)
|
||||
AV_CODEC_ID_VP6 = AvCodecID(C.AV_CODEC_ID_VP6)
|
||||
AV_CODEC_ID_VP6F = AvCodecID(C.AV_CODEC_ID_VP6F)
|
||||
AV_CODEC_ID_TARGA = AvCodecID(C.AV_CODEC_ID_TARGA)
|
||||
AV_CODEC_ID_DSICINVIDEO = AvCodecID(C.AV_CODEC_ID_DSICINVIDEO)
|
||||
AV_CODEC_ID_TIERTEXSEQVIDEO = AvCodecID(C.AV_CODEC_ID_TIERTEXSEQVIDEO)
|
||||
AV_CODEC_ID_TIFF = AvCodecID(C.AV_CODEC_ID_TIFF)
|
||||
AV_CODEC_ID_GIF = AvCodecID(C.AV_CODEC_ID_GIF)
|
||||
AV_CODEC_ID_DXA = AvCodecID(C.AV_CODEC_ID_DXA)
|
||||
AV_CODEC_ID_DNXHD = AvCodecID(C.AV_CODEC_ID_DNXHD)
|
||||
AV_CODEC_ID_THP = AvCodecID(C.AV_CODEC_ID_THP)
|
||||
AV_CODEC_ID_SGI = AvCodecID(C.AV_CODEC_ID_SGI)
|
||||
AV_CODEC_ID_C93 = AvCodecID(C.AV_CODEC_ID_C93)
|
||||
AV_CODEC_ID_BETHSOFTVID = AvCodecID(C.AV_CODEC_ID_BETHSOFTVID)
|
||||
AV_CODEC_ID_PTX = AvCodecID(C.AV_CODEC_ID_PTX)
|
||||
AV_CODEC_ID_TXD = AvCodecID(C.AV_CODEC_ID_TXD)
|
||||
AV_CODEC_ID_VP6A = AvCodecID(C.AV_CODEC_ID_VP6A)
|
||||
AV_CODEC_ID_AMV = AvCodecID(C.AV_CODEC_ID_AMV)
|
||||
AV_CODEC_ID_VB = AvCodecID(C.AV_CODEC_ID_VB)
|
||||
AV_CODEC_ID_PCX = AvCodecID(C.AV_CODEC_ID_PCX)
|
||||
AV_CODEC_ID_SUNRAST = AvCodecID(C.AV_CODEC_ID_SUNRAST)
|
||||
AV_CODEC_ID_INDEO4 = AvCodecID(C.AV_CODEC_ID_INDEO4)
|
||||
AV_CODEC_ID_INDEO5 = AvCodecID(C.AV_CODEC_ID_INDEO5)
|
||||
AV_CODEC_ID_MIMIC = AvCodecID(C.AV_CODEC_ID_MIMIC)
|
||||
AV_CODEC_ID_RL2 = AvCodecID(C.AV_CODEC_ID_RL2)
|
||||
AV_CODEC_ID_ESCAPE124 = AvCodecID(C.AV_CODEC_ID_ESCAPE124)
|
||||
AV_CODEC_ID_DIRAC = AvCodecID(C.AV_CODEC_ID_DIRAC)
|
||||
AV_CODEC_ID_BFI = AvCodecID(C.AV_CODEC_ID_BFI)
|
||||
AV_CODEC_ID_CMV = AvCodecID(C.AV_CODEC_ID_CMV)
|
||||
AV_CODEC_ID_MOTIONPIXELS = AvCodecID(C.AV_CODEC_ID_MOTIONPIXELS)
|
||||
AV_CODEC_ID_TGV = AvCodecID(C.AV_CODEC_ID_TGV)
|
||||
AV_CODEC_ID_TGQ = AvCodecID(C.AV_CODEC_ID_TGQ)
|
||||
AV_CODEC_ID_TQI = AvCodecID(C.AV_CODEC_ID_TQI)
|
||||
AV_CODEC_ID_AURA = AvCodecID(C.AV_CODEC_ID_AURA)
|
||||
AV_CODEC_ID_AURA2 = AvCodecID(C.AV_CODEC_ID_AURA2)
|
||||
AV_CODEC_ID_V210X = AvCodecID(C.AV_CODEC_ID_V210X)
|
||||
AV_CODEC_ID_TMV = AvCodecID(C.AV_CODEC_ID_TMV)
|
||||
AV_CODEC_ID_V210 = AvCodecID(C.AV_CODEC_ID_V210)
|
||||
AV_CODEC_ID_DPX = AvCodecID(C.AV_CODEC_ID_DPX)
|
||||
AV_CODEC_ID_MAD = AvCodecID(C.AV_CODEC_ID_MAD)
|
||||
AV_CODEC_ID_FRWU = AvCodecID(C.AV_CODEC_ID_FRWU)
|
||||
AV_CODEC_ID_FLASHSV2 = AvCodecID(C.AV_CODEC_ID_FLASHSV2)
|
||||
AV_CODEC_ID_CDGRAPHICS = AvCodecID(C.AV_CODEC_ID_CDGRAPHICS)
|
||||
AV_CODEC_ID_R210 = AvCodecID(C.AV_CODEC_ID_R210)
|
||||
AV_CODEC_ID_ANM = AvCodecID(C.AV_CODEC_ID_ANM)
|
||||
AV_CODEC_ID_BINKVIDEO = AvCodecID(C.AV_CODEC_ID_BINKVIDEO)
|
||||
AV_CODEC_ID_IFF_ILBM = AvCodecID(C.AV_CODEC_ID_IFF_ILBM)
|
||||
AV_CODEC_ID_IFF_BYTERUN1 = AvCodecID(C.AV_CODEC_ID_IFF_BYTERUN1)
|
||||
AV_CODEC_ID_KGV1 = AvCodecID(C.AV_CODEC_ID_KGV1)
|
||||
AV_CODEC_ID_YOP = AvCodecID(C.AV_CODEC_ID_YOP)
|
||||
AV_CODEC_ID_VP8 = AvCodecID(C.AV_CODEC_ID_VP8)
|
||||
AV_CODEC_ID_PICTOR = AvCodecID(C.AV_CODEC_ID_PICTOR)
|
||||
AV_CODEC_ID_ANSI = AvCodecID(C.AV_CODEC_ID_ANSI)
|
||||
AV_CODEC_ID_A64_MULTI = AvCodecID(C.AV_CODEC_ID_A64_MULTI)
|
||||
AV_CODEC_ID_A64_MULTI5 = AvCodecID(C.AV_CODEC_ID_A64_MULTI5)
|
||||
AV_CODEC_ID_R10K = AvCodecID(C.AV_CODEC_ID_R10K)
|
||||
AV_CODEC_ID_MXPEG = AvCodecID(C.AV_CODEC_ID_MXPEG)
|
||||
AV_CODEC_ID_LAGARITH = AvCodecID(C.AV_CODEC_ID_LAGARITH)
|
||||
AV_CODEC_ID_PRORES = AvCodecID(C.AV_CODEC_ID_PRORES)
|
||||
AV_CODEC_ID_JV = AvCodecID(C.AV_CODEC_ID_JV)
|
||||
AV_CODEC_ID_DFA = AvCodecID(C.AV_CODEC_ID_DFA)
|
||||
AV_CODEC_ID_WMV3IMAGE = AvCodecID(C.AV_CODEC_ID_WMV3IMAGE)
|
||||
AV_CODEC_ID_VC1IMAGE = AvCodecID(C.AV_CODEC_ID_VC1IMAGE)
|
||||
AV_CODEC_ID_UTVIDEO = AvCodecID(C.AV_CODEC_ID_UTVIDEO)
|
||||
AV_CODEC_ID_BMV_VIDEO = AvCodecID(C.AV_CODEC_ID_BMV_VIDEO)
|
||||
AV_CODEC_ID_VBLE = AvCodecID(C.AV_CODEC_ID_VBLE)
|
||||
AV_CODEC_ID_DXTORY = AvCodecID(C.AV_CODEC_ID_DXTORY)
|
||||
AV_CODEC_ID_V410 = AvCodecID(C.AV_CODEC_ID_V410)
|
||||
AV_CODEC_ID_XWD = AvCodecID(C.AV_CODEC_ID_XWD)
|
||||
AV_CODEC_ID_CDXL = AvCodecID(C.AV_CODEC_ID_CDXL)
|
||||
AV_CODEC_ID_XBM = AvCodecID(C.AV_CODEC_ID_XBM)
|
||||
AV_CODEC_ID_ZEROCODEC = AvCodecID(C.AV_CODEC_ID_ZEROCODEC)
|
||||
AV_CODEC_ID_MSS1 = AvCodecID(C.AV_CODEC_ID_MSS1)
|
||||
AV_CODEC_ID_MSA1 = AvCodecID(C.AV_CODEC_ID_MSA1)
|
||||
AV_CODEC_ID_TSCC2 = AvCodecID(C.AV_CODEC_ID_TSCC2)
|
||||
AV_CODEC_ID_MTS2 = AvCodecID(C.AV_CODEC_ID_MTS2)
|
||||
AV_CODEC_ID_CLLC = AvCodecID(C.AV_CODEC_ID_CLLC)
|
||||
AV_CODEC_ID_MSS2 = AvCodecID(C.AV_CODEC_ID_MSS2)
|
||||
AV_CODEC_ID_VP9 = AvCodecID(C.AV_CODEC_ID_VP9)
|
||||
AV_CODEC_ID_AIC = AvCodecID(C.AV_CODEC_ID_AIC)
|
||||
AV_CODEC_ID_ESCAPE130 = AvCodecID(C.AV_CODEC_ID_ESCAPE130)
|
||||
AV_CODEC_ID_G2M = AvCodecID(C.AV_CODEC_ID_G2M)
|
||||
AV_CODEC_ID_WEBP = AvCodecID(C.AV_CODEC_ID_WEBP)
|
||||
AV_CODEC_ID_HNM4_VIDEO = AvCodecID(C.AV_CODEC_ID_HNM4_VIDEO)
|
||||
AV_CODEC_ID_HEVC = AvCodecID(C.AV_CODEC_ID_HEVC)
|
||||
AV_CODEC_ID_H265 = AvCodecID(C.AV_CODEC_ID_H265)
|
||||
AV_CODEC_ID_FIC = AvCodecID(C.AV_CODEC_ID_FIC)
|
||||
AV_CODEC_ID_ALIAS_PIX = AvCodecID(C.AV_CODEC_ID_ALIAS_PIX)
|
||||
AV_CODEC_ID_BRENDER_PIX = AvCodecID(C.AV_CODEC_ID_BRENDER_PIX)
|
||||
AV_CODEC_ID_PAF_VIDEO = AvCodecID(C.AV_CODEC_ID_PAF_VIDEO)
|
||||
AV_CODEC_ID_EXR = AvCodecID(C.AV_CODEC_ID_EXR)
|
||||
AV_CODEC_ID_VP7 = AvCodecID(C.AV_CODEC_ID_VP7)
|
||||
AV_CODEC_ID_SANM = AvCodecID(C.AV_CODEC_ID_SANM)
|
||||
AV_CODEC_ID_SGIRLE = AvCodecID(C.AV_CODEC_ID_SGIRLE)
|
||||
AV_CODEC_ID_MVC1 = AvCodecID(C.AV_CODEC_ID_MVC1)
|
||||
AV_CODEC_ID_MVC2 = AvCodecID(C.AV_CODEC_ID_MVC2)
|
||||
AV_CODEC_ID_HQX = AvCodecID(C.AV_CODEC_ID_HQX)
|
||||
AV_CODEC_ID_TDSC = AvCodecID(C.AV_CODEC_ID_TDSC)
|
||||
AV_CODEC_ID_HQ_HQA = AvCodecID(C.AV_CODEC_ID_HQ_HQA)
|
||||
AV_CODEC_ID_HAP = AvCodecID(C.AV_CODEC_ID_HAP)
|
||||
AV_CODEC_ID_DDS = AvCodecID(C.AV_CODEC_ID_DDS)
|
||||
AV_CODEC_ID_DXV = AvCodecID(C.AV_CODEC_ID_DXV)
|
||||
AV_CODEC_ID_SCREENPRESSO = AvCodecID(C.AV_CODEC_ID_SCREENPRESSO)
|
||||
AV_CODEC_ID_RSCC = AvCodecID(C.AV_CODEC_ID_RSCC)
|
||||
AV_CODEC_ID_AVS2 = AvCodecID(C.AV_CODEC_ID_AVS2)
|
||||
AV_CODEC_ID_PGX = AvCodecID(C.AV_CODEC_ID_PGX)
|
||||
AV_CODEC_ID_AVS3 = AvCodecID(C.AV_CODEC_ID_AVS3)
|
||||
AV_CODEC_ID_MSP2 = AvCodecID(C.AV_CODEC_ID_MSP2)
|
||||
AV_CODEC_ID_VVC = AvCodecID(C.AV_CODEC_ID_VVC)
|
||||
AV_CODEC_ID_H266 = AvCodecID(C.AV_CODEC_ID_H266)
|
||||
AV_CODEC_ID_Y41P = AvCodecID(C.AV_CODEC_ID_Y41P)
|
||||
AV_CODEC_ID_AVRP = AvCodecID(C.AV_CODEC_ID_AVRP)
|
||||
AV_CODEC_ID_012V = AvCodecID(C.AV_CODEC_ID_012V)
|
||||
AV_CODEC_ID_AVUI = AvCodecID(C.AV_CODEC_ID_AVUI)
|
||||
AV_CODEC_ID_AYUV = AvCodecID(C.AV_CODEC_ID_AYUV)
|
||||
AV_CODEC_ID_TARGA_Y216 = AvCodecID(C.AV_CODEC_ID_TARGA_Y216)
|
||||
AV_CODEC_ID_V308 = AvCodecID(C.AV_CODEC_ID_V308)
|
||||
AV_CODEC_ID_V408 = AvCodecID(C.AV_CODEC_ID_V408)
|
||||
AV_CODEC_ID_YUV4 = AvCodecID(C.AV_CODEC_ID_YUV4)
|
||||
AV_CODEC_ID_AVRN = AvCodecID(C.AV_CODEC_ID_AVRN)
|
||||
AV_CODEC_ID_CPIA = AvCodecID(C.AV_CODEC_ID_CPIA)
|
||||
AV_CODEC_ID_XFACE = AvCodecID(C.AV_CODEC_ID_XFACE)
|
||||
AV_CODEC_ID_SNOW = AvCodecID(C.AV_CODEC_ID_SNOW)
|
||||
AV_CODEC_ID_SMVJPEG = AvCodecID(C.AV_CODEC_ID_SMVJPEG)
|
||||
AV_CODEC_ID_APNG = AvCodecID(C.AV_CODEC_ID_APNG)
|
||||
AV_CODEC_ID_DAALA = AvCodecID(C.AV_CODEC_ID_DAALA)
|
||||
AV_CODEC_ID_CFHD = AvCodecID(C.AV_CODEC_ID_CFHD)
|
||||
AV_CODEC_ID_TRUEMOTION2RT = AvCodecID(C.AV_CODEC_ID_TRUEMOTION2RT)
|
||||
AV_CODEC_ID_M101 = AvCodecID(C.AV_CODEC_ID_M101)
|
||||
AV_CODEC_ID_MAGICYUV = AvCodecID(C.AV_CODEC_ID_MAGICYUV)
|
||||
AV_CODEC_ID_SHEERVIDEO = AvCodecID(C.AV_CODEC_ID_SHEERVIDEO)
|
||||
AV_CODEC_ID_YLC = AvCodecID(C.AV_CODEC_ID_YLC)
|
||||
AV_CODEC_ID_PSD = AvCodecID(C.AV_CODEC_ID_PSD)
|
||||
AV_CODEC_ID_PIXLET = AvCodecID(C.AV_CODEC_ID_PIXLET)
|
||||
AV_CODEC_ID_SPEEDHQ = AvCodecID(C.AV_CODEC_ID_SPEEDHQ)
|
||||
AV_CODEC_ID_FMVC = AvCodecID(C.AV_CODEC_ID_FMVC)
|
||||
AV_CODEC_ID_SCPR = AvCodecID(C.AV_CODEC_ID_SCPR)
|
||||
AV_CODEC_ID_CLEARVIDEO = AvCodecID(C.AV_CODEC_ID_CLEARVIDEO)
|
||||
AV_CODEC_ID_XPM = AvCodecID(C.AV_CODEC_ID_XPM)
|
||||
AV_CODEC_ID_AV1 = AvCodecID(C.AV_CODEC_ID_AV1)
|
||||
AV_CODEC_ID_BITPACKED = AvCodecID(C.AV_CODEC_ID_BITPACKED)
|
||||
AV_CODEC_ID_MSCC = AvCodecID(C.AV_CODEC_ID_MSCC)
|
||||
AV_CODEC_ID_SRGC = AvCodecID(C.AV_CODEC_ID_SRGC)
|
||||
AV_CODEC_ID_SVG = AvCodecID(C.AV_CODEC_ID_SVG)
|
||||
AV_CODEC_ID_GDV = AvCodecID(C.AV_CODEC_ID_GDV)
|
||||
AV_CODEC_ID_FITS = AvCodecID(C.AV_CODEC_ID_FITS)
|
||||
AV_CODEC_ID_IMM4 = AvCodecID(C.AV_CODEC_ID_IMM4)
|
||||
AV_CODEC_ID_PROSUMER = AvCodecID(C.AV_CODEC_ID_PROSUMER)
|
||||
AV_CODEC_ID_MWSC = AvCodecID(C.AV_CODEC_ID_MWSC)
|
||||
AV_CODEC_ID_WCMV = AvCodecID(C.AV_CODEC_ID_WCMV)
|
||||
AV_CODEC_ID_RASC = AvCodecID(C.AV_CODEC_ID_RASC)
|
||||
AV_CODEC_ID_HYMT = AvCodecID(C.AV_CODEC_ID_HYMT)
|
||||
AV_CODEC_ID_ARBC = AvCodecID(C.AV_CODEC_ID_ARBC)
|
||||
AV_CODEC_ID_AGM = AvCodecID(C.AV_CODEC_ID_AGM)
|
||||
AV_CODEC_ID_LSCR = AvCodecID(C.AV_CODEC_ID_LSCR)
|
||||
AV_CODEC_ID_VP4 = AvCodecID(C.AV_CODEC_ID_VP4)
|
||||
AV_CODEC_ID_IMM5 = AvCodecID(C.AV_CODEC_ID_IMM5)
|
||||
AV_CODEC_ID_MVDV = AvCodecID(C.AV_CODEC_ID_MVDV)
|
||||
AV_CODEC_ID_MVHA = AvCodecID(C.AV_CODEC_ID_MVHA)
|
||||
AV_CODEC_ID_CDTOONS = AvCodecID(C.AV_CODEC_ID_CDTOONS)
|
||||
AV_CODEC_ID_MV30 = AvCodecID(C.AV_CODEC_ID_MV30)
|
||||
AV_CODEC_ID_NOTCHLC = AvCodecID(C.AV_CODEC_ID_NOTCHLC)
|
||||
AV_CODEC_ID_PFM = AvCodecID(C.AV_CODEC_ID_PFM)
|
||||
AV_CODEC_ID_MOBICLIP = AvCodecID(C.AV_CODEC_ID_MOBICLIP)
|
||||
AV_CODEC_ID_PHOTOCD = AvCodecID(C.AV_CODEC_ID_PHOTOCD)
|
||||
AV_CODEC_ID_IPU = AvCodecID(C.AV_CODEC_ID_IPU)
|
||||
AV_CODEC_ID_ARGO = AvCodecID(C.AV_CODEC_ID_ARGO)
|
||||
AV_CODEC_ID_CRI = AvCodecID(C.AV_CODEC_ID_CRI)
|
||||
AV_CODEC_ID_SIMBIOSIS_IMX = AvCodecID(C.AV_CODEC_ID_SIMBIOSIS_IMX)
|
||||
AV_CODEC_ID_SGA_VIDEO = AvCodecID(C.AV_CODEC_ID_SGA_VIDEO)
|
||||
|
||||
// various PCM "codecs"
|
||||
AV_CODEC_ID_FIRST_AUDIO = AvCodecID(C.AV_CODEC_ID_FIRST_AUDIO)
|
||||
AV_CODEC_ID_PCM_S16LE = AvCodecID(C.AV_CODEC_ID_PCM_S16LE)
|
||||
AV_CODEC_ID_PCM_S16BE = AvCodecID(C.AV_CODEC_ID_PCM_S16BE)
|
||||
AV_CODEC_ID_PCM_U16LE = AvCodecID(C.AV_CODEC_ID_PCM_U16LE)
|
||||
AV_CODEC_ID_PCM_U16BE = AvCodecID(C.AV_CODEC_ID_PCM_U16BE)
|
||||
AV_CODEC_ID_PCM_S8 = AvCodecID(C.AV_CODEC_ID_PCM_S8)
|
||||
AV_CODEC_ID_PCM_U8 = AvCodecID(C.AV_CODEC_ID_PCM_U8)
|
||||
AV_CODEC_ID_PCM_MULAW = AvCodecID(C.AV_CODEC_ID_PCM_MULAW)
|
||||
AV_CODEC_ID_PCM_ALAW = AvCodecID(C.AV_CODEC_ID_PCM_ALAW)
|
||||
AV_CODEC_ID_PCM_S32LE = AvCodecID(C.AV_CODEC_ID_PCM_S32LE)
|
||||
AV_CODEC_ID_PCM_S32BE = AvCodecID(C.AV_CODEC_ID_PCM_S32BE)
|
||||
AV_CODEC_ID_PCM_U32LE = AvCodecID(C.AV_CODEC_ID_PCM_U32LE)
|
||||
AV_CODEC_ID_PCM_U32BE = AvCodecID(C.AV_CODEC_ID_PCM_U32BE)
|
||||
AV_CODEC_ID_PCM_S24LE = AvCodecID(C.AV_CODEC_ID_PCM_S24LE)
|
||||
AV_CODEC_ID_PCM_S24BE = AvCodecID(C.AV_CODEC_ID_PCM_S24BE)
|
||||
AV_CODEC_ID_PCM_U24LE = AvCodecID(C.AV_CODEC_ID_PCM_U24LE)
|
||||
AV_CODEC_ID_PCM_U24BE = AvCodecID(C.AV_CODEC_ID_PCM_U24BE)
|
||||
AV_CODEC_ID_PCM_S24DAUD = AvCodecID(C.AV_CODEC_ID_PCM_S24DAUD)
|
||||
AV_CODEC_ID_PCM_ZORK = AvCodecID(C.AV_CODEC_ID_PCM_ZORK)
|
||||
AV_CODEC_ID_PCM_S16LE_PLANAR = AvCodecID(C.AV_CODEC_ID_PCM_S16LE_PLANAR)
|
||||
AV_CODEC_ID_PCM_DVD = AvCodecID(C.AV_CODEC_ID_PCM_DVD)
|
||||
AV_CODEC_ID_PCM_F32BE = AvCodecID(C.AV_CODEC_ID_PCM_F32BE)
|
||||
AV_CODEC_ID_PCM_F32LE = AvCodecID(C.AV_CODEC_ID_PCM_F32LE)
|
||||
AV_CODEC_ID_PCM_F64BE = AvCodecID(C.AV_CODEC_ID_PCM_F64BE)
|
||||
AV_CODEC_ID_PCM_F64LE = AvCodecID(C.AV_CODEC_ID_PCM_F64LE)
|
||||
AV_CODEC_ID_PCM_BLURAY = AvCodecID(C.AV_CODEC_ID_PCM_BLURAY)
|
||||
AV_CODEC_ID_PCM_LXF = AvCodecID(C.AV_CODEC_ID_PCM_LXF)
|
||||
AV_CODEC_ID_S302M = AvCodecID(C.AV_CODEC_ID_S302M)
|
||||
AV_CODEC_ID_PCM_S8_PLANAR = AvCodecID(C.AV_CODEC_ID_PCM_S8_PLANAR)
|
||||
AV_CODEC_ID_PCM_S24LE_PLANAR = AvCodecID(C.AV_CODEC_ID_PCM_S24LE_PLANAR)
|
||||
AV_CODEC_ID_PCM_S32LE_PLANAR = AvCodecID(C.AV_CODEC_ID_PCM_S32LE_PLANAR)
|
||||
AV_CODEC_ID_PCM_S16BE_PLANAR = AvCodecID(C.AV_CODEC_ID_PCM_S16BE_PLANAR)
|
||||
AV_CODEC_ID_PCM_S64LE = AvCodecID(C.AV_CODEC_ID_PCM_S64LE)
|
||||
AV_CODEC_ID_PCM_S64BE = AvCodecID(C.AV_CODEC_ID_PCM_S64BE)
|
||||
AV_CODEC_ID_PCM_F16LE = AvCodecID(C.AV_CODEC_ID_PCM_F16LE)
|
||||
AV_CODEC_ID_PCM_F24LE = AvCodecID(C.AV_CODEC_ID_PCM_F24LE)
|
||||
AV_CODEC_ID_PCM_VIDC = AvCodecID(C.AV_CODEC_ID_PCM_VIDC)
|
||||
AV_CODEC_ID_PCM_SGA = AvCodecID(C.AV_CODEC_ID_PCM_SGA)
|
||||
|
||||
// various ADPCM codecs
|
||||
AV_CODEC_ID_ADPCM_IMA_QT = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_QT)
|
||||
AV_CODEC_ID_ADPCM_IMA_WAV = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_WAV)
|
||||
AV_CODEC_ID_ADPCM_IMA_DK3 = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_DK3)
|
||||
AV_CODEC_ID_ADPCM_IMA_DK4 = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_DK4)
|
||||
AV_CODEC_ID_ADPCM_IMA_WS = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_WS)
|
||||
AV_CODEC_ID_ADPCM_IMA_SMJPEG = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_SMJPEG)
|
||||
AV_CODEC_ID_ADPCM_MS = AvCodecID(C.AV_CODEC_ID_ADPCM_MS)
|
||||
AV_CODEC_ID_ADPCM_4XM = AvCodecID(C.AV_CODEC_ID_ADPCM_4XM)
|
||||
AV_CODEC_ID_ADPCM_XA = AvCodecID(C.AV_CODEC_ID_ADPCM_XA)
|
||||
AV_CODEC_ID_ADPCM_ADX = AvCodecID(C.AV_CODEC_ID_ADPCM_ADX)
|
||||
AV_CODEC_ID_ADPCM_EA = AvCodecID(C.AV_CODEC_ID_ADPCM_EA)
|
||||
AV_CODEC_ID_ADPCM_G726 = AvCodecID(C.AV_CODEC_ID_ADPCM_G726)
|
||||
AV_CODEC_ID_ADPCM_CT = AvCodecID(C.AV_CODEC_ID_ADPCM_CT)
|
||||
AV_CODEC_ID_ADPCM_SWF = AvCodecID(C.AV_CODEC_ID_ADPCM_SWF)
|
||||
AV_CODEC_ID_ADPCM_YAMAHA = AvCodecID(C.AV_CODEC_ID_ADPCM_YAMAHA)
|
||||
AV_CODEC_ID_ADPCM_SBPRO_4 = AvCodecID(C.AV_CODEC_ID_ADPCM_SBPRO_4)
|
||||
AV_CODEC_ID_ADPCM_SBPRO_3 = AvCodecID(C.AV_CODEC_ID_ADPCM_SBPRO_3)
|
||||
AV_CODEC_ID_ADPCM_SBPRO_2 = AvCodecID(C.AV_CODEC_ID_ADPCM_SBPRO_2)
|
||||
AV_CODEC_ID_ADPCM_THP = AvCodecID(C.AV_CODEC_ID_ADPCM_THP)
|
||||
AV_CODEC_ID_ADPCM_IMA_AMV = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_AMV)
|
||||
AV_CODEC_ID_ADPCM_EA_R1 = AvCodecID(C.AV_CODEC_ID_ADPCM_EA_R1)
|
||||
AV_CODEC_ID_ADPCM_EA_R3 = AvCodecID(C.AV_CODEC_ID_ADPCM_EA_R3)
|
||||
AV_CODEC_ID_ADPCM_EA_R2 = AvCodecID(C.AV_CODEC_ID_ADPCM_EA_R2)
|
||||
AV_CODEC_ID_ADPCM_IMA_EA_SEAD = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_EA_SEAD)
|
||||
AV_CODEC_ID_ADPCM_IMA_EA_EACS = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_EA_EACS)
|
||||
AV_CODEC_ID_ADPCM_EA_XAS = AvCodecID(C.AV_CODEC_ID_ADPCM_EA_XAS)
|
||||
AV_CODEC_ID_ADPCM_EA_MAXIS_XA = AvCodecID(C.AV_CODEC_ID_ADPCM_EA_MAXIS_XA)
|
||||
AV_CODEC_ID_ADPCM_IMA_ISS = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_ISS)
|
||||
AV_CODEC_ID_ADPCM_G722 = AvCodecID(C.AV_CODEC_ID_ADPCM_G722)
|
||||
AV_CODEC_ID_ADPCM_IMA_APC = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_APC)
|
||||
AV_CODEC_ID_ADPCM_VIMA = AvCodecID(C.AV_CODEC_ID_ADPCM_VIMA)
|
||||
AV_CODEC_ID_ADPCM_AFC = AvCodecID(C.AV_CODEC_ID_ADPCM_AFC)
|
||||
AV_CODEC_ID_ADPCM_IMA_OKI = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_OKI)
|
||||
AV_CODEC_ID_ADPCM_DTK = AvCodecID(C.AV_CODEC_ID_ADPCM_DTK)
|
||||
AV_CODEC_ID_ADPCM_IMA_RAD = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_RAD)
|
||||
AV_CODEC_ID_ADPCM_G726LE = AvCodecID(C.AV_CODEC_ID_ADPCM_G726LE)
|
||||
AV_CODEC_ID_ADPCM_THP_LE = AvCodecID(C.AV_CODEC_ID_ADPCM_THP_LE)
|
||||
AV_CODEC_ID_ADPCM_PSX = AvCodecID(C.AV_CODEC_ID_ADPCM_PSX)
|
||||
AV_CODEC_ID_ADPCM_AICA = AvCodecID(C.AV_CODEC_ID_ADPCM_AICA)
|
||||
AV_CODEC_ID_ADPCM_IMA_DAT4 = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_DAT4)
|
||||
AV_CODEC_ID_ADPCM_MTAF = AvCodecID(C.AV_CODEC_ID_ADPCM_MTAF)
|
||||
AV_CODEC_ID_ADPCM_AGM = AvCodecID(C.AV_CODEC_ID_ADPCM_AGM)
|
||||
AV_CODEC_ID_ADPCM_ARGO = AvCodecID(C.AV_CODEC_ID_ADPCM_ARGO)
|
||||
AV_CODEC_ID_ADPCM_IMA_SSI = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_SSI)
|
||||
AV_CODEC_ID_ADPCM_ZORK = AvCodecID(C.AV_CODEC_ID_ADPCM_ZORK)
|
||||
AV_CODEC_ID_ADPCM_IMA_APM = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_APM)
|
||||
AV_CODEC_ID_ADPCM_IMA_ALP = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_ALP)
|
||||
AV_CODEC_ID_ADPCM_IMA_MTF = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_MTF)
|
||||
AV_CODEC_ID_ADPCM_IMA_CUNNING = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_CUNNING)
|
||||
AV_CODEC_ID_ADPCM_IMA_MOFLEX = AvCodecID(C.AV_CODEC_ID_ADPCM_IMA_MOFLEX)
|
||||
|
||||
// AMR
|
||||
AV_CODEC_ID_AMR_NB = AvCodecID(C.AV_CODEC_ID_AMR_NB)
|
||||
AV_CODEC_ID_AMR_WB = AvCodecID(C.AV_CODEC_ID_AMR_WB)
|
||||
|
||||
// RealAudio codecs
|
||||
AV_CODEC_ID_RA_144 = AvCodecID(C.AV_CODEC_ID_RA_144)
|
||||
AV_CODEC_ID_RA_288 = AvCodecID(C.AV_CODEC_ID_RA_288)
|
||||
|
||||
// various DPCM codecs
|
||||
AV_CODEC_ID_ROQ_DPCM = AvCodecID(C.AV_CODEC_ID_ROQ_DPCM)
|
||||
AV_CODEC_ID_INTERPLAY_DPCM = AvCodecID(C.AV_CODEC_ID_INTERPLAY_DPCM)
|
||||
AV_CODEC_ID_XAN_DPCM = AvCodecID(C.AV_CODEC_ID_XAN_DPCM)
|
||||
AV_CODEC_ID_SOL_DPCM = AvCodecID(C.AV_CODEC_ID_SOL_DPCM)
|
||||
|
||||
AV_CODEC_ID_SDX2_DPCM = AvCodecID(C.AV_CODEC_ID_SDX2_DPCM)
|
||||
AV_CODEC_ID_GREMLIN_DPCM = AvCodecID(C.AV_CODEC_ID_GREMLIN_DPCM)
|
||||
AV_CODEC_ID_DERF_DPCM = AvCodecID(C.AV_CODEC_ID_DERF_DPCM)
|
||||
|
||||
// audio codecs
|
||||
AV_CODEC_ID_MP2 = AvCodecID(C.AV_CODEC_ID_MP2)
|
||||
AV_CODEC_ID_MP3 = AvCodecID(C.AV_CODEC_ID_MP3)
|
||||
AV_CODEC_ID_AAC = AvCodecID(C.AV_CODEC_ID_AAC)
|
||||
AV_CODEC_ID_AC3 = AvCodecID(C.AV_CODEC_ID_AC3)
|
||||
AV_CODEC_ID_DTS = AvCodecID(C.AV_CODEC_ID_DTS)
|
||||
AV_CODEC_ID_VORBIS = AvCodecID(C.AV_CODEC_ID_VORBIS)
|
||||
AV_CODEC_ID_DVAUDIO = AvCodecID(C.AV_CODEC_ID_DVAUDIO)
|
||||
AV_CODEC_ID_WMAV1 = AvCodecID(C.AV_CODEC_ID_WMAV1)
|
||||
AV_CODEC_ID_WMAV2 = AvCodecID(C.AV_CODEC_ID_WMAV2)
|
||||
AV_CODEC_ID_MACE3 = AvCodecID(C.AV_CODEC_ID_MACE3)
|
||||
AV_CODEC_ID_MACE6 = AvCodecID(C.AV_CODEC_ID_MACE6)
|
||||
AV_CODEC_ID_VMDAUDIO = AvCodecID(C.AV_CODEC_ID_VMDAUDIO)
|
||||
AV_CODEC_ID_FLAC = AvCodecID(C.AV_CODEC_ID_FLAC)
|
||||
AV_CODEC_ID_MP3ADU = AvCodecID(C.AV_CODEC_ID_MP3ADU)
|
||||
AV_CODEC_ID_MP3ON4 = AvCodecID(C.AV_CODEC_ID_MP3ON4)
|
||||
AV_CODEC_ID_SHORTEN = AvCodecID(C.AV_CODEC_ID_SHORTEN)
|
||||
AV_CODEC_ID_ALAC = AvCodecID(C.AV_CODEC_ID_ALAC)
|
||||
AV_CODEC_ID_WESTWOOD_SND1 = AvCodecID(C.AV_CODEC_ID_WESTWOOD_SND1)
|
||||
AV_CODEC_ID_GSM = AvCodecID(C.AV_CODEC_ID_GSM)
|
||||
AV_CODEC_ID_QDM2 = AvCodecID(C.AV_CODEC_ID_QDM2)
|
||||
AV_CODEC_ID_COOK = AvCodecID(C.AV_CODEC_ID_COOK)
|
||||
AV_CODEC_ID_TRUESPEECH = AvCodecID(C.AV_CODEC_ID_TRUESPEECH)
|
||||
AV_CODEC_ID_TTA = AvCodecID(C.AV_CODEC_ID_TTA)
|
||||
AV_CODEC_ID_SMACKAUDIO = AvCodecID(C.AV_CODEC_ID_SMACKAUDIO)
|
||||
AV_CODEC_ID_QCELP = AvCodecID(C.AV_CODEC_ID_QCELP)
|
||||
AV_CODEC_ID_WAVPACK = AvCodecID(C.AV_CODEC_ID_WAVPACK)
|
||||
AV_CODEC_ID_DSICINAUDIO = AvCodecID(C.AV_CODEC_ID_DSICINAUDIO)
|
||||
AV_CODEC_ID_IMC = AvCodecID(C.AV_CODEC_ID_IMC)
|
||||
AV_CODEC_ID_MUSEPACK7 = AvCodecID(C.AV_CODEC_ID_MUSEPACK7)
|
||||
AV_CODEC_ID_MLP = AvCodecID(C.AV_CODEC_ID_MLP)
|
||||
AV_CODEC_ID_GSM_MS = AvCodecID(C.AV_CODEC_ID_GSM_MS)
|
||||
AV_CODEC_ID_ATRAC3 = AvCodecID(C.AV_CODEC_ID_ATRAC3)
|
||||
AV_CODEC_ID_APE = AvCodecID(C.AV_CODEC_ID_APE)
|
||||
AV_CODEC_ID_NELLYMOSER = AvCodecID(C.AV_CODEC_ID_NELLYMOSER)
|
||||
AV_CODEC_ID_MUSEPACK8 = AvCodecID(C.AV_CODEC_ID_MUSEPACK8)
|
||||
AV_CODEC_ID_SPEEX = AvCodecID(C.AV_CODEC_ID_SPEEX)
|
||||
AV_CODEC_ID_WMAVOICE = AvCodecID(C.AV_CODEC_ID_WMAVOICE)
|
||||
AV_CODEC_ID_WMAPRO = AvCodecID(C.AV_CODEC_ID_WMAPRO)
|
||||
AV_CODEC_ID_WMALOSSLESS = AvCodecID(C.AV_CODEC_ID_WMALOSSLESS)
|
||||
AV_CODEC_ID_ATRAC3P = AvCodecID(C.AV_CODEC_ID_ATRAC3P)
|
||||
AV_CODEC_ID_EAC3 = AvCodecID(C.AV_CODEC_ID_EAC3)
|
||||
AV_CODEC_ID_SIPR = AvCodecID(C.AV_CODEC_ID_SIPR)
|
||||
AV_CODEC_ID_MP1 = AvCodecID(C.AV_CODEC_ID_MP1)
|
||||
AV_CODEC_ID_TWINVQ = AvCodecID(C.AV_CODEC_ID_TWINVQ)
|
||||
AV_CODEC_ID_TRUEHD = AvCodecID(C.AV_CODEC_ID_TRUEHD)
|
||||
AV_CODEC_ID_MP4ALS = AvCodecID(C.AV_CODEC_ID_MP4ALS)
|
||||
AV_CODEC_ID_ATRAC1 = AvCodecID(C.AV_CODEC_ID_ATRAC1)
|
||||
AV_CODEC_ID_BINKAUDIO_RDFT = AvCodecID(C.AV_CODEC_ID_BINKAUDIO_RDFT)
|
||||
AV_CODEC_ID_BINKAUDIO_DCT = AvCodecID(C.AV_CODEC_ID_BINKAUDIO_DCT)
|
||||
AV_CODEC_ID_AAC_LATM = AvCodecID(C.AV_CODEC_ID_AAC_LATM)
|
||||
AV_CODEC_ID_QDMC = AvCodecID(C.AV_CODEC_ID_QDMC)
|
||||
AV_CODEC_ID_CELT = AvCodecID(C.AV_CODEC_ID_CELT)
|
||||
AV_CODEC_ID_G723_1 = AvCodecID(C.AV_CODEC_ID_G723_1)
|
||||
AV_CODEC_ID_G729 = AvCodecID(C.AV_CODEC_ID_G729)
|
||||
AV_CODEC_ID_8SVX_EXP = AvCodecID(C.AV_CODEC_ID_8SVX_EXP)
|
||||
AV_CODEC_ID_8SVX_FIB = AvCodecID(C.AV_CODEC_ID_8SVX_FIB)
|
||||
AV_CODEC_ID_BMV_AUDIO = AvCodecID(C.AV_CODEC_ID_BMV_AUDIO)
|
||||
AV_CODEC_ID_RALF = AvCodecID(C.AV_CODEC_ID_RALF)
|
||||
AV_CODEC_ID_IAC = AvCodecID(C.AV_CODEC_ID_IAC)
|
||||
AV_CODEC_ID_ILBC = AvCodecID(C.AV_CODEC_ID_ILBC)
|
||||
AV_CODEC_ID_OPUS = AvCodecID(C.AV_CODEC_ID_OPUS)
|
||||
AV_CODEC_ID_COMFORT_NOISE = AvCodecID(C.AV_CODEC_ID_COMFORT_NOISE)
|
||||
AV_CODEC_ID_TAK = AvCodecID(C.AV_CODEC_ID_TAK)
|
||||
AV_CODEC_ID_METASOUND = AvCodecID(C.AV_CODEC_ID_METASOUND)
|
||||
AV_CODEC_ID_PAF_AUDIO = AvCodecID(C.AV_CODEC_ID_PAF_AUDIO)
|
||||
AV_CODEC_ID_ON2AVC = AvCodecID(C.AV_CODEC_ID_ON2AVC)
|
||||
AV_CODEC_ID_DSS_SP = AvCodecID(C.AV_CODEC_ID_DSS_SP)
|
||||
AV_CODEC_ID_CODEC2 = AvCodecID(C.AV_CODEC_ID_CODEC2)
|
||||
|
||||
AV_CODEC_ID_FFWAVESYNTH = AvCodecID(C.AV_CODEC_ID_FFWAVESYNTH)
|
||||
AV_CODEC_ID_SONIC = AvCodecID(C.AV_CODEC_ID_SONIC)
|
||||
AV_CODEC_ID_SONIC_LS = AvCodecID(C.AV_CODEC_ID_SONIC_LS)
|
||||
AV_CODEC_ID_EVRC = AvCodecID(C.AV_CODEC_ID_EVRC)
|
||||
AV_CODEC_ID_SMV = AvCodecID(C.AV_CODEC_ID_SMV)
|
||||
AV_CODEC_ID_DSD_LSBF = AvCodecID(C.AV_CODEC_ID_DSD_LSBF)
|
||||
AV_CODEC_ID_DSD_MSBF = AvCodecID(C.AV_CODEC_ID_DSD_MSBF)
|
||||
AV_CODEC_ID_DSD_LSBF_PLANAR = AvCodecID(C.AV_CODEC_ID_DSD_LSBF_PLANAR)
|
||||
AV_CODEC_ID_DSD_MSBF_PLANAR = AvCodecID(C.AV_CODEC_ID_DSD_MSBF_PLANAR)
|
||||
AV_CODEC_ID_4GV = AvCodecID(C.AV_CODEC_ID_4GV)
|
||||
AV_CODEC_ID_INTERPLAY_ACM = AvCodecID(C.AV_CODEC_ID_INTERPLAY_ACM)
|
||||
AV_CODEC_ID_XMA1 = AvCodecID(C.AV_CODEC_ID_XMA1)
|
||||
AV_CODEC_ID_XMA2 = AvCodecID(C.AV_CODEC_ID_XMA2)
|
||||
AV_CODEC_ID_DST = AvCodecID(C.AV_CODEC_ID_DST)
|
||||
AV_CODEC_ID_ATRAC3AL = AvCodecID(C.AV_CODEC_ID_ATRAC3AL)
|
||||
AV_CODEC_ID_ATRAC3PAL = AvCodecID(C.AV_CODEC_ID_ATRAC3PAL)
|
||||
AV_CODEC_ID_DOLBY_E = AvCodecID(C.AV_CODEC_ID_DOLBY_E)
|
||||
AV_CODEC_ID_APTX = AvCodecID(C.AV_CODEC_ID_APTX)
|
||||
AV_CODEC_ID_APTX_HD = AvCodecID(C.AV_CODEC_ID_APTX_HD)
|
||||
AV_CODEC_ID_SBC = AvCodecID(C.AV_CODEC_ID_SBC)
|
||||
AV_CODEC_ID_ATRAC9 = AvCodecID(C.AV_CODEC_ID_ATRAC9)
|
||||
AV_CODEC_ID_HCOM = AvCodecID(C.AV_CODEC_ID_HCOM)
|
||||
AV_CODEC_ID_ACELP_KELVIN = AvCodecID(C.AV_CODEC_ID_ACELP_KELVIN)
|
||||
AV_CODEC_ID_MPEGH_3D_AUDIO = AvCodecID(C.AV_CODEC_ID_MPEGH_3D_AUDIO)
|
||||
AV_CODEC_ID_SIREN = AvCodecID(C.AV_CODEC_ID_SIREN)
|
||||
AV_CODEC_ID_HCA = AvCodecID(C.AV_CODEC_ID_HCA)
|
||||
AV_CODEC_ID_FASTAUDIO = AvCodecID(C.AV_CODEC_ID_FASTAUDIO)
|
||||
|
||||
// subtitle codecs
|
||||
AV_CODEC_ID_FIRST_SUBTITLE = AvCodecID(C.AV_CODEC_ID_FIRST_SUBTITLE)
|
||||
AV_CODEC_ID_DVD_SUBTITLE = AvCodecID(C.AV_CODEC_ID_DVD_SUBTITLE)
|
||||
AV_CODEC_ID_DVB_SUBTITLE = AvCodecID(C.AV_CODEC_ID_DVB_SUBTITLE)
|
||||
AV_CODEC_ID_TEXT = AvCodecID(C.AV_CODEC_ID_TEXT)
|
||||
AV_CODEC_ID_XSUB = AvCodecID(C.AV_CODEC_ID_XSUB)
|
||||
AV_CODEC_ID_SSA = AvCodecID(C.AV_CODEC_ID_SSA)
|
||||
AV_CODEC_ID_MOV_TEXT = AvCodecID(C.AV_CODEC_ID_MOV_TEXT)
|
||||
AV_CODEC_ID_HDMV_PGS_SUBTITLE = AvCodecID(C.AV_CODEC_ID_HDMV_PGS_SUBTITLE)
|
||||
AV_CODEC_ID_DVB_TELETEXT = AvCodecID(C.AV_CODEC_ID_DVB_TELETEXT)
|
||||
AV_CODEC_ID_SRT = AvCodecID(C.AV_CODEC_ID_SRT)
|
||||
|
||||
AV_CODEC_ID_MICRODVD = AvCodecID(C.AV_CODEC_ID_MICRODVD)
|
||||
AV_CODEC_ID_EIA_608 = AvCodecID(C.AV_CODEC_ID_EIA_608)
|
||||
AV_CODEC_ID_JACOSUB = AvCodecID(C.AV_CODEC_ID_JACOSUB)
|
||||
AV_CODEC_ID_SAMI = AvCodecID(C.AV_CODEC_ID_SAMI)
|
||||
AV_CODEC_ID_REALTEXT = AvCodecID(C.AV_CODEC_ID_REALTEXT)
|
||||
AV_CODEC_ID_STL = AvCodecID(C.AV_CODEC_ID_STL)
|
||||
AV_CODEC_ID_SUBVIEWER1 = AvCodecID(C.AV_CODEC_ID_SUBVIEWER1)
|
||||
AV_CODEC_ID_SUBVIEWER = AvCodecID(C.AV_CODEC_ID_SUBVIEWER)
|
||||
AV_CODEC_ID_SUBRIP = AvCodecID(C.AV_CODEC_ID_SUBRIP)
|
||||
AV_CODEC_ID_WEBVTT = AvCodecID(C.AV_CODEC_ID_WEBVTT)
|
||||
AV_CODEC_ID_MPL2 = AvCodecID(C.AV_CODEC_ID_MPL2)
|
||||
AV_CODEC_ID_VPLAYER = AvCodecID(C.AV_CODEC_ID_VPLAYER)
|
||||
AV_CODEC_ID_PJS = AvCodecID(C.AV_CODEC_ID_PJS)
|
||||
AV_CODEC_ID_ASS = AvCodecID(C.AV_CODEC_ID_ASS)
|
||||
AV_CODEC_ID_HDMV_TEXT_SUBTITLE = AvCodecID(C.AV_CODEC_ID_HDMV_TEXT_SUBTITLE)
|
||||
AV_CODEC_ID_TTML = AvCodecID(C.AV_CODEC_ID_TTML)
|
||||
AV_CODEC_ID_ARIB_CAPTION = AvCodecID(C.AV_CODEC_ID_ARIB_CAPTION)
|
||||
|
||||
// other specific kind of codecs (generally used for attachments)
|
||||
AV_CODEC_ID_FIRST_UNKNOWN = AvCodecID(C.AV_CODEC_ID_FIRST_UNKNOWN)
|
||||
AV_CODEC_ID_TTF = AvCodecID(C.AV_CODEC_ID_TTF)
|
||||
|
||||
AV_CODEC_ID_SCTE_35 = AvCodecID(C.AV_CODEC_ID_SCTE_35)
|
||||
AV_CODEC_ID_EPG = AvCodecID(C.AV_CODEC_ID_EPG)
|
||||
AV_CODEC_ID_BINTEXT = AvCodecID(C.AV_CODEC_ID_BINTEXT)
|
||||
AV_CODEC_ID_XBIN = AvCodecID(C.AV_CODEC_ID_XBIN)
|
||||
AV_CODEC_ID_IDF = AvCodecID(C.AV_CODEC_ID_IDF)
|
||||
AV_CODEC_ID_OTF = AvCodecID(C.AV_CODEC_ID_OTF)
|
||||
AV_CODEC_ID_SMPTE_KLV = AvCodecID(C.AV_CODEC_ID_SMPTE_KLV)
|
||||
AV_CODEC_ID_DVD_NAV = AvCodecID(C.AV_CODEC_ID_DVD_NAV)
|
||||
AV_CODEC_ID_TIMED_ID3 = AvCodecID(C.AV_CODEC_ID_TIMED_ID3)
|
||||
AV_CODEC_ID_BIN_DATA = AvCodecID(C.AV_CODEC_ID_BIN_DATA)
|
||||
|
||||
// codec_id is not known (like AV_CODEC_ID_NONE) but lavf should attempt to identify it
|
||||
AV_CODEC_ID_PROBE = AvCodecID(C.AV_CODEC_ID_PROBE)
|
||||
|
||||
// Fake codec to indicate a raw MPEG-2 TS stream (only used by libavformat)
|
||||
AV_CODEC_ID_MPEG2TS = AvCodecID(C.AV_CODEC_ID_MPEG2TS)
|
||||
|
||||
// Fake codec to indicate a MPEG-4 Systems stream (only used by libavformat)
|
||||
AV_CODEC_ID_MPEG4SYSTEMS = AvCodecID(C.AV_CODEC_ID_MPEG4SYSTEMS)
|
||||
|
||||
// Dummy codec for streams containing only metadata information.
|
||||
AV_CODEC_ID_FFMETADATA = AvCodecID(C.AV_CODEC_ID_FFMETADATA)
|
||||
// Passthrough codec, AVFrames wrapped in AVPacket.
|
||||
AV_CODEC_ID_WRAPPED_AVFRAME = AvCodecID(C.AV_CODEC_ID_WRAPPED_AVFRAME)
|
||||
)
|
||||
|
||||
// AvCodecGetType gets the type of the given codec.
|
||||
func AvCodecGetType(codecID AvCodecID) AvMediaType {
|
||||
return (AvMediaType)(C.avcodec_get_type((C.enum_AVCodecID)(codecID)))
|
||||
}
|
||||
|
||||
// AvCodecGetName gets the name of a codec.
|
||||
func AvCodecGetName(codecID AvCodecID) string {
|
||||
return C.GoString(C.avcodec_get_name((C.enum_AVCodecID)(codecID)))
|
||||
}
|
474
avcodec_codec_par.go
Normal file
474
avcodec_codec_par.go
Normal file
@@ -0,0 +1,474 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavcodec/codec_par.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
type AvFieldOrder int32
|
||||
|
||||
const (
|
||||
AV_FIELD_UNKNOWN = AvFieldOrder(C.AV_FIELD_UNKNOWN)
|
||||
AV_FIELD_PROGRESSIVE = AvFieldOrder(C.AV_FIELD_PROGRESSIVE)
|
||||
AV_FIELD_TT = AvFieldOrder(C.AV_FIELD_TT)
|
||||
AV_FIELD_BB = AvFieldOrder(C.AV_FIELD_BB)
|
||||
AV_FIELD_TB = AvFieldOrder(C.AV_FIELD_TB)
|
||||
AV_FIELD_BT = AvFieldOrder(C.AV_FIELD_BT)
|
||||
)
|
||||
|
||||
// AvCodecParameters
|
||||
type AvCodecParameters C.struct_AVCodecParameters
|
||||
|
||||
// Custom: GetCodecType gets `AVCodecParameters.codec_type` value.
|
||||
func (par *AvCodecParameters) GetCodecType() AvMediaType {
|
||||
return (AvMediaType)(par.codec_type)
|
||||
}
|
||||
|
||||
// Custom: SetCodecType sets `AVCodecParameters.codec_type` value.
|
||||
func (par *AvCodecParameters) SetCodecType(v AvMediaType) {
|
||||
par.codec_type = (C.enum_AVMediaType)(v)
|
||||
}
|
||||
|
||||
// Custom: GetCodecTypeAddr gets `AVCodecParameters.codec_type` address.
|
||||
func (par *AvCodecParameters) GetCodecTypeAddr() *AvMediaType {
|
||||
return (*AvMediaType)(unsafe.Pointer(&par.codec_type))
|
||||
}
|
||||
|
||||
// Custom: GetCodecId gets `AVCodecParameters.codec_id` value.
|
||||
func (par *AvCodecParameters) GetCodecId() AvCodecID {
|
||||
return (AvCodecID)(par.codec_id)
|
||||
}
|
||||
|
||||
// Custom: SetCodecId sets `AVCodecParameters.codec_id` value.
|
||||
func (par *AvCodecParameters) SetCodecId(v AvCodecID) {
|
||||
par.codec_id = (C.enum_AVCodecID)(v)
|
||||
}
|
||||
|
||||
// Custom: GetCodecIdAddr gets `AVCodecParameters.codec_id` address.
|
||||
func (par *AvCodecParameters) GetCodecIdAddr() *AvCodecID {
|
||||
return (*AvCodecID)(unsafe.Pointer(&par.codec_id))
|
||||
}
|
||||
|
||||
// Custom: GetCodecTag gets `AVCodecParameters.codec_tag` value.
|
||||
func (par *AvCodecParameters) GetCodecTag() uint32 {
|
||||
return (uint32)(par.codec_tag)
|
||||
}
|
||||
|
||||
// Custom: SetCodecTag sets `AVCodecParameters.codec_tag` value.
|
||||
func (par *AvCodecParameters) SetCodecTag(v uint32) {
|
||||
par.codec_tag = (C.uint)(v)
|
||||
}
|
||||
|
||||
// Custom: GetCodecTagAddr gets `AVCodecParameters.codec_tag` address.
|
||||
func (par *AvCodecParameters) GetCodecTagAddr() *uint32 {
|
||||
return (*uint32)(&par.codec_tag)
|
||||
}
|
||||
|
||||
// Custom: GetExtradata gets `AVCodecParameters.extradata` value.
|
||||
func (par *AvCodecParameters) GetExtradata() *uint8 {
|
||||
return (*uint8)(par.extradata)
|
||||
}
|
||||
|
||||
// Custom: SetExtradata sets `AVCodecParameters.extradata` value.
|
||||
func (par *AvCodecParameters) SetExtradata(v *uint8) {
|
||||
par.extradata = (*C.uint8_t)(v)
|
||||
}
|
||||
|
||||
// Custom: GetExtradataAddr gets `AVCodecParameters.extradata` address.
|
||||
func (par *AvCodecParameters) GetExtradataAddr() *uint8 {
|
||||
return (*uint8)(unsafe.Pointer(&par.extradata))
|
||||
}
|
||||
|
||||
// Custom: GetExtradataSize gets `AVCodecParameters.extradata_size` value.
|
||||
func (par *AvCodecParameters) GetExtradataSize() int32 {
|
||||
return (int32)(par.extradata_size)
|
||||
}
|
||||
|
||||
// Custom: SetExtradataSize sets `AVCodecParameters.extradata_size` value.
|
||||
func (par *AvCodecParameters) SetExtradataSize(v int32) {
|
||||
par.extradata_size = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetExtradataSizeAddr gets `AVCodecParameters.extradata_size` address.
|
||||
func (par *AvCodecParameters) GetExtradataSizeAddr() *int32 {
|
||||
return (*int32)(&par.extradata_size)
|
||||
}
|
||||
|
||||
// Custom: GetFormat gets `AVCodecParameters.format` value.
|
||||
func (par *AvCodecParameters) GetFormat() int32 {
|
||||
return (int32)(par.format)
|
||||
}
|
||||
|
||||
// Custom: SetFormat sets `AVCodecParameters.format` value.
|
||||
func (par *AvCodecParameters) SetFormat(v int32) {
|
||||
par.format = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetFormatAddr gets `AVCodecParameters.format` address.
|
||||
func (par *AvCodecParameters) GetFormatAddr() *int32 {
|
||||
return (*int32)(&par.format)
|
||||
}
|
||||
|
||||
// Custom: GetBitRate gets `AVCodecParameters.bit_rate` value.
|
||||
func (par *AvCodecParameters) GetBitRate() int64 {
|
||||
return (int64)(par.bit_rate)
|
||||
}
|
||||
|
||||
// Custom: SetBitRate sets `AVCodecParameters.bit_rate` value.
|
||||
func (par *AvCodecParameters) SetBitRate(v int64) {
|
||||
par.bit_rate = (C.int64_t)(v)
|
||||
}
|
||||
|
||||
// Custom: GetBitRateAddr gets `AVCodecParameters.bit_rate` address.
|
||||
func (par *AvCodecParameters) GetBitRateAddr() *int64 {
|
||||
return (*int64)(&par.bit_rate)
|
||||
}
|
||||
|
||||
// Custom: GetBitsPerCodedSample gets `AVCodecParameters.bits_per_coded_sample` value.
|
||||
func (par *AvCodecParameters) GetBitsPerCodedSample() int32 {
|
||||
return (int32)(par.bits_per_coded_sample)
|
||||
}
|
||||
|
||||
// Custom: SetBitsPerCodedSample sets `AVCodecParameters.bits_per_coded_sample` value.
|
||||
func (par *AvCodecParameters) SetBitsPerCodedSample(v int32) {
|
||||
par.bits_per_coded_sample = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetBitsPerCodedSampleAddr gets `AVCodecParameters.bits_per_coded_sample` address.
|
||||
func (par *AvCodecParameters) GetBitsPerCodedSampleAddr() *int32 {
|
||||
return (*int32)(&par.bits_per_coded_sample)
|
||||
}
|
||||
|
||||
// Custom: GetBitsPerRawSample gets `AVCodecParameters.bits_per_raw_sample` value.
|
||||
func (par *AvCodecParameters) GetBitsPerRawSample() int32 {
|
||||
return (int32)(par.bits_per_raw_sample)
|
||||
}
|
||||
|
||||
// Custom: SetBitsPerRawSample sets `AVCodecParameters.bits_per_raw_sample` value.
|
||||
func (par *AvCodecParameters) SetBitsPerRawSample(v int32) {
|
||||
par.bits_per_raw_sample = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetBitsPerRawSampleAddr gets `AVCodecParameters.bits_per_raw_sample` address.
|
||||
func (par *AvCodecParameters) GetBitsPerRawSampleAddr() *int32 {
|
||||
return (*int32)(&par.bits_per_raw_sample)
|
||||
}
|
||||
|
||||
// Custom: GetProfile gets `AVCodecParameters.profile` value.
|
||||
func (par *AvCodecParameters) GetProfile() int32 {
|
||||
return (int32)(par.profile)
|
||||
}
|
||||
|
||||
// Custom: SetProfile sets `AVCodecParameters.profile` value.
|
||||
func (par *AvCodecParameters) SetProfile(v int32) {
|
||||
par.profile = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetProfileAddr gets `AVCodecParameters.profile` address.
|
||||
func (par *AvCodecParameters) GetProfileAddr() *int32 {
|
||||
return (*int32)(&par.profile)
|
||||
}
|
||||
|
||||
// Custom: GetLevel gets `AVCodecParameters.level` value.
|
||||
func (par *AvCodecParameters) GetLevel() int32 {
|
||||
return (int32)(par.level)
|
||||
}
|
||||
|
||||
// Custom: SetLevel sets `AVCodecParameters.level` value.
|
||||
func (par *AvCodecParameters) SetLevel(v int32) {
|
||||
par.level = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetLevelAddr gets `AVCodecParameters.level` address.
|
||||
func (par *AvCodecParameters) GetLevelAddr() *int32 {
|
||||
return (*int32)(&par.level)
|
||||
}
|
||||
|
||||
// Custom: GetWidth gets `AVCodecParameters.width` value.
|
||||
func (par *AvCodecParameters) GetWidth() int32 {
|
||||
return (int32)(par.width)
|
||||
}
|
||||
|
||||
// Custom: SetWidth sets `AVCodecParameters.width` value.
|
||||
func (par *AvCodecParameters) SetWidth(v int32) {
|
||||
par.width = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetWidthAddr gets `AVCodecParameters.width` address.
|
||||
func (par *AvCodecParameters) GetWidthAddr() *int32 {
|
||||
return (*int32)(&par.width)
|
||||
}
|
||||
|
||||
// Custom: GetHeight gets `AVCodecParameters.height` value.
|
||||
func (par *AvCodecParameters) GetHeight() int32 {
|
||||
return (int32)(par.height)
|
||||
}
|
||||
|
||||
// Custom: SetHeight sets `AVCodecParameters.height` value.
|
||||
func (par *AvCodecParameters) SetHeight(v int32) {
|
||||
par.height = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetHeightAddr gets `AVCodecParameters.height` address.
|
||||
func (par *AvCodecParameters) GetHeightAddr() *int32 {
|
||||
return (*int32)(&par.height)
|
||||
}
|
||||
|
||||
// Custom: GetSampleAspectRatio gets `AVCodecParameters.sample_aspect_ratio` value.
|
||||
func (par *AvCodecParameters) GetSampleAspectRatio() AvRational {
|
||||
return (AvRational)(par.sample_aspect_ratio)
|
||||
}
|
||||
|
||||
// Custom: SetSampleAspectRatio sets `AVCodecParameters.sample_aspect_ratio` value.
|
||||
func (par *AvCodecParameters) SetSampleAspectRatio(v AvRational) {
|
||||
par.sample_aspect_ratio = (C.struct_AVRational)(v)
|
||||
}
|
||||
|
||||
// Custom: GetSampleAspectRatioAddr gets `AVCodecParameters.sample_aspect_ratio` address.
|
||||
func (par *AvCodecParameters) GetSampleAspectRatioAddr() *AvRational {
|
||||
return (*AvRational)(&par.sample_aspect_ratio)
|
||||
}
|
||||
|
||||
// Custom: GetFieldOrder gets `AVCodecParameters.field_order` value.
|
||||
func (par *AvCodecParameters) GetFieldOrder() AvFieldOrder {
|
||||
return (AvFieldOrder)(par.field_order)
|
||||
}
|
||||
|
||||
// Custom: SetFieldOrder sets `AVCodecParameters.field_order` value.
|
||||
func (par *AvCodecParameters) SetFieldOrder(v AvFieldOrder) {
|
||||
par.field_order = (C.enum_AVFieldOrder)(v)
|
||||
}
|
||||
|
||||
// Custom: GetFieldOrderAddr gets `AVCodecParameters.field_order` address.
|
||||
func (par *AvCodecParameters) GetFieldOrderAddr() *AvFieldOrder {
|
||||
return (*AvFieldOrder)(unsafe.Pointer(&par.field_order))
|
||||
}
|
||||
|
||||
// Custom: GetColorRange gets `AVCodecParameters.color_range` value.
|
||||
func (par *AvCodecParameters) GetColorRange() AvColorRange {
|
||||
return (AvColorRange)(par.color_range)
|
||||
}
|
||||
|
||||
// Custom: SetColorRange sets `AVCodecParameters.color_range` value.
|
||||
func (par *AvCodecParameters) SetColorRange(v AvColorRange) {
|
||||
par.color_range = (C.enum_AVColorRange)(v)
|
||||
}
|
||||
|
||||
// Custom: GetColorRangeAddr gets `AVCodecParameters.color_range` address.
|
||||
func (par *AvCodecParameters) GetColorRangeAddr() *AvColorRange {
|
||||
return (*AvColorRange)(unsafe.Pointer(&par.color_range))
|
||||
}
|
||||
|
||||
// Custom: GetColorPrimaries gets `AVCodecParameters.color_primaries` value.
|
||||
func (par *AvCodecParameters) GetColorPrimaries() AvColorPrimaries {
|
||||
return (AvColorPrimaries)(par.color_primaries)
|
||||
}
|
||||
|
||||
// Custom: SetColorPrimaries sets `AVCodecParameters.color_primaries` value.
|
||||
func (par *AvCodecParameters) SetColorPrimaries(v AvColorPrimaries) {
|
||||
par.color_primaries = (C.enum_AVColorPrimaries)(v)
|
||||
}
|
||||
|
||||
// Custom: GetColorPrimariesAddr gets `AVCodecParameters.color_primaries` address.
|
||||
func (par *AvCodecParameters) GetColorPrimariesAddr() *AvColorPrimaries {
|
||||
return (*AvColorPrimaries)(unsafe.Pointer(&par.color_primaries))
|
||||
}
|
||||
|
||||
// Custom: GetColorTrc gets `AVCodecParameters.color_trc` value.
|
||||
func (par *AvCodecParameters) GetColorTrc() AvColorTransferCharacteristic {
|
||||
return (AvColorTransferCharacteristic)(par.color_trc)
|
||||
}
|
||||
|
||||
// Custom: SetColorTrc sets `AVCodecParameters.color_trc` value.
|
||||
func (par *AvCodecParameters) SetColorTrc(v AvColorTransferCharacteristic) {
|
||||
par.color_trc = (C.enum_AVColorTransferCharacteristic)(v)
|
||||
}
|
||||
|
||||
// Custom: GetColorTrcAddr gets `AVCodecParameters.color_trc` address.
|
||||
func (par *AvCodecParameters) GetColorTrcAddr() *AvColorTransferCharacteristic {
|
||||
return (*AvColorTransferCharacteristic)(unsafe.Pointer(&par.color_trc))
|
||||
}
|
||||
|
||||
// Custom: GetColorSpace gets `AVCodecParameters.color_space` value.
|
||||
func (par *AvCodecParameters) GetColorSpace() AvColorSpace {
|
||||
return (AvColorSpace)(par.color_space)
|
||||
}
|
||||
|
||||
// Custom: SetColorSpace sets `AVCodecParameters.color_space` value.
|
||||
func (par *AvCodecParameters) SetColorSpace(v AvColorSpace) {
|
||||
par.color_space = (C.enum_AVColorSpace)(v)
|
||||
}
|
||||
|
||||
// Custom: GetColorSpaceAddr gets `AVCodecParameters.color_space` address.
|
||||
func (par *AvCodecParameters) GetColorSpaceAddr() *AvColorSpace {
|
||||
return (*AvColorSpace)(unsafe.Pointer(&par.color_space))
|
||||
}
|
||||
|
||||
// Custom: GetChromaLocation gets `AVCodecParameters.chroma_location` value.
|
||||
func (par *AvCodecParameters) GetChromaLocation() AvChromaLocation {
|
||||
return (AvChromaLocation)(par.chroma_location)
|
||||
}
|
||||
|
||||
// Custom: SetChromaLocation sets `AVCodecParameters.chroma_location` value.
|
||||
func (par *AvCodecParameters) SetChromaLocation(v AvChromaLocation) {
|
||||
par.chroma_location = (C.enum_AVChromaLocation)(v)
|
||||
}
|
||||
|
||||
// Custom: GetChromaLocationAddr gets `AVCodecParameters.chroma_location` address.
|
||||
func (par *AvCodecParameters) GetChromaLocationAddr() *AvChromaLocation {
|
||||
return (*AvChromaLocation)(unsafe.Pointer(&par.chroma_location))
|
||||
}
|
||||
|
||||
// Custom: GetVideoDelay gets `AVCodecParameters.video_delay` value.
|
||||
func (par *AvCodecParameters) GetVideoDelay() int32 {
|
||||
return (int32)(par.video_delay)
|
||||
}
|
||||
|
||||
// Custom: SetVideoDelay sets `AVCodecParameters.video_delay` value.
|
||||
func (par *AvCodecParameters) SetVideoDelay(v int32) {
|
||||
par.video_delay = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetVideoDelayAddr gets `AVCodecParameters.video_delay` address.
|
||||
func (par *AvCodecParameters) GetVideoDelayAddr() *int32 {
|
||||
return (*int32)(&par.video_delay)
|
||||
}
|
||||
|
||||
// Custom: GetChannelLayout gets `AVCodecParameters.channel_layout` value.
|
||||
func (par *AvCodecParameters) GetChannelLayout() uint64 {
|
||||
return (uint64)(par.channel_layout)
|
||||
}
|
||||
|
||||
// Custom: SetChannelLayout sets `AVCodecParameters.channel_layout` value.
|
||||
func (par *AvCodecParameters) SetChannelLayout(v uint64) {
|
||||
par.channel_layout = (C.uint64_t)(v)
|
||||
}
|
||||
|
||||
// Custom: GetChannelLayoutAddr gets `AVCodecParameters.channel_layout` address.
|
||||
func (par *AvCodecParameters) GetChannelLayoutAddr() *uint64 {
|
||||
return (*uint64)(&par.channel_layout)
|
||||
}
|
||||
|
||||
// Custom: GetChannels gets `AVCodecParameters.channels` value.
|
||||
func (par *AvCodecParameters) GetChannels() int32 {
|
||||
return (int32)(par.channels)
|
||||
}
|
||||
|
||||
// Custom: SetChannels sets `AVCodecParameters.channels` value.
|
||||
func (par *AvCodecParameters) SetChannels(v int32) {
|
||||
par.channels = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetChannelsAddr gets `AVCodecParameters.channels` address.
|
||||
func (par *AvCodecParameters) GetChannelsAddr() *int32 {
|
||||
return (*int32)(&par.channels)
|
||||
}
|
||||
|
||||
// Custom: GetSampleRate gets `AVCodecParameters.sample_rate` value.
|
||||
func (par *AvCodecParameters) GetSampleRate() int32 {
|
||||
return (int32)(par.sample_rate)
|
||||
}
|
||||
|
||||
// Custom: SetSampleRate sets `AVCodecParameters.sample_rate` value.
|
||||
func (par *AvCodecParameters) SetSampleRate(v int32) {
|
||||
par.sample_rate = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetSampleRateAddr gets `AVCodecParameters.sample_rate` address.
|
||||
func (par *AvCodecParameters) GetSampleRateAddr() *int32 {
|
||||
return (*int32)(&par.sample_rate)
|
||||
}
|
||||
|
||||
// Custom: GetBlockAlign gets `AVCodecParameters.block_align` value.
|
||||
func (par *AvCodecParameters) GetBlockAlign() int32 {
|
||||
return (int32)(par.block_align)
|
||||
}
|
||||
|
||||
// Custom: SetBlockAlign sets `AVCodecParameters.block_align` value.
|
||||
func (par *AvCodecParameters) SetBlockAlign(v int32) {
|
||||
par.block_align = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetBlockAlignAddr gets `AVCodecParameters.block_align` address.
|
||||
func (par *AvCodecParameters) GetBlockAlignAddr() *int32 {
|
||||
return (*int32)(&par.block_align)
|
||||
}
|
||||
|
||||
// Custom: GetFrameSize gets `AVCodecParameters.frame_size` value.
|
||||
func (par *AvCodecParameters) GetFrameSize() int32 {
|
||||
return (int32)(par.frame_size)
|
||||
}
|
||||
|
||||
// Custom: SetFrameSize sets `AVCodecParameters.frame_size` value.
|
||||
func (par *AvCodecParameters) SetFrameSize(v int32) {
|
||||
par.frame_size = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetFrameSizeAddr gets `AVCodecParameters.frame_size` address.
|
||||
func (par *AvCodecParameters) GetFrameSizeAddr() *int32 {
|
||||
return (*int32)(&par.frame_size)
|
||||
}
|
||||
|
||||
// Custom: GetInitialPadding gets `AVCodecParameters.initial_padding` value.
|
||||
func (par *AvCodecParameters) GetInitialPadding() int32 {
|
||||
return (int32)(par.initial_padding)
|
||||
}
|
||||
|
||||
// Custom: SetInitialPadding sets `AVCodecParameters.initial_padding` value.
|
||||
func (par *AvCodecParameters) SetInitialPadding(v int32) {
|
||||
par.initial_padding = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetInitialPaddingAddr gets `AVCodecParameters.initial_padding` address.
|
||||
func (par *AvCodecParameters) GetInitialPaddingAddr() *int32 {
|
||||
return (*int32)(&par.initial_padding)
|
||||
}
|
||||
|
||||
// Custom: GetTrailingPadding gets `AVCodecParameters.trailing_padding` value.
|
||||
func (par *AvCodecParameters) GetTrailingPadding() int32 {
|
||||
return (int32)(par.trailing_padding)
|
||||
}
|
||||
|
||||
// Custom: SetTrailingPadding sets `AVCodecParameters.trailing_padding` value.
|
||||
func (par *AvCodecParameters) SetTrailingPadding(v int32) {
|
||||
par.trailing_padding = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetTrailingPaddingAddr gets `AVCodecParameters.trailing_padding` address.
|
||||
func (par *AvCodecParameters) GetTrailingPaddingAddr() *int32 {
|
||||
return (*int32)(&par.trailing_padding)
|
||||
}
|
||||
|
||||
// Custom: GetSeekPreroll gets `AVCodecParameters.seek_preroll` value.
|
||||
func (par *AvCodecParameters) GetSeekPreroll() int32 {
|
||||
return (int32)(par.seek_preroll)
|
||||
}
|
||||
|
||||
// Custom: SetSeekPreroll sets `AVCodecParameters.seek_preroll` value.
|
||||
func (par *AvCodecParameters) SetSeekPreroll(v int32) {
|
||||
par.seek_preroll = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetSeekPrerollAddr gets `AVCodecParameters.seek_preroll` address.
|
||||
func (par *AvCodecParameters) GetSeekPrerollAddr() *int32 {
|
||||
return (*int32)(&par.seek_preroll)
|
||||
}
|
||||
|
||||
// AvCodecParametersAlloc allocates a new AVCodecParameters and set its fields to default values
|
||||
// (unknown/invalid/0). The returned struct must be freed with AvCodecParametersFree().
|
||||
func AvCodecParametersAlloc() *AvCodecParameters {
|
||||
return (*AvCodecParameters)(C.avcodec_parameters_alloc())
|
||||
}
|
||||
|
||||
// AvCodecParametersFree frees an AVCodecParameters instance and everything associated with it and
|
||||
// write NULL to the supplied pointer.
|
||||
func AvCodecParametersFree(par **AvCodecParameters) {
|
||||
C.avcodec_parameters_free((**C.struct_AVCodecParameters)(unsafe.Pointer(par)))
|
||||
}
|
||||
|
||||
// AvCodecParametersCopy copies the contents of src to dst.
|
||||
func AvCodecParametersCopy(dst, src *AvCodecParameters) int32 {
|
||||
return (int32)(C.avcodec_parameters_copy((*C.struct_AVCodecParameters)(dst),
|
||||
(*C.struct_AVCodecParameters)(src)))
|
||||
}
|
409
avcodec_packet.go
Normal file
409
avcodec_packet.go
Normal file
@@ -0,0 +1,409 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavcodec/packet.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// AvPacketSideDataType
|
||||
type AvPacketSideDataType int32
|
||||
|
||||
const (
|
||||
AV_PKT_DATA_PALETTE = AvPacketSideDataType(C.AV_PKT_DATA_PALETTE)
|
||||
AV_PKT_DATA_NEW_EXTRADATA = AvPacketSideDataType(C.AV_PKT_DATA_NEW_EXTRADATA)
|
||||
AV_PKT_DATA_PARAM_CHANGE = AvPacketSideDataType(C.AV_PKT_DATA_PARAM_CHANGE)
|
||||
AV_PKT_DATA_H263_MB_INFO = AvPacketSideDataType(C.AV_PKT_DATA_H263_MB_INFO)
|
||||
AV_PKT_DATA_REPLAYGAIN = AvPacketSideDataType(C.AV_PKT_DATA_REPLAYGAIN)
|
||||
AV_PKT_DATA_DISPLAYMATRIX = AvPacketSideDataType(C.AV_PKT_DATA_DISPLAYMATRIX)
|
||||
AV_PKT_DATA_STEREO3D = AvPacketSideDataType(C.AV_PKT_DATA_STEREO3D)
|
||||
AV_PKT_DATA_AUDIO_SERVICE_TYPE = AvPacketSideDataType(C.AV_PKT_DATA_AUDIO_SERVICE_TYPE)
|
||||
AV_PKT_DATA_QUALITY_STATS = AvPacketSideDataType(C.AV_PKT_DATA_QUALITY_STATS)
|
||||
AV_PKT_DATA_FALLBACK_TRACK = AvPacketSideDataType(C.AV_PKT_DATA_FALLBACK_TRACK)
|
||||
AV_PKT_DATA_CPB_PROPERTIES = AvPacketSideDataType(C.AV_PKT_DATA_CPB_PROPERTIES)
|
||||
AV_PKT_DATA_SKIP_SAMPLES = AvPacketSideDataType(C.AV_PKT_DATA_SKIP_SAMPLES)
|
||||
AV_PKT_DATA_JP_DUALMONO = AvPacketSideDataType(C.AV_PKT_DATA_JP_DUALMONO)
|
||||
AV_PKT_DATA_STRINGS_METADATA = AvPacketSideDataType(C.AV_PKT_DATA_STRINGS_METADATA)
|
||||
AV_PKT_DATA_SUBTITLE_POSITION = AvPacketSideDataType(C.AV_PKT_DATA_SUBTITLE_POSITION)
|
||||
AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL = AvPacketSideDataType(C.AV_PKT_DATA_MATROSKA_BLOCKADDITIONAL)
|
||||
AV_PKT_DATA_WEBVTT_IDENTIFIER = AvPacketSideDataType(C.AV_PKT_DATA_WEBVTT_IDENTIFIER)
|
||||
AV_PKT_DATA_WEBVTT_SETTINGS = AvPacketSideDataType(C.AV_PKT_DATA_WEBVTT_SETTINGS)
|
||||
AV_PKT_DATA_METADATA_UPDATE = AvPacketSideDataType(C.AV_PKT_DATA_METADATA_UPDATE)
|
||||
AV_PKT_DATA_MPEGTS_STREAM_ID = AvPacketSideDataType(C.AV_PKT_DATA_MPEGTS_STREAM_ID)
|
||||
AV_PKT_DATA_MASTERING_DISPLAY_METADATA = AvPacketSideDataType(C.AV_PKT_DATA_MASTERING_DISPLAY_METADATA)
|
||||
AV_PKT_DATA_SPHERICAL = AvPacketSideDataType(C.AV_PKT_DATA_SPHERICAL)
|
||||
AV_PKT_DATA_CONTENT_LIGHT_LEVEL = AvPacketSideDataType(C.AV_PKT_DATA_CONTENT_LIGHT_LEVEL)
|
||||
AV_PKT_DATA_A53_CC = AvPacketSideDataType(C.AV_PKT_DATA_A53_CC)
|
||||
AV_PKT_DATA_ENCRYPTION_INIT_INFO = AvPacketSideDataType(C.AV_PKT_DATA_ENCRYPTION_INIT_INFO)
|
||||
AV_PKT_DATA_ENCRYPTION_INFO = AvPacketSideDataType(C.AV_PKT_DATA_ENCRYPTION_INFO)
|
||||
AV_PKT_DATA_AFD = AvPacketSideDataType(C.AV_PKT_DATA_AFD)
|
||||
AV_PKT_DATA_PRFT = AvPacketSideDataType(C.AV_PKT_DATA_PRFT)
|
||||
AV_PKT_DATA_ICC_PROFILE = AvPacketSideDataType(C.AV_PKT_DATA_ICC_PROFILE)
|
||||
AV_PKT_DATA_DOVI_CONF = AvPacketSideDataType(C.AV_PKT_DATA_DOVI_CONF)
|
||||
AV_PKT_DATA_S12M_TIMECODE = AvPacketSideDataType(C.AV_PKT_DATA_S12M_TIMECODE)
|
||||
AV_PKT_DATA_NB = AvPacketSideDataType(C.AV_PKT_DATA_NB)
|
||||
)
|
||||
|
||||
const (
|
||||
// Deprecated: No use
|
||||
AV_PKT_DATA_QUALITY_FACTOR = AvPacketSideDataType(C.AV_PKT_DATA_QUALITY_FACTOR)
|
||||
)
|
||||
|
||||
// AvPacketSideData
|
||||
type AvPacketSideData C.struct_AVPacketSideData
|
||||
|
||||
// AvPacket
|
||||
type AvPacket C.struct_AVPacket
|
||||
|
||||
// Custom: GetBuf gets `AVPacket.buf` value.
|
||||
func (pkt *AvPacket) GetBuf() *AvBufferRef {
|
||||
return (*AvBufferRef)(pkt.buf)
|
||||
}
|
||||
|
||||
// Custom: SetBuf sets `AVPacket.buf` value.
|
||||
func (pkt *AvPacket) SetBuf(v *AvBufferRef) {
|
||||
pkt.buf = (*C.struct_AVBufferRef)(v)
|
||||
}
|
||||
|
||||
// Custom: GetBufAddr gets `AVPacket.buf` address.
|
||||
func (pkt *AvPacket) GetBufAddr() **AvBufferRef {
|
||||
return (**AvBufferRef)(unsafe.Pointer(&pkt.buf))
|
||||
}
|
||||
|
||||
// Custom: GetPts gets `AVPacket.pts` value.
|
||||
func (pkt *AvPacket) GetPts() int64 {
|
||||
return (int64)(pkt.pts)
|
||||
}
|
||||
|
||||
// Custom: SetPts sets `AVPacket.pts` value.
|
||||
func (pkt *AvPacket) SetPts(v int64) {
|
||||
pkt.pts = (C.int64_t)(v)
|
||||
}
|
||||
|
||||
// Custom: GetPtsAddr gets `AVPacket.pts` address.
|
||||
func (pkt *AvPacket) GetPtsAddr() *int64 {
|
||||
return (*int64)(&pkt.pts)
|
||||
}
|
||||
|
||||
// Custom: GetDts gets `AVPacket.dts` value.
|
||||
func (pkt *AvPacket) GetDts() int64 {
|
||||
return (int64)(pkt.dts)
|
||||
}
|
||||
|
||||
// Custom: SetDts sets `AVPacket.dts` value.
|
||||
func (pkt *AvPacket) SetDts(v int64) {
|
||||
pkt.dts = (C.int64_t)(v)
|
||||
}
|
||||
|
||||
// Custom: GetDtsAddr gets `AVPacket.dts` address.
|
||||
func (pkt *AvPacket) GetDtsAddr() *int64 {
|
||||
return (*int64)(&pkt.dts)
|
||||
}
|
||||
|
||||
// Custom: GetData gets `AVPacket.data` value.
|
||||
func (pkt *AvPacket) GetData() *uint8 {
|
||||
return (*uint8)(pkt.data)
|
||||
}
|
||||
|
||||
// Custom: SetData sets `AVPacket.data` value.
|
||||
func (pkt *AvPacket) SetData(v *uint8) {
|
||||
pkt.data = (*C.uint8_t)(v)
|
||||
}
|
||||
|
||||
// Custom: GetDataAddr gets `AVPacket.data` address.
|
||||
func (pkt *AvPacket) GetDataAddr() **uint8 {
|
||||
return (**uint8)(unsafe.Pointer(&pkt.data))
|
||||
}
|
||||
|
||||
// Custom: GetSize gets `AVPacket.size` value.
|
||||
func (pkt *AvPacket) GetSize() int32 {
|
||||
return (int32)(pkt.size)
|
||||
}
|
||||
|
||||
// Custom: SetSize sets `AVPacket.size` value.
|
||||
func (pkt *AvPacket) SetSize(v int32) {
|
||||
pkt.size = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetSizeAddr gets `AVPacket.size` address.
|
||||
func (pkt *AvPacket) GetSizeAddr() *int32 {
|
||||
return (*int32)(&pkt.size)
|
||||
}
|
||||
|
||||
// Custom: GetStreamIndex gets `AVPacket.stream_index` value.
|
||||
func (pkt *AvPacket) GetStreamIndex() int32 {
|
||||
return (int32)(pkt.stream_index)
|
||||
}
|
||||
|
||||
// Custom: SetStreamIndex sets `AVPacket.stream_index` value.
|
||||
func (pkt *AvPacket) SetStreamIndex(v int32) {
|
||||
pkt.stream_index = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetStreamIndexAddr gets `AVPacket.stream_index` address.
|
||||
func (pkt *AvPacket) GetStreamIndexAddr() *int32 {
|
||||
return (*int32)(&pkt.stream_index)
|
||||
}
|
||||
|
||||
// Custom: GetFlags gets `AVPacket.flags` value.
|
||||
func (pkt *AvPacket) GetFlags() int32 {
|
||||
return (int32)(pkt.flags)
|
||||
}
|
||||
|
||||
// Custom: SetFlags sets `AVPacket.flags` value.
|
||||
func (pkt *AvPacket) SetFlags(v int32) {
|
||||
pkt.flags = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetFlagsAddr gets `AVPacket.flags` address.
|
||||
func (pkt *AvPacket) GetFlagsAddr() *int32 {
|
||||
return (*int32)(&pkt.flags)
|
||||
}
|
||||
|
||||
// Custom: GetSideData gets `AVPacket.side_data` value.
|
||||
func (pkt *AvPacket) GetSideData() *AvPacketSideData {
|
||||
return (*AvPacketSideData)(pkt.side_data)
|
||||
}
|
||||
|
||||
// Custom: SetSideData sets `AVPacket.side_data` value.
|
||||
func (pkt *AvPacket) SetSideData(v *AvPacketSideData) {
|
||||
pkt.side_data = (*C.struct_AVPacketSideData)(v)
|
||||
}
|
||||
|
||||
// Custom: GetSideDataAddr gets `AVPacket.side_data` address.
|
||||
func (pkt *AvPacket) GetSideDataAddr() **AvPacketSideData {
|
||||
return (**AvPacketSideData)(unsafe.Pointer(&pkt.side_data))
|
||||
}
|
||||
|
||||
// Custom: GetSideDataElems gets `AVPacket.side_data_elems` value.
|
||||
func (pkt *AvPacket) GetSideDataElems() int32 {
|
||||
return (int32)(pkt.side_data_elems)
|
||||
}
|
||||
|
||||
// Custom: SetSideDataElems sets `AVPacket.side_data_elems` value.
|
||||
func (pkt *AvPacket) SetSideDataElems(v int32) {
|
||||
pkt.side_data_elems = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetSideDataElemsAddr gets `AVPacket.side_data_elems` address.
|
||||
func (pkt *AvPacket) GetSideDataElemsAddr() *int32 {
|
||||
return (*int32)(&pkt.side_data_elems)
|
||||
}
|
||||
|
||||
// Custom: GetDuration gets `AVPacket.duration` value.
|
||||
func (pkt *AvPacket) GetDuration() int64 {
|
||||
return (int64)(pkt.duration)
|
||||
}
|
||||
|
||||
// Custom: SetDuration sets `AVPacket.duration` value.
|
||||
func (pkt *AvPacket) SetDuration(v int64) {
|
||||
pkt.duration = (C.int64_t)(v)
|
||||
}
|
||||
|
||||
// Custom: GetDurationAddr gets `AVPacket.duration` address.
|
||||
func (pkt *AvPacket) GetDurationAddr() *int64 {
|
||||
return (*int64)(&pkt.duration)
|
||||
}
|
||||
|
||||
// Custom: GetPos gets `AVPacket.pos` value.
|
||||
func (pkt *AvPacket) GetPos() int64 {
|
||||
return (int64)(pkt.pos)
|
||||
}
|
||||
|
||||
// Custom: SetPos sets `AVPacket.pos` value.
|
||||
func (pkt *AvPacket) SetPos(v int64) {
|
||||
pkt.pos = (C.int64_t)(v)
|
||||
}
|
||||
|
||||
// Custom: GetPosAddr gets `AVPacket.pos` address.
|
||||
func (pkt *AvPacket) GetPosAddr() *int64 {
|
||||
return (*int64)(&pkt.pos)
|
||||
}
|
||||
|
||||
// Custom: GetConvergenceDuration gets `AVPacket.convergence_duration` value.
|
||||
func (pkt *AvPacket) GetConvergenceDuration() int64 {
|
||||
return (int64)(pkt.convergence_duration)
|
||||
}
|
||||
|
||||
// Custom: SetConvergenceDuration sets `AVPacket.convergence_duration` value.
|
||||
func (pkt *AvPacket) SetConvergenceDuration(v int64) {
|
||||
pkt.convergence_duration = (C.int64_t)(v)
|
||||
}
|
||||
|
||||
// Custom: GetConvergenceDurationAddr gets `AVPacket.convergence_duration` address.
|
||||
func (pkt *AvPacket) GetConvergenceDurationAddr() *int64 {
|
||||
return (*int64)(&pkt.convergence_duration)
|
||||
}
|
||||
|
||||
// AvPacketList
|
||||
type AvPacketList C.struct_AVPacketList
|
||||
|
||||
const (
|
||||
AV_PKT_FLAG_KEY = C.AV_PKT_FLAG_KEY
|
||||
AV_PKT_FLAG_CORRUPT = C.AV_PKT_FLAG_CORRUPT
|
||||
AV_PKT_FLAG_DISCARD = C.AV_PKT_FLAG_DISCARD
|
||||
AV_PKT_FLAG_TRUSTED = C.AV_PKT_FLAG_TRUSTED
|
||||
AV_PKT_FLAG_DISPOSABLE = C.AV_PKT_FLAG_DISPOSABLE
|
||||
)
|
||||
|
||||
// AvSideDataParamChangeFlags
|
||||
type AvSideDataParamChangeFlags int32
|
||||
|
||||
const (
|
||||
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT = AvSideDataParamChangeFlags(C.AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)
|
||||
AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT = AvSideDataParamChangeFlags(C.AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)
|
||||
AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE = AvSideDataParamChangeFlags(C.AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)
|
||||
AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS = AvSideDataParamChangeFlags(C.AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)
|
||||
)
|
||||
|
||||
// AvPacketAlloc allocates an AVPacket and set its fields to default values. The resulting
|
||||
// struct must be freed using AvPacketFree().
|
||||
func AvPacketAlloc() *AvPacket {
|
||||
return (*AvPacket)(C.av_packet_alloc())
|
||||
}
|
||||
|
||||
// AvPacketClone creates a new packet that references the same data as src.
|
||||
func AvPacketClone(pkt *AvPacket) *AvPacket {
|
||||
return (*AvPacket)(C.av_packet_clone((*C.struct_AVPacket)(pkt)))
|
||||
}
|
||||
|
||||
// AvPacketFree frees the packet, if the packet is reference counted, it will be
|
||||
// unreferenced first.
|
||||
func AvPacketFree(pkt **AvPacket) {
|
||||
C.av_packet_free((**C.struct_AVPacket)(unsafe.Pointer(pkt)))
|
||||
}
|
||||
|
||||
// AvNewPacket allocates the payload of a packet and initialize its fields with
|
||||
// default values.
|
||||
func AvNewPacket(pkt *AvPacket, size int32) int32 {
|
||||
return (int32)(C.av_new_packet((*C.struct_AVPacket)(pkt), (C.int)(size)))
|
||||
}
|
||||
|
||||
// AvShrinkPacket reduces packet size, correctly zeroing padding
|
||||
func AvShrinkPacket(pkt *AvPacket, size int32) {
|
||||
C.av_shrink_packet((*C.struct_AVPacket)(pkt), (C.int)(size))
|
||||
}
|
||||
|
||||
// AvGrowPacket increases packet size, correctly zeroing padding
|
||||
func AvGrowPacket(pkt *AvPacket, growBy int32) int32 {
|
||||
return (int32)(C.av_grow_packet((*C.struct_AVPacket)(pkt), (C.int)(growBy)))
|
||||
}
|
||||
|
||||
// AvPacketFromData initializes a reference-counted packet from AvMalloc()ed data.
|
||||
func AvPacketFromData(pkt *AvPacket, data *uint8, size int32) int32 {
|
||||
return (int32)(C.av_packet_from_data((*C.struct_AVPacket)(pkt),
|
||||
(*C.uint8_t)(data), (C.int)(size)))
|
||||
}
|
||||
|
||||
// Deprecated: Use AvPacketRef() or AvPacketMakeRefcounted() instead.
|
||||
func AvDupPacket(pkt *AvPacket) {
|
||||
C.av_dup_packet((*C.struct_AVPacket)(pkt))
|
||||
}
|
||||
|
||||
// Deprecated: Use AvPacketRef instead.
|
||||
// AvCopyPacket copies packet, including contents
|
||||
func AvCopyPacket(dst, src *AvPacket) int32 {
|
||||
return (int32)(C.av_copy_packet((*C.struct_AVPacket)(dst), (*C.struct_AVPacket)(src)))
|
||||
}
|
||||
|
||||
// Deprecated: Use AvPacketCopyProps instead.
|
||||
// AvCopyPacketSideData copies packet side data
|
||||
func AvCopyPacketSideData(dst, src *AvPacket) int32 {
|
||||
return (int32)(C.av_copy_packet_side_data((*C.struct_AVPacket)(dst), (*C.struct_AVPacket)(src)))
|
||||
}
|
||||
|
||||
// Deprecated: Use AvPacketUnref() instead.
|
||||
// AvFreePacket frees a packet.
|
||||
func AvFreePacket(pkt *AvPacket) {
|
||||
C.av_free_packet((*C.struct_AVPacket)(pkt))
|
||||
}
|
||||
|
||||
// AvPacketNewSideData allocates new information of a packet.
|
||||
func AvPacketNewSideData(pkt *AvPacket, _type AvPacketSideDataType, size int32) *uint8 {
|
||||
return (*uint8)(C.av_packet_new_side_data((*C.struct_AVPacket)(pkt),
|
||||
(C.enum_AVPacketSideDataType)(_type), (C.int)(size)))
|
||||
}
|
||||
|
||||
// AvPacketAddSideData wraps an existing array as a packet side data.
|
||||
func AvPacketAddSideData(pkt *AvPacket, _type AvPacketSideDataType, data *uint8, size uint) int32 {
|
||||
return (int32)(C.av_packet_add_side_data((*C.struct_AVPacket)(pkt),
|
||||
(C.enum_AVPacketSideDataType)(_type), (*C.uint8_t)(data), (C.size_t)(size)))
|
||||
}
|
||||
|
||||
// AvPacketShrinkSideData shrinks the already allocated side data buffer.
|
||||
func AvPacketShrinkSideData(pkt *AvPacket, _type AvPacketSideDataType, size int32) int32 {
|
||||
return (int32)(C.av_packet_shrink_side_data((*C.struct_AVPacket)(pkt),
|
||||
(C.enum_AVPacketSideDataType)(_type), (C.int)(size)))
|
||||
}
|
||||
|
||||
// AvPacketGetSideData gets side information from packet.
|
||||
func AvPacketGetSideData(pkt *AvPacket, _type AvPacketSideDataType, size *int32) *uint8 {
|
||||
return (*uint8)(C.av_packet_get_side_data((*C.struct_AVPacket)(pkt),
|
||||
(C.enum_AVPacketSideDataType)(_type), (*C.int)(size)))
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func AvPacketMergeSideData(pkt *AvPacket) int32 {
|
||||
return (int32)(C.av_packet_merge_side_data((*C.struct_AVPacket)(pkt)))
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func AvPacketSplitSideData(pkt *AvPacket) int32 {
|
||||
return (int32)(C.av_packet_split_side_data((*C.struct_AVPacket)(pkt)))
|
||||
}
|
||||
|
||||
// AvPacketPackDictionary packs a dictionary for use in side_data.
|
||||
func AvPacketPackDictionary(dict *AvDictionary, size *int32) *uint8 {
|
||||
return (*uint8)(C.av_packet_pack_dictionary((*C.struct_AVDictionary)(dict),
|
||||
(*C.int)(size)))
|
||||
}
|
||||
|
||||
// AvPacketUnpackDictionary unpacks a dictionary from side_data.
|
||||
func AvPacketUnpackDictionary(data *uint8, size int32, dict **AvDictionary) int32 {
|
||||
return (int32)(C.av_packet_unpack_dictionary((*C.uint8_t)(data), (C.int)(size),
|
||||
(**C.struct_AVDictionary)(unsafe.Pointer(dict))))
|
||||
}
|
||||
|
||||
// AvPacketFreeSideData is a convenience function to free all the side data stored.
|
||||
func AvPacketFreeSideData(pkt *AvPacket) {
|
||||
C.av_packet_free_side_data((*C.struct_AVPacket)(pkt))
|
||||
}
|
||||
|
||||
// AvPacketRef setups a new reference to the data described by a given packet
|
||||
func AvPacketRef(dst, src *AvPacket) int32 {
|
||||
return (int32)(C.av_packet_ref((*C.struct_AVPacket)(dst), (*C.struct_AVPacket)(src)))
|
||||
}
|
||||
|
||||
// AvPacketUnref unreferences the buffer referenced by the packet and reset the
|
||||
// remaining packet fields to their default values.
|
||||
func AvPacketUnref(pkt *AvPacket) {
|
||||
C.av_packet_unref((*C.struct_AVPacket)(pkt))
|
||||
}
|
||||
|
||||
// AvPacketMoveRef moves every field in src to dst and reset src.
|
||||
func AvPacketMoveRef(dst, src *AvPacket) {
|
||||
C.av_packet_move_ref((*C.struct_AVPacket)(dst), (*C.struct_AVPacket)(src))
|
||||
}
|
||||
|
||||
// AvPacketCopyProps copies only "properties" fields from src to dst.
|
||||
func AvPacketCopyProps(dst, src *AvPacket) int32 {
|
||||
return (int32)(C.av_packet_copy_props((*C.struct_AVPacket)(dst), (*C.struct_AVPacket)(src)))
|
||||
}
|
||||
|
||||
// AvPacketMakeRefcounted ensures the data described by a given packet is reference counted.
|
||||
func AvPacketMakeRefcounted(pkt *AvPacket) {
|
||||
C.av_packet_make_refcounted((*C.struct_AVPacket)(pkt))
|
||||
}
|
||||
|
||||
// AvPacketMakeWritable creates a writable reference for the data described by a given packet,
|
||||
// avoiding data copy if possible.
|
||||
func AvPacketMakeWritable(pkt *AvPacket) {
|
||||
C.av_packet_make_writable((*C.struct_AVPacket)(pkt))
|
||||
}
|
||||
|
||||
// AvPacketRescaleTs converts valid timing fields (timestamps / durations) in a packet from one
|
||||
// timebase to another. Timestamps with unknown values (AV_NOPTS_VALUE) will be ignored.
|
||||
func AvPacketRescaleTs(pkt *AvPacket, tbSrc, tbDst AvRational) {
|
||||
C.av_packet_rescale_ts((*C.struct_AVPacket)(pkt),
|
||||
(C.struct_AVRational)(tbSrc), (C.struct_AVRational)(tbDst))
|
||||
}
|
12
avcodec_version.go
Normal file
12
avcodec_version.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavcodec/version.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
LIBAVCODEC_VERSION_MAJOR = C.LIBAVCODEC_VERSION_MAJOR
|
||||
LIBAVCODEC_VERSION_MINOR = C.LIBAVCODEC_VERSION_MINOR
|
||||
LIBAVCODEC_VERSION_MICRO = C.LIBAVCODEC_VERSION_MICRO
|
||||
)
|
43
avcodec_vorbis_parser.go
Normal file
43
avcodec_vorbis_parser.go
Normal file
@@ -0,0 +1,43 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavcodec/vorbis_parser.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
type AvVorbisParseContext C.struct_AVVorbisParseContext
|
||||
|
||||
// AvVorbisParseInit allocates and initialize the Vorbis parser using headers in the extradata.
|
||||
func AvVorbisParseInit(extradata *uint8, extradataSize int32) *AvVorbisParseContext {
|
||||
return (*AvVorbisParseContext)(C.av_vorbis_parse_init((*C.uint8_t)(extradata),
|
||||
(C.int)(extradataSize)))
|
||||
}
|
||||
|
||||
// AvVorbisParseFree frees the parser and everything associated with it.
|
||||
func AvVorbisParseFree(s **AvVorbisParseContext) {
|
||||
C.av_vorbis_parse_free((**C.struct_AVVorbisParseContext)(unsafe.Pointer(s)))
|
||||
}
|
||||
|
||||
const (
|
||||
VORBIS_FLAG_HEADER = C.VORBIS_FLAG_HEADER
|
||||
VORBIS_FLAG_COMMENT = C.VORBIS_FLAG_COMMENT
|
||||
VORBIS_FLAG_SETUP = C.VORBIS_FLAG_SETUP
|
||||
)
|
||||
|
||||
// AvVorbisParseFrameFlags gets the duration for a Vorbis packet.
|
||||
func AvVorbisParseFrameFlags(s *AvVorbisParseContext, buf *uint8, bufSize int32, flags *int32) int32 {
|
||||
return (int32)(C.av_vorbis_parse_frame_flags((*C.struct_AVVorbisParseContext)(s),
|
||||
(*C.uint8_t)(buf), (C.int)(bufSize), (*C.int)(flags)))
|
||||
}
|
||||
|
||||
// AvVorbisParseFrame gets the duration for a Vorbis packet.
|
||||
func AvVorbisParseFrame(s *AvVorbisParseContext, buf *uint8, bufSize int32) int32 {
|
||||
return (int32)(C.av_vorbis_parse_frame((*C.struct_AVVorbisParseContext)(s),
|
||||
(*C.uint8_t)(buf), (C.int)(bufSize)))
|
||||
}
|
||||
|
||||
// AvVorbisParseReset
|
||||
func AvVorbisParseReset(s *AvVorbisParseContext) {
|
||||
C.av_vorbis_parse_reset((*C.struct_AVVorbisParseContext)(s))
|
||||
}
|
152
avdevice.go
Normal file
152
avdevice.go
Normal file
@@ -0,0 +1,152 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavdevice/avdevice.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// AvDeviceVersion returns the LIBAVDEVICE_VERSION_INT constant.
|
||||
func AvDeviceVersion() uint32 {
|
||||
return (uint32)(C.avdevice_version())
|
||||
}
|
||||
|
||||
// AvDeviceConfiguration returns the libavdevice build-time configuration.
|
||||
func AvDeviceConfiguration() string {
|
||||
return C.GoString(C.avdevice_configuration())
|
||||
}
|
||||
|
||||
// AvDeviceLicense returns the libavdevice license.
|
||||
func AvDeviceLicense() string {
|
||||
return C.GoString(C.avdevice_license())
|
||||
}
|
||||
|
||||
// AvDeviceRegisterAll initializes libavdevice and register all the input and output devices.
|
||||
func AvDeviceRegisterAll() {
|
||||
C.avdevice_register_all()
|
||||
}
|
||||
|
||||
// AvInputAudioDeviceNext iterates audio input devices.
|
||||
func AvInputAudioDeviceNext(d *AvInputFormat) *AvInputFormat {
|
||||
return (*AvInputFormat)(C.av_input_audio_device_next((*C.struct_AVInputFormat)(d)))
|
||||
}
|
||||
|
||||
// AvInputVideoDeviceNext iterates video input devices.
|
||||
func AvInputVideoDeviceNext(d *AvInputFormat) *AvInputFormat {
|
||||
return (*AvInputFormat)(C.av_input_video_device_next((*C.struct_AVInputFormat)(d)))
|
||||
}
|
||||
|
||||
// AvOutputAudioDeviceNext iterates audio output devices.
|
||||
func AvOutputAudioDeviceNext(d *AvOutputFormat) *AvOutputFormat {
|
||||
return (*AvOutputFormat)(C.av_output_audio_device_next((*C.struct_AVOutputFormat)(d)))
|
||||
}
|
||||
|
||||
// AvOutputVideoDeviceNext iterates video output devices.
|
||||
func AvOutputVideoDeviceNext(d *AvOutputFormat) *AvOutputFormat {
|
||||
return (*AvOutputFormat)(C.av_output_video_device_next((*C.struct_AVOutputFormat)(d)))
|
||||
}
|
||||
|
||||
// AvDeviceRect
|
||||
type AvDeviceRect C.struct_AVDeviceRect
|
||||
|
||||
// AvAppToDevMessageType
|
||||
type AvAppToDevMessageType int32
|
||||
|
||||
const (
|
||||
AV_APP_TO_DEV_NONE = AvAppToDevMessageType(C.AV_APP_TO_DEV_NONE)
|
||||
AV_APP_TO_DEV_WINDOW_SIZE = AvAppToDevMessageType(C.AV_APP_TO_DEV_WINDOW_SIZE)
|
||||
AV_APP_TO_DEV_WINDOW_REPAINT = AvAppToDevMessageType(C.AV_APP_TO_DEV_WINDOW_REPAINT)
|
||||
AV_APP_TO_DEV_PAUSE = AvAppToDevMessageType(C.AV_APP_TO_DEV_PAUSE)
|
||||
AV_APP_TO_DEV_PLAY = AvAppToDevMessageType(C.AV_APP_TO_DEV_PLAY)
|
||||
AV_APP_TO_DEV_TOGGLE_PAUSE = AvAppToDevMessageType(C.AV_APP_TO_DEV_TOGGLE_PAUSE)
|
||||
AV_APP_TO_DEV_SET_VOLUME = AvAppToDevMessageType(C.AV_APP_TO_DEV_SET_VOLUME)
|
||||
AV_APP_TO_DEV_MUTE = AvAppToDevMessageType(C.AV_APP_TO_DEV_MUTE)
|
||||
AV_APP_TO_DEV_UNMUTE = AvAppToDevMessageType(C.AV_APP_TO_DEV_UNMUTE)
|
||||
AV_APP_TO_DEV_TOGGLE_MUTE = AvAppToDevMessageType(C.AV_APP_TO_DEV_TOGGLE_MUTE)
|
||||
AV_APP_TO_DEV_GET_VOLUME = AvAppToDevMessageType(C.AV_APP_TO_DEV_GET_VOLUME)
|
||||
AV_APP_TO_DEV_GET_MUTE = AvAppToDevMessageType(C.AV_APP_TO_DEV_GET_MUTE)
|
||||
)
|
||||
|
||||
// AvDevToAppMessageType
|
||||
type AvDevToAppMessageType int32
|
||||
|
||||
const (
|
||||
AV_DEV_TO_APP_NONE = AvDevToAppMessageType(C.AV_DEV_TO_APP_NONE)
|
||||
AV_DEV_TO_APP_CREATE_WINDOW_BUFFER = AvDevToAppMessageType(C.AV_DEV_TO_APP_CREATE_WINDOW_BUFFER)
|
||||
AV_DEV_TO_APP_PREPARE_WINDOW_BUFFER = AvDevToAppMessageType(C.AV_DEV_TO_APP_PREPARE_WINDOW_BUFFER)
|
||||
AV_DEV_TO_APP_DISPLAY_WINDOW_BUFFER = AvDevToAppMessageType(C.AV_DEV_TO_APP_DISPLAY_WINDOW_BUFFER)
|
||||
AV_DEV_TO_APP_DESTROY_WINDOW_BUFFER = AvDevToAppMessageType(C.AV_DEV_TO_APP_DESTROY_WINDOW_BUFFER)
|
||||
AV_DEV_TO_APP_BUFFER_OVERFLOW = AvDevToAppMessageType(C.AV_DEV_TO_APP_BUFFER_OVERFLOW)
|
||||
AV_DEV_TO_APP_BUFFER_UNDERFLOW = AvDevToAppMessageType(C.AV_DEV_TO_APP_BUFFER_UNDERFLOW)
|
||||
AV_DEV_TO_APP_BUFFER_READABLE = AvDevToAppMessageType(C.AV_DEV_TO_APP_BUFFER_READABLE)
|
||||
AV_DEV_TO_APP_BUFFER_WRITABLE = AvDevToAppMessageType(C.AV_DEV_TO_APP_BUFFER_WRITABLE)
|
||||
AV_DEV_TO_APP_MUTE_STATE_CHANGED = AvDevToAppMessageType(C.AV_DEV_TO_APP_MUTE_STATE_CHANGED)
|
||||
AV_DEV_TO_APP_VOLUME_LEVEL_CHANGED = AvDevToAppMessageType(C.AV_DEV_TO_APP_VOLUME_LEVEL_CHANGED)
|
||||
)
|
||||
|
||||
// AvDeviceAppToDevControlMessage sends control message from application to device.
|
||||
func AvDeviceAppToDevControlMessage(s *AvFormatContext,
|
||||
_type AvAppToDevMessageType, data unsafe.Pointer, dataSize uint) int32 {
|
||||
return (int32)(C.avdevice_app_to_dev_control_message((*C.struct_AVFormatContext)(s),
|
||||
(C.enum_AVAppToDevMessageType)(_type), data, (C.size_t)(dataSize)))
|
||||
}
|
||||
|
||||
// AvDeviceDevToAppControlMessage sends control message from device to application.
|
||||
func AvDeviceDevToAppControlMessage(s *AvFormatContext,
|
||||
_type AvDevToAppMessageType, data unsafe.Pointer, dataSize uint) int32 {
|
||||
return (int32)(C.avdevice_dev_to_app_control_message((*C.struct_AVFormatContext)(s),
|
||||
(C.enum_AVDevToAppMessageType)(_type), data, (C.size_t)(dataSize)))
|
||||
}
|
||||
|
||||
// AvDeviceCapabilitiesQuery
|
||||
type AvDeviceCapabilitiesQuery C.struct_AVDeviceCapabilitiesQuery
|
||||
|
||||
// Deprecated: No use
|
||||
func AvDeviceCapabilitiesCreate(caps **AvDeviceCapabilitiesQuery,
|
||||
s *AvFormatContext, deviceOptions **AvDictionary) int32 {
|
||||
return (int32)(C.avdevice_capabilities_create((**C.struct_AVDeviceCapabilitiesQuery)(unsafe.Pointer(caps)),
|
||||
(*C.struct_AVFormatContext)(s), (**C.struct_AVDictionary)(unsafe.Pointer(deviceOptions))))
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func AvDeviceCapabilitiesFree(caps **AvDeviceCapabilitiesQuery, s *AvFormatContext) {
|
||||
C.avdevice_capabilities_free((**C.struct_AVDeviceCapabilitiesQuery)(unsafe.Pointer(caps)),
|
||||
(*C.struct_AVFormatContext)(s))
|
||||
}
|
||||
|
||||
// AvDeviceInfo
|
||||
type AvDeviceInfo C.struct_AVDeviceInfo
|
||||
|
||||
// AvDeviceInfoList
|
||||
type AvDeviceInfoList C.struct_AVDeviceInfoList
|
||||
|
||||
// AvDeviceListDevices returns available device names and their parameters.
|
||||
func AvDeviceListDevices(s *AvFormatContext, deviceList **AvDeviceInfoList) int32 {
|
||||
return (int32)(C.avdevice_list_devices((*C.struct_AVFormatContext)(s),
|
||||
(**C.struct_AVDeviceInfoList)(unsafe.Pointer(deviceList))))
|
||||
}
|
||||
|
||||
// AvDeviceFreeListDevices frees result of AvDeviceListDevices().
|
||||
func AvDeviceFreeListDevices(deviceList **AvDeviceInfoList) {
|
||||
C.avdevice_free_list_devices((**C.struct_AVDeviceInfoList)(unsafe.Pointer(deviceList)))
|
||||
}
|
||||
|
||||
// AvDeviceListInputSources lists input devices.
|
||||
func AvDeviceListInputSources(device *AvInputFormat, deviceName string,
|
||||
deviceOptions *AvDictionary, deviceList **AvDeviceInfoList) int32 {
|
||||
deviceNamePtr, deviceNameFunc := StringCasting(deviceName)
|
||||
defer deviceNameFunc()
|
||||
return (int32)(C.avdevice_list_input_sources((*C.struct_AVInputFormat)(device),
|
||||
(*C.char)(deviceNamePtr), (*C.struct_AVDictionary)(deviceOptions),
|
||||
(**C.struct_AVDeviceInfoList)(unsafe.Pointer(deviceList))))
|
||||
}
|
||||
|
||||
// AvDeviceListOutputSinks lists output devices.
|
||||
func AvDeviceListOutputSinks(device *AvOutputFormat, deviceName string,
|
||||
deviceOptions *AvDictionary, deviceList **AvDeviceInfoList) int32 {
|
||||
deviceNamePtr, deviceNameFunc := StringCasting(deviceName)
|
||||
defer deviceNameFunc()
|
||||
return (int32)(C.avdevice_list_output_sinks((*C.struct_AVOutputFormat)(device),
|
||||
(*C.char)(deviceNamePtr), (*C.struct_AVDictionary)(deviceOptions),
|
||||
(**C.struct_AVDeviceInfoList)(unsafe.Pointer(deviceList))))
|
||||
}
|
12
avdevice_version.go
Normal file
12
avdevice_version.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavdevice/version.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
LIBAVDEVICE_VERSION_MAJOR = C.LIBAVDEVICE_VERSION_MAJOR
|
||||
LIBAVDEVICE_VERSION_MINOR = C.LIBAVDEVICE_VERSION_MINOR
|
||||
LIBAVDEVICE_VERSION_MICRO = C.LIBAVDEVICE_VERSION_MICRO
|
||||
)
|
332
avfilter.go
Normal file
332
avfilter.go
Normal file
@@ -0,0 +1,332 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavfilter/avfilter.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// AvFilterVersion returns the LIBAVFILTER_VERSION_INT constant.
|
||||
func AvFilterVersion() uint32 {
|
||||
return (uint32)(C.avfilter_version())
|
||||
}
|
||||
|
||||
// AvFilterConfiguration returns the libavfilter build-time configuration.
|
||||
func AvFilterConfiguration() string {
|
||||
return C.GoString(C.avfilter_configuration())
|
||||
}
|
||||
|
||||
// AvFilterLicense returns the libavfilter license.
|
||||
func AvFilterLicense() string {
|
||||
return C.GoString(C.avfilter_license())
|
||||
}
|
||||
|
||||
// AvFilterPad
|
||||
type AvFilterPad C.struct_AVFilterPad
|
||||
|
||||
// AvFilterFormats
|
||||
type AvFilterFormats C.struct_AVFilterFormats
|
||||
|
||||
// AvFilterChannelLayouts
|
||||
type AvFilterChannelLayouts C.struct_AVFilterChannelLayouts
|
||||
|
||||
// AvFilterPadCount gets the number of elements in a NULL-terminated array of AVFilterPads (e.g.
|
||||
// AvFilter.inputs/outputs).
|
||||
func AvFilterPadCount(pads *AvFilterPad) int32 {
|
||||
return (int32)(C.avfilter_pad_count((*C.struct_AVFilterPad)(pads)))
|
||||
}
|
||||
|
||||
// AvFilterPadGetName gets the name of an AvFilterPad.
|
||||
func AvFilterPadGetName(pads *AvFilterPad, padIdx int32) string {
|
||||
return C.GoString(C.avfilter_pad_get_name((*C.struct_AVFilterPad)(pads), (C.int)(padIdx)))
|
||||
}
|
||||
|
||||
// AvFilterPadGetType gets the type of an AvFilterPad.
|
||||
func AvFilterPadGetType(pads *AvFilterPad, padIdx int32) AvMediaType {
|
||||
return (AvMediaType)(C.avfilter_pad_get_type((*C.struct_AVFilterPad)(pads), (C.int)(padIdx)))
|
||||
}
|
||||
|
||||
const (
|
||||
AVFILTER_FLAG_DYNAMIC_INPUTS = C.AVFILTER_FLAG_DYNAMIC_INPUTS
|
||||
AVFILTER_FLAG_DYNAMIC_OUTPUTS = C.AVFILTER_FLAG_DYNAMIC_OUTPUTS
|
||||
AVFILTER_FLAG_SLICE_THREADS = C.AVFILTER_FLAG_SLICE_THREADS
|
||||
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC = C.AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
|
||||
AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL = C.AVFILTER_FLAG_SUPPORT_TIMELINE_INTERNAL
|
||||
AVFILTER_FLAG_SUPPORT_TIMELINE = C.AVFILTER_FLAG_SUPPORT_TIMELINE
|
||||
)
|
||||
|
||||
// Filter definition. This defines the pads a filter contains, and all the
|
||||
// callback functions used to interact with the filter.
|
||||
type AvFilter C.struct_AVFilter
|
||||
|
||||
const (
|
||||
AVFILTER_THREAD_SLICE = C.AVFILTER_THREAD_SLICE
|
||||
)
|
||||
|
||||
// AvFilterInternal
|
||||
type AvFilterInternal C.struct_AVFilterInternal
|
||||
|
||||
// AvFilterContext
|
||||
type AvFilterContext C.struct_AVFilterContext
|
||||
|
||||
// AvFilterFormatsConfig
|
||||
type AvFilterFormatsConfig C.struct_AVFilterFormatsConfig
|
||||
|
||||
// AvFilterLink
|
||||
type AvFilterLink C.struct_AVFilterLink
|
||||
|
||||
// AvFilterContextLink links two filters together.
|
||||
func AvFilterContextLink(src *AvFilterContext, srcpad uint32,
|
||||
dst *AvFilterContext, dstpad uint32) int32 {
|
||||
return (int32)(C.avfilter_link((*C.struct_AVFilterContext)(src), (C.uint)(srcpad),
|
||||
(*C.struct_AVFilterContext)(dst), (C.uint)(dstpad)))
|
||||
}
|
||||
|
||||
// AvFilterLinkFree frees the link in *link, and set its pointer to NULL.
|
||||
func AvFilterLinkFree(link **AvFilterLink) {
|
||||
C.avfilter_link_free((**C.struct_AVFilterLink)(unsafe.Pointer(link)))
|
||||
}
|
||||
|
||||
// Deprecated: Use av_buffersink_get_channels() instead.
|
||||
func AvFilterLinkGetChannels(link *AvFilterLink) int32 {
|
||||
return (int32)(C.avfilter_link_get_channels((*C.struct_AVFilterLink)(link)))
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func AvFilterLinkSetClosed(link *AvFilterLink, closed int32) {
|
||||
C.avfilter_link_set_closed((*C.struct_AVFilterLink)(link), (C.int)(closed))
|
||||
}
|
||||
|
||||
// AvFilterConfigLinks negotiates the media format, dimensions, etc of all inputs to a filter.
|
||||
func AvFilterConfigLinks(filter *AvFilterContext) int32 {
|
||||
return (int32)(C.avfilter_config_links((*C.struct_AVFilterContext)(filter)))
|
||||
}
|
||||
|
||||
const (
|
||||
AVFILTER_CMD_FLAG_ONE = C.AVFILTER_CMD_FLAG_ONE
|
||||
AVFILTER_CMD_FLAG_FAST = C.AVFILTER_CMD_FLAG_FAST
|
||||
)
|
||||
|
||||
// AvFilterProcessCommand makes the filter instance process a command.
|
||||
// It is recommended to use AvFilterGraphSendCommand().
|
||||
func AvFilterProcessCommand(filter *AvFilterContext, cmd, arg string, resLen, flags int32) (res string, ret int32) {
|
||||
cmdPtr, cmdFunc := StringCasting(cmd)
|
||||
defer cmdFunc()
|
||||
argPtr, argFunc := StringCasting(arg)
|
||||
defer argFunc()
|
||||
resBuf := make([]C.char, resLen)
|
||||
ret = (int32)(C.avfilter_process_command((*C.struct_AVFilterContext)(filter),
|
||||
(*C.char)(cmdPtr), (*C.char)(argPtr), (*C.char)(&resBuf[0]), (C.int)(resLen), (C.int)(flags)))
|
||||
return C.GoString(&resBuf[0]), ret
|
||||
}
|
||||
|
||||
// AvFilterIterate iterates over all registered filters.
|
||||
func AvFilterIterate(opaque *unsafe.Pointer) *AvFilter {
|
||||
return (*AvFilter)(C.av_filter_iterate(opaque))
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func AvFilterRegisterAll() {
|
||||
C.avfilter_register_all()
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func AvFilterRegister(filter *AvFilter) {
|
||||
C.avfilter_register((*C.struct_AVFilter)(filter))
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func AvFilterNext(filter *AvFilter) *AvFilter {
|
||||
return (*AvFilter)(C.avfilter_next((*C.struct_AVFilter)(filter)))
|
||||
}
|
||||
|
||||
// AvFilterGetByName gets a filter definition matching the given name.
|
||||
func AvFilterGetByName(name string) *AvFilter {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (*AvFilter)(C.avfilter_get_by_name((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvFilterInitStr initializes a filter with the supplied parameters.
|
||||
func AvFilterInitStr(ctx *AvFilterContext, args string) int32 {
|
||||
argsPtr, argsFunc := StringCasting(args)
|
||||
defer argsFunc()
|
||||
return (int32)(C.avfilter_init_str((*C.struct_AVFilterContext)(ctx),
|
||||
(*C.char)(argsPtr)))
|
||||
}
|
||||
|
||||
// AvFilterInitDict initialize a filter with the supplied dictionary of options.
|
||||
func AvFilterInitDict(ctx *AvFilterContext, options **AvDictionary) int32 {
|
||||
return (int32)(C.avfilter_init_dict((*C.struct_AVFilterContext)(ctx),
|
||||
(**C.struct_AVDictionary)(unsafe.Pointer(options))))
|
||||
}
|
||||
|
||||
// AvFilterFree frees a filter context. This will also remove the filter from its
|
||||
// filtergraph's list of filters.
|
||||
func AvFilterFree(ctx *AvFilterContext) {
|
||||
C.avfilter_free((*C.struct_AVFilterContext)(ctx))
|
||||
}
|
||||
|
||||
// AvFilterInsertFilter inserts a filter in the middle of an existing link.
|
||||
func AvFilterInsertFilter(ctx *AvFilterContext, link *AvFilterLink,
|
||||
filtSrcpadIdx, filtDstpadIdx uint32) int32 {
|
||||
return (int32)(C.avfilter_insert_filter(
|
||||
(*C.struct_AVFilterLink)(link),
|
||||
(*C.struct_AVFilterContext)(ctx),
|
||||
(C.uint)(filtSrcpadIdx), (C.uint)(filtDstpadIdx)))
|
||||
}
|
||||
|
||||
// AvFilterGetClass returns AvClass for AvFilterContext.
|
||||
func AvFilterGetClass() *AvClass {
|
||||
return (*AvClass)(C.avfilter_get_class())
|
||||
}
|
||||
|
||||
// typedef int (avfilter_action_func)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
|
||||
type AvfilterActionFunc C.avfilter_action_func
|
||||
|
||||
// typedef int (avfilter_execute_func)(AVFilterContext *ctx, avfilter_action_func *func,
|
||||
// void *arg, int *ret, int nb_jobs)
|
||||
type AvfilterExecuteFunc C.avfilter_execute_func
|
||||
|
||||
type AvFilterGraph C.struct_AVFilterGraph
|
||||
|
||||
// AvFilterGraphAlloc allocates a filter graph.
|
||||
func AvFilterGraphAlloc() *AvFilterGraph {
|
||||
return (*AvFilterGraph)(C.avfilter_graph_alloc())
|
||||
}
|
||||
|
||||
// AvFilterGraphAllocFilter creates a new filter instance in a filter graph.
|
||||
func AvFilterGraphAllocFilter(graph *AvFilterGraph, filter *AvFilter, name string) *AvFilterContext {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (*AvFilterContext)(C.avfilter_graph_alloc_filter((*C.struct_AVFilterGraph)(graph),
|
||||
(*C.struct_AVFilter)(filter), (*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvFilterGraphGetFilter gets a filter instance identified by instance name from graph.
|
||||
func AvFilterGraphGetFilter(graph *AvFilterGraph, name string) *AvFilterContext {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (*AvFilterContext)(C.avfilter_graph_get_filter((*C.struct_AVFilterGraph)(graph),
|
||||
(*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvFilterGraphCreateFilter creates and adds a filter instance into an existing graph.
|
||||
func AvFilterGraphCreateFilter(graph *AvFilterGraph, filtCtx **AvFilterContext, filter *AvFilter,
|
||||
name, args string, opaque unsafe.Pointer) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
argsPtr, argsFunc := StringCasting(args)
|
||||
defer argsFunc()
|
||||
return (int32)(C.avfilter_graph_create_filter(
|
||||
(**C.struct_AVFilterContext)(unsafe.Pointer(filtCtx)),
|
||||
(*C.struct_AVFilter)(filter), (*C.char)(namePtr), (*C.char)(argsPtr),
|
||||
opaque, (*C.struct_AVFilterGraph)(graph)))
|
||||
}
|
||||
|
||||
// AvFilterGraphSetAutoConvert enables or disables automatic format conversion inside the graph.
|
||||
func AvFilterGraphSetAutoConvert(graph *AvFilterGraph, flags uint32) {
|
||||
C.avfilter_graph_set_auto_convert((*C.struct_AVFilterGraph)(graph), (C.uint)(flags))
|
||||
}
|
||||
|
||||
const (
|
||||
AVFILTER_AUTO_CONVERT_ALL = int32(C.AVFILTER_AUTO_CONVERT_ALL)
|
||||
AVFILTER_AUTO_CONVERT_NONE = int32(C.AVFILTER_AUTO_CONVERT_NONE)
|
||||
)
|
||||
|
||||
// AvFilterGraphConfig checks validity and configure all the links and formats in the graph.
|
||||
func AvFilterGraphConfig(graph *AvFilterGraph, logCtx unsafe.Pointer) int32 {
|
||||
return (int32)(C.avfilter_graph_config((*C.struct_AVFilterGraph)(graph), logCtx))
|
||||
}
|
||||
|
||||
// AvFilterGraphFree frees a graph, destroy its links, and set *graph to NULL.
|
||||
func AvFilterGraphFree(graph **AvFilterGraph) {
|
||||
C.avfilter_graph_free((**C.struct_AVFilterGraph)(unsafe.Pointer(graph)))
|
||||
}
|
||||
|
||||
type AvFilterInOut C.struct_AVFilterInOut
|
||||
|
||||
// AvFilterInoutAlloc allocates a single AVFilterInOut entry.
|
||||
func AvFilterInoutAlloc() *AvFilterInOut {
|
||||
return (*AvFilterInOut)(C.avfilter_inout_alloc())
|
||||
}
|
||||
|
||||
// AvFilterInoutFree frees the supplied list of AVFilterInOut and set *inout to NULL.
|
||||
func AvFilterInoutFree(inout **AvFilterInOut) {
|
||||
C.avfilter_inout_free((**C.struct_AVFilterInOut)(unsafe.Pointer(inout)))
|
||||
}
|
||||
|
||||
// AvFilterGraphParse adds a graph described by a string to a graph.
|
||||
func AvFilterGraphParse(graph *AvFilterGraph, filters string, inputs, outputs *AvFilterInOut,
|
||||
logCtx unsafe.Pointer) int32 {
|
||||
filtersPtr, filtersFunc := StringCasting(filters)
|
||||
defer filtersFunc()
|
||||
return (int32)(C.avfilter_graph_parse((*C.struct_AVFilterGraph)(graph),
|
||||
(*C.char)(filtersPtr),
|
||||
(*C.struct_AVFilterInOut)(inputs),
|
||||
(*C.struct_AVFilterInOut)(outputs), logCtx))
|
||||
}
|
||||
|
||||
// AvFilterGraphParsePtr adds a graph described by a string to a graph.
|
||||
func AvFilterGraphParsePtr(graph *AvFilterGraph, filters string, inputs, outputs *AvFilterInOut,
|
||||
logCtx unsafe.Pointer) int32 {
|
||||
filtersPtr, filtersFunc := StringCasting(filters)
|
||||
defer filtersFunc()
|
||||
return (int32)(C.avfilter_graph_parse_ptr((*C.struct_AVFilterGraph)(graph),
|
||||
(*C.char)(filtersPtr),
|
||||
(**C.struct_AVFilterInOut)(unsafe.Pointer(inputs)),
|
||||
(**C.struct_AVFilterInOut)(unsafe.Pointer(outputs)), logCtx))
|
||||
}
|
||||
|
||||
// AvFilterGraphParse2 adds a graph described by a string to a graph.
|
||||
func AvFilterGraphParse2(graph *AvFilterGraph, filters string,
|
||||
inputs, outputs *AvFilterInOut) int32 {
|
||||
filtersPtr, filtersFunc := StringCasting(filters)
|
||||
defer filtersFunc()
|
||||
return (int32)(C.avfilter_graph_parse2((*C.struct_AVFilterGraph)(graph),
|
||||
(*C.char)(filtersPtr),
|
||||
(**C.struct_AVFilterInOut)(unsafe.Pointer(inputs)),
|
||||
(**C.struct_AVFilterInOut)(unsafe.Pointer(outputs))))
|
||||
}
|
||||
|
||||
// AvFilterGraphSendCommand sends a command to one or more filter instances.
|
||||
func AvFilterGraphSendCommand(graph *AvFilterGraph, target, cmd, arg string,
|
||||
resLen, flags int32) (res string, ret int32) {
|
||||
targetPtr, targetFunc := StringCasting(target)
|
||||
defer targetFunc()
|
||||
cmdPtr, cmdFunc := StringCasting(cmd)
|
||||
defer cmdFunc()
|
||||
argPtr, argFunc := StringCasting(arg)
|
||||
defer argFunc()
|
||||
resBuf := make([]C.char, resLen)
|
||||
ret = (int32)(C.avfilter_graph_send_command((*C.struct_AVFilterGraph)(graph),
|
||||
(*C.char)(targetPtr), (*C.char)(cmdPtr), (*C.char)(argPtr),
|
||||
(*C.char)(&resBuf[0]), (C.int)(resLen), (C.int)(flags)))
|
||||
return C.GoString(&resBuf[0]), ret
|
||||
}
|
||||
|
||||
// AvFilterGraphQueueCommand queues a command for one or more filter instances.
|
||||
func AvFilterGraphQueueCommand(graph *AvFilterGraph, target, cmd, arg string,
|
||||
flags int32, ts float64) int32 {
|
||||
targetPtr, targetFunc := StringCasting(target)
|
||||
defer targetFunc()
|
||||
cmdPtr, cmdFunc := StringCasting(cmd)
|
||||
defer cmdFunc()
|
||||
argPtr, argFunc := StringCasting(arg)
|
||||
defer argFunc()
|
||||
return (int32)(C.avfilter_graph_queue_command((*C.struct_AVFilterGraph)(graph),
|
||||
(*C.char)(targetPtr), (*C.char)(cmdPtr), (*C.char)(argPtr), (C.int)(flags), (C.double)(ts)))
|
||||
}
|
||||
|
||||
// AvFilterGraphDump dumps a graph into a human-readable string representation.
|
||||
func AvFilterGraphDump(graph *AvFilterGraph, options string) string {
|
||||
optionsPtr, optionsFunc := StringCasting(options)
|
||||
defer optionsFunc()
|
||||
return C.GoString(C.avfilter_graph_dump((*C.struct_AVFilterGraph)(graph),
|
||||
(*C.char)(optionsPtr)))
|
||||
}
|
||||
|
||||
// AvFilterGraphRequestOldest requests a frame on the oldest sink link.
|
||||
func AvFilterGraphRequestOldest(graph *AvFilterGraph) int32 {
|
||||
return (int32)(C.avfilter_graph_request_oldest((*C.struct_AVFilterGraph)(graph)))
|
||||
}
|
104
avfilter_buffersink.go
Normal file
104
avfilter_buffersink.go
Normal file
@@ -0,0 +1,104 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavfilter/buffersink.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
// AvBuffersinkGetFrameFlags gets a frame with filtered data from sink and put it in frame.
|
||||
func AvBuffersinkGetFrameFlags(ctx *AvFilterContext, frame *AvFrame, flags int32) int32 {
|
||||
return (int32)(C.av_buffersink_get_frame_flags((*C.struct_AVFilterContext)(ctx),
|
||||
(*C.struct_AVFrame)(frame), (C.int)(flags)))
|
||||
}
|
||||
|
||||
const (
|
||||
AV_BUFFERSINK_FLAG_PEEK = C.AV_BUFFERSINK_FLAG_PEEK
|
||||
AV_BUFFERSINK_FLAG_NO_REQUEST = C.AV_BUFFERSINK_FLAG_NO_REQUEST
|
||||
)
|
||||
|
||||
type AvBufferSinkParams C.struct_AVBufferSinkParams
|
||||
|
||||
// Deprecated: No use
|
||||
func AvBuffersinkParamsAlloc() *AvBufferSinkParams {
|
||||
return (*AvBufferSinkParams)(C.av_buffersink_params_alloc())
|
||||
}
|
||||
|
||||
type AvABufferSinkParams C.struct_AVABufferSinkParams
|
||||
|
||||
// Deprecated: No use
|
||||
func AvAbuffersinkParamsAlloc() *AvABufferSinkParams {
|
||||
return (*AvABufferSinkParams)(C.av_abuffersink_params_alloc())
|
||||
}
|
||||
|
||||
// AvBuffersinkSetFrameSize sets the frame size for an audio buffer sink.
|
||||
func AvBuffersinkSetFrameSize(ctx *AvFilterContext, frameSize uint32) {
|
||||
C.av_buffersink_set_frame_size((*C.struct_AVFilterContext)(ctx), (C.uint)(frameSize))
|
||||
}
|
||||
|
||||
// AvBuffersinkGetType
|
||||
func AvBuffersinkGetType(ctx *AvFilterContext) AvMediaType {
|
||||
return (AvMediaType)(C.av_buffersink_get_type((*C.struct_AVFilterContext)(ctx)))
|
||||
}
|
||||
|
||||
// AvBuffersinkGetTimeBase
|
||||
func AvBuffersinkGetTimeBase(ctx *AvFilterContext) AvRational {
|
||||
return (AvRational)(C.av_buffersink_get_time_base((*C.struct_AVFilterContext)(ctx)))
|
||||
}
|
||||
|
||||
// AvBuffersinkGetFormat
|
||||
func AvBuffersinkGetFormat(ctx *AvFilterContext) int32 {
|
||||
return (int32)(C.av_buffersink_get_format((*C.struct_AVFilterContext)(ctx)))
|
||||
}
|
||||
|
||||
// AvBuffersinkGetFrameRate
|
||||
func AvBuffersinkGetFrameRate(ctx *AvFilterContext) AvRational {
|
||||
return (AvRational)(C.av_buffersink_get_frame_rate((*C.struct_AVFilterContext)(ctx)))
|
||||
}
|
||||
|
||||
// AvBuffersinkGetW
|
||||
func AvBuffersinkGetW(ctx *AvFilterContext) int32 {
|
||||
return (int32)(C.av_buffersink_get_w((*C.struct_AVFilterContext)(ctx)))
|
||||
}
|
||||
|
||||
// AvBuffersinkGetH
|
||||
func AvBuffersinkGetH(ctx *AvFilterContext) int32 {
|
||||
return (int32)(C.av_buffersink_get_h((*C.struct_AVFilterContext)(ctx)))
|
||||
}
|
||||
|
||||
// AvBuffersinkGetSampleAspectRatio
|
||||
func AvBuffersinkGetSampleAspectRatio(ctx *AvFilterContext) AvRational {
|
||||
return (AvRational)(C.av_buffersink_get_sample_aspect_ratio((*C.struct_AVFilterContext)(ctx)))
|
||||
}
|
||||
|
||||
// AvBuffersinkGetChannels
|
||||
func AvBuffersinkGetChannels(ctx *AvFilterContext) int32 {
|
||||
return (int32)(C.av_buffersink_get_channels((*C.struct_AVFilterContext)(ctx)))
|
||||
}
|
||||
|
||||
// AvBuffersinkGetChannelLayout
|
||||
func AvBuffersinkGetChannelLayout(ctx *AvFilterContext) uint64 {
|
||||
return (uint64)(C.av_buffersink_get_channel_layout((*C.struct_AVFilterContext)(ctx)))
|
||||
}
|
||||
|
||||
// AvBuffersinkGetSampleRate
|
||||
func AvBuffersinkGetSampleRate(ctx *AvFilterContext) int32 {
|
||||
return (int32)(C.av_buffersink_get_sample_rate((*C.struct_AVFilterContext)(ctx)))
|
||||
}
|
||||
|
||||
// AvBuffersinkGetHwFramesCtx
|
||||
func AvBuffersinkGetHwFramesCtx(ctx *AvFilterContext) *AvBufferRef {
|
||||
return (*AvBufferRef)(C.av_buffersink_get_hw_frames_ctx((*C.struct_AVFilterContext)(ctx)))
|
||||
}
|
||||
|
||||
// AvBuffersinkGetFrame gets a frame with filtered data from sink and put it in frame.
|
||||
func AvBuffersinkGetFrame(ctx *AvFilterContext, frame *AvFrame) int32 {
|
||||
return (int32)(C.av_buffersink_get_frame((*C.struct_AVFilterContext)(ctx),
|
||||
(*C.struct_AVFrame)(frame)))
|
||||
}
|
||||
|
||||
// AvBuffersinkGetSamples same as AvBuffersinkGetFrame(), but with the ability to specify the number
|
||||
// of samples read. This function is less efficient than AvBuffersinkGetFrame(), because it copies the data around.
|
||||
func AvBuffersinkGetSamples(ctx *AvFilterContext, frame *AvFrame, nbSamples int32) int32 {
|
||||
return (int32)(C.av_buffersink_get_samples((*C.struct_AVFilterContext)(ctx),
|
||||
(*C.struct_AVFrame)(frame), (C.int)(nbSamples)))
|
||||
}
|
55
avfilter_buffersrc.go
Normal file
55
avfilter_buffersrc.go
Normal file
@@ -0,0 +1,55 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavfilter/buffersrc.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT = int32(C.AV_BUFFERSRC_FLAG_NO_CHECK_FORMAT)
|
||||
AV_BUFFERSRC_FLAG_PUSH = int32(C.AV_BUFFERSRC_FLAG_PUSH)
|
||||
AV_BUFFERSRC_FLAG_KEEP_REF = int32(C.AV_BUFFERSRC_FLAG_KEEP_REF)
|
||||
)
|
||||
|
||||
// AvBuffersrcGetNbFailedRequests gets the number of failed requests.
|
||||
func AvBuffersrcGetNbFailedRequests(bufferSrc *AvFilterContext) uint32 {
|
||||
return (uint32)(C.av_buffersrc_get_nb_failed_requests((*C.struct_AVFilterContext)(bufferSrc)))
|
||||
}
|
||||
|
||||
type AvBufferSrcParameters C.struct_AVBufferSrcParameters
|
||||
|
||||
// AvBuffersrcParametersAlloc allocates a new AVBufferSrcParameters instance. It should be freed by the
|
||||
// caller with AvFree().
|
||||
func AvBuffersrcParametersAlloc() *AvBufferSrcParameters {
|
||||
return (*AvBufferSrcParameters)(C.av_buffersrc_parameters_alloc())
|
||||
}
|
||||
|
||||
// AvBuffersrcParametersSet initializes the buffersrc or abuffersrc filter with the provided parameters.
|
||||
func AvBuffersrcParametersSet(ctx *AvFilterContext, param *AvBufferSrcParameters) int32 {
|
||||
return (int32)(C.av_buffersrc_parameters_set((*C.struct_AVFilterContext)(ctx),
|
||||
(*C.struct_AVBufferSrcParameters)(param)))
|
||||
}
|
||||
|
||||
// AvBuffersrcWriteFrame adds a frame to the buffer source.
|
||||
func AvBuffersrcWriteFrame(ctx *AvFilterContext, frame *AvFrame) int32 {
|
||||
return (int32)(C.av_buffersrc_write_frame((*C.struct_AVFilterContext)(ctx),
|
||||
(*C.struct_AVFrame)(frame)))
|
||||
}
|
||||
|
||||
// AvBuffersrcAddFrame adds a frame to the buffer source.
|
||||
func AvBuffersrcAddFrame(ctx *AvFilterContext, frame *AvFrame) int32 {
|
||||
return (int32)(C.av_buffersrc_add_frame((*C.struct_AVFilterContext)(ctx),
|
||||
(*C.struct_AVFrame)(frame)))
|
||||
}
|
||||
|
||||
// AvBuffersrcAddFrameFlags adds a frame to the buffer source.
|
||||
func AvBuffersrcAddFrameFlags(ctx *AvFilterContext, frame *AvFrame, flags int32) int32 {
|
||||
return (int32)(C.av_buffersrc_add_frame_flags((*C.struct_AVFilterContext)(ctx),
|
||||
(*C.struct_AVFrame)(frame), (C.int)(flags)))
|
||||
}
|
||||
|
||||
// AvBuffersrcClose closes the buffer source after EOF.
|
||||
func AvBuffersrcClose(ctx *AvFilterContext, pts int64, flags uint32) int32 {
|
||||
return (int32)(C.av_buffersrc_close((*C.struct_AVFilterContext)(ctx),
|
||||
(C.int64_t)(pts), (C.uint)(flags)))
|
||||
}
|
12
avfilter_version.go
Normal file
12
avfilter_version.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavfilter/version.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
LIBAVFILTER_VERSION_MAJOR = C.LIBAVFILTER_VERSION_MAJOR
|
||||
LIBAVFILTER_VERSION_MINOR = C.LIBAVFILTER_VERSION_MINOR
|
||||
LIBAVFILTER_VERSION_MICRO = C.LIBAVFILTER_VERSION_MICRO
|
||||
)
|
2550
avformat.go
Normal file
2550
avformat.go
Normal file
File diff suppressed because it is too large
Load Diff
435
avformat_avio.go
Normal file
435
avformat_avio.go
Normal file
@@ -0,0 +1,435 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavformat/avio.h>
|
||||
|
||||
typedef int (*avio_context_read_packet_func)(void *opaque, uint8_t *buf, int buf_size);
|
||||
typedef int (*avio_context_write_packet_func)(void *opaque, uint8_t *buf, int buf_size);
|
||||
typedef int64_t (*avio_context_seek_func)(void *opaque, int64_t offset, int whence);
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
const (
|
||||
AVIO_SEEKABLE_NORMAL = C.AVIO_SEEKABLE_NORMAL
|
||||
AVIO_SEEKABLE_TIME = C.AVIO_SEEKABLE_TIME
|
||||
)
|
||||
|
||||
// AvIOInterruptCB
|
||||
type AvIOInterruptCB C.struct_AVIOInterruptCB
|
||||
|
||||
// AvIODirEntry
|
||||
type AvIODirEntry C.struct_AVIODirEntry
|
||||
|
||||
// AvIODirEntryType
|
||||
type AvIODirEntryType int32
|
||||
|
||||
const (
|
||||
AVIO_ENTRY_UNKNOWN = AvIODirEntryType(C.AVIO_ENTRY_UNKNOWN)
|
||||
AVIO_ENTRY_BLOCK_DEVICE = AvIODirEntryType(C.AVIO_ENTRY_BLOCK_DEVICE)
|
||||
AVIO_ENTRY_CHARACTER_DEVICE = AvIODirEntryType(C.AVIO_ENTRY_CHARACTER_DEVICE)
|
||||
AVIO_ENTRY_DIRECTORY = AvIODirEntryType(C.AVIO_ENTRY_DIRECTORY)
|
||||
AVIO_ENTRY_NAMED_PIPE = AvIODirEntryType(C.AVIO_ENTRY_NAMED_PIPE)
|
||||
AVIO_ENTRY_SYMBOLIC_LINK = AvIODirEntryType(C.AVIO_ENTRY_SYMBOLIC_LINK)
|
||||
AVIO_ENTRY_SOCKET = AvIODirEntryType(C.AVIO_ENTRY_SOCKET)
|
||||
AVIO_ENTRY_FILE = AvIODirEntryType(C.AVIO_ENTRY_FILE)
|
||||
AVIO_ENTRY_SERVER = AvIODirEntryType(C.AVIO_ENTRY_SERVER)
|
||||
AVIO_ENTRY_SHARE = AvIODirEntryType(C.AVIO_ENTRY_SHARE)
|
||||
AVIO_ENTRY_WORKGROUP = AvIODirEntryType(C.AVIO_ENTRY_WORKGROUP)
|
||||
)
|
||||
|
||||
// AvIODirContext
|
||||
type AvIODirContext C.struct_AVIODirContext
|
||||
|
||||
// AvIODataMarkerType
|
||||
type AvIODataMarkerType int32
|
||||
|
||||
const (
|
||||
AVIO_DATA_MARKER_HEADER = AvIODataMarkerType(C.AVIO_DATA_MARKER_HEADER)
|
||||
AVIO_DATA_MARKER_SYNC_POINT = AvIODataMarkerType(C.AVIO_DATA_MARKER_SYNC_POINT)
|
||||
AVIO_DATA_MARKER_BOUNDARY_POINT = AvIODataMarkerType(C.AVIO_DATA_MARKER_BOUNDARY_POINT)
|
||||
AVIO_DATA_MARKER_UNKNOWN = AvIODataMarkerType(C.AVIO_DATA_MARKER_UNKNOWN)
|
||||
AVIO_DATA_MARKER_TRAILER = AvIODataMarkerType(C.AVIO_DATA_MARKER_TRAILER)
|
||||
AVIO_DATA_MARKER_FLUSH_POINT = AvIODataMarkerType(C.AVIO_DATA_MARKER_FLUSH_POINT)
|
||||
)
|
||||
|
||||
// AvIOContext
|
||||
type AvIOContext C.struct_AVIOContext
|
||||
|
||||
// AvIOFindProtocolName returns the name of the protocol that will handle the passed URL.
|
||||
func AvIOFindProtocolName(url string) string {
|
||||
urlPtr, urlFunc := StringCasting(url)
|
||||
defer urlFunc()
|
||||
return C.GoString(C.avio_find_protocol_name((*C.char)(urlPtr)))
|
||||
}
|
||||
|
||||
// AvIOCheck returns AVIO_FLAG_* access flags corresponding to the access permissions
|
||||
// of the resource in url, or a negative value corresponding to an
|
||||
// AVERROR code in case of failure. The returned access flags are
|
||||
// masked by the value in flags.
|
||||
// avio_check
|
||||
func AvIOCheck(url string, flags int32) int32 {
|
||||
urlPtr, urlFunc := StringCasting(url)
|
||||
defer urlFunc()
|
||||
return (int32)(C.avio_check((*C.char)(urlPtr), (C.int)(flags)))
|
||||
}
|
||||
|
||||
// AvPrivIoMove moves or renames a resource.
|
||||
func AvPrivIoMove(urlSrc, urlDst string) int32 {
|
||||
urlSrcPtr, urlSrcFunc := StringCasting(urlSrc)
|
||||
defer urlSrcFunc()
|
||||
urlDstPtr, urlDstFunc := StringCasting(urlDst)
|
||||
defer urlDstFunc()
|
||||
return (int32)(C.avpriv_io_move((*C.char)(urlSrcPtr), (*C.char)(urlDstPtr)))
|
||||
}
|
||||
|
||||
// AvPrivIoDelete deletes a resource.
|
||||
func AvPrivIoDelete(url string) int32 {
|
||||
urlPtr, urlFunc := StringCasting(url)
|
||||
defer urlFunc()
|
||||
return (int32)(C.avpriv_io_delete((*C.char)(urlPtr)))
|
||||
}
|
||||
|
||||
// AvIOOpenDir opens directory for reading.
|
||||
func AvIOOpenDir(s **AvIODirContext, url string, options **AvDictionary) int32 {
|
||||
urlPtr, urlFunc := StringCasting(url)
|
||||
defer urlFunc()
|
||||
return (int32)(C.avio_open_dir((**C.struct_AVIODirContext)(unsafe.Pointer(s)),
|
||||
(*C.char)(urlPtr), (**C.struct_AVDictionary)(unsafe.Pointer(options))))
|
||||
}
|
||||
|
||||
// AvIOReadDir gets next directory entry.
|
||||
func AvIOReadDir(s *AvIODirContext, next **AvIODirEntry) int32 {
|
||||
return (int32)(C.avio_read_dir((*C.struct_AVIODirContext)(s),
|
||||
(**C.struct_AVIODirEntry)(unsafe.Pointer(next))))
|
||||
}
|
||||
|
||||
// AvIOCloseDir closes directory.
|
||||
func AvIOCloseDir(s **AvIODirContext) int32 {
|
||||
return (int32)(C.avio_close_dir((**C.struct_AVIODirContext)(unsafe.Pointer(s))))
|
||||
}
|
||||
|
||||
// AvIOFreeDirectoryEntry frees entry allocated by AvIOReadDir().
|
||||
func AvIOFreeDirectoryEntry(entry **AvIODirEntry) {
|
||||
C.avio_free_directory_entry((**C.struct_AVIODirEntry)(unsafe.Pointer(entry)))
|
||||
}
|
||||
|
||||
// typedef int (*avio_context_read_packet_func)(void *opaque, uint8_t *buf, int buf_size)
|
||||
type AvIOContextReadPacketFunc C.avio_context_read_packet_func
|
||||
|
||||
// typedef int (*avio_context_write_packet_func)(void *opaque, uint8_t *buf, int buf_size)
|
||||
type AvIOContextWritePacketFunc C.avio_context_write_packet_func
|
||||
|
||||
// typedef int64_t (*avio_context_seek_func)(void *opaque, int64_t offset, int whence)
|
||||
type AvIOContextSeekFunc C.avio_context_seek_func
|
||||
|
||||
// avio_alloc_context
|
||||
func avio_alloc_context(buffer *uint8, bufferSize, writeFlag int32,
|
||||
opaque unsafe.Pointer,
|
||||
readPacket AvIOContextReadPacketFunc,
|
||||
writePacket AvIOContextWritePacketFunc,
|
||||
seek AvIOContextSeekFunc) *AvIOContext {
|
||||
return (*AvIOContext)(C.avio_alloc_context((*C.uint8_t)(buffer), (C.int)(bufferSize),
|
||||
(C.int)(writeFlag), opaque,
|
||||
(C.avio_context_read_packet_func)(readPacket),
|
||||
(C.avio_context_write_packet_func)(writePacket),
|
||||
(C.avio_context_seek_func)(seek)))
|
||||
}
|
||||
|
||||
// AvIOContextFree frees the supplied IO context and everything associated with it.
|
||||
func AvIOContextFree(s **AvIOContext) {
|
||||
C.avio_context_free((**C.struct_AVIOContext)(unsafe.Pointer(s)))
|
||||
}
|
||||
|
||||
// AvIOW8
|
||||
func AvIOW8(s *AvIOContext, b int32) {
|
||||
C.avio_w8((*C.struct_AVIOContext)(s), (C.int)(b))
|
||||
}
|
||||
|
||||
// AvIOWrite
|
||||
func AvIOWrite(s *AvIOContext, buf *uint8, size int32) {
|
||||
C.avio_write((*C.struct_AVIOContext)(s), (*C.uchar)(buf), (C.int)(size))
|
||||
}
|
||||
|
||||
// AvIOWl64
|
||||
func AvIOWl64(s *AvIOContext, val uint64) {
|
||||
C.avio_wl64((*C.struct_AVIOContext)(s), (C.uint64_t)(val))
|
||||
}
|
||||
|
||||
// AvIOWb64
|
||||
func AvIOWb64(s *AvIOContext, val uint64) {
|
||||
C.avio_wb64((*C.struct_AVIOContext)(s), (C.uint64_t)(val))
|
||||
}
|
||||
|
||||
// AvIOWl32
|
||||
func AvIOWl32(s *AvIOContext, val uint32) {
|
||||
C.avio_wl32((*C.struct_AVIOContext)(s), (C.uint32_t)(val))
|
||||
}
|
||||
|
||||
// AvIOWb32
|
||||
func AvIOWb32(s *AvIOContext, val uint32) {
|
||||
C.avio_wb32((*C.struct_AVIOContext)(s), (C.uint32_t)(val))
|
||||
}
|
||||
|
||||
// AvIOWl24
|
||||
func AvIOWl24(s *AvIOContext, val uint32) {
|
||||
C.avio_wl24((*C.struct_AVIOContext)(s), (C.uint32_t)(val))
|
||||
}
|
||||
|
||||
// AvIOWb24
|
||||
func AvIOWb24(s *AvIOContext, val uint32) {
|
||||
C.avio_wb24((*C.struct_AVIOContext)(s), (C.uint32_t)(val))
|
||||
}
|
||||
|
||||
// AvIOWl16
|
||||
func AvIOWl16(s *AvIOContext, val uint32) {
|
||||
C.avio_wl16((*C.struct_AVIOContext)(s), (C.uint32_t)(val))
|
||||
}
|
||||
|
||||
// AvIOWb16
|
||||
func AvIOWb16(s *AvIOContext, val uint32) {
|
||||
C.avio_wb16((*C.struct_AVIOContext)(s), (C.uint32_t)(val))
|
||||
}
|
||||
|
||||
// AvIOPutStr Write a string.
|
||||
func AvIOPutStr(s *AvIOContext, str string) int32 {
|
||||
strPtr, strFunc := StringCasting(str)
|
||||
defer strFunc()
|
||||
return (int32)(C.avio_put_str((*C.struct_AVIOContext)(s), (*C.char)(strPtr)))
|
||||
}
|
||||
|
||||
// AvIOPutStr16le converts an UTF-8 string to UTF-16LE and write it.
|
||||
func AvIOPutStr16le(s *AvIOContext, str string) int32 {
|
||||
strPtr, strFunc := StringCasting(str)
|
||||
defer strFunc()
|
||||
return (int32)(C.avio_put_str16le((*C.struct_AVIOContext)(s), (*C.char)(strPtr)))
|
||||
}
|
||||
|
||||
// AvIOPutStr16be converts an UTF-8 string to UTF-16BE and write it.
|
||||
func AvIOPutStr16be(s *AvIOContext, str string) int32 {
|
||||
strPtr, strFunc := StringCasting(str)
|
||||
defer strFunc()
|
||||
return (int32)(C.avio_put_str16be((*C.struct_AVIOContext)(s), (*C.char)(strPtr)))
|
||||
}
|
||||
|
||||
// AvIOWriteMarker
|
||||
func AvIOWriteMarker(s *AvIOContext, time int64, _type AvIODataMarkerType) {
|
||||
C.avio_write_marker((*C.struct_AVIOContext)(s), (C.int64_t)(time), (C.enum_AVIODataMarkerType)(_type))
|
||||
}
|
||||
|
||||
const (
|
||||
AVSEEK_SIZE = C.AVSEEK_SIZE
|
||||
AVSEEK_FORCE = C.AVSEEK_FORCE
|
||||
)
|
||||
|
||||
// AvIOSeek equivalents fseek().
|
||||
func AvIOSeek(s *AvIOContext, offset int64, whence int32) int64 {
|
||||
return (int64)(C.avio_seek((*C.struct_AVIOContext)(s), (C.int64_t)(offset), (C.int)(whence)))
|
||||
}
|
||||
|
||||
// AvIOSkip skips given number of bytes forward.
|
||||
func AvIOSkip(s *AvIOContext, offset int64) int64 {
|
||||
return (int64)(C.avio_skip((*C.struct_AVIOContext)(s), (C.int64_t)(offset)))
|
||||
}
|
||||
|
||||
// AvIOTell equivalents ftell().
|
||||
func AvIOTell(s *AvIOContext) int64 {
|
||||
return (int64)(C.avio_tell((*C.struct_AVIOContext)(s)))
|
||||
}
|
||||
|
||||
// AvIOSize gets the filesize.
|
||||
func AvIOSize(s *AvIOContext) int64 {
|
||||
return (int64)(C.avio_size((*C.struct_AVIOContext)(s)))
|
||||
}
|
||||
|
||||
// AvIOFeof similar to feof() but also returns nonzero on read errors.
|
||||
func AvIOFeof(s *AvIOContext) int32 {
|
||||
return (int32)(C.avio_feof((*C.struct_AVIOContext)(s)))
|
||||
}
|
||||
|
||||
// TODO. avio_printf
|
||||
|
||||
// TODO. avio_print_string_array
|
||||
|
||||
// TODO. avio_print
|
||||
|
||||
// AvIOFlush forces flushing of buffered data.
|
||||
func AvIOFlush(s *AvIOContext) {
|
||||
C.avio_flush((*C.struct_AVIOContext)(s))
|
||||
}
|
||||
|
||||
// AvIORead reads size bytes from AVIOContext into buf.
|
||||
func AvIORead(s *AvIOContext, buf *uint8, size int32) int32 {
|
||||
return (int32)(C.avio_read((*C.struct_AVIOContext)(s), (*C.uchar)(buf), (C.int)(size)))
|
||||
}
|
||||
|
||||
// AvIOReadPartial sead size bytes from AVIOContext into buf. Unlike avio_read(), this is allowed
|
||||
// to read fewer bytes than requested. The missing bytes can be read in the next
|
||||
// call. This always tries to read at least 1 byte.
|
||||
// Useful to reduce latency in certain cases.
|
||||
func AvIOReadPartial(s *AvIOContext, buf *uint8, size int32) int32 {
|
||||
return (int32)(C.avio_read_partial((*C.struct_AVIOContext)(s), (*C.uchar)(buf), (C.int)(size)))
|
||||
}
|
||||
|
||||
// AvIOR8
|
||||
func AvIOR8(s *AvIOContext) int32 {
|
||||
return (int32)(C.avio_r8((*C.struct_AVIOContext)(s)))
|
||||
}
|
||||
|
||||
// AvIORl16
|
||||
func AvIORl16(s *AvIOContext) uint32 {
|
||||
return (uint32)(C.avio_rl16((*C.struct_AVIOContext)(s)))
|
||||
}
|
||||
|
||||
// AvIORl24
|
||||
func AvIORl24(s *AvIOContext) uint32 {
|
||||
return (uint32)(C.avio_rl24((*C.struct_AVIOContext)(s)))
|
||||
}
|
||||
|
||||
// AvIORl32
|
||||
func AvIORl32(s *AvIOContext) uint32 {
|
||||
return (uint32)(C.avio_rl32((*C.struct_AVIOContext)(s)))
|
||||
}
|
||||
|
||||
// AvIORl64
|
||||
func AvIORl64(s *AvIOContext) uint64 {
|
||||
return (uint64)(C.avio_rl64((*C.struct_AVIOContext)(s)))
|
||||
}
|
||||
|
||||
// AvIORb16
|
||||
func AvIORb16(s *AvIOContext) uint32 {
|
||||
return (uint32)(C.avio_rb16((*C.struct_AVIOContext)(s)))
|
||||
}
|
||||
|
||||
// AvIORb24
|
||||
func AvIORb24(s *AvIOContext) uint32 {
|
||||
return (uint32)(C.avio_rb24((*C.struct_AVIOContext)(s)))
|
||||
}
|
||||
|
||||
// AvIORb32
|
||||
func AvIORb32(s *AvIOContext) uint32 {
|
||||
return (uint32)(C.avio_rb32((*C.struct_AVIOContext)(s)))
|
||||
}
|
||||
|
||||
// AvIORb64
|
||||
func AvIORb64(s *AvIOContext) uint64 {
|
||||
return (uint64)(C.avio_rb64((*C.struct_AVIOContext)(s)))
|
||||
}
|
||||
|
||||
// AvIOGetStr reads a string from pb into buf. The reading will terminate when either
|
||||
// a NULL character was encountered, maxlen bytes have been read, or nothing
|
||||
// more can be read from pb. The result is guaranteed to be NULL-terminated, it
|
||||
// will be truncated if buf is too small.
|
||||
// Note that the string is not interpreted or validated in any way, it
|
||||
// might get truncated in the middle of a sequence for multi-byte encodings.
|
||||
func AvIOGetStr(s *AvIOContext, maxLen int32, buf *int8, buflen int32) int32 {
|
||||
return (int32)(C.avio_get_str((*C.struct_AVIOContext)(s), (C.int)(maxLen), (*C.char)(buf), (C.int)(buflen)))
|
||||
}
|
||||
|
||||
// AvIOGetStr16le reads a UTF-16LE string from pb and convert it to UTF-8.
|
||||
func AvIOGetStr16le(s *AvIOContext, maxLen int32, buf *int8, buflen int32) int32 {
|
||||
return (int32)(C.avio_get_str16le((*C.struct_AVIOContext)(s), (C.int)(maxLen), (*C.char)(buf), (C.int)(buflen)))
|
||||
}
|
||||
|
||||
// AvIOGetStr16be reads a UTF-16BE string from pb and convert it to UTF-8.
|
||||
func AvIOGetStr16be(s *AvIOContext, maxLen int32, buf *int8, buflen int32) int32 {
|
||||
return (int32)(C.avio_get_str16be((*C.struct_AVIOContext)(s), (C.int)(maxLen), (*C.char)(buf), (C.int)(buflen)))
|
||||
}
|
||||
|
||||
const (
|
||||
AVIO_FLAG_READ = C.AVIO_FLAG_READ
|
||||
AVIO_FLAG_WRITE = C.AVIO_FLAG_WRITE
|
||||
AVIO_FLAG_READ_WRITE = C.AVIO_FLAG_READ_WRITE
|
||||
AVIO_FLAG_NONBLOCK = C.AVIO_FLAG_NONBLOCK
|
||||
AVIO_FLAG_DIRECT = C.AVIO_FLAG_DIRECT
|
||||
)
|
||||
|
||||
// AvIOOpen creates and initializes a AVIOContext for accessing the resource indicated by url.
|
||||
func AvIOOpen(s **AvIOContext, url string, flags int32) int32 {
|
||||
urlPtr, urlFunc := StringCasting(url)
|
||||
defer urlFunc()
|
||||
return (int32)(C.avio_open((**C.struct_AVIOContext)(unsafe.Pointer(s)),
|
||||
(*C.char)(urlPtr), (C.int)(flags)))
|
||||
}
|
||||
|
||||
// avio_open2 creates and initializes a AVIOContext for accessing the resource indicated by url.
|
||||
func avio_open2(s **AvIOContext, url string, flags int32,
|
||||
intCb *AvIOInterruptCB, options **AvDictionary) int32 {
|
||||
urlPtr, urlFunc := StringCasting(url)
|
||||
defer urlFunc()
|
||||
return (int32)(C.avio_open2((**C.struct_AVIOContext)(unsafe.Pointer(s)),
|
||||
(*C.char)(urlPtr), (C.int)(flags),
|
||||
(*C.struct_AVIOInterruptCB)(intCb), (**C.struct_AVDictionary)(unsafe.Pointer(options))))
|
||||
}
|
||||
|
||||
// AvIOClose
|
||||
func AvIOClose(s *AvIOContext) int32 {
|
||||
return (int32)(C.avio_close((*C.struct_AVIOContext)(s)))
|
||||
}
|
||||
|
||||
// AvIOClosep closes the resource accessed by the AVIOContext *s, free it
|
||||
// and set the pointer pointing to it to NULL.
|
||||
func AvIOClosep(s **AvIOContext) int32 {
|
||||
return (int32)(C.avio_closep((**C.struct_AVIOContext)(unsafe.Pointer(s))))
|
||||
}
|
||||
|
||||
// AvIOOpenDynBuf opens a write only memory stream.
|
||||
func AvIOOpenDynBuf(s **AvIOContext) int32 {
|
||||
return (int32)(C.avio_open_dyn_buf((**C.struct_AVIOContext)(unsafe.Pointer(s))))
|
||||
}
|
||||
|
||||
// AvIOGetDynBuf returns the written size and a pointer to the buffer.
|
||||
func AvIOGetDynBuf(s *AvIOContext, pbuffer **uint8) int32 {
|
||||
return (int32)(C.avio_get_dyn_buf((*C.struct_AVIOContext)(s),
|
||||
(**C.uint8_t)(unsafe.Pointer(pbuffer))))
|
||||
}
|
||||
|
||||
// AvIOCloseDynBuf returns the written size and a pointer to the buffer. The buffer
|
||||
// must be freed with AvFree().
|
||||
func AvIOCloseDynBuf(s *AvIOContext, pbuffer **uint8) int32 {
|
||||
return (int32)(C.avio_close_dyn_buf((*C.struct_AVIOContext)(s),
|
||||
(**C.uint8_t)(unsafe.Pointer(pbuffer))))
|
||||
}
|
||||
|
||||
// AvIOEnumProtocols iterates through names of available protocols.
|
||||
func AvIOEnumProtocols(opaque *unsafe.Pointer, output int32) string {
|
||||
return C.GoString(C.avio_enum_protocols(opaque, (C.int)(output)))
|
||||
}
|
||||
|
||||
// AvIOProtocolGetClass gets AVClass by names of available protocols.
|
||||
func AvIOProtocolGetClass(name string) *AvClass {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (*AvClass)(C.avio_protocol_get_class((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvIOPause pauses and resumes playing - only meaningful if using a network streaming
|
||||
// protocol (e.g. MMS).
|
||||
func AvIOPause(s *AvIOContext, pause int32) int32 {
|
||||
return (int32)(C.avio_pause((*C.struct_AVIOContext)(s), (C.int)(pause)))
|
||||
}
|
||||
|
||||
// AvIOSeekTime seeks to a given timestamp relative to some component stream.
|
||||
// Only meaningful if using a network streaming protocol (e.g. MMS.).
|
||||
func AvIOSeekTime(s *AvIOContext, streamIndex int32, timestamp int64, flags int32) int64 {
|
||||
return (int64)(C.avio_seek_time((*C.struct_AVIOContext)(s),
|
||||
(C.int)(streamIndex), (C.int64_t)(timestamp), (C.int)(flags)))
|
||||
}
|
||||
|
||||
type AvBPrint C.struct_AVBPrint
|
||||
|
||||
// avio_read_to_bprint
|
||||
func avio_read_to_bprint(s *AvIOContext, pb *AvBPrint, maxSize uint) int32 {
|
||||
return (int32)(C.avio_read_to_bprint((*C.struct_AVIOContext)(s),
|
||||
(*C.struct_AVBPrint)(pb), (C.size_t)(maxSize)))
|
||||
}
|
||||
|
||||
// AvIOAccept accepts and allocates a client context on a server context.
|
||||
func AvIOAccept(s *AvIOContext, c **AvIOContext) int32 {
|
||||
return (int32)(C.avio_accept((*C.struct_AVIOContext)(s), (**C.struct_AVIOContext)(unsafe.Pointer(c))))
|
||||
}
|
||||
|
||||
// AvIOHandshake performs one step of the protocol handshake to accept a new client.
|
||||
func AvIOHandshake(s *AvIOContext) int32 {
|
||||
return (int32)(C.avio_handshake((*C.struct_AVIOContext)(s)))
|
||||
}
|
12
avformat_version.go
Normal file
12
avformat_version.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavformat/version.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
LIBAVFORMAT_VERSION_MAJOR = C.LIBAVFORMAT_VERSION_MAJOR
|
||||
LIBAVFORMAT_VERSION_MINOR = C.LIBAVFORMAT_VERSION_MINOR
|
||||
LIBAVFORMAT_VERSION_MICRO = C.LIBAVFORMAT_VERSION_MICRO
|
||||
)
|
164
avresample.go
Normal file
164
avresample.go
Normal file
@@ -0,0 +1,164 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavresample/avresample.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
const (
|
||||
AVRESAMPLE_MAX_CHANNELS = C.AVRESAMPLE_MAX_CHANNELS
|
||||
)
|
||||
|
||||
type AvAudioResampleContext C.struct_AVAudioResampleContext
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
type AvMixCoeffType int32
|
||||
|
||||
const (
|
||||
AV_MIX_COEFF_TYPE_Q8 = AvMixCoeffType(C.AV_MIX_COEFF_TYPE_Q8)
|
||||
AV_MIX_COEFF_TYPE_Q15 = AvMixCoeffType(C.AV_MIX_COEFF_TYPE_Q15)
|
||||
AV_MIX_COEFF_TYPE_FLT = AvMixCoeffType(C.AV_MIX_COEFF_TYPE_FLT)
|
||||
AV_MIX_COEFF_TYPE_NB = AvMixCoeffType(C.AV_MIX_COEFF_TYPE_NB)
|
||||
)
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
type AvResampleFilterType int32
|
||||
|
||||
const (
|
||||
AV_RESAMPLE_FILTER_TYPE_CUBIC = AvResampleFilterType(C.AV_RESAMPLE_FILTER_TYPE_CUBIC)
|
||||
AV_RESAMPLE_FILTER_TYPE_BLACKMAN_NUTTALL = AvResampleFilterType(C.AV_RESAMPLE_FILTER_TYPE_BLACKMAN_NUTTALL)
|
||||
AV_RESAMPLE_FILTER_TYPE_KAISER = AvResampleFilterType(C.AV_RESAMPLE_FILTER_TYPE_KAISER)
|
||||
)
|
||||
|
||||
type AvResampleDitherMethod int32
|
||||
|
||||
const (
|
||||
AV_RESAMPLE_DITHER_NONE = AvResampleDitherMethod(C.AV_RESAMPLE_DITHER_NONE)
|
||||
AV_RESAMPLE_DITHER_RECTANGULAR = AvResampleDitherMethod(C.AV_RESAMPLE_DITHER_RECTANGULAR)
|
||||
AV_RESAMPLE_DITHER_TRIANGULAR = AvResampleDitherMethod(C.AV_RESAMPLE_DITHER_TRIANGULAR)
|
||||
AV_RESAMPLE_DITHER_TRIANGULAR_HP = AvResampleDitherMethod(C.AV_RESAMPLE_DITHER_TRIANGULAR_HP)
|
||||
AV_RESAMPLE_DITHER_TRIANGULAR_NS = AvResampleDitherMethod(C.AV_RESAMPLE_DITHER_TRIANGULAR_NS)
|
||||
AV_RESAMPLE_DITHER_NB = AvResampleDitherMethod(C.AV_RESAMPLE_DITHER_NB)
|
||||
)
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleVersion() uint32 {
|
||||
return (uint32)(C.avresample_version())
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleConfiguration() string {
|
||||
return C.GoString(C.avresample_configuration())
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleLicense() string {
|
||||
return C.GoString(C.avresample_license())
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleGetClass() *AvClass {
|
||||
return (*AvClass)(C.avresample_get_class())
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleAllocContext() *AvAudioResampleContext {
|
||||
return (*AvAudioResampleContext)(C.avresample_alloc_context())
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleOpen(avr *AvAudioResampleContext) int32 {
|
||||
return (int32)(C.avresample_open((*C.struct_AVAudioResampleContext)(avr)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleIsOpen(avr *AvAudioResampleContext) int32 {
|
||||
return (int32)(C.avresample_is_open((*C.struct_AVAudioResampleContext)(avr)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleClose(avr *AvAudioResampleContext) {
|
||||
C.avresample_close((*C.struct_AVAudioResampleContext)(avr))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleFree(avr **AvAudioResampleContext) {
|
||||
C.avresample_free((**C.struct_AVAudioResampleContext)(unsafe.Pointer(avr)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleBuildMatrix(inLayout, outLayout uint64,
|
||||
centerMixLevel, surroundMixLevel, lfeMixLevel float64,
|
||||
normalize int32, matrix *float64, stride int32, matrixEncoding AvMatrixEncoding) int32 {
|
||||
return (int32)(C.avresample_build_matrix((C.uint64_t)(inLayout), (C.uint64_t)(outLayout),
|
||||
(C.double)(centerMixLevel), (C.double)(surroundMixLevel), (C.double)(lfeMixLevel),
|
||||
(C.int)(normalize), (*C.double)(matrix), (C.int)(stride),
|
||||
(C.enum_AVMatrixEncoding)(matrixEncoding)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleGetMatrix(avr *AvAudioResampleContext, matrix *float64, stride int32) int32 {
|
||||
return (int32)(C.avresample_get_matrix((*C.struct_AVAudioResampleContext)(avr),
|
||||
(*C.double)(matrix), (C.int)(stride)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleSetMatrix(avr *AvAudioResampleContext, matrix *float64, stride int32) int32 {
|
||||
return (int32)(C.avresample_set_matrix((*C.struct_AVAudioResampleContext)(avr),
|
||||
(*C.double)(matrix), (C.int)(stride)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleSetChannelMapping(avr *AvAudioResampleContext, channelMap *int32) int32 {
|
||||
return (int32)(C.avresample_set_channel_mapping((*C.struct_AVAudioResampleContext)(avr),
|
||||
(*C.int)(channelMap)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleSetCompensation(avr *AvAudioResampleContext, sampleDelta, compensationDistance int32) int32 {
|
||||
return (int32)(C.avresample_set_compensation((*C.struct_AVAudioResampleContext)(avr),
|
||||
(C.int)(sampleDelta), (C.int)(compensationDistance)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleGetOutSamples(avr *AvAudioResampleContext, inNbSamples int32) int32 {
|
||||
return (int32)(C.avresample_get_out_samples((*C.struct_AVAudioResampleContext)(avr),
|
||||
(C.int)(inNbSamples)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleConvert(avr *AvAudioResampleContext, output **uint8, outPlaneSize, outSamples int32,
|
||||
input **uint8, inPlaneSize, inSamples int32) int32 {
|
||||
return (int32)(C.avresample_convert((*C.struct_AVAudioResampleContext)(avr),
|
||||
(**C.uint8_t)(unsafe.Pointer(output)), (C.int)(outPlaneSize), (C.int)(outSamples),
|
||||
(**C.uint8_t)(unsafe.Pointer(input)), (C.int)(inPlaneSize), (C.int)(inSamples)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleGetDelay(avr *AvAudioResampleContext) int32 {
|
||||
return (int32)(C.avresample_get_delay((*C.struct_AVAudioResampleContext)(avr)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleAvailable(avr *AvAudioResampleContext) int32 {
|
||||
return (int32)(C.avresample_available((*C.struct_AVAudioResampleContext)(avr)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleRead(avr *AvAudioResampleContext, output **uint8, nbSamples int32) int32 {
|
||||
return (int32)(C.avresample_read((*C.struct_AVAudioResampleContext)(avr),
|
||||
(**C.uint8_t)(unsafe.Pointer(output)), (C.int)(nbSamples)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleConvertFrame(avr *AvAudioResampleContext, output, input *AvFrame) int32 {
|
||||
return (int32)(C.avresample_convert_frame((*C.struct_AVAudioResampleContext)(avr),
|
||||
(*C.struct_AVFrame)(output), (*C.struct_AVFrame)(input)))
|
||||
}
|
||||
|
||||
// Deprecated: Use libswresample
|
||||
func AvResampleConfig(avr *AvAudioResampleContext, out, in *AvFrame) int32 {
|
||||
return (int32)(C.avresample_config((*C.struct_AVAudioResampleContext)(avr),
|
||||
(*C.struct_AVFrame)(out), (*C.struct_AVFrame)(in)))
|
||||
}
|
12
avresample_version.go
Normal file
12
avresample_version.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavresample/version.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
LIBAVRESAMPLE_VERSION_MAJOR = C.LIBAVRESAMPLE_VERSION_MAJOR
|
||||
LIBAVRESAMPLE_VERSION_MINOR = C.LIBAVRESAMPLE_VERSION_MINOR
|
||||
LIBAVRESAMPLE_VERSION_MICRO = C.LIBAVRESAMPLE_VERSION_MICRO
|
||||
)
|
119
avutil.go
Normal file
119
avutil.go
Normal file
@@ -0,0 +1,119 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/avutil.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// AvutilVersion returns the LIBAVUTIL_VERSION_INT constant.
|
||||
func AvutilVersion() uint32 {
|
||||
return (uint32)(C.avutil_version())
|
||||
}
|
||||
|
||||
// AvVersionInfo returns an informative version string.
|
||||
func AvVersionInfo() string {
|
||||
return C.GoString(C.av_version_info())
|
||||
}
|
||||
|
||||
// AvutilConfiguration returns the libavutil build-time configuration.
|
||||
func AvutilConfiguration() string {
|
||||
return C.GoString(C.avutil_configuration())
|
||||
}
|
||||
|
||||
// AvutilLicense returns the libavutil license.
|
||||
func AvutilLicense() string {
|
||||
return C.GoString(C.avutil_license())
|
||||
}
|
||||
|
||||
// Media Type
|
||||
type AvMediaType int32
|
||||
|
||||
const (
|
||||
AVMEDIA_TYPE_UNKNOWN = AvMediaType(C.AVMEDIA_TYPE_UNKNOWN)
|
||||
AVMEDIA_TYPE_VIDEO = AvMediaType(C.AVMEDIA_TYPE_VIDEO)
|
||||
AVMEDIA_TYPE_AUDIO = AvMediaType(C.AVMEDIA_TYPE_AUDIO)
|
||||
AVMEDIA_TYPE_DATA = AvMediaType(C.AVMEDIA_TYPE_DATA)
|
||||
AVMEDIA_TYPE_SUBTITLE = AvMediaType(C.AVMEDIA_TYPE_SUBTITLE)
|
||||
AVMEDIA_TYPE_ATTACHMENT = AvMediaType(C.AVMEDIA_TYPE_ATTACHMENT)
|
||||
AVMEDIA_TYPE_NB = AvMediaType(C.AVMEDIA_TYPE_NB)
|
||||
)
|
||||
|
||||
// AvGetMediaTypeString returns a string describing the MediaType,
|
||||
// Empty string if media_type is unknown.
|
||||
func AvGetMediaTypeString(mt AvMediaType) string {
|
||||
return C.GoString(C.av_get_media_type_string((C.enum_AVMediaType)(mt)))
|
||||
}
|
||||
|
||||
const (
|
||||
FF_LAMBDA_SHIFT = C.FF_LAMBDA_SHIFT
|
||||
FF_LAMBDA_SCALE = C.FF_LAMBDA_SCALE
|
||||
FF_QP2LAMBDA = C.FF_QP2LAMBDA
|
||||
FF_LAMBDA_MAX = C.FF_LAMBDA_MAX
|
||||
|
||||
FF_QUALITY_SCALE = C.FF_QUALITY_SCALE
|
||||
)
|
||||
|
||||
const (
|
||||
AV_NOPTS_VALUE = C.AV_NOPTS_VALUE
|
||||
AV_TIME_BASE = C.AV_TIME_BASE
|
||||
)
|
||||
|
||||
var (
|
||||
AV_TIME_BASE_Q = AvRational(C.AV_TIME_BASE_Q)
|
||||
)
|
||||
|
||||
// AvPictureType, pixel formats and basic image planes manipulation.
|
||||
type AvPictureType int32
|
||||
|
||||
const (
|
||||
AV_PICTURE_TYPE_NONE = AvPictureType(C.AV_PICTURE_TYPE_NONE)
|
||||
AV_PICTURE_TYPE_I = AvPictureType(C.AV_PICTURE_TYPE_I)
|
||||
AV_PICTURE_TYPE_P = AvPictureType(C.AV_PICTURE_TYPE_P)
|
||||
AV_PICTURE_TYPE_B = AvPictureType(C.AV_PICTURE_TYPE_B)
|
||||
AV_PICTURE_TYPE_S = AvPictureType(C.AV_PICTURE_TYPE_S)
|
||||
AV_PICTURE_TYPE_SI = AvPictureType(C.AV_PICTURE_TYPE_SI)
|
||||
AV_PICTURE_TYPE_SP = AvPictureType(C.AV_PICTURE_TYPE_SP)
|
||||
AV_PICTURE_TYPE_BI = AvPictureType(C.AV_PICTURE_TYPE_BI)
|
||||
)
|
||||
|
||||
// AvGetPictureTypeChar returns a single letter to describe the given picture type.
|
||||
func AvGetPictureTypeChar(pictType AvPictureType) string {
|
||||
c := C.av_get_picture_type_char((C.enum_AVPictureType)(pictType))
|
||||
return C.GoStringN(&c, 1)
|
||||
}
|
||||
|
||||
// AvXIfNull returns x default pointer in case p is NULL.
|
||||
func AvXIfNull(p, x unsafe.Pointer) unsafe.Pointer {
|
||||
return C.av_x_if_null(p, x)
|
||||
}
|
||||
|
||||
// AvIntListLengthForSize computes the length of an integer list.
|
||||
func AvIntListLengthForSize(elsize uint32, list unsafe.Pointer, term uint64) uint32 {
|
||||
return (uint32)(C.av_int_list_length_for_size((C.uint)(elsize), list, (C.uint64_t)(term)))
|
||||
}
|
||||
|
||||
// TODO. av_int_list_length
|
||||
|
||||
// TODO. av_fopen_utf8
|
||||
|
||||
// AvGetTimeBaseQ returns the fractional representation of the internal time base.
|
||||
func AvGetTimeBaseQ() AvRational {
|
||||
return (AvRational)(C.av_get_time_base_q())
|
||||
}
|
||||
|
||||
const (
|
||||
AV_FOURCC_MAX_STRING_SIZE = C.AV_FOURCC_MAX_STRING_SIZE
|
||||
)
|
||||
|
||||
// AvFourcc2str
|
||||
func AvFourcc2str(fourcc uint32) string {
|
||||
buf := make([]C.char, AV_FOURCC_MAX_STRING_SIZE+1)
|
||||
return C.GoString(C.av_fourcc_make_string((*C.char)(&buf[0]), (C.uint32_t)(fourcc)))
|
||||
}
|
||||
|
||||
// AvFourccMakeString fill the provided buffer with a string containing a FourCC
|
||||
// (four-character code) representation.
|
||||
func AvFourccMakeString(buf *int8, fourcc uint32) *int8 {
|
||||
return (*int8)(C.av_fourcc_make_string((*C.char)(buf), (C.uint32_t)(fourcc)))
|
||||
}
|
66
avutil_audio_fifo.go
Normal file
66
avutil_audio_fifo.go
Normal file
@@ -0,0 +1,66 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/audio_fifo.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
type AvAudioFifo C.struct_AVAudioFifo
|
||||
|
||||
// AvAudioFifoFree frees an AVAudioFifo.
|
||||
func AvAudioFifoFree(af *AvAudioFifo) {
|
||||
C.av_audio_fifo_free((*C.struct_AVAudioFifo)(af))
|
||||
}
|
||||
|
||||
// AvAudioFifoAlloc allocates an AVAudioFifo.
|
||||
func AvAudioFifoAlloc(sampleFmt AvSampleFormat, channels, nbSamples int32) *AvAudioFifo {
|
||||
return (*AvAudioFifo)(C.av_audio_fifo_alloc((C.enum_AVSampleFormat)(sampleFmt),
|
||||
(C.int)(channels), (C.int)(nbSamples)))
|
||||
}
|
||||
|
||||
// AvAudioFifoRealloc reallocate an AVAudioFifo.
|
||||
func AvAudioFifoRealloc(af *AvAudioFifo, nbSamples int32) int32 {
|
||||
return (int32)(C.av_audio_fifo_realloc((*C.struct_AVAudioFifo)(af), (C.int)(nbSamples)))
|
||||
}
|
||||
|
||||
// AvAudioFifoWrite writes data to an AVAudioFifo.
|
||||
func AvAudioFifoWrite(af *AvAudioFifo, data *unsafe.Pointer, nbSamples int32) int32 {
|
||||
return (int32)(C.av_audio_fifo_write((*C.struct_AVAudioFifo)(af), data, (C.int)(nbSamples)))
|
||||
}
|
||||
|
||||
// AvAudioFifoPeek peeks data from an AVAudioFifo.
|
||||
func AvAudioFifoPeek(af *AvAudioFifo, data *unsafe.Pointer, nbSamples int32) int32 {
|
||||
return (int32)(C.av_audio_fifo_peek((*C.struct_AVAudioFifo)(af), data, (C.int)(nbSamples)))
|
||||
}
|
||||
|
||||
// AvAudioFifoPeekAt peeks data from an AVAudioFifo.
|
||||
func AvAudioFifoPeekAt(af *AvAudioFifo, data *unsafe.Pointer, nbSamples, offset int32) int32 {
|
||||
return (int32)(C.av_audio_fifo_peek_at((*C.struct_AVAudioFifo)(af), data,
|
||||
(C.int)(nbSamples), (C.int)(offset)))
|
||||
}
|
||||
|
||||
// AvAudioFifoRead reads data from an AVAudioFifo.
|
||||
func AvAudioFifoRead(af *AvAudioFifo, data *unsafe.Pointer, nbSamples int32) int32 {
|
||||
return (int32)(C.av_audio_fifo_read((*C.struct_AVAudioFifo)(af), data, (C.int)(nbSamples)))
|
||||
}
|
||||
|
||||
// AvAudioFifoDrain drains data from an AVAudioFifo.
|
||||
func AvAudioFifoDrain(af *AvAudioFifo, nbSamples int32) int32 {
|
||||
return (int32)(C.av_audio_fifo_drain((*C.struct_AVAudioFifo)(af), (C.int)(nbSamples)))
|
||||
}
|
||||
|
||||
// AvAudioFifoReset resets the AVAudioFifo buffer.
|
||||
func AvAudioFifoReset(af *AvAudioFifo) {
|
||||
C.av_audio_fifo_reset((*C.struct_AVAudioFifo)(af))
|
||||
}
|
||||
|
||||
// AvAudioFifoSize gets the current number of samples in the AVAudioFifo available for reading.
|
||||
func AvAudioFifoSize(af *AvAudioFifo) int32 {
|
||||
return (int32)(C.av_audio_fifo_size((*C.struct_AVAudioFifo)(af)))
|
||||
}
|
||||
|
||||
// AvAudioFifoSpace gets the current number of samples in the AVAudioFifo available for writing.
|
||||
func AvAudioFifoSpace(af *AvAudioFifo) int32 {
|
||||
return (int32)(C.av_audio_fifo_space((*C.struct_AVAudioFifo)(af)))
|
||||
}
|
11
avutil_avconfig.go
Normal file
11
avutil_avconfig.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/avconfig.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
AV_HAVE_BIGENDIAN = C.AV_HAVE_BIGENDIAN
|
||||
AV_HAVE_FAST_UNALIGNED = C.AV_HAVE_FAST_UNALIGNED
|
||||
)
|
129
avutil_buffer.go
Normal file
129
avutil_buffer.go
Normal file
@@ -0,0 +1,129 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/buffer.h>
|
||||
|
||||
typedef void (*av_buffer_free_func)(void *opaque, uint8_t *data);
|
||||
typedef AVBufferRef* (*av_buffer_pool_alloc_func)(int size);
|
||||
typedef AVBufferRef* (*av_buffer_pool_alloc2_func)(void* opaque, int size);
|
||||
typedef void (*av_buffer_pool_free_func)(void* opaque);
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// AvBufferRef
|
||||
type AvBuffer C.struct_AVBuffer
|
||||
|
||||
// AvBufferRef
|
||||
type AvBufferRef C.struct_AVBufferRef
|
||||
|
||||
// AvBufferAlloc allocates an AVBuffer of the given size using AvMalloc().
|
||||
func AvBufferAlloc(size int32) *AvBufferRef {
|
||||
return (*AvBufferRef)(C.av_buffer_alloc((C.int)(size)))
|
||||
}
|
||||
|
||||
// AvBufferAllocz same as AvBufferAlloc(), except the returned buffer will be initialized
|
||||
// to zero.
|
||||
func AvBufferAllocz(size int32) *AvBufferRef {
|
||||
return (*AvBufferRef)(C.av_buffer_allocz((C.int)(size)))
|
||||
}
|
||||
|
||||
const AV_BUFFER_FLAG_READONLY = C.AV_BUFFER_FLAG_READONLY
|
||||
|
||||
// typedef void (*av_buffer_free_func)(void *opaque, uint8_t *data)
|
||||
type AvBufferFreeFunc C.av_buffer_free_func
|
||||
|
||||
// AvBufferCreate Create an AvBuffer from an existing array.
|
||||
func AvBufferCreate(data *uint8, size int32, free AvBufferFreeFunc, opaque unsafe.Pointer, flags int32) *AvBufferRef {
|
||||
return (*AvBufferRef)(C.av_buffer_create((*C.uint8_t)(data), (C.int)(size),
|
||||
(C.av_buffer_free_func)(free), opaque, (C.int)(flags)))
|
||||
}
|
||||
|
||||
// AvBufferDefaultFree frees buffer data.
|
||||
func AvBufferDefaultFree(opaque unsafe.Pointer, data *uint8) {
|
||||
C.av_buffer_default_free(opaque, (*C.uint8_t)(data))
|
||||
}
|
||||
|
||||
// AvBufferRef creates a new reference to an AVBuffer.
|
||||
func AvBufferReference(buf *AvBufferRef) *AvBufferRef {
|
||||
return (*AvBufferRef)(C.av_buffer_ref((*C.struct_AVBufferRef)(buf)))
|
||||
}
|
||||
|
||||
// AvBufferUnreference frees a given reference and automatically free the buffer if there are no more
|
||||
// references to it.
|
||||
func AvBufferUnreference(buf **AvBufferRef) {
|
||||
C.av_buffer_unref((**C.struct_AVBufferRef)(unsafe.Pointer(buf)))
|
||||
}
|
||||
|
||||
// AvBufferIsWritable returns 1 if the caller may write to the data referred to by buf (which is
|
||||
// true if and only if buf is the only reference to the underlying AVBuffer).
|
||||
// Return 0 otherwise.
|
||||
func AvBufferIsWritable(buf *AvBufferRef) int32 {
|
||||
return (int32)(C.av_buffer_is_writable((*C.struct_AVBufferRef)(buf)))
|
||||
}
|
||||
|
||||
// AvBufferGetOpaque returns the opaque parameter set by AvBufferCreate.
|
||||
func AvBufferGetOpaque(buf *AvBufferRef) unsafe.Pointer {
|
||||
return (unsafe.Pointer)(C.av_buffer_get_opaque((*C.struct_AVBufferRef)(buf)))
|
||||
}
|
||||
|
||||
// AvBufferGetRefCount
|
||||
func AvBufferGetRefCount(buf *AvBufferRef) int32 {
|
||||
return (int32)(C.av_buffer_get_ref_count((*C.struct_AVBufferRef)(buf)))
|
||||
}
|
||||
|
||||
// AvBufferMakeWritable creates a writable reference from a given buffer reference,
|
||||
// avoiding data copy if possible.
|
||||
func AvBufferMakeWritable(buf **AvBufferRef) int32 {
|
||||
return (int32)(C.av_buffer_make_writable((**C.struct_AVBufferRef)(unsafe.Pointer(buf))))
|
||||
}
|
||||
|
||||
// AvBufferRealloc reallocates a given buffer.
|
||||
func AvBufferRealloc(buf **AvBufferRef, size int32) int32 {
|
||||
return (int32)(C.av_buffer_realloc((**C.struct_AVBufferRef)(unsafe.Pointer(buf)), (C.int)(size)))
|
||||
}
|
||||
|
||||
// AvBufferReplace ensures dst refers to the same data as src.
|
||||
func AvBufferReplace(dst **AvBufferRef, src *AvBufferRef) int32 {
|
||||
return (int32)(C.av_buffer_replace((**C.struct_AVBufferRef)(unsafe.Pointer(dst)),
|
||||
(*C.struct_AVBufferRef)(src)))
|
||||
}
|
||||
|
||||
type AvBufferPool C.struct_AVBufferPool
|
||||
|
||||
// typedef AVBufferRef* (*av_buffer_pool_alloc_func)(int size)
|
||||
type AvBufferPoolAllocFunc C.av_buffer_pool_alloc_func
|
||||
|
||||
// typedef AVBufferRef* (*av_buffer_pool_alloc2_func)(void* opaque, int size)
|
||||
type AvBufferPoolAlloc2Func C.av_buffer_pool_alloc2_func
|
||||
|
||||
// typedef void (*av_buffer_pool_free_func)(void* opaque)
|
||||
type AvBufferPoolFreeFunc C.av_buffer_pool_free_func
|
||||
|
||||
// AvBufferPoolInit allocates and initializes a buffer pool.
|
||||
func av_buffer_pool_init(size int32, alloc AvBufferPoolAllocFunc) *AvBufferPool {
|
||||
return (*AvBufferPool)(C.av_buffer_pool_init((C.int)(size), (C.av_buffer_pool_alloc_func)(alloc)))
|
||||
}
|
||||
|
||||
// AvBufferPoolInit2 allocates and initialize a buffer pool with a more complex allocator.
|
||||
func AvBufferPoolInit2(size int32, opaque unsafe.Pointer,
|
||||
alloc AvBufferPoolAllocFunc, free AvBufferPoolFreeFunc) *AvBufferPool {
|
||||
return (*AvBufferPool)(C.av_buffer_pool_init2((C.int)(size), opaque,
|
||||
(C.av_buffer_pool_alloc_func)(alloc),
|
||||
(C.av_buffer_pool_free_func)(free)))
|
||||
}
|
||||
|
||||
// AvBufferPoolUninit marks the pool as being available for freeing.
|
||||
func AvBufferPoolUninit(pool **AvBufferPool) {
|
||||
C.av_buffer_pool_uninit((**C.struct_AVBufferPool)(unsafe.Pointer(pool)))
|
||||
}
|
||||
|
||||
// AvBufferPoolGet allocates a new AVBuffer, reusing an old buffer from the pool when available.
|
||||
func AvBufferPoolGet(pool *AvBufferPool) *AvBufferRef {
|
||||
return (*AvBufferRef)(C.av_buffer_pool_get((*C.struct_AVBufferPool)(pool)))
|
||||
}
|
||||
|
||||
// AvBufferPoolBufferGetOpaque queries the original opaque parameter of an allocated buffer in the pool.
|
||||
func AvBufferPoolBufferGetOpaque(buf *AvBufferRef) unsafe.Pointer {
|
||||
return (unsafe.Pointer)(C.av_buffer_pool_buffer_get_opaque((*C.struct_AVBufferRef)(buf)))
|
||||
}
|
152
avutil_channel_layout.go
Normal file
152
avutil_channel_layout.go
Normal file
@@ -0,0 +1,152 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/channel_layout.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
const (
|
||||
AV_CH_FRONT_LEFT = uint64(C.AV_CH_FRONT_LEFT)
|
||||
AV_CH_FRONT_RIGHT = uint64(C.AV_CH_FRONT_RIGHT)
|
||||
AV_CH_FRONT_CENTER = uint64(C.AV_CH_FRONT_CENTER)
|
||||
AV_CH_LOW_FREQUENCY = uint64(C.AV_CH_LOW_FREQUENCY)
|
||||
AV_CH_BACK_LEFT = uint64(C.AV_CH_BACK_LEFT)
|
||||
AV_CH_BACK_RIGHT = uint64(C.AV_CH_BACK_RIGHT)
|
||||
AV_CH_FRONT_LEFT_OF_CENTER = uint64(C.AV_CH_FRONT_LEFT_OF_CENTER)
|
||||
AV_CH_FRONT_RIGHT_OF_CENTER = uint64(C.AV_CH_FRONT_RIGHT_OF_CENTER)
|
||||
AV_CH_BACK_CENTER = uint64(C.AV_CH_BACK_CENTER)
|
||||
AV_CH_SIDE_LEFT = uint64(C.AV_CH_SIDE_LEFT)
|
||||
AV_CH_SIDE_RIGHT = uint64(C.AV_CH_SIDE_RIGHT)
|
||||
AV_CH_TOP_CENTER = uint64(C.AV_CH_TOP_CENTER)
|
||||
AV_CH_TOP_FRONT_LEFT = uint64(C.AV_CH_TOP_FRONT_LEFT)
|
||||
AV_CH_TOP_FRONT_CENTER = uint64(C.AV_CH_TOP_FRONT_CENTER)
|
||||
AV_CH_TOP_FRONT_RIGHT = uint64(C.AV_CH_TOP_FRONT_RIGHT)
|
||||
AV_CH_TOP_BACK_LEFT = uint64(C.AV_CH_TOP_BACK_LEFT)
|
||||
AV_CH_TOP_BACK_CENTER = uint64(C.AV_CH_TOP_BACK_CENTER)
|
||||
AV_CH_TOP_BACK_RIGHT = uint64(C.AV_CH_TOP_BACK_RIGHT)
|
||||
AV_CH_STEREO_LEFT = uint64(C.AV_CH_STEREO_LEFT)
|
||||
AV_CH_STEREO_RIGHT = uint64(C.AV_CH_STEREO_RIGHT)
|
||||
AV_CH_WIDE_LEFT = uint64(C.AV_CH_WIDE_LEFT)
|
||||
AV_CH_WIDE_RIGHT = uint64(C.AV_CH_WIDE_RIGHT)
|
||||
AV_CH_SURROUND_DIRECT_LEFT = uint64(C.AV_CH_SURROUND_DIRECT_LEFT)
|
||||
AV_CH_SURROUND_DIRECT_RIGHT = uint64(C.AV_CH_SURROUND_DIRECT_RIGHT)
|
||||
AV_CH_LOW_FREQUENCY_2 = uint64(C.AV_CH_LOW_FREQUENCY_2)
|
||||
AV_CH_TOP_SIDE_LEFT = uint64(C.AV_CH_TOP_SIDE_LEFT)
|
||||
AV_CH_TOP_SIDE_RIGHT = uint64(C.AV_CH_TOP_SIDE_RIGHT)
|
||||
AV_CH_BOTTOM_FRONT_CENTER = uint64(C.AV_CH_BOTTOM_FRONT_CENTER)
|
||||
AV_CH_BOTTOM_FRONT_LEFT = uint64(C.AV_CH_BOTTOM_FRONT_LEFT)
|
||||
AV_CH_BOTTOM_FRONT_RIGHT = uint64(C.AV_CH_BOTTOM_FRONT_RIGHT)
|
||||
|
||||
AV_CH_LAYOUT_NATIVE = uint64(C.AV_CH_LAYOUT_NATIVE)
|
||||
)
|
||||
|
||||
const (
|
||||
AV_CH_LAYOUT_MONO = uint64(C.AV_CH_LAYOUT_MONO)
|
||||
AV_CH_LAYOUT_STEREO = uint64(C.AV_CH_LAYOUT_STEREO)
|
||||
AV_CH_LAYOUT_2POINT1 = uint64(C.AV_CH_LAYOUT_2POINT1)
|
||||
AV_CH_LAYOUT_2_1 = uint64(C.AV_CH_LAYOUT_2_1)
|
||||
AV_CH_LAYOUT_SURROUND = uint64(C.AV_CH_LAYOUT_SURROUND)
|
||||
AV_CH_LAYOUT_3POINT1 = uint64(C.AV_CH_LAYOUT_3POINT1)
|
||||
AV_CH_LAYOUT_4POINT0 = uint64(C.AV_CH_LAYOUT_4POINT0)
|
||||
AV_CH_LAYOUT_4POINT1 = uint64(C.AV_CH_LAYOUT_4POINT1)
|
||||
AV_CH_LAYOUT_2_2 = uint64(C.AV_CH_LAYOUT_2_2)
|
||||
AV_CH_LAYOUT_QUAD = uint64(C.AV_CH_LAYOUT_QUAD)
|
||||
AV_CH_LAYOUT_5POINT0 = uint64(C.AV_CH_LAYOUT_5POINT0)
|
||||
AV_CH_LAYOUT_5POINT1 = uint64(C.AV_CH_LAYOUT_5POINT1)
|
||||
AV_CH_LAYOUT_5POINT0_BACK = uint64(C.AV_CH_LAYOUT_5POINT0_BACK)
|
||||
AV_CH_LAYOUT_5POINT1_BACK = uint64(C.AV_CH_LAYOUT_5POINT1_BACK)
|
||||
AV_CH_LAYOUT_6POINT0 = uint64(C.AV_CH_LAYOUT_6POINT0)
|
||||
AV_CH_LAYOUT_6POINT0_FRONT = uint64(C.AV_CH_LAYOUT_6POINT0_FRONT)
|
||||
AV_CH_LAYOUT_HEXAGONAL = uint64(C.AV_CH_LAYOUT_HEXAGONAL)
|
||||
AV_CH_LAYOUT_6POINT1 = uint64(C.AV_CH_LAYOUT_6POINT1)
|
||||
AV_CH_LAYOUT_6POINT1_BACK = uint64(C.AV_CH_LAYOUT_6POINT1_BACK)
|
||||
AV_CH_LAYOUT_6POINT1_FRONT = uint64(C.AV_CH_LAYOUT_6POINT1_FRONT)
|
||||
AV_CH_LAYOUT_7POINT0 = uint64(C.AV_CH_LAYOUT_7POINT0)
|
||||
AV_CH_LAYOUT_7POINT0_FRONT = uint64(C.AV_CH_LAYOUT_7POINT0_FRONT)
|
||||
AV_CH_LAYOUT_7POINT1 = uint64(C.AV_CH_LAYOUT_7POINT1)
|
||||
AV_CH_LAYOUT_7POINT1_WIDE = uint64(C.AV_CH_LAYOUT_7POINT1_WIDE)
|
||||
AV_CH_LAYOUT_7POINT1_WIDE_BACK = uint64(C.AV_CH_LAYOUT_7POINT1_WIDE_BACK)
|
||||
AV_CH_LAYOUT_OCTAGONAL = uint64(C.AV_CH_LAYOUT_OCTAGONAL)
|
||||
AV_CH_LAYOUT_HEXADECAGONAL = uint64(C.AV_CH_LAYOUT_HEXADECAGONAL)
|
||||
AV_CH_LAYOUT_STEREO_DOWNMIX = uint64(C.AV_CH_LAYOUT_STEREO_DOWNMIX)
|
||||
AV_CH_LAYOUT_22POINT2 = uint64(C.AV_CH_LAYOUT_22POINT2)
|
||||
)
|
||||
|
||||
type AvMatrixEncoding int32
|
||||
|
||||
const (
|
||||
AV_MATRIX_ENCODING_NONE = AvMatrixEncoding(C.AV_MATRIX_ENCODING_NONE)
|
||||
AV_MATRIX_ENCODING_DOLBY = AvMatrixEncoding(C.AV_MATRIX_ENCODING_DOLBY)
|
||||
AV_MATRIX_ENCODING_DPLII = AvMatrixEncoding(C.AV_MATRIX_ENCODING_DPLII)
|
||||
AV_MATRIX_ENCODING_DPLIIX = AvMatrixEncoding(C.AV_MATRIX_ENCODING_DPLIIX)
|
||||
AV_MATRIX_ENCODING_DPLIIZ = AvMatrixEncoding(C.AV_MATRIX_ENCODING_DPLIIZ)
|
||||
AV_MATRIX_ENCODING_DOLBYEX = AvMatrixEncoding(C.AV_MATRIX_ENCODING_DOLBYEX)
|
||||
AV_MATRIX_ENCODING_DOLBYHEADPHONE = AvMatrixEncoding(C.AV_MATRIX_ENCODING_DOLBYHEADPHONE)
|
||||
AV_MATRIX_ENCODING_NB = AvMatrixEncoding(C.AV_MATRIX_ENCODING_NB)
|
||||
)
|
||||
|
||||
// AvGetChannelLayout returns a channel layout id that matches name, or 0 if no match is found.
|
||||
func AvGetChannelLayout(name string) uint64 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (uint64)(C.av_get_channel_layout((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvGetExtendedChannelLayout returns a channel layout and the number of channels based on the specified name.
|
||||
func AvGetExtendedChannelLayout(name string, channelLayout *uint64, nbChannels *int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_get_extended_channel_layout((*C.char)(namePtr),
|
||||
(*C.uint64_t)(channelLayout), (*C.int32_t)(nbChannels)))
|
||||
}
|
||||
|
||||
// AvGetChannelLayoutString returns a description of a channel layout.
|
||||
func AvGetChannelLayoutString(buf *int8, bufSize, nbChannels int32, channelLayout uint64) {
|
||||
C.av_get_channel_layout_string((*C.char)(buf), (C.int)(bufSize),
|
||||
(C.int)(nbChannels), (C.uint64_t)(channelLayout))
|
||||
}
|
||||
|
||||
// AvBprintChannelLayout appends a description of a channel layout to a bprint buffer.
|
||||
func AvBprintChannelLayout(bp *AvBPrint, nbChannels int32, channelLayout uint64) {
|
||||
C.av_bprint_channel_layout((*C.struct_AVBPrint)(bp),
|
||||
(C.int)(nbChannels), (C.uint64_t)(channelLayout))
|
||||
}
|
||||
|
||||
// AvGetChannelLayoutNbChannels returns the number of channels in the channel layout.
|
||||
func AvGetChannelLayoutNbChannels(channelLayout uint64) int32 {
|
||||
return (int32)(C.av_get_channel_layout_nb_channels((C.uint64_t)(channelLayout)))
|
||||
}
|
||||
|
||||
// AvGetDefaultChannelLayout returns default channel layout for a given number of channels.
|
||||
func AvGetDefaultChannelLayout(nbChannels int32) int64 {
|
||||
return (int64)(C.av_get_default_channel_layout((C.int)(nbChannels)))
|
||||
}
|
||||
|
||||
// AvGetChannelLayoutChannelIndex gets the index of a channel in channel_layout.
|
||||
func AvGetChannelLayoutChannelIndex(channelLayout, channel uint64) int32 {
|
||||
return (int32)(C.av_get_channel_layout_channel_index((C.uint64_t)(channelLayout),
|
||||
(C.uint64_t)(channel)))
|
||||
}
|
||||
|
||||
// AvChannelLayoutExtractChannel gets the channel with the given index in channel_layout.
|
||||
func AvChannelLayoutExtractChannel(channelLayout uint64, index int32) uint64 {
|
||||
return (uint64)(C.av_channel_layout_extract_channel((C.uint64_t)(channelLayout),
|
||||
(C.int)(index)))
|
||||
}
|
||||
|
||||
// AvGetChannelName gets the name of a given channel.
|
||||
func AvGetChannelName(channel uint64) string {
|
||||
return C.GoString(C.av_get_channel_name((C.uint64_t)(channel)))
|
||||
}
|
||||
|
||||
// AvGetChannelDescription gets the value and name of a standard channel layout.
|
||||
func AvGetChannelDescription(channel uint64) string {
|
||||
return C.GoString(C.av_get_channel_description((C.uint64_t)(channel)))
|
||||
}
|
||||
|
||||
// AvGetStandardChannelLayout Get the value and name of a standard channel layout.
|
||||
func AvGetStandardChannelLayout(index uint32, layout *uint64, name **int8) int32 {
|
||||
return (int32)(C.av_get_standard_channel_layout((C.uint)(index),
|
||||
(*C.uint64_t)(layout), (**C.char)(unsafe.Pointer(name))))
|
||||
}
|
49
avutil_common.go
Normal file
49
avutil_common.go
Normal file
@@ -0,0 +1,49 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/common.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
func AV_NE[T any](be, le T) T {
|
||||
if C.AV_HAVE_BIGENDIAN > 0 {
|
||||
return be
|
||||
}
|
||||
return le
|
||||
}
|
||||
|
||||
func FFABS[T HelperSingedInteger](a T) T {
|
||||
if a >= 0 {
|
||||
return a
|
||||
}
|
||||
return 0 - a
|
||||
}
|
||||
|
||||
func FFSIGNT[T HelperSingedInteger](a T) T {
|
||||
if a > 0 {
|
||||
return 1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
func FFMAX[T HelperInteger](a, b T) T {
|
||||
if a > b {
|
||||
return a
|
||||
}
|
||||
return b
|
||||
}
|
||||
|
||||
func FFMAX3[T HelperInteger](a, b, c T) T {
|
||||
return FFMAX(FFMAX(a, b), c)
|
||||
}
|
||||
|
||||
func FFMIN[T HelperInteger](a, b T) T {
|
||||
if a > b {
|
||||
return b
|
||||
}
|
||||
return a
|
||||
}
|
||||
|
||||
func FFMIN3[T HelperInteger](a, b, c T) T {
|
||||
return FFMIN(FFMIN(a, b), c)
|
||||
}
|
94
avutil_cpu.go
Normal file
94
avutil_cpu.go
Normal file
@@ -0,0 +1,94 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/cpu.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
AV_CPU_FLAG_FORCE = C.AV_CPU_FLAG_FORCE
|
||||
AV_CPU_FLAG_MMX = C.AV_CPU_FLAG_MMX
|
||||
AV_CPU_FLAG_MMXEXT = C.AV_CPU_FLAG_MMXEXT
|
||||
AV_CPU_FLAG_MMX2 = C.AV_CPU_FLAG_MMX2
|
||||
AV_CPU_FLAG_3DNOW = C.AV_CPU_FLAG_3DNOW
|
||||
AV_CPU_FLAG_SSE = C.AV_CPU_FLAG_SSE
|
||||
AV_CPU_FLAG_SSE2 = C.AV_CPU_FLAG_SSE2
|
||||
AV_CPU_FLAG_SSE2SLOW = C.AV_CPU_FLAG_SSE2SLOW
|
||||
|
||||
AV_CPU_FLAG_3DNOWEXT = C.AV_CPU_FLAG_3DNOWEXT
|
||||
AV_CPU_FLAG_SSE3 = C.AV_CPU_FLAG_SSE3
|
||||
AV_CPU_FLAG_SSE3SLOW = C.AV_CPU_FLAG_SSE3SLOW
|
||||
|
||||
AV_CPU_FLAG_SSSE3 = C.AV_CPU_FLAG_SSSE3
|
||||
AV_CPU_FLAG_SSSE3SLOW = C.AV_CPU_FLAG_SSSE3SLOW
|
||||
AV_CPU_FLAG_ATOM = C.AV_CPU_FLAG_ATOM
|
||||
AV_CPU_FLAG_SSE4 = C.AV_CPU_FLAG_SSE4
|
||||
AV_CPU_FLAG_SSE42 = C.AV_CPU_FLAG_SSE42
|
||||
AV_CPU_FLAG_AESNI = C.AV_CPU_FLAG_AESNI
|
||||
AV_CPU_FLAG_AVX = C.AV_CPU_FLAG_AVX
|
||||
AV_CPU_FLAG_AVXSLOW = C.AV_CPU_FLAG_AVXSLOW
|
||||
AV_CPU_FLAG_XOP = C.AV_CPU_FLAG_XOP
|
||||
AV_CPU_FLAG_FMA4 = C.AV_CPU_FLAG_FMA4
|
||||
AV_CPU_FLAG_CMOV = C.AV_CPU_FLAG_CMOV
|
||||
AV_CPU_FLAG_AVX2 = C.AV_CPU_FLAG_AVX2
|
||||
AV_CPU_FLAG_FMA3 = C.AV_CPU_FLAG_FMA3
|
||||
AV_CPU_FLAG_BMI1 = C.AV_CPU_FLAG_BMI1
|
||||
AV_CPU_FLAG_BMI2 = C.AV_CPU_FLAG_BMI2
|
||||
AV_CPU_FLAG_AVX512 = C.AV_CPU_FLAG_AVX512
|
||||
|
||||
AV_CPU_FLAG_ALTIVEC = C.AV_CPU_FLAG_ALTIVEC
|
||||
AV_CPU_FLAG_VSX = C.AV_CPU_FLAG_VSX
|
||||
AV_CPU_FLAG_POWER8 = C.AV_CPU_FLAG_POWER8
|
||||
|
||||
AV_CPU_FLAG_ARMV5TE = C.AV_CPU_FLAG_ARMV5TE
|
||||
AV_CPU_FLAG_ARMV6 = C.AV_CPU_FLAG_ARMV6
|
||||
AV_CPU_FLAG_ARMV6T2 = C.AV_CPU_FLAG_ARMV6T2
|
||||
AV_CPU_FLAG_VFP = C.AV_CPU_FLAG_VFP
|
||||
AV_CPU_FLAG_VFPV3 = C.AV_CPU_FLAG_VFPV3
|
||||
AV_CPU_FLAG_NEON = C.AV_CPU_FLAG_NEON
|
||||
AV_CPU_FLAG_ARMV8 = C.AV_CPU_FLAG_ARMV8
|
||||
AV_CPU_FLAG_VFP_VM = C.AV_CPU_FLAG_VFP_VM
|
||||
AV_CPU_FLAG_SETEND = C.AV_CPU_FLAG_SETEND
|
||||
|
||||
AV_CPU_FLAG_MMI = C.AV_CPU_FLAG_MMI
|
||||
AV_CPU_FLAG_MSA = C.AV_CPU_FLAG_MSA
|
||||
)
|
||||
|
||||
// AvGetCpuFlags returns the flags which specify extensions supported by the CPU.
|
||||
func AvGetCpuFlags() int32 {
|
||||
return (int32)(C.av_get_cpu_flags())
|
||||
}
|
||||
|
||||
// AvForceCpuFlags disables cpu detection and forces the specified flags.
|
||||
func AvForceCpuFlags(flags int32) {
|
||||
C.av_force_cpu_flags((C.int)(flags))
|
||||
}
|
||||
|
||||
// Deprecated: Use AvForceCpuFlags() and AvGetCpuFlags() instead
|
||||
func AvSetCpuFlagsMask(mask int32) {
|
||||
C.av_set_cpu_flags_mask((C.int)(mask))
|
||||
}
|
||||
|
||||
// Deprecated: Use AvParseCpuCaps() when possible.
|
||||
func AvParseCpuFlags(str string) int32 {
|
||||
strPtr, strFunc := StringCasting(str)
|
||||
defer strFunc()
|
||||
return (int32)(C.av_parse_cpu_flags((*C.char)(strPtr)))
|
||||
}
|
||||
|
||||
// AvParseCpuCaps parses CPU caps from a string and update the given AV_CPU_* flags based on that.
|
||||
func AvParseCpuCaps(flags *uint32, str string) int32 {
|
||||
strPtr, strFunc := StringCasting(str)
|
||||
defer strFunc()
|
||||
return (int32)(C.av_parse_cpu_caps((*C.uint)(flags), (*C.char)(strPtr)))
|
||||
}
|
||||
|
||||
// AvCpuCount returns the number of logical CPU cores present.
|
||||
func AvCpuCount() int32 {
|
||||
return (int32)(C.av_cpu_count())
|
||||
}
|
||||
|
||||
// AvCpuMaxAlign gets the maximum data alignment that may be required by FFmpeg.
|
||||
func AvCpuMaxAlign() int32 {
|
||||
return (int32)(C.av_cpu_max_align())
|
||||
}
|
86
avutil_dict.go
Normal file
86
avutil_dict.go
Normal file
@@ -0,0 +1,86 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/dict.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
const (
|
||||
AV_DICT_MATCH_CASE = C.AV_DICT_MATCH_CASE
|
||||
AV_DICT_IGNORE_SUFFIX = C.AV_DICT_IGNORE_SUFFIX
|
||||
AV_DICT_DONT_STRDUP_KEY = C.AV_DICT_DONT_STRDUP_KEY
|
||||
AV_DICT_DONT_STRDUP_VAL = C.AV_DICT_DONT_STRDUP_VAL
|
||||
AV_DICT_DONT_OVERWRITE = C.AV_DICT_DONT_OVERWRITE
|
||||
AV_DICT_APPEND = C.AV_DICT_APPEND
|
||||
AV_DICT_MULTIKEY = C.AV_DICT_MULTIKEY
|
||||
)
|
||||
|
||||
type AvDictionaryEntry C.struct_AVDictionaryEntry
|
||||
|
||||
// AvDictionary gets a dictionary entry with matching key.
|
||||
type AvDictionary C.struct_AVDictionary
|
||||
|
||||
// AvDictGet
|
||||
func AvDictGet(m *AvDictionary, key string, prev *AvDictionaryEntry, flags int32) *AvDictionaryEntry {
|
||||
keyPtr, keyFunc := StringCasting(key)
|
||||
defer keyFunc()
|
||||
return (*AvDictionaryEntry)(C.av_dict_get((*C.struct_AVDictionary)(m),
|
||||
(*C.char)(keyPtr), (*C.struct_AVDictionaryEntry)(prev), (C.int)(flags)))
|
||||
}
|
||||
|
||||
// AvDictCount gets number of entries in dictionary.
|
||||
func AvDictCount(m *AvDictionary) int32 {
|
||||
return (int32)(C.av_dict_count((*C.struct_AVDictionary)(m)))
|
||||
}
|
||||
|
||||
// AvDictSet sets the given entry in *pm, overwriting an existing entry.
|
||||
func av_dict_set(pm **AvDictionary, key, value string, flags int32) int32 {
|
||||
keyPtr, keyFunc := StringCasting(key)
|
||||
defer keyFunc()
|
||||
valuePtr, valueFunc := StringCasting(value)
|
||||
defer valueFunc()
|
||||
return (int32)(C.av_dict_set((**C.struct_AVDictionary)(unsafe.Pointer(pm)),
|
||||
(*C.char)(keyPtr), (*C.char)(valuePtr), (C.int)(flags)))
|
||||
}
|
||||
|
||||
// AvDictSetInt sets the given entry in *pm, overwriting an existing entry.
|
||||
func AvDictSetInt(pm **AvDictionary, key string, value int64, flags int32) int32 {
|
||||
keyPtr, keyFunc := StringCasting(key)
|
||||
defer keyFunc()
|
||||
return (int32)(C.av_dict_set_int((**C.struct_AVDictionary)(unsafe.Pointer(pm)),
|
||||
(*C.char)(keyPtr), (C.int64_t)(value), (C.int)(flags)))
|
||||
}
|
||||
|
||||
// AvDictParseString parses the key/value pairs list and add the parsed entries to a dictionary.
|
||||
func AvDictParseString(pm **AvDictionary, str, keyValSep, pairsSep string, flags int32) int32 {
|
||||
strPtr, strFunc := StringCasting(str)
|
||||
defer strFunc()
|
||||
keyValSepPtr, keyValSepFunc := StringCasting(keyValSep)
|
||||
defer keyValSepFunc()
|
||||
pairsSepPtr, pairsSepFunc := StringCasting(pairsSep)
|
||||
defer pairsSepFunc()
|
||||
return (int32)(C.av_dict_parse_string((**C.struct_AVDictionary)(unsafe.Pointer(pm)),
|
||||
(*C.char)(strPtr), (*C.char)(keyValSepPtr), (*C.char)(pairsSepPtr), (C.int)(flags)))
|
||||
}
|
||||
|
||||
// AvDictCopy copies entries from one AVDictionary struct into another.
|
||||
func AvDictCopy(dst **AvDictionary, src *AvDictionary, flags int32) int32 {
|
||||
return (int32)(C.av_dict_copy((**C.struct_AVDictionary)(unsafe.Pointer(dst)),
|
||||
(*C.struct_AVDictionary)(src), (C.int)(flags)))
|
||||
}
|
||||
|
||||
// AvDictFree frees all the memory allocated for an AVDictionary struct and all keys and values.
|
||||
func AvDictFree(m *AvDictionary) {
|
||||
C.av_dict_free((**C.struct_AVDictionary)(unsafe.Pointer(m)))
|
||||
}
|
||||
|
||||
// AvDictGetString get dictionary entries as a string.
|
||||
func AvDictGetString(m *AvDictionary, buffer **int8, keyValSep, pairsSep string) int32 {
|
||||
keyValSepPtr, keyValSepFunc := StringCasting(keyValSep)
|
||||
defer keyValSepFunc()
|
||||
pairsSepPtr, pairsSepFunc := StringCasting(pairsSep)
|
||||
defer pairsSepFunc()
|
||||
return (int32)(C.av_dict_get_string((*C.struct_AVDictionary)(m),
|
||||
(**C.char)(unsafe.Pointer(buffer)), (C.char)(*keyValSepPtr), (C.char)(*pairsSepPtr)))
|
||||
}
|
78
avutil_error.go
Normal file
78
avutil_error.go
Normal file
@@ -0,0 +1,78 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/common.h>
|
||||
#include <libavutil/error.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
// AVERROR returns a negative error code from a POSIX error code, to return from library functions.
|
||||
func AVERROR(e int32) int32 {
|
||||
if C.EDOM > 0 {
|
||||
return (-e)
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// AVUNERROR returns a POSIX error code from a library function error return value.
|
||||
func AVUNERROR(e int32) int32 {
|
||||
if C.EDOM > 0 {
|
||||
return (-e)
|
||||
}
|
||||
return e
|
||||
}
|
||||
|
||||
// Error handling
|
||||
const (
|
||||
AVERROR_BSF_NOT_FOUND = int32(C.AVERROR_BSF_NOT_FOUND)
|
||||
AVERROR_BUG = int32(C.AVERROR_BUG)
|
||||
AVERROR_BUFFER_TOO_SMALL = int32(C.AVERROR_BUFFER_TOO_SMALL)
|
||||
AVERROR_DECODER_NOT_FOUND = int32(C.AVERROR_DECODER_NOT_FOUND)
|
||||
AVERROR_DEMUXER_NOT_FOUND = int32(C.AVERROR_DEMUXER_NOT_FOUND)
|
||||
AVERROR_ENCODER_NOT_FOUND = int32(C.AVERROR_ENCODER_NOT_FOUND)
|
||||
AVERROR_EOF = int32(C.AVERROR_EOF)
|
||||
AVERROR_EXIT = int32(C.AVERROR_EXIT)
|
||||
AVERROR_EXTERNAL = int32(C.AVERROR_EXTERNAL)
|
||||
AVERROR_FILTER_NOT_FOUND = int32(C.AVERROR_FILTER_NOT_FOUND)
|
||||
AVERROR_INVALIDDATA = int32(C.AVERROR_INVALIDDATA)
|
||||
AVERROR_MUXER_NOT_FOUND = int32(C.AVERROR_MUXER_NOT_FOUND)
|
||||
AVERROR_OPTION_NOT_FOUND = int32(C.AVERROR_OPTION_NOT_FOUND)
|
||||
AVERROR_PATCHWELCOME = int32(C.AVERROR_PATCHWELCOME)
|
||||
AVERROR_PROTOCOL_NOT_FOUND = int32(C.AVERROR_PROTOCOL_NOT_FOUND)
|
||||
|
||||
AVERROR_STREAM_NOT_FOUND = int32(C.AVERROR_STREAM_NOT_FOUND)
|
||||
|
||||
AVERROR_BUG2 = int32(C.AVERROR_BUG2)
|
||||
AVERROR_UNKNOWN = int32(C.AVERROR_UNKNOWN)
|
||||
AVERROR_EXPERIMENTAL = int32(C.AVERROR_EXPERIMENTAL)
|
||||
AVERROR_INPUT_CHANGED = int32(C.AVERROR_INPUT_CHANGED)
|
||||
AVERROR_OUTPUT_CHANGED = int32(C.AVERROR_OUTPUT_CHANGED)
|
||||
AVERROR_HTTP_BAD_REQUEST = int32(C.AVERROR_HTTP_BAD_REQUEST)
|
||||
AVERROR_HTTP_UNAUTHORIZED = int32(C.AVERROR_HTTP_UNAUTHORIZED)
|
||||
AVERROR_HTTP_FORBIDDEN = int32(C.AVERROR_HTTP_FORBIDDEN)
|
||||
AVERROR_HTTP_NOT_FOUND = int32(C.AVERROR_HTTP_NOT_FOUND)
|
||||
AVERROR_HTTP_OTHER_4XX = int32(C.AVERROR_HTTP_OTHER_4XX)
|
||||
AVERROR_HTTP_SERVER_ERROR = int32(C.AVERROR_HTTP_SERVER_ERROR)
|
||||
AV_ERROR_MAX_STRING_SIZE = int32(C.AV_ERROR_MAX_STRING_SIZE)
|
||||
)
|
||||
|
||||
// AvStrerror puts a description of the AVERROR code errnum in errbuf.
|
||||
// In case of failure the global variable errno is set to indicate the
|
||||
// error. Even in case of failure AvStrerror() will print a generic
|
||||
// error message indicating the errnum provided to errbuf.
|
||||
func AvStrerror(errnum int32, errbuf *int8, errbufSize uint) int32 {
|
||||
return (int32)(C.av_strerror((C.int)(errnum), (*C.char)(errbuf), (C.size_t)(errbufSize)))
|
||||
}
|
||||
|
||||
// AvMakeErrorString fills the provided buffer with a string containing an error string
|
||||
// corresponding to the AVERROR code errnum.
|
||||
func AvMakeErrorString(errbuf *int8, errbufSize uint, errnum int32) *int8 {
|
||||
return (*int8)(C.av_make_error_string((*C.char)(errbuf), (C.size_t)(errbufSize), (C.int)(errnum)))
|
||||
}
|
||||
|
||||
// AvErr2str
|
||||
func AvErr2str(errnum int32) string {
|
||||
buf := make([]int8, AV_ERROR_MAX_STRING_SIZE)
|
||||
return C.GoString(C.av_make_error_string((*C.char)(&buf[0]),
|
||||
(C.size_t)(AV_ERROR_MAX_STRING_SIZE), (C.int)(errnum)))
|
||||
}
|
10
avutil_ffversion.go
Normal file
10
avutil_ffversion.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/ffversion.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
FFMPEG_VERSION = C.FFMPEG_VERSION
|
||||
)
|
1141
avutil_frame.go
Normal file
1141
avutil_frame.go
Normal file
File diff suppressed because it is too large
Load Diff
85
avutil_log.go
Normal file
85
avutil_log.go
Normal file
@@ -0,0 +1,85 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/log.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
// AvClassCategory
|
||||
type AvClassCategory int32
|
||||
|
||||
const (
|
||||
AV_CLASS_CATEGORY_NA = AvClassCategory(C.AV_CLASS_CATEGORY_NA)
|
||||
AV_CLASS_CATEGORY_INPUT = AvClassCategory(C.AV_CLASS_CATEGORY_INPUT)
|
||||
AV_CLASS_CATEGORY_OUTPUT = AvClassCategory(C.AV_CLASS_CATEGORY_OUTPUT)
|
||||
AV_CLASS_CATEGORY_MUXER = AvClassCategory(C.AV_CLASS_CATEGORY_MUXER)
|
||||
AV_CLASS_CATEGORY_DEMUXER = AvClassCategory(C.AV_CLASS_CATEGORY_DEMUXER)
|
||||
AV_CLASS_CATEGORY_ENCODER = AvClassCategory(C.AV_CLASS_CATEGORY_ENCODER)
|
||||
AV_CLASS_CATEGORY_DECODER = AvClassCategory(C.AV_CLASS_CATEGORY_DECODER)
|
||||
AV_CLASS_CATEGORY_FILTER = AvClassCategory(C.AV_CLASS_CATEGORY_FILTER)
|
||||
AV_CLASS_CATEGORY_BITSTREAM_FILTER = AvClassCategory(C.AV_CLASS_CATEGORY_BITSTREAM_FILTER)
|
||||
AV_CLASS_CATEGORY_SWSCALER = AvClassCategory(C.AV_CLASS_CATEGORY_SWSCALER)
|
||||
AV_CLASS_CATEGORY_SWRESAMPLER = AvClassCategory(C.AV_CLASS_CATEGORY_SWRESAMPLER)
|
||||
AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT = AvClassCategory(C.AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT)
|
||||
AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT = AvClassCategory(C.AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT)
|
||||
AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT = AvClassCategory(C.AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT)
|
||||
AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT = AvClassCategory(C.AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT)
|
||||
AV_CLASS_CATEGORY_DEVICE_OUTPUT = AvClassCategory(C.AV_CLASS_CATEGORY_DEVICE_OUTPUT)
|
||||
AV_CLASS_CATEGORY_DEVICE_INPUT = AvClassCategory(C.AV_CLASS_CATEGORY_DEVICE_INPUT)
|
||||
AV_CLASS_CATEGORY_NB = AvClassCategory(C.AV_CLASS_CATEGORY_NB)
|
||||
)
|
||||
|
||||
func AV_IS_INPUT_DEVICE(c AvClassCategory) bool {
|
||||
return c == AV_CLASS_CATEGORY_DEVICE_VIDEO_INPUT ||
|
||||
c == AV_CLASS_CATEGORY_DEVICE_AUDIO_INPUT ||
|
||||
c == AV_CLASS_CATEGORY_DEVICE_INPUT
|
||||
}
|
||||
|
||||
func AV_IS_OUTPUT_DEVICE(c AvClassCategory) bool {
|
||||
return c == AV_CLASS_CATEGORY_DEVICE_VIDEO_OUTPUT ||
|
||||
c == AV_CLASS_CATEGORY_DEVICE_AUDIO_OUTPUT ||
|
||||
c == AV_CLASS_CATEGORY_DEVICE_OUTPUT
|
||||
}
|
||||
|
||||
// AvClass
|
||||
type AvClass C.struct_AVClass
|
||||
|
||||
// AvLogLevelType
|
||||
type AvLogLevelType int32
|
||||
|
||||
const (
|
||||
AV_LOG_QUIET = AvLogLevelType(C.AV_LOG_QUIET)
|
||||
AV_LOG_PANIC = AvLogLevelType(C.AV_LOG_PANIC)
|
||||
AV_LOG_FATAL = AvLogLevelType(C.AV_LOG_FATAL)
|
||||
AV_LOG_ERROR = AvLogLevelType(C.AV_LOG_ERROR)
|
||||
AV_LOG_WARNING = AvLogLevelType(C.AV_LOG_WARNING)
|
||||
AV_LOG_INFO = AvLogLevelType(C.AV_LOG_INFO)
|
||||
AV_LOG_VERBOSE = AvLogLevelType(C.AV_LOG_VERBOSE)
|
||||
AV_LOG_DEBUG = AvLogLevelType(C.AV_LOG_DEBUG)
|
||||
AV_LOG_TRACE = AvLogLevelType(C.AV_LOG_TRACE)
|
||||
)
|
||||
|
||||
// AvLogSetLevel sets the log level
|
||||
func AvLogSetLevel(level AvLogLevelType) {
|
||||
C.av_log_set_level(C.int(level))
|
||||
}
|
||||
|
||||
// AvLogGetLevel gets the current log level
|
||||
func AvLogGetLevel() AvLogLevelType {
|
||||
return AvLogLevelType(C.av_log_get_level())
|
||||
}
|
||||
|
||||
const (
|
||||
AV_LOG_SKIP_REPEATED = C.AV_LOG_SKIP_REPEATED
|
||||
AV_LOG_PRINT_LEVEL = C.AV_LOG_PRINT_LEVEL
|
||||
)
|
||||
|
||||
// AvLogSetFlags
|
||||
func AvLogSetFlags(arg int32) {
|
||||
C.av_log_set_flags((C.int)(arg))
|
||||
}
|
||||
|
||||
// AvLogGetFlags
|
||||
func AvLogGetFlags() int32 {
|
||||
return (int32)(C.av_log_get_flags())
|
||||
}
|
72
avutil_mathematics.go
Normal file
72
avutil_mathematics.go
Normal file
@@ -0,0 +1,72 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/mathematics.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
type AvRounding int32
|
||||
|
||||
const (
|
||||
AV_ROUND_ZERO = AvRounding(C.AV_ROUND_ZERO)
|
||||
AV_ROUND_INF = AvRounding(C.AV_ROUND_INF)
|
||||
AV_ROUND_DOWN = AvRounding(C.AV_ROUND_DOWN)
|
||||
AV_ROUND_UP = AvRounding(C.AV_ROUND_UP)
|
||||
AV_ROUND_NEAR_INF = AvRounding(C.AV_ROUND_NEAR_INF)
|
||||
AV_ROUND_PASS_MINMAX = AvRounding(C.AV_ROUND_PASS_MINMAX)
|
||||
)
|
||||
|
||||
// AvGcd computes the greatest common divisor of two integer operands.
|
||||
func AvGcd(a, b int64) int64 {
|
||||
return (int64)(C.av_gcd((C.int64_t)(a), (C.int64_t)(b)))
|
||||
}
|
||||
|
||||
// AvRescale rescale a 64-bit integer with rounding to nearest.
|
||||
func AvRescale(a, b, c int64) int64 {
|
||||
return (int64)(C.av_rescale((C.int64_t)(a), (C.int64_t)(b), (C.int64_t)(c)))
|
||||
}
|
||||
|
||||
// AvRescaleRnd rescales a 64-bit integer with specified rounding.
|
||||
func AvRescaleRnd(a, b, c int64, rnd AvRounding) int64 {
|
||||
return (int64)(C.av_rescale_rnd((C.int64_t)(a), (C.int64_t)(b), (C.int64_t)(c),
|
||||
(C.enum_AVRounding)(rnd)))
|
||||
}
|
||||
|
||||
// AvRescaleQ rescales a 64-bit integer by 2 rational numbers.
|
||||
func AvRescaleQ(a int64, bq, cq AvRational) int64 {
|
||||
return (int64)(C.av_rescale_q((C.int64_t)(a), (C.struct_AVRational)(bq), (C.struct_AVRational)(cq)))
|
||||
}
|
||||
|
||||
// AvRescaleQRnd rescales a 64-bit integer by 2 rational numbers with specified rounding.
|
||||
func AvRescaleQRnd(a int64, bq, cq AvRational, rnd AvRounding) int64 {
|
||||
return (int64)(C.av_rescale_q_rnd((C.int64_t)(a), (C.struct_AVRational)(bq), (C.struct_AVRational)(cq),
|
||||
(C.enum_AVRounding)(rnd)))
|
||||
}
|
||||
|
||||
// AvCompareTs compares two timestamps each in its own time base.
|
||||
func AvCompareTs(tsA int64, tbA AvRational, tsB int64, tbB AvRational) int32 {
|
||||
return (int32)(C.av_compare_ts((C.int64_t)(tsA), (C.struct_AVRational)(tbA),
|
||||
(C.int64_t)(tsB), (C.struct_AVRational)(tbB)))
|
||||
}
|
||||
|
||||
// AvCompareMod compares the remainders of two integer operands divided by a common divisor.
|
||||
func AvCompareMod(a, b, mod uint64) int64 {
|
||||
return (int64)(C.av_compare_mod((C.uint64_t)(a), (C.uint64_t)(b), (C.uint64_t)(mod)))
|
||||
}
|
||||
|
||||
// AvRescaleDelta rescales a timestamp while preserving known durations.
|
||||
func AvRescaleDelta(inTb AvRational, inTs int64, fsTb AvRational,
|
||||
duration int32, last *int64, outTb AvRational) int64 {
|
||||
return (int64)(C.av_rescale_delta((C.struct_AVRational)(inTb),
|
||||
(C.int64_t)(inTs),
|
||||
(C.struct_AVRational)(fsTb),
|
||||
(C.int)(duration),
|
||||
(*C.int64_t)(last),
|
||||
(C.struct_AVRational)(fsTb)))
|
||||
}
|
||||
|
||||
// AvAddStable adds a value to a timestamp.
|
||||
func AvAddStable(tsTb AvRational, ts int64, incTb AvRational, inc int64) int32 {
|
||||
return (int32)(C.av_add_stable((C.struct_AVRational)(tsTb), (C.int64_t)(ts),
|
||||
(C.struct_AVRational)(incTb), (C.int64_t)(inc)))
|
||||
}
|
129
avutil_mem.go
Normal file
129
avutil_mem.go
Normal file
@@ -0,0 +1,129 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/mem.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// AvMalloc allocates a memory block with alignment suitable for all memory accesses
|
||||
// (including vectors if available on the CPU).
|
||||
func AvMalloc(size uint) unsafe.Pointer {
|
||||
return (unsafe.Pointer)(C.av_malloc((C.size_t)(size)))
|
||||
}
|
||||
|
||||
// AvMallocz allocates a memory block with alignment suitable for all memory accesses
|
||||
// (including vectors if available on the CPU) and zero all the bytes of the
|
||||
// block.
|
||||
func AvMallocz(size uint) unsafe.Pointer {
|
||||
return (unsafe.Pointer)(C.av_mallocz((C.size_t)(size)))
|
||||
}
|
||||
|
||||
// AvMallocArray allocates a memory block for an array with AvMalloc().
|
||||
func AvMallocArray(nmemb, size uint) unsafe.Pointer {
|
||||
return (unsafe.Pointer)(C.av_malloc_array((C.size_t)(nmemb), (C.size_t)(size)))
|
||||
}
|
||||
|
||||
// AvMalloczArray allocates a memory block for an array with AvMallocz().
|
||||
func AvMalloczArray(nmemb, size uint) unsafe.Pointer {
|
||||
return C.av_mallocz_array((C.size_t)(nmemb), (C.size_t)(size))
|
||||
}
|
||||
|
||||
// AvCalloc is non-inlined equivalent of AvMalloczArray().
|
||||
func AvCalloc(nmemb, size uint) unsafe.Pointer {
|
||||
return C.av_calloc((C.size_t)(nmemb), (C.size_t)(size))
|
||||
}
|
||||
|
||||
// AvRealloc allocates, reallocates, or frees a block of memory.
|
||||
func AvRealloc(ptr unsafe.Pointer, size uint) unsafe.Pointer {
|
||||
return (unsafe.Pointer)(C.av_realloc(ptr, (C.size_t)(size)))
|
||||
}
|
||||
|
||||
// AvReallocp allocates, reallocates, or frees a block of memory through a pointer to a pointer.
|
||||
func AvReallocp(ptr unsafe.Pointer, size uint) int32 {
|
||||
return (int32)(C.av_reallocp(ptr, (C.size_t)(size)))
|
||||
}
|
||||
|
||||
// AvReallocF allocates, reallocates, or frees a block of memory.
|
||||
func AvReallocF(ptr unsafe.Pointer, nelem, elsize uint) unsafe.Pointer {
|
||||
return (unsafe.Pointer)(C.av_realloc_f(ptr, (C.size_t)(nelem), (C.size_t)(elsize)))
|
||||
}
|
||||
|
||||
// AvReallocpArray allocates, reallocates, or frees an array through a pointer to a pointer.
|
||||
func AvReallocpArray(ptr unsafe.Pointer, nmemb, size uint) int32 {
|
||||
return (int32)(C.av_reallocp_array(ptr, (C.size_t)(nmemb), (C.size_t)(size)))
|
||||
}
|
||||
|
||||
// AvFastRealloc reallocates the given buffer if it is not large enough, otherwise do nothing.
|
||||
func AvFastRealloc(ptr unsafe.Pointer, size *uint32, minSize uint) unsafe.Pointer {
|
||||
return (unsafe.Pointer)(C.av_fast_realloc(ptr, (*C.uint)(size), (C.size_t)(minSize)))
|
||||
}
|
||||
|
||||
// AvFastMalloc allocates a buffer, reusing the given one if large enough.
|
||||
func AvFastMalloc(ptr unsafe.Pointer, size *uint32, minSize uint) {
|
||||
C.av_fast_malloc(ptr, (*C.uint)(size), (C.size_t)(minSize))
|
||||
}
|
||||
|
||||
// AvFastMallocz allocates and clear a buffer, reusing the given one if large enough.
|
||||
func AvFastMallocz(ptr unsafe.Pointer, size *uint32, minSize uint) {
|
||||
C.av_fast_mallocz(ptr, (*C.uint)(size), (C.size_t)(minSize))
|
||||
}
|
||||
|
||||
// AvFree free a memory block which has been allocated with a function of AvMalloc()
|
||||
// or AvRealloc() family.
|
||||
func AvFree(ptr unsafe.Pointer) {
|
||||
C.av_free(ptr)
|
||||
}
|
||||
|
||||
// AvFreep frees a memory block which has been allocated with a function of AvMalloc()
|
||||
// or AvRealloc() family, and set the pointer pointing to it to `NULL`.
|
||||
func AvFreep(ptr unsafe.Pointer) {
|
||||
C.av_freep(ptr)
|
||||
}
|
||||
|
||||
// AvStrdup
|
||||
func AvStrdup(s *int8) *int8 {
|
||||
return (*int8)(C.av_strdup((*C.char)(s)))
|
||||
}
|
||||
|
||||
// AvStrndup
|
||||
func AvStrndup(s *int8, len uint) *int8 {
|
||||
return (*int8)(C.av_strndup((*C.char)(s), (C.size_t)(len)))
|
||||
}
|
||||
|
||||
// AvMemdup duplicates a buffer with av_malloc().
|
||||
func AvMemdup(p unsafe.Pointer, size uint) unsafe.Pointer {
|
||||
return (unsafe.Pointer)(C.av_memdup(p, (C.size_t)(size)))
|
||||
}
|
||||
|
||||
// Overlapping memcpy() implementation.
|
||||
func av_memcpy_backptr(dst *uint8, back, cnt int32) {
|
||||
C.av_memcpy_backptr((*C.uint8_t)(dst), (C.int)(back), (C.int)(cnt))
|
||||
}
|
||||
|
||||
// AvDynarrayAdd adds the pointer to an element to a dynamic array.
|
||||
func AvDynarrayAdd(tabPtr unsafe.Pointer, nbPtr *int32, elem unsafe.Pointer) {
|
||||
C.av_dynarray_add(tabPtr, (*C.int)(nbPtr), elem)
|
||||
}
|
||||
|
||||
// AvDynarrayAddNofree adds an element to a dynamic array.
|
||||
func AvDynarrayAddNofree(tabPtr unsafe.Pointer, nbPtr *int32, elem unsafe.Pointer) int32 {
|
||||
return (int32)(C.av_dynarray_add_nofree(tabPtr, (*C.int)(nbPtr), elem))
|
||||
}
|
||||
|
||||
// AvDynarray2Add adds an element of size `elem_size` to a dynamic array.
|
||||
func AvDynarray2Add(tabPtr *unsafe.Pointer, nbPtr *int32,
|
||||
elemSize uint, elemData *uint8) unsafe.Pointer {
|
||||
return (unsafe.Pointer)(C.av_dynarray2_add(tabPtr,
|
||||
(*C.int)(nbPtr), (C.size_t)(elemSize), (*C.uint8_t)(elemData)))
|
||||
}
|
||||
|
||||
// AvSizeMult multiplies two `size_t` values checking for overflow.
|
||||
func AvSizeMult(a, b uint, r *uint) int32 {
|
||||
return (int32)(C.av_size_mult((C.size_t)(a), (C.size_t)(b), (*C.size_t)(unsafe.Pointer(r))))
|
||||
}
|
||||
|
||||
// AvMaxAlloc sets the maximum size that may be allocated in one block.
|
||||
func AvMaxAlloc(max uint) {
|
||||
C.av_max_alloc((C.size_t)(max))
|
||||
}
|
423
avutil_opt.go
Normal file
423
avutil_opt.go
Normal file
@@ -0,0 +1,423 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/opt.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
type AvOptionType int32
|
||||
|
||||
const (
|
||||
AV_OPT_TYPE_FLAGS = int32(C.AV_OPT_TYPE_FLAGS)
|
||||
AV_OPT_TYPE_INT = int32(C.AV_OPT_TYPE_INT)
|
||||
AV_OPT_TYPE_INT64 = int32(C.AV_OPT_TYPE_INT64)
|
||||
AV_OPT_TYPE_DOUBLE = int32(C.AV_OPT_TYPE_DOUBLE)
|
||||
AV_OPT_TYPE_FLOAT = int32(C.AV_OPT_TYPE_FLOAT)
|
||||
AV_OPT_TYPE_STRING = int32(C.AV_OPT_TYPE_STRING)
|
||||
AV_OPT_TYPE_RATIONAL = int32(C.AV_OPT_TYPE_RATIONAL)
|
||||
AV_OPT_TYPE_BINARY = int32(C.AV_OPT_TYPE_BINARY)
|
||||
AV_OPT_TYPE_DICT = int32(C.AV_OPT_TYPE_DICT)
|
||||
AV_OPT_TYPE_UINT64 = int32(C.AV_OPT_TYPE_UINT64)
|
||||
AV_OPT_TYPE_CONST = int32(C.AV_OPT_TYPE_CONST)
|
||||
AV_OPT_TYPE_IMAGE_SIZE = int32(C.AV_OPT_TYPE_IMAGE_SIZE)
|
||||
AV_OPT_TYPE_PIXEL_FMT = int32(C.AV_OPT_TYPE_PIXEL_FMT)
|
||||
AV_OPT_TYPE_SAMPLE_FMT = int32(C.AV_OPT_TYPE_SAMPLE_FMT)
|
||||
AV_OPT_TYPE_VIDEO_RATE = int32(C.AV_OPT_TYPE_VIDEO_RATE)
|
||||
AV_OPT_TYPE_DURATION = int32(C.AV_OPT_TYPE_DURATION)
|
||||
AV_OPT_TYPE_COLOR = int32(C.AV_OPT_TYPE_COLOR)
|
||||
AV_OPT_TYPE_CHANNEL_LAYOUT = int32(C.AV_OPT_TYPE_CHANNEL_LAYOUT)
|
||||
AV_OPT_TYPE_BOOL = int32(C.AV_OPT_TYPE_BOOL)
|
||||
)
|
||||
|
||||
type AvOption C.struct_AVOption
|
||||
|
||||
const (
|
||||
AV_OPT_FLAG_ENCODING_PARAM = int32(C.AV_OPT_FLAG_ENCODING_PARAM)
|
||||
AV_OPT_FLAG_DECODING_PARAM = int32(C.AV_OPT_FLAG_DECODING_PARAM)
|
||||
AV_OPT_FLAG_AUDIO_PARAM = int32(C.AV_OPT_FLAG_AUDIO_PARAM)
|
||||
AV_OPT_FLAG_VIDEO_PARAM = int32(C.AV_OPT_FLAG_VIDEO_PARAM)
|
||||
AV_OPT_FLAG_SUBTITLE_PARAM = int32(C.AV_OPT_FLAG_SUBTITLE_PARAM)
|
||||
|
||||
AV_OPT_FLAG_EXPORT = int32(C.AV_OPT_FLAG_EXPORT)
|
||||
|
||||
AV_OPT_FLAG_READONLY = int32(C.AV_OPT_FLAG_READONLY)
|
||||
AV_OPT_FLAG_BSF_PARAM = int32(C.AV_OPT_FLAG_BSF_PARAM)
|
||||
AV_OPT_FLAG_RUNTIME_PARAM = int32(C.AV_OPT_FLAG_RUNTIME_PARAM)
|
||||
AV_OPT_FLAG_FILTERING_PARAM = int32(C.AV_OPT_FLAG_FILTERING_PARAM)
|
||||
AV_OPT_FLAG_DEPRECATED = int32(C.AV_OPT_FLAG_DEPRECATED)
|
||||
AV_OPT_FLAG_CHILD_CONSTS = int32(C.AV_OPT_FLAG_CHILD_CONSTS)
|
||||
)
|
||||
|
||||
type AvOptionRange C.struct_AVOptionRange
|
||||
|
||||
type AvOptionRanges C.struct_AVOptionRanges
|
||||
|
||||
// AvOptShow2 shows the obj options.
|
||||
func AvOptShow2(obj, avLogObj unsafe.Pointer, reqFlags, rejFlags int32) int32 {
|
||||
return (int32)(C.av_opt_show2(obj, avLogObj, (C.int)(reqFlags), (C.int)(rejFlags)))
|
||||
}
|
||||
|
||||
// AvOptSetDefaults sets the values of all AVOption fields to their default values.
|
||||
func AvOptSetDefaults(s unsafe.Pointer) {
|
||||
C.av_opt_set_defaults(s)
|
||||
}
|
||||
|
||||
// AvOptSetDefaults2 sets the values of all AVOption fields to their default values.
|
||||
func AvOptSetDefaults2(s unsafe.Pointer, mask, flags int32) {
|
||||
C.av_opt_set_defaults2(s, (C.int)(mask), (C.int)(flags))
|
||||
}
|
||||
|
||||
// AvSetOptionsString parses the key/value pairs list in opts. For each key/value pair
|
||||
// found, stores the value in the field in ctx that is named like the
|
||||
// key. ctx must be an AVClass context, storing is done using AVOptions.
|
||||
func AvSetOptionsString(ctx unsafe.Pointer, opts, keyValSep, pairsSep string) int32 {
|
||||
optsPtr, optsFunc := StringCasting(opts)
|
||||
defer optsFunc()
|
||||
keyValSepPtr, keyValSepFunc := StringCasting(keyValSep)
|
||||
defer keyValSepFunc()
|
||||
pairsSepPtr, pairsSepFunc := StringCasting(pairsSep)
|
||||
defer pairsSepFunc()
|
||||
return (int32)(C.av_set_options_string(ctx, (*C.char)(optsPtr),
|
||||
(*C.char)(keyValSepPtr), (*C.char)(pairsSepPtr)))
|
||||
}
|
||||
|
||||
// TODO. av_opt_set_from_string
|
||||
|
||||
// AvOptFree frees all allocated objects in obj.
|
||||
func AvOptFree(obj unsafe.Pointer) {
|
||||
C.av_opt_free(obj)
|
||||
}
|
||||
|
||||
// AvOptFlagIsSet checks whether a particular flag is set in a flags field.
|
||||
func AvOptFlagIsSet(obj unsafe.Pointer, fieldName, flagName string) int32 {
|
||||
fieldNamePtr, fieldNameFunc := StringCasting(fieldName)
|
||||
defer fieldNameFunc()
|
||||
flagNamePtr, flagNameFunc := StringCasting(flagName)
|
||||
defer flagNameFunc()
|
||||
return (int32)(C.av_opt_flag_is_set(obj, (*C.char)(fieldNamePtr), (*C.char)(flagNamePtr)))
|
||||
}
|
||||
|
||||
// AvOptSetDict sets all the options from a given dictionary on an object.
|
||||
func AvOptSetDict(obj unsafe.Pointer, options **AvDictionary) int32 {
|
||||
return (int32)(C.av_opt_set_dict(obj, (**C.struct_AVDictionary)(unsafe.Pointer(options))))
|
||||
}
|
||||
|
||||
// AvOptSetDict2 sets all the options from a given dictionary on an object.
|
||||
func AvOptSetDict2(obj unsafe.Pointer, options **AvDictionary, searchFlags int32) int32 {
|
||||
return (int32)(C.av_opt_set_dict2(obj, (**C.struct_AVDictionary)(unsafe.Pointer(options)),
|
||||
(C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
// TODO. av_opt_get_key_value
|
||||
|
||||
const (
|
||||
AV_OPT_FLAG_IMPLICIT_KEY = int32(C.AV_OPT_FLAG_IMPLICIT_KEY)
|
||||
)
|
||||
|
||||
// AvOptEvalFlags
|
||||
func AvOptEvalFlags(obj unsafe.Pointer, o *AvOption, val string, flags_out *int32) int32 {
|
||||
valPtr, valFunc := StringCasting(val)
|
||||
defer valFunc()
|
||||
return (int32)(C.av_opt_eval_flags(obj, (*C.struct_AVOption)(o), (*C.char)(valPtr), (*C.int)(flags_out)))
|
||||
}
|
||||
|
||||
// AvOptEvalInt
|
||||
func AvOptEvalInt(obj unsafe.Pointer, o *AvOption, val string, int_out *int32) int32 {
|
||||
valPtr, valFunc := StringCasting(val)
|
||||
defer valFunc()
|
||||
return (int32)(C.av_opt_eval_int(obj, (*C.struct_AVOption)(o), (*C.char)(valPtr), (*C.int)(int_out)))
|
||||
}
|
||||
|
||||
// AvOptEvalInt64
|
||||
func AvOptEvalInt64(obj unsafe.Pointer, o *AvOption, val string, int64_out *int64) int32 {
|
||||
valPtr, valFunc := StringCasting(val)
|
||||
defer valFunc()
|
||||
return (int32)(C.av_opt_eval_int64(obj, (*C.struct_AVOption)(o), (*C.char)(valPtr), (*C.int64_t)(int64_out)))
|
||||
}
|
||||
|
||||
// AvOptEvalFloat
|
||||
func AvOptEvalFloat(obj unsafe.Pointer, o *AvOption, val string, float_out *float32) int32 {
|
||||
valPtr, valFunc := StringCasting(val)
|
||||
defer valFunc()
|
||||
return (int32)(C.av_opt_eval_float(obj, (*C.struct_AVOption)(o), (*C.char)(valPtr), (*C.float)(float_out)))
|
||||
}
|
||||
|
||||
// AvOptEvalDouble
|
||||
func AvOptEvalDouble(obj unsafe.Pointer, o *AvOption, val string, double_out *float64) int32 {
|
||||
valPtr, valFunc := StringCasting(val)
|
||||
defer valFunc()
|
||||
return (int32)(C.av_opt_eval_double(obj, (*C.struct_AVOption)(o), (*C.char)(valPtr), (*C.double)(double_out)))
|
||||
}
|
||||
|
||||
// AvOptEvalQ
|
||||
func AvOptEvalQ(obj unsafe.Pointer, o *AvOption, val string, q_out *AvRational) int32 {
|
||||
valPtr, valFunc := StringCasting(val)
|
||||
defer valFunc()
|
||||
return (int32)(C.av_opt_eval_q(obj, (*C.struct_AVOption)(o), (*C.char)(valPtr), (*C.struct_AVRational)(q_out)))
|
||||
}
|
||||
|
||||
const (
|
||||
AV_OPT_SEARCH_CHILDREN = C.AV_OPT_SEARCH_CHILDREN
|
||||
AV_OPT_SEARCH_FAKE_OBJ = C.AV_OPT_SEARCH_FAKE_OBJ
|
||||
AV_OPT_ALLOW_NULL = C.AV_OPT_ALLOW_NULL
|
||||
AV_OPT_MULTI_COMPONENT_RANGE = C.AV_OPT_MULTI_COMPONENT_RANGE
|
||||
)
|
||||
|
||||
// AvOptFind looks for an option in an object. Consider only options which
|
||||
// have all the specified flags set.
|
||||
func AvOptFind(obj unsafe.Pointer, name, unit string, optFlags, searchFlags int32) *AvOption {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
unitPtr, unitFunc := StringCasting(unit)
|
||||
defer unitFunc()
|
||||
return (*AvOption)(C.av_opt_find(obj, namePtr, unitPtr, (C.int)(optFlags), (C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
// AvOptFind2 looks for an option in an object. Consider only options which
|
||||
// have all the specified flags set.
|
||||
func AvOptFind2(obj unsafe.Pointer, name, unit string, optFlags, searchFlags int32,
|
||||
targetObj *unsafe.Pointer) *AvOption {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
unitPtr, unitFunc := StringCasting(unit)
|
||||
defer unitFunc()
|
||||
return (*AvOption)(C.av_opt_find2(obj, namePtr, unitPtr,
|
||||
(C.int)(optFlags), (C.int)(searchFlags), targetObj))
|
||||
}
|
||||
|
||||
// AvOptNext iterates over all AVOptions belonging to obj.
|
||||
func AvOptNext(obj unsafe.Pointer, prev *AvOption) *AvOption {
|
||||
return (*AvOption)(C.av_opt_next(obj, (*C.struct_AVOption)(prev)))
|
||||
}
|
||||
|
||||
// AvOptChildNext iterates over AVOptions-enabled children of obj.
|
||||
func AvOptChildNext(obj, prev unsafe.Pointer) unsafe.Pointer {
|
||||
return C.av_opt_child_next(obj, prev)
|
||||
}
|
||||
|
||||
// Deprecated: Use AvOptChildClassIterate instead.
|
||||
func AvOptChildClassNext(parent, prev *AvClass) *AvClass {
|
||||
return (*AvClass)(C.av_opt_child_class_next((*C.struct_AVClass)(parent),
|
||||
(*C.struct_AVClass)(prev)))
|
||||
}
|
||||
|
||||
// AvOptChildClassIterate iterates over potential AVOptions-enabled children of parent.
|
||||
func AvOptChildClassIterate(parent *AvClass, iter *unsafe.Pointer) *AvClass {
|
||||
return (*AvClass)(C.av_opt_child_class_iterate((*C.struct_AVClass)(parent), iter))
|
||||
}
|
||||
|
||||
// AvOptSet
|
||||
func AvOptSet(obj unsafe.Pointer, name string, val string, searchFlags int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
valPtr, valFunc := StringCasting(val)
|
||||
defer valFunc()
|
||||
return (int32)(C.av_opt_set(obj, (*C.char)(namePtr), (*C.char)(valPtr), (C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
// AvOptSetInt
|
||||
func AvOptSetInt(obj unsafe.Pointer, name string, val int64, searchFlags int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_set_int(obj, (*C.char)(namePtr), (C.int64_t)(val), (C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
// AvOptSetDouble
|
||||
func AvOptSetDouble(obj unsafe.Pointer, name string, val float64, searchFlags int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_set_double(obj, (*C.char)(namePtr), (C.double)(val), (C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
// AvOptSetQ
|
||||
func AvOptSetQ(obj unsafe.Pointer, name string, val AvRational, searchFlags int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_set_q(obj, (*C.char)(namePtr), (C.AVRational)(val), (C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
// AvOptSetBin
|
||||
func AvOptSetBin(obj unsafe.Pointer, name string, val *uint8, size int32, searchFlags int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_set_bin(obj, (*C.char)(namePtr), (*C.uint8_t)(val), (C.int)(size), (C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
// AvOptSetImageSize
|
||||
func AvOptSetImageSize(obj unsafe.Pointer, name string, w, h int32, searchFlags int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_set_image_size(obj, (*C.char)(namePtr), (C.int)(w), (C.int)(h), (C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
// AvOptSetPixelFmt
|
||||
func AvOptSetPixelFmt(obj unsafe.Pointer, name string, fmt AvPixelFormat, searchFlags int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_set_pixel_fmt(obj, (*C.char)(namePtr), (C.enum_AVPixelFormat)(fmt), (C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
// AvOptSetSampleFmt
|
||||
func AvOptSetSampleFmt(obj unsafe.Pointer, name string, fmt AvSampleFormat, searchFlags int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_set_sample_fmt(obj, (*C.char)(namePtr), (C.enum_AVSampleFormat)(fmt), (C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
// AvOptSetVideoRate
|
||||
func AvOptSetVideoRate(obj unsafe.Pointer, name string, val AvRational, searchFlags int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_set_video_rate(obj, (*C.char)(namePtr), (C.struct_AVRational)(val), (C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
// AvOptSetChannelLayout
|
||||
func AvOptSetChannelLayout(obj unsafe.Pointer, name string, chLayout int64, searchFlags int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_set_channel_layout(obj, (*C.char)(namePtr), (C.int64_t)(chLayout), (C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
// AvOptSetDictVal
|
||||
func AvOptSetDictVal(obj unsafe.Pointer, name string, val *AvDictionary, searchFlags int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_set_dict_val(obj, (*C.char)(namePtr), (*C.struct_AVDictionary)(val), (C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
// TODO. av_opt_set_int_list
|
||||
|
||||
// AvOptGet
|
||||
func AvOptGet(obj unsafe.Pointer, name string, searchFlags int32, outVal **uint8) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_get(obj, (*C.char)(namePtr), (C.int)(searchFlags),
|
||||
(**C.uint8_t)(unsafe.Pointer(outVal))))
|
||||
}
|
||||
|
||||
// AvOptGetInt
|
||||
func AvOptGetInt(obj unsafe.Pointer, name string, searchFlags int32, outVal *int64) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_get_int(obj, (*C.char)(namePtr), (C.int)(searchFlags), (*C.int64_t)(outVal)))
|
||||
}
|
||||
|
||||
// AvOptGetDouble
|
||||
func AvOptGetDouble(obj unsafe.Pointer, name string, searchFlags int32, outVal *float64) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_get_double(obj, (*C.char)(namePtr), (C.int)(searchFlags), (*C.double)(outVal)))
|
||||
}
|
||||
|
||||
// AvOptGetQ
|
||||
func AvOptGetQ(obj unsafe.Pointer, name string, searchFlags int32, outVal *AvRational) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_get_q(obj, (*C.char)(namePtr), (C.int)(searchFlags), (*C.struct_AVRational)(outVal)))
|
||||
}
|
||||
|
||||
// AvOptGetImageSize
|
||||
func AvOptGetImageSize(obj unsafe.Pointer, name string, searchFlags int32, wOut, hOut *int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_get_image_size(obj, (*C.char)(namePtr), (C.int)(searchFlags), (*C.int)(wOut), (*C.int)(hOut)))
|
||||
}
|
||||
|
||||
// AvOptGetPixelFmt
|
||||
func AvOptGetPixelFmt(obj unsafe.Pointer, name string, searchFlags int32, outFmt *AvPixelFormat) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_get_pixel_fmt(obj, (*C.char)(namePtr), (C.int)(searchFlags), (*C.enum_AVPixelFormat)(outFmt)))
|
||||
}
|
||||
|
||||
// AvOptGetSampleFmt
|
||||
func AvOptGetSampleFmt(obj unsafe.Pointer, name string, searchFlags int32, outFmt *AvSampleFormat) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_get_sample_fmt(obj, (*C.char)(namePtr), (C.int)(searchFlags), (*C.enum_AVSampleFormat)(outFmt)))
|
||||
}
|
||||
|
||||
// AvOptGetVideoRate
|
||||
func AvOptGetVideoRate(obj unsafe.Pointer, name string, searchFlags int32, outVal *AvRational) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_get_video_rate(obj, (*C.char)(namePtr), (C.int)(searchFlags), (*C.struct_AVRational)(outVal)))
|
||||
}
|
||||
|
||||
// AvOptGetChannelLayout
|
||||
func AvOptGetChannelLayout(obj unsafe.Pointer, name string, searchFlags int32, outVal *int64) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_get_channel_layout(obj, (*C.char)(namePtr), (C.int)(searchFlags), (*C.int64_t)(outVal)))
|
||||
}
|
||||
|
||||
// AvOptGetDictVal
|
||||
func AvOptGetDictVal(obj unsafe.Pointer, name string, searchFlags int32, outVal **AvDictionary) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_get_dict_val(obj, (*C.char)(namePtr), (C.int)(searchFlags),
|
||||
(**C.struct_AVDictionary)(unsafe.Pointer(outVal))))
|
||||
}
|
||||
|
||||
// AvOptPtr gets a pointer to the requested field in a struct.
|
||||
func AvOptPtr(avclass *AvClass, obj unsafe.Pointer, name string) {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
C.av_opt_ptr((*C.struct_AVClass)(avclass), obj, (*C.char)(namePtr))
|
||||
}
|
||||
|
||||
// AvOptFreepRanges frees an AvOptionRanges struct and set it to NULL.
|
||||
func AvOptFreepRanges(ranges **AvOptionRanges) {
|
||||
C.av_opt_freep_ranges((**C.struct_AVOptionRanges)(unsafe.Pointer(ranges)))
|
||||
}
|
||||
|
||||
// AvOptQueryRanges gets a list of allowed ranges for the given option.
|
||||
func AvOptQueryRanges(ranges **AvOptionRanges, obj unsafe.Pointer, key string, flags int32) int32 {
|
||||
keyPtr, keyFunc := StringCasting(key)
|
||||
defer keyFunc()
|
||||
return (int32)(C.av_opt_query_ranges((**C.struct_AVOptionRanges)(unsafe.Pointer(ranges)),
|
||||
obj, (*C.char)(keyPtr), (C.int)(flags)))
|
||||
}
|
||||
|
||||
// AvOptCopy copies options from src object into dest object.
|
||||
func AvOptCopy(dest, src unsafe.Pointer) int32 {
|
||||
return (int32)(C.av_opt_copy(dest, src))
|
||||
}
|
||||
|
||||
// AvOptQueryRangesDefault gets a default list of allowed ranges for the given option.
|
||||
func AvOptQueryRangesDefault(ranges **AvOptionRanges, obj unsafe.Pointer, key string, flags int32) int32 {
|
||||
keyPtr, keyFunc := StringCasting(key)
|
||||
defer keyFunc()
|
||||
return (int32)(C.av_opt_query_ranges_default((**C.struct_AVOptionRanges)(unsafe.Pointer(ranges)),
|
||||
obj, (*C.char)(keyPtr), (C.int)(flags)))
|
||||
}
|
||||
|
||||
// AvOptIsSetToDefault checks if given option is set to its default value.
|
||||
func AvOptIsSetToDefault(obj unsafe.Pointer, o *AvOption) int32 {
|
||||
return (int32)(C.av_opt_is_set_to_default(obj, (*C.struct_AVOption)(o)))
|
||||
}
|
||||
|
||||
// AvOptIsSetToDefaultByName checks if given option is set to its default value.
|
||||
func AvOptIsSetToDefaultByName(obj unsafe.Pointer, name string, searchFlags int32) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_opt_is_set_to_default_by_name(obj, (*C.char)(namePtr), (C.int)(searchFlags)))
|
||||
}
|
||||
|
||||
const (
|
||||
AV_OPT_SERIALIZE_SKIP_DEFAULTS = int32(C.AV_OPT_SERIALIZE_SKIP_DEFAULTS)
|
||||
AV_OPT_SERIALIZE_OPT_FLAGS_EXACT = int32(C.AV_OPT_SERIALIZE_OPT_FLAGS_EXACT)
|
||||
)
|
||||
|
||||
// AvOptSerialize serializes object's options.
|
||||
func AvOptSerialize(obj unsafe.Pointer, optFlags, flags int32, keyValSep, pairsSep string) (output string, ret int32) {
|
||||
var buffer *C.char
|
||||
keyValSepPtr, keyValSepFunc := StringCasting(keyValSep)
|
||||
defer keyValSepFunc()
|
||||
pairsSepPtr, pairsSepFunc := StringCasting(pairsSep)
|
||||
defer pairsSepFunc()
|
||||
ret = (int32)(C.av_opt_serialize(obj, (C.int)(optFlags), (C.int)(flags),
|
||||
(**C.char)(unsafe.Pointer(&buffer)), (C.char)(*keyValSepPtr), (C.char)(*pairsSepPtr)))
|
||||
return C.GoString(buffer), ret
|
||||
}
|
220
avutil_pixdesc.go
Normal file
220
avutil_pixdesc.go
Normal file
@@ -0,0 +1,220 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/pixdesc.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
type AvComponentDescriptor C.struct_AVComponentDescriptor
|
||||
|
||||
type AvPixFmtDescriptor C.struct_AVPixFmtDescriptor
|
||||
|
||||
const (
|
||||
AV_PIX_FMT_FLAG_BE = C.AV_PIX_FMT_FLAG_BE
|
||||
AV_PIX_FMT_FLAG_PAL = C.AV_PIX_FMT_FLAG_PAL
|
||||
AV_PIX_FMT_FLAG_BITSTREAM = C.AV_PIX_FMT_FLAG_BITSTREAM
|
||||
AV_PIX_FMT_FLAG_HWACCEL = C.AV_PIX_FMT_FLAG_HWACCEL
|
||||
AV_PIX_FMT_FLAG_PLANAR = C.AV_PIX_FMT_FLAG_PLANAR
|
||||
AV_PIX_FMT_FLAG_RGB = C.AV_PIX_FMT_FLAG_RGB
|
||||
AV_PIX_FMT_FLAG_PSEUDOPAL = C.AV_PIX_FMT_FLAG_PSEUDOPAL
|
||||
AV_PIX_FMT_FLAG_ALPHA = C.AV_PIX_FMT_FLAG_ALPHA
|
||||
AV_PIX_FMT_FLAG_BAYER = C.AV_PIX_FMT_FLAG_BAYER
|
||||
AV_PIX_FMT_FLAG_FLOAT = C.AV_PIX_FMT_FLAG_FLOAT
|
||||
)
|
||||
|
||||
// AvGetBitsPerPixel returns the number of bits per pixel used by the pixel format
|
||||
// described by pixdesc.
|
||||
func AvGetBitsPerPixel(pixdesc *AvPixFmtDescriptor) int32 {
|
||||
return (int32)(C.av_get_bits_per_pixel((*C.struct_AVPixFmtDescriptor)(pixdesc)))
|
||||
}
|
||||
|
||||
// AvGetPaddedBitsPerPixel returns the number of bits per pixel for the pixel format
|
||||
// described by pixdesc, including any padding or unused bits.
|
||||
func AvGetPaddedBitsPerPixel(pixdesc *AvPixFmtDescriptor) int32 {
|
||||
return (int32)(C.av_get_padded_bits_per_pixel((*C.struct_AVPixFmtDescriptor)(pixdesc)))
|
||||
}
|
||||
|
||||
// AvPixFmtDescGet returns a pixel format descriptor for provided pixel format or NULL if
|
||||
// this pixel format is unknown.
|
||||
func AvPixFmtDescGet(pixFmt AvPixelFormat) *AvPixFmtDescriptor {
|
||||
return (*AvPixFmtDescriptor)(C.av_pix_fmt_desc_get((C.enum_AVPixelFormat)(pixFmt)))
|
||||
}
|
||||
|
||||
// AvPixFmtDescNext iterates over all pixel format descriptors known to libavutil.
|
||||
func AvPixFmtDescNext(prev *AvPixFmtDescriptor) *AvPixFmtDescriptor {
|
||||
return (*AvPixFmtDescriptor)(C.av_pix_fmt_desc_next((*C.struct_AVPixFmtDescriptor)(prev)))
|
||||
}
|
||||
|
||||
// AvPixFmtDescGetId returns an AvPixelFormat id described by desc, or AV_PIX_FMT_NONE if desc
|
||||
// is not a valid pointer to a pixel format descriptor.
|
||||
func AvPixFmtDescGetId(desc *AvPixFmtDescriptor) AvPixelFormat {
|
||||
return (AvPixelFormat)(C.av_pix_fmt_desc_get_id((*C.struct_AVPixFmtDescriptor)(desc)))
|
||||
}
|
||||
|
||||
// AvPixFmtGetChromaSubSample accesses log2_chroma_w log2_chroma_h from the pixel format AvPixFmtDescriptor.
|
||||
func AvPixFmtGetChromaSubSample(pixFmt AvPixelFormat, hShift, vShift *int32) int32 {
|
||||
return (int32)(C.av_pix_fmt_get_chroma_sub_sample((C.enum_AVPixelFormat)(pixFmt),
|
||||
(*C.int)(hShift), (*C.int)(vShift)))
|
||||
}
|
||||
|
||||
// AvPixFmtCountPlanes returns number of planes in pix_fmt, a negative AvERROR if pix_fmt is not a
|
||||
// valid pixel format.
|
||||
func AvPixFmtCountPlanes(pixFmt AvPixelFormat) int32 {
|
||||
return (int32)(C.av_pix_fmt_count_planes((C.enum_AVPixelFormat)(pixFmt)))
|
||||
}
|
||||
|
||||
// AvColorRangeName returns the name for provided color range or NULL if unknown.
|
||||
func AvColorRangeName(_range AvColorRange) string {
|
||||
return C.GoString(C.av_color_range_name((C.enum_AVColorRange)(_range)))
|
||||
}
|
||||
|
||||
// AvColorRangeFromName returns the AvColorRange value for name or an AvError if not found.
|
||||
func AvColorRangeFromName(name string) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_color_range_from_name((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvColorPrimariesName returns the name for provided color primaries or NULL if unknown.
|
||||
func AvColorPrimariesName(primaries AvColorPrimaries) string {
|
||||
return C.GoString(C.av_color_primaries_name((C.enum_AVColorRange)(primaries)))
|
||||
}
|
||||
|
||||
// AvColorPrimariesFromName returns the AvColorPrimaries value for name or an AVError if not found.
|
||||
func AvColorPrimariesFromName(name string) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_color_primaries_from_name((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvColorTransferName returns the name for provided color transfer or NULL if unknown.
|
||||
func AvColorTransferName(transfer AvColorTransferCharacteristic) string {
|
||||
return C.GoString(C.av_color_transfer_name((C.enum_AVColorTransferCharacteristic)(transfer)))
|
||||
}
|
||||
|
||||
// AvColorTransferFromName returns the AvColorTransferCharacteristic value for name or an AvError if not found.
|
||||
func AvColorTransferFromName(name string) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_color_transfer_from_name((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvColorSpaceName returns the name for provided color space or NULL if unknown.
|
||||
func AvColorSpaceName(space AvColorSpace) string {
|
||||
return C.GoString(C.av_color_space_name((C.enum_AVColorSpace)(space)))
|
||||
}
|
||||
|
||||
// AvColorSpaceFromName returns the AvColorSpace value for name or an AvError if not found.
|
||||
func AvColorSpaceFromName(name string) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_color_space_from_name((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvChromaLocationName returns the name for provided chroma location or NULL if unknown.
|
||||
func AvChromaLocationName(location AvChromaLocation) string {
|
||||
return C.GoString(C.av_chroma_location_name((C.enum_AVChromaLocation)(location)))
|
||||
}
|
||||
|
||||
// AvChromaLocationFromName returns the AvChromaLocation value for name or an AVError if not found.
|
||||
func AvChromaLocationFromName(name string) int32 {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (int32)(C.av_chroma_location_from_name((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvGetPixFmt returns the pixel format corresponding to name.
|
||||
func AvGetPixFmt(name string) AvPixelFormat {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (AvPixelFormat)(C.av_get_pix_fmt((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvGetPixFmtName returns the short name for a pixel format, NULL in case pix_fmt is unknown.
|
||||
func AvGetPixFmtName(pixFmt AvPixelFormat) string {
|
||||
return C.GoString(C.av_get_pix_fmt_name((C.enum_AVPixelFormat)(pixFmt)))
|
||||
}
|
||||
|
||||
// AvGetPixFmtString prints in buf the string corresponding to the pixel format with
|
||||
// number pix_fmt, or a header if pix_fmt is negative.
|
||||
func AvGetPixFmtString(buf *int8, bufSize int32, pixFmt AvPixelFormat) string {
|
||||
return C.GoString(C.av_get_pix_fmt_string((*C.char)(buf), (C.int)(bufSize),
|
||||
(C.enum_AVPixelFormat)(pixFmt)))
|
||||
}
|
||||
|
||||
// AvReadImageLine2 reads a line from an image, and write the values of the
|
||||
// pixel format component c to dst.
|
||||
func AvReadImageLine2(dst unsafe.Pointer, data [4]*uint8, linesize [4]int,
|
||||
desc *AvPixFmtDescriptor, x, y, c, w, readPalComponent, dstElementSize int32) {
|
||||
C.av_read_image_line2(dst,
|
||||
(**C.uint8_t)(unsafe.Pointer(&data[0])),
|
||||
(*C.int)(unsafe.Pointer(&linesize[0])),
|
||||
(*C.struct_AVPixFmtDescriptor)(desc),
|
||||
(C.int)(x), (C.int)(y), (C.int)(c), (C.int)(w),
|
||||
(C.int)(readPalComponent), (C.int)(dstElementSize))
|
||||
}
|
||||
|
||||
// AvReadImageLine reads a line from an image, and write the values of the
|
||||
// pixel format component c to dst.
|
||||
func AvReadImageLine(dst *uint16, data [4]*uint8, linesize [4]int,
|
||||
desc *AvPixFmtDescriptor, x, y, c, w, readPalComponent int32) {
|
||||
C.av_read_image_line((*C.uint16_t)(dst),
|
||||
(**C.uint8_t)(unsafe.Pointer(&data[0])),
|
||||
(*C.int)(unsafe.Pointer(&linesize[0])),
|
||||
(*C.struct_AVPixFmtDescriptor)(desc),
|
||||
(C.int)(x), (C.int)(y), (C.int)(c), (C.int)(w),
|
||||
(C.int)(readPalComponent))
|
||||
}
|
||||
|
||||
// AvWriteImageLine2 writes the values from src to the pixel format component c of an image line.
|
||||
func AvWriteImageLine2(src unsafe.Pointer, data [4]*uint8, linesize [4]int,
|
||||
desc *AvPixFmtDescriptor, x, y, c, w, srcElementSize int32) {
|
||||
C.av_write_image_line2(src,
|
||||
(**C.uint8_t)(unsafe.Pointer(&data[0])),
|
||||
(*C.int)(unsafe.Pointer(&linesize[0])),
|
||||
(*C.struct_AVPixFmtDescriptor)(desc),
|
||||
(C.int)(x), (C.int)(y), (C.int)(c), (C.int)(w),
|
||||
(C.int)(srcElementSize))
|
||||
}
|
||||
|
||||
// AvWriteImageLine writes the values from src to the pixel format component c of an image line.
|
||||
func AvWriteImageLine(src *uint16, data [4]*uint8, linesize [4]int,
|
||||
desc *AvPixFmtDescriptor, x, y, c, w int32) {
|
||||
C.av_write_image_line((*C.uint16_t)(src),
|
||||
(**C.uint8_t)(unsafe.Pointer(&data[0])),
|
||||
(*C.int)(unsafe.Pointer(&linesize[0])),
|
||||
(*C.struct_AVPixFmtDescriptor)(desc),
|
||||
(C.int)(x), (C.int)(y), (C.int)(c), (C.int)(w))
|
||||
}
|
||||
|
||||
// AvPixFmtSwapEndianness
|
||||
func AvPixFmtSwapEndianness(pixFmt AvPixelFormat) AvPixelFormat {
|
||||
return (AvPixelFormat)(C.av_pix_fmt_swap_endianness((C.enum_AVPixelFormat)(pixFmt)))
|
||||
}
|
||||
|
||||
const (
|
||||
FF_LOSS_RESOLUTION = C.FF_LOSS_RESOLUTION
|
||||
FF_LOSS_DEPTH = C.FF_LOSS_DEPTH
|
||||
FF_LOSS_COLORSPACE = C.FF_LOSS_COLORSPACE
|
||||
FF_LOSS_ALPHA = C.FF_LOSS_ALPHA
|
||||
FF_LOSS_COLORQUANT = C.FF_LOSS_COLORQUANT
|
||||
FF_LOSS_CHROMA = C.FF_LOSS_CHROMA
|
||||
)
|
||||
|
||||
// AvGetPixFmtLoss computes what kind of losses will occur when converting from one specific
|
||||
// pixel format to another.
|
||||
func AvGetPixFmtLoss(dstPixFmt, srcPixFmt AvPixelFormat, hasAlpha int32) int32 {
|
||||
return (int32)(C.av_get_pix_fmt_loss((C.enum_AVPixelFormat)(dstPixFmt),
|
||||
(C.enum_AVPixelFormat)(srcPixFmt), (C.int)(hasAlpha)))
|
||||
}
|
||||
|
||||
// AvFindBestPixFmtOf2 compute what kind of losses will occur when converting from one specific
|
||||
// pixel format to another.
|
||||
func AvFindBestPixFmtOf2(dstPixFmt1, dstPixFmt2, srcPixFmt AvPixelFormat,
|
||||
hasAlpha int32, lossPtr *int32) AvPixelFormat {
|
||||
return (AvPixelFormat)(C.av_find_best_pix_fmt_of_2((C.enum_AVPixelFormat)(dstPixFmt1),
|
||||
(C.enum_AVPixelFormat)(dstPixFmt2),
|
||||
(C.enum_AVPixelFormat)(srcPixFmt),
|
||||
(C.int)(hasAlpha), (*C.int)(lossPtr)))
|
||||
}
|
442
avutil_pixfmt.go
Normal file
442
avutil_pixfmt.go
Normal file
@@ -0,0 +1,442 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/pixfmt.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
// Pixel format.
|
||||
type AvPixelFormat int32
|
||||
|
||||
const (
|
||||
AV_PIX_FMT_NONE = AvPixelFormat(C.AV_PIX_FMT_NONE)
|
||||
AV_PIX_FMT_YUV420P = AvPixelFormat(C.AV_PIX_FMT_YUV420P)
|
||||
AV_PIX_FMT_YUYV422 = AvPixelFormat(C.AV_PIX_FMT_YUYV422)
|
||||
AV_PIX_FMT_RGB24 = AvPixelFormat(C.AV_PIX_FMT_RGB24)
|
||||
AV_PIX_FMT_BGR24 = AvPixelFormat(C.AV_PIX_FMT_BGR24)
|
||||
AV_PIX_FMT_YUV422P = AvPixelFormat(C.AV_PIX_FMT_YUV422P)
|
||||
AV_PIX_FMT_YUV444P = AvPixelFormat(C.AV_PIX_FMT_YUV444P)
|
||||
AV_PIX_FMT_YUV410P = AvPixelFormat(C.AV_PIX_FMT_YUV410P)
|
||||
AV_PIX_FMT_YUV411P = AvPixelFormat(C.AV_PIX_FMT_YUV411P)
|
||||
AV_PIX_FMT_GRAY8 = AvPixelFormat(C.AV_PIX_FMT_GRAY8)
|
||||
AV_PIX_FMT_MONOWHITE = AvPixelFormat(C.AV_PIX_FMT_MONOWHITE)
|
||||
AV_PIX_FMT_MONOBLACK = AvPixelFormat(C.AV_PIX_FMT_MONOBLACK)
|
||||
AV_PIX_FMT_PAL8 = AvPixelFormat(C.AV_PIX_FMT_PAL8)
|
||||
AV_PIX_FMT_YUVJ420P = AvPixelFormat(C.AV_PIX_FMT_YUVJ420P)
|
||||
AV_PIX_FMT_YUVJ422P = AvPixelFormat(C.AV_PIX_FMT_YUVJ422P)
|
||||
AV_PIX_FMT_YUVJ444P = AvPixelFormat(C.AV_PIX_FMT_YUVJ444P)
|
||||
AV_PIX_FMT_UYVY422 = AvPixelFormat(C.AV_PIX_FMT_UYVY422)
|
||||
AV_PIX_FMT_UYYVYY411 = AvPixelFormat(C.AV_PIX_FMT_UYYVYY411)
|
||||
AV_PIX_FMT_BGR8 = AvPixelFormat(C.AV_PIX_FMT_BGR8)
|
||||
AV_PIX_FMT_BGR4 = AvPixelFormat(C.AV_PIX_FMT_BGR4)
|
||||
AV_PIX_FMT_BGR4_BYTE = AvPixelFormat(C.AV_PIX_FMT_BGR4_BYTE)
|
||||
AV_PIX_FMT_RGB8 = AvPixelFormat(C.AV_PIX_FMT_RGB8)
|
||||
AV_PIX_FMT_RGB4 = AvPixelFormat(C.AV_PIX_FMT_RGB4)
|
||||
AV_PIX_FMT_RGB4_BYTE = AvPixelFormat(C.AV_PIX_FMT_RGB4_BYTE)
|
||||
AV_PIX_FMT_NV12 = AvPixelFormat(C.AV_PIX_FMT_NV12)
|
||||
AV_PIX_FMT_NV21 = AvPixelFormat(C.AV_PIX_FMT_NV21)
|
||||
|
||||
AV_PIX_FMT_ARGB = AvPixelFormat(C.AV_PIX_FMT_ARGB)
|
||||
AV_PIX_FMT_RGBA = AvPixelFormat(C.AV_PIX_FMT_RGBA)
|
||||
AV_PIX_FMT_ABGR = AvPixelFormat(C.AV_PIX_FMT_ABGR)
|
||||
AV_PIX_FMT_BGRA = AvPixelFormat(C.AV_PIX_FMT_BGRA)
|
||||
|
||||
AV_PIX_FMT_GRAY16BE = AvPixelFormat(C.AV_PIX_FMT_GRAY16BE)
|
||||
AV_PIX_FMT_GRAY16LE = AvPixelFormat(C.AV_PIX_FMT_GRAY16LE)
|
||||
AV_PIX_FMT_YUV440P = AvPixelFormat(C.AV_PIX_FMT_YUV440P)
|
||||
AV_PIX_FMT_YUVJ440P = AvPixelFormat(C.AV_PIX_FMT_YUVJ440P)
|
||||
AV_PIX_FMT_YUVA420P = AvPixelFormat(C.AV_PIX_FMT_YUVA420P)
|
||||
AV_PIX_FMT_RGB48BE = AvPixelFormat(C.AV_PIX_FMT_RGB48BE)
|
||||
AV_PIX_FMT_RGB48LE = AvPixelFormat(C.AV_PIX_FMT_RGB48LE)
|
||||
|
||||
AV_PIX_FMT_RGB565BE = AvPixelFormat(C.AV_PIX_FMT_RGB565BE)
|
||||
AV_PIX_FMT_RGB565LE = AvPixelFormat(C.AV_PIX_FMT_RGB565LE)
|
||||
AV_PIX_FMT_RGB555BE = AvPixelFormat(C.AV_PIX_FMT_RGB555BE)
|
||||
AV_PIX_FMT_RGB555LE = AvPixelFormat(C.AV_PIX_FMT_RGB555LE)
|
||||
|
||||
AV_PIX_FMT_BGR565BE = AvPixelFormat(C.AV_PIX_FMT_BGR565BE)
|
||||
AV_PIX_FMT_BGR565LE = AvPixelFormat(C.AV_PIX_FMT_BGR565LE)
|
||||
AV_PIX_FMT_BGR555BE = AvPixelFormat(C.AV_PIX_FMT_BGR555BE)
|
||||
AV_PIX_FMT_BGR555LE = AvPixelFormat(C.AV_PIX_FMT_BGR555LE)
|
||||
|
||||
AV_PIX_FMT_VAAPI_MOCO = AvPixelFormat(C.AV_PIX_FMT_VAAPI_MOCO)
|
||||
AV_PIX_FMT_VAAPI_IDCT = AvPixelFormat(C.AV_PIX_FMT_VAAPI_IDCT)
|
||||
AV_PIX_FMT_VAAPI_VLD = AvPixelFormat(C.AV_PIX_FMT_VAAPI_VLD)
|
||||
AV_PIX_FMT_VAAPI = AvPixelFormat(C.AV_PIX_FMT_VAAPI)
|
||||
|
||||
AV_PIX_FMT_YUV420P16LE = AvPixelFormat(C.AV_PIX_FMT_YUV420P16LE)
|
||||
AV_PIX_FMT_YUV420P16BE = AvPixelFormat(C.AV_PIX_FMT_YUV420P16BE)
|
||||
AV_PIX_FMT_YUV422P16LE = AvPixelFormat(C.AV_PIX_FMT_YUV422P16LE)
|
||||
AV_PIX_FMT_YUV422P16BE = AvPixelFormat(C.AV_PIX_FMT_YUV422P16BE)
|
||||
AV_PIX_FMT_YUV444P16LE = AvPixelFormat(C.AV_PIX_FMT_YUV444P16LE)
|
||||
AV_PIX_FMT_YUV444P16BE = AvPixelFormat(C.AV_PIX_FMT_YUV444P16BE)
|
||||
AV_PIX_FMT_DXVA2_VLD = AvPixelFormat(C.AV_PIX_FMT_DXVA2_VLD)
|
||||
|
||||
AV_PIX_FMT_RGB444LE = AvPixelFormat(C.AV_PIX_FMT_RGB444LE)
|
||||
AV_PIX_FMT_RGB444BE = AvPixelFormat(C.AV_PIX_FMT_RGB444BE)
|
||||
AV_PIX_FMT_BGR444LE = AvPixelFormat(C.AV_PIX_FMT_BGR444LE)
|
||||
AV_PIX_FMT_BGR444BE = AvPixelFormat(C.AV_PIX_FMT_BGR444BE)
|
||||
AV_PIX_FMT_YA8 = AvPixelFormat(C.AV_PIX_FMT_YA8)
|
||||
|
||||
AV_PIX_FMT_Y400A = AvPixelFormat(C.AV_PIX_FMT_Y400A)
|
||||
AV_PIX_FMT_GRAY8A = AvPixelFormat(C.AV_PIX_FMT_GRAY8A)
|
||||
|
||||
AV_PIX_FMT_BGR48BE = AvPixelFormat(C.AV_PIX_FMT_BGR48BE)
|
||||
AV_PIX_FMT_BGR48LE = AvPixelFormat(C.AV_PIX_FMT_BGR48LE)
|
||||
|
||||
AV_PIX_FMT_YUV420P9BE = AvPixelFormat(C.AV_PIX_FMT_YUV420P9BE)
|
||||
AV_PIX_FMT_YUV420P9LE = AvPixelFormat(C.AV_PIX_FMT_YUV420P9LE)
|
||||
AV_PIX_FMT_YUV420P10BE = AvPixelFormat(C.AV_PIX_FMT_YUV420P10BE)
|
||||
AV_PIX_FMT_YUV420P10LE = AvPixelFormat(C.AV_PIX_FMT_YUV420P10LE)
|
||||
AV_PIX_FMT_YUV422P10BE = AvPixelFormat(C.AV_PIX_FMT_YUV422P10BE)
|
||||
AV_PIX_FMT_YUV422P10LE = AvPixelFormat(C.AV_PIX_FMT_YUV422P10LE)
|
||||
AV_PIX_FMT_YUV444P9BE = AvPixelFormat(C.AV_PIX_FMT_YUV444P9BE)
|
||||
AV_PIX_FMT_YUV444P9LE = AvPixelFormat(C.AV_PIX_FMT_YUV444P9LE)
|
||||
AV_PIX_FMT_YUV444P10BE = AvPixelFormat(C.AV_PIX_FMT_YUV444P10BE)
|
||||
AV_PIX_FMT_YUV444P10LE = AvPixelFormat(C.AV_PIX_FMT_YUV444P10LE)
|
||||
AV_PIX_FMT_YUV422P9BE = AvPixelFormat(C.AV_PIX_FMT_YUV422P9BE)
|
||||
AV_PIX_FMT_YUV422P9LE = AvPixelFormat(C.AV_PIX_FMT_YUV422P9LE)
|
||||
AV_PIX_FMT_GBRP = AvPixelFormat(C.AV_PIX_FMT_GBRP)
|
||||
AV_PIX_FMT_GBR24P = AvPixelFormat(C.AV_PIX_FMT_GBR24P)
|
||||
AV_PIX_FMT_GBRP9BE = AvPixelFormat(C.AV_PIX_FMT_GBRP9BE)
|
||||
AV_PIX_FMT_GBRP9LE = AvPixelFormat(C.AV_PIX_FMT_GBRP9LE)
|
||||
AV_PIX_FMT_GBRP10BE = AvPixelFormat(C.AV_PIX_FMT_GBRP10BE)
|
||||
AV_PIX_FMT_GBRP10LE = AvPixelFormat(C.AV_PIX_FMT_GBRP10LE)
|
||||
AV_PIX_FMT_GBRP16BE = AvPixelFormat(C.AV_PIX_FMT_GBRP16BE)
|
||||
AV_PIX_FMT_GBRP16LE = AvPixelFormat(C.AV_PIX_FMT_GBRP16LE)
|
||||
AV_PIX_FMT_YUVA422P = AvPixelFormat(C.AV_PIX_FMT_YUVA422P)
|
||||
AV_PIX_FMT_YUVA444P = AvPixelFormat(C.AV_PIX_FMT_YUVA444P)
|
||||
AV_PIX_FMT_YUVA420P9BE = AvPixelFormat(C.AV_PIX_FMT_YUVA420P9BE)
|
||||
AV_PIX_FMT_YUVA420P9LE = AvPixelFormat(C.AV_PIX_FMT_YUVA420P9LE)
|
||||
AV_PIX_FMT_YUVA422P9BE = AvPixelFormat(C.AV_PIX_FMT_YUVA422P9BE)
|
||||
AV_PIX_FMT_YUVA422P9LE = AvPixelFormat(C.AV_PIX_FMT_YUVA422P9LE)
|
||||
AV_PIX_FMT_YUVA444P9BE = AvPixelFormat(C.AV_PIX_FMT_YUVA444P9BE)
|
||||
AV_PIX_FMT_YUVA444P9LE = AvPixelFormat(C.AV_PIX_FMT_YUVA444P9LE)
|
||||
AV_PIX_FMT_YUVA420P10BE = AvPixelFormat(C.AV_PIX_FMT_YUVA420P10BE)
|
||||
AV_PIX_FMT_YUVA420P10LE = AvPixelFormat(C.AV_PIX_FMT_YUVA420P10LE)
|
||||
AV_PIX_FMT_YUVA422P10BE = AvPixelFormat(C.AV_PIX_FMT_YUVA422P10BE)
|
||||
AV_PIX_FMT_YUVA422P10LE = AvPixelFormat(C.AV_PIX_FMT_YUVA422P10LE)
|
||||
AV_PIX_FMT_YUVA444P10BE = AvPixelFormat(C.AV_PIX_FMT_YUVA444P10BE)
|
||||
AV_PIX_FMT_YUVA444P10LE = AvPixelFormat(C.AV_PIX_FMT_YUVA444P10LE)
|
||||
AV_PIX_FMT_YUVA420P16BE = AvPixelFormat(C.AV_PIX_FMT_YUVA420P16BE)
|
||||
AV_PIX_FMT_YUVA420P16LE = AvPixelFormat(C.AV_PIX_FMT_YUVA420P16LE)
|
||||
AV_PIX_FMT_YUVA422P16BE = AvPixelFormat(C.AV_PIX_FMT_YUVA422P16BE)
|
||||
AV_PIX_FMT_YUVA422P16LE = AvPixelFormat(C.AV_PIX_FMT_YUVA422P16LE)
|
||||
AV_PIX_FMT_YUVA444P16BE = AvPixelFormat(C.AV_PIX_FMT_YUVA444P16BE)
|
||||
AV_PIX_FMT_YUVA444P16LE = AvPixelFormat(C.AV_PIX_FMT_YUVA444P16LE)
|
||||
|
||||
AV_PIX_FMT_VDPAU = AvPixelFormat(C.AV_PIX_FMT_VDPAU)
|
||||
|
||||
AV_PIX_FMT_XYZ12LE = AvPixelFormat(C.AV_PIX_FMT_XYZ12LE)
|
||||
AV_PIX_FMT_XYZ12BE = AvPixelFormat(C.AV_PIX_FMT_XYZ12BE)
|
||||
AV_PIX_FMT_NV16 = AvPixelFormat(C.AV_PIX_FMT_NV16)
|
||||
AV_PIX_FMT_NV20LE = AvPixelFormat(C.AV_PIX_FMT_NV20LE)
|
||||
AV_PIX_FMT_NV20BE = AvPixelFormat(C.AV_PIX_FMT_NV20BE)
|
||||
AV_PIX_FMT_RGBA64BE = AvPixelFormat(C.AV_PIX_FMT_RGBA64BE)
|
||||
AV_PIX_FMT_RGBA64LE = AvPixelFormat(C.AV_PIX_FMT_RGBA64LE)
|
||||
AV_PIX_FMT_BGRA64BE = AvPixelFormat(C.AV_PIX_FMT_BGRA64BE)
|
||||
AV_PIX_FMT_BGRA64LE = AvPixelFormat(C.AV_PIX_FMT_BGRA64LE)
|
||||
|
||||
AV_PIX_FMT_YVYU422 = AvPixelFormat(C.AV_PIX_FMT_YVYU422)
|
||||
|
||||
AV_PIX_FMT_YA16BE = AvPixelFormat(C.AV_PIX_FMT_YA16BE)
|
||||
AV_PIX_FMT_YA16LE = AvPixelFormat(C.AV_PIX_FMT_YA16LE)
|
||||
|
||||
AV_PIX_FMT_GBRAP = AvPixelFormat(C.AV_PIX_FMT_GBRAP)
|
||||
AV_PIX_FMT_GBRAP16BE = AvPixelFormat(C.AV_PIX_FMT_GBRAP16BE)
|
||||
AV_PIX_FMT_GBRAP16LE = AvPixelFormat(C.AV_PIX_FMT_GBRAP16LE)
|
||||
|
||||
AV_PIX_FMT_QSV = AvPixelFormat(C.AV_PIX_FMT_QSV)
|
||||
|
||||
AV_PIX_FMT_MMAL = AvPixelFormat(C.AV_PIX_FMT_MMAL)
|
||||
|
||||
AV_PIX_FMT_D3D11VA_VLD = AvPixelFormat(C.AV_PIX_FMT_D3D11VA_VLD)
|
||||
|
||||
AV_PIX_FMT_CUDA = AvPixelFormat(C.AV_PIX_FMT_CUDA)
|
||||
|
||||
AV_PIX_FMT_0RGB = AvPixelFormat(C.AV_PIX_FMT_0RGB)
|
||||
AV_PIX_FMT_RGB0 = AvPixelFormat(C.AV_PIX_FMT_RGB0)
|
||||
AV_PIX_FMT_0BGR = AvPixelFormat(C.AV_PIX_FMT_0BGR)
|
||||
AV_PIX_FMT_BGR0 = AvPixelFormat(C.AV_PIX_FMT_BGR0)
|
||||
|
||||
AV_PIX_FMT_YUV420P12BE = AvPixelFormat(C.AV_PIX_FMT_YUV420P12BE)
|
||||
AV_PIX_FMT_YUV420P12LE = AvPixelFormat(C.AV_PIX_FMT_YUV420P12LE)
|
||||
AV_PIX_FMT_YUV420P14BE = AvPixelFormat(C.AV_PIX_FMT_YUV420P14BE)
|
||||
AV_PIX_FMT_YUV420P14LE = AvPixelFormat(C.AV_PIX_FMT_YUV420P14LE)
|
||||
AV_PIX_FMT_YUV422P12BE = AvPixelFormat(C.AV_PIX_FMT_YUV422P12BE)
|
||||
AV_PIX_FMT_YUV422P12LE = AvPixelFormat(C.AV_PIX_FMT_YUV422P12LE)
|
||||
AV_PIX_FMT_YUV422P14BE = AvPixelFormat(C.AV_PIX_FMT_YUV422P14BE)
|
||||
AV_PIX_FMT_YUV422P14LE = AvPixelFormat(C.AV_PIX_FMT_YUV422P14LE)
|
||||
AV_PIX_FMT_YUV444P12BE = AvPixelFormat(C.AV_PIX_FMT_YUV444P12BE)
|
||||
AV_PIX_FMT_YUV444P12LE = AvPixelFormat(C.AV_PIX_FMT_YUV444P12LE)
|
||||
AV_PIX_FMT_YUV444P14BE = AvPixelFormat(C.AV_PIX_FMT_YUV444P14BE)
|
||||
AV_PIX_FMT_YUV444P14LE = AvPixelFormat(C.AV_PIX_FMT_YUV444P14LE)
|
||||
AV_PIX_FMT_GBRP12BE = AvPixelFormat(C.AV_PIX_FMT_GBRP12BE)
|
||||
AV_PIX_FMT_GBRP12LE = AvPixelFormat(C.AV_PIX_FMT_GBRP12LE)
|
||||
AV_PIX_FMT_GBRP14BE = AvPixelFormat(C.AV_PIX_FMT_GBRP14BE)
|
||||
AV_PIX_FMT_GBRP14LE = AvPixelFormat(C.AV_PIX_FMT_GBRP14LE)
|
||||
AV_PIX_FMT_YUVJ411P = AvPixelFormat(C.AV_PIX_FMT_YUVJ411P)
|
||||
|
||||
AV_PIX_FMT_BAYER_BGGR8 = AvPixelFormat(C.AV_PIX_FMT_BAYER_BGGR8)
|
||||
AV_PIX_FMT_BAYER_RGGB8 = AvPixelFormat(C.AV_PIX_FMT_BAYER_RGGB8)
|
||||
AV_PIX_FMT_BAYER_GBRG8 = AvPixelFormat(C.AV_PIX_FMT_BAYER_GBRG8)
|
||||
AV_PIX_FMT_BAYER_GRBG8 = AvPixelFormat(C.AV_PIX_FMT_BAYER_GRBG8)
|
||||
AV_PIX_FMT_BAYER_BGGR16LE = AvPixelFormat(C.AV_PIX_FMT_BAYER_BGGR16LE)
|
||||
AV_PIX_FMT_BAYER_BGGR16BE = AvPixelFormat(C.AV_PIX_FMT_BAYER_BGGR16BE)
|
||||
AV_PIX_FMT_BAYER_RGGB16LE = AvPixelFormat(C.AV_PIX_FMT_BAYER_RGGB16LE)
|
||||
AV_PIX_FMT_BAYER_RGGB16BE = AvPixelFormat(C.AV_PIX_FMT_BAYER_RGGB16BE)
|
||||
AV_PIX_FMT_BAYER_GBRG16LE = AvPixelFormat(C.AV_PIX_FMT_BAYER_GBRG16LE)
|
||||
AV_PIX_FMT_BAYER_GBRG16BE = AvPixelFormat(C.AV_PIX_FMT_BAYER_GBRG16BE)
|
||||
AV_PIX_FMT_BAYER_GRBG16LE = AvPixelFormat(C.AV_PIX_FMT_BAYER_GRBG16LE)
|
||||
AV_PIX_FMT_BAYER_GRBG16BE = AvPixelFormat(C.AV_PIX_FMT_BAYER_GRBG16BE)
|
||||
|
||||
AV_PIX_FMT_XVMC = AvPixelFormat(C.AV_PIX_FMT_XVMC)
|
||||
|
||||
AV_PIX_FMT_YUV440P10LE = AvPixelFormat(C.AV_PIX_FMT_YUV440P10LE)
|
||||
AV_PIX_FMT_YUV440P10BE = AvPixelFormat(C.AV_PIX_FMT_YUV440P10BE)
|
||||
AV_PIX_FMT_YUV440P12LE = AvPixelFormat(C.AV_PIX_FMT_YUV440P12LE)
|
||||
AV_PIX_FMT_YUV440P12BE = AvPixelFormat(C.AV_PIX_FMT_YUV440P12BE)
|
||||
AV_PIX_FMT_AYUV64LE = AvPixelFormat(C.AV_PIX_FMT_AYUV64LE)
|
||||
AV_PIX_FMT_AYUV64BE = AvPixelFormat(C.AV_PIX_FMT_AYUV64BE)
|
||||
|
||||
AV_PIX_FMT_VIDEOTOOLBOX = AvPixelFormat(C.AV_PIX_FMT_VIDEOTOOLBOX)
|
||||
|
||||
AV_PIX_FMT_P010LE = AvPixelFormat(C.AV_PIX_FMT_P010LE)
|
||||
AV_PIX_FMT_P010BE = AvPixelFormat(C.AV_PIX_FMT_P010BE)
|
||||
|
||||
AV_PIX_FMT_GBRAP12BE = AvPixelFormat(C.AV_PIX_FMT_GBRAP12BE)
|
||||
AV_PIX_FMT_GBRAP12LE = AvPixelFormat(C.AV_PIX_FMT_GBRAP12LE)
|
||||
|
||||
AV_PIX_FMT_GBRAP10BE = AvPixelFormat(C.AV_PIX_FMT_GBRAP10BE)
|
||||
AV_PIX_FMT_GBRAP10LE = AvPixelFormat(C.AV_PIX_FMT_GBRAP10LE)
|
||||
|
||||
AV_PIX_FMT_MEDIACODEC = AvPixelFormat(C.AV_PIX_FMT_MEDIACODEC)
|
||||
|
||||
AV_PIX_FMT_GRAY12BE = AvPixelFormat(C.AV_PIX_FMT_GRAY12BE)
|
||||
AV_PIX_FMT_GRAY12LE = AvPixelFormat(C.AV_PIX_FMT_GRAY12LE)
|
||||
AV_PIX_FMT_GRAY10BE = AvPixelFormat(C.AV_PIX_FMT_GRAY10BE)
|
||||
AV_PIX_FMT_GRAY10LE = AvPixelFormat(C.AV_PIX_FMT_GRAY10LE)
|
||||
|
||||
AV_PIX_FMT_P016LE = AvPixelFormat(C.AV_PIX_FMT_P016LE)
|
||||
AV_PIX_FMT_P016BE = AvPixelFormat(C.AV_PIX_FMT_P016BE)
|
||||
|
||||
AV_PIX_FMT_D3D11 = AvPixelFormat(C.AV_PIX_FMT_D3D11)
|
||||
|
||||
AV_PIX_FMT_GRAY9BE = AvPixelFormat(C.AV_PIX_FMT_GRAY9BE)
|
||||
AV_PIX_FMT_GRAY9LE = AvPixelFormat(C.AV_PIX_FMT_GRAY9LE)
|
||||
|
||||
AV_PIX_FMT_GBRPF32BE = AvPixelFormat(C.AV_PIX_FMT_GBRPF32BE)
|
||||
AV_PIX_FMT_GBRPF32LE = AvPixelFormat(C.AV_PIX_FMT_GBRPF32LE)
|
||||
AV_PIX_FMT_GBRAPF32BE = AvPixelFormat(C.AV_PIX_FMT_GBRAPF32BE)
|
||||
AV_PIX_FMT_GBRAPF32LE = AvPixelFormat(C.AV_PIX_FMT_GBRAPF32LE)
|
||||
|
||||
AV_PIX_FMT_DRM_PRIME = AvPixelFormat(C.AV_PIX_FMT_DRM_PRIME)
|
||||
|
||||
AV_PIX_FMT_OPENCL = AvPixelFormat(C.AV_PIX_FMT_OPENCL)
|
||||
|
||||
AV_PIX_FMT_GRAY14BE = AvPixelFormat(C.AV_PIX_FMT_GRAY14BE)
|
||||
AV_PIX_FMT_GRAY14LE = AvPixelFormat(C.AV_PIX_FMT_GRAY14LE)
|
||||
|
||||
AV_PIX_FMT_GRAYF32BE = AvPixelFormat(C.AV_PIX_FMT_GRAYF32BE)
|
||||
AV_PIX_FMT_GRAYF32LE = AvPixelFormat(C.AV_PIX_FMT_GRAYF32LE)
|
||||
|
||||
AV_PIX_FMT_YUVA422P12BE = AvPixelFormat(C.AV_PIX_FMT_YUVA422P12BE)
|
||||
AV_PIX_FMT_YUVA422P12LE = AvPixelFormat(C.AV_PIX_FMT_YUVA422P12LE)
|
||||
AV_PIX_FMT_YUVA444P12BE = AvPixelFormat(C.AV_PIX_FMT_YUVA444P12BE)
|
||||
AV_PIX_FMT_YUVA444P12LE = AvPixelFormat(C.AV_PIX_FMT_YUVA444P12LE)
|
||||
|
||||
AV_PIX_FMT_NV24 = AvPixelFormat(C.AV_PIX_FMT_NV24)
|
||||
AV_PIX_FMT_NV42 = AvPixelFormat(C.AV_PIX_FMT_NV42)
|
||||
|
||||
AV_PIX_FMT_VULKAN = AvPixelFormat(C.AV_PIX_FMT_VULKAN)
|
||||
|
||||
AV_PIX_FMT_Y210BE = AvPixelFormat(C.AV_PIX_FMT_Y210BE)
|
||||
AV_PIX_FMT_Y210LE = AvPixelFormat(C.AV_PIX_FMT_Y210LE)
|
||||
|
||||
AV_PIX_FMT_X2RGB10LE = AvPixelFormat(C.AV_PIX_FMT_X2RGB10LE)
|
||||
AV_PIX_FMT_X2RGB10BE = AvPixelFormat(C.AV_PIX_FMT_X2RGB10BE)
|
||||
AV_PIX_FMT_NB = AvPixelFormat(C.AV_PIX_FMT_NB)
|
||||
)
|
||||
|
||||
const (
|
||||
AV_PIX_FMT_RGB32 = AvPixelFormat(C.AV_PIX_FMT_RGB32)
|
||||
AV_PIX_FMT_RGB32_1 = AvPixelFormat(C.AV_PIX_FMT_RGB32_1)
|
||||
AV_PIX_FMT_BGR32 = AvPixelFormat(C.AV_PIX_FMT_BGR32)
|
||||
AV_PIX_FMT_BGR32_1 = AvPixelFormat(C.AV_PIX_FMT_BGR32_1)
|
||||
AV_PIX_FMT_0RGB32 = AvPixelFormat(C.AV_PIX_FMT_0RGB32)
|
||||
AV_PIX_FMT_0BGR32 = AvPixelFormat(C.AV_PIX_FMT_0BGR32)
|
||||
|
||||
AV_PIX_FMT_GRAY9 = AvPixelFormat(C.AV_PIX_FMT_GRAY9)
|
||||
AV_PIX_FMT_GRAY10 = AvPixelFormat(C.AV_PIX_FMT_GRAY10)
|
||||
AV_PIX_FMT_GRAY12 = AvPixelFormat(C.AV_PIX_FMT_GRAY12)
|
||||
AV_PIX_FMT_GRAY14 = AvPixelFormat(C.AV_PIX_FMT_GRAY14)
|
||||
AV_PIX_FMT_GRAY16 = AvPixelFormat(C.AV_PIX_FMT_GRAY16)
|
||||
AV_PIX_FMT_YA16 = AvPixelFormat(C.AV_PIX_FMT_YA16)
|
||||
AV_PIX_FMT_RGB48 = AvPixelFormat(C.AV_PIX_FMT_RGB48)
|
||||
AV_PIX_FMT_RGB565 = AvPixelFormat(C.AV_PIX_FMT_RGB565)
|
||||
AV_PIX_FMT_RGB555 = AvPixelFormat(C.AV_PIX_FMT_RGB555)
|
||||
AV_PIX_FMT_RGB444 = AvPixelFormat(C.AV_PIX_FMT_RGB444)
|
||||
AV_PIX_FMT_RGBA64 = AvPixelFormat(C.AV_PIX_FMT_RGBA64)
|
||||
AV_PIX_FMT_BGR48 = AvPixelFormat(C.AV_PIX_FMT_BGR48)
|
||||
AV_PIX_FMT_BGR565 = AvPixelFormat(C.AV_PIX_FMT_BGR565)
|
||||
AV_PIX_FMT_BGR555 = AvPixelFormat(C.AV_PIX_FMT_BGR555)
|
||||
AV_PIX_FMT_BGR444 = AvPixelFormat(C.AV_PIX_FMT_BGR444)
|
||||
AV_PIX_FMT_BGRA64 = AvPixelFormat(C.AV_PIX_FMT_BGRA64)
|
||||
|
||||
AV_PIX_FMT_YUV420P9 = AvPixelFormat(C.AV_PIX_FMT_YUV420P9)
|
||||
AV_PIX_FMT_YUV422P9 = AvPixelFormat(C.AV_PIX_FMT_YUV422P9)
|
||||
AV_PIX_FMT_YUV444P9 = AvPixelFormat(C.AV_PIX_FMT_YUV444P9)
|
||||
AV_PIX_FMT_YUV420P10 = AvPixelFormat(C.AV_PIX_FMT_YUV420P10)
|
||||
AV_PIX_FMT_YUV422P10 = AvPixelFormat(C.AV_PIX_FMT_YUV422P10)
|
||||
AV_PIX_FMT_YUV440P10 = AvPixelFormat(C.AV_PIX_FMT_YUV440P10)
|
||||
AV_PIX_FMT_YUV444P10 = AvPixelFormat(C.AV_PIX_FMT_YUV444P10)
|
||||
AV_PIX_FMT_YUV420P12 = AvPixelFormat(C.AV_PIX_FMT_YUV420P12)
|
||||
AV_PIX_FMT_YUV422P12 = AvPixelFormat(C.AV_PIX_FMT_YUV422P12)
|
||||
AV_PIX_FMT_YUV440P12 = AvPixelFormat(C.AV_PIX_FMT_YUV440P12)
|
||||
AV_PIX_FMT_YUV444P12 = AvPixelFormat(C.AV_PIX_FMT_YUV444P12)
|
||||
AV_PIX_FMT_YUV420P14 = AvPixelFormat(C.AV_PIX_FMT_YUV420P14)
|
||||
AV_PIX_FMT_YUV422P14 = AvPixelFormat(C.AV_PIX_FMT_YUV422P14)
|
||||
AV_PIX_FMT_YUV444P14 = AvPixelFormat(C.AV_PIX_FMT_YUV444P14)
|
||||
AV_PIX_FMT_YUV420P16 = AvPixelFormat(C.AV_PIX_FMT_YUV420P16)
|
||||
AV_PIX_FMT_YUV422P16 = AvPixelFormat(C.AV_PIX_FMT_YUV422P16)
|
||||
AV_PIX_FMT_YUV444P16 = AvPixelFormat(C.AV_PIX_FMT_YUV444P16)
|
||||
|
||||
AV_PIX_FMT_GBRP9 = AvPixelFormat(C.AV_PIX_FMT_GBRP9)
|
||||
AV_PIX_FMT_GBRP10 = AvPixelFormat(C.AV_PIX_FMT_GBRP10)
|
||||
AV_PIX_FMT_GBRP12 = AvPixelFormat(C.AV_PIX_FMT_GBRP12)
|
||||
AV_PIX_FMT_GBRP14 = AvPixelFormat(C.AV_PIX_FMT_GBRP14)
|
||||
AV_PIX_FMT_GBRP16 = AvPixelFormat(C.AV_PIX_FMT_GBRP16)
|
||||
AV_PIX_FMT_GBRAP10 = AvPixelFormat(C.AV_PIX_FMT_GBRAP10)
|
||||
AV_PIX_FMT_GBRAP12 = AvPixelFormat(C.AV_PIX_FMT_GBRAP12)
|
||||
AV_PIX_FMT_GBRAP16 = AvPixelFormat(C.AV_PIX_FMT_GBRAP16)
|
||||
|
||||
AV_PIX_FMT_BAYER_BGGR16 = AvPixelFormat(C.AV_PIX_FMT_BAYER_BGGR16)
|
||||
AV_PIX_FMT_BAYER_RGGB16 = AvPixelFormat(C.AV_PIX_FMT_BAYER_RGGB16)
|
||||
AV_PIX_FMT_BAYER_GBRG16 = AvPixelFormat(C.AV_PIX_FMT_BAYER_GBRG16)
|
||||
AV_PIX_FMT_BAYER_GRBG16 = AvPixelFormat(C.AV_PIX_FMT_BAYER_GRBG16)
|
||||
|
||||
AV_PIX_FMT_GBRPF32 = AvPixelFormat(C.AV_PIX_FMT_GBRPF32)
|
||||
AV_PIX_FMT_GBRAPF32 = AvPixelFormat(C.AV_PIX_FMT_GBRAPF32)
|
||||
|
||||
AV_PIX_FMT_GRAYF32 = AvPixelFormat(C.AV_PIX_FMT_GRAYF32)
|
||||
|
||||
AV_PIX_FMT_YUVA420P9 = AvPixelFormat(C.AV_PIX_FMT_YUVA420P9)
|
||||
AV_PIX_FMT_YUVA422P9 = AvPixelFormat(C.AV_PIX_FMT_YUVA422P9)
|
||||
AV_PIX_FMT_YUVA444P9 = AvPixelFormat(C.AV_PIX_FMT_YUVA444P9)
|
||||
AV_PIX_FMT_YUVA420P10 = AvPixelFormat(C.AV_PIX_FMT_YUVA420P10)
|
||||
AV_PIX_FMT_YUVA422P10 = AvPixelFormat(C.AV_PIX_FMT_YUVA422P10)
|
||||
AV_PIX_FMT_YUVA444P10 = AvPixelFormat(C.AV_PIX_FMT_YUVA444P10)
|
||||
AV_PIX_FMT_YUVA422P12 = AvPixelFormat(C.AV_PIX_FMT_YUVA422P12)
|
||||
AV_PIX_FMT_YUVA444P12 = AvPixelFormat(C.AV_PIX_FMT_YUVA444P12)
|
||||
AV_PIX_FMT_YUVA420P16 = AvPixelFormat(C.AV_PIX_FMT_YUVA420P16)
|
||||
AV_PIX_FMT_YUVA422P16 = AvPixelFormat(C.AV_PIX_FMT_YUVA422P16)
|
||||
AV_PIX_FMT_YUVA444P16 = AvPixelFormat(C.AV_PIX_FMT_YUVA444P16)
|
||||
|
||||
AV_PIX_FMT_XYZ12 = AvPixelFormat(C.AV_PIX_FMT_XYZ12)
|
||||
AV_PIX_FMT_NV20 = AvPixelFormat(C.AV_PIX_FMT_NV20)
|
||||
AV_PIX_FMT_AYUV64 = AvPixelFormat(C.AV_PIX_FMT_AYUV64)
|
||||
AV_PIX_FMT_P010 = AvPixelFormat(C.AV_PIX_FMT_P010)
|
||||
AV_PIX_FMT_P016 = AvPixelFormat(C.AV_PIX_FMT_P016)
|
||||
|
||||
AV_PIX_FMT_Y210 = AvPixelFormat(C.AV_PIX_FMT_Y210)
|
||||
AV_PIX_FMT_X2RGB10 = AvPixelFormat(C.AV_PIX_FMT_X2RGB10)
|
||||
)
|
||||
|
||||
// Chromaticity coordinates of the source primaries.
|
||||
type AvColorPrimaries int32
|
||||
|
||||
const (
|
||||
AVCOL_PRI_RESERVED0 = AvColorPrimaries(C.AVCOL_PRI_RESERVED0)
|
||||
AVCOL_PRI_BT709 = AvColorPrimaries(C.AVCOL_PRI_BT709)
|
||||
AVCOL_PRI_UNSPECIFIED = AvColorPrimaries(C.AVCOL_PRI_UNSPECIFIED)
|
||||
AVCOL_PRI_RESERVED = AvColorPrimaries(C.AVCOL_PRI_RESERVED)
|
||||
AVCOL_PRI_BT470M = AvColorPrimaries(C.AVCOL_PRI_BT470M)
|
||||
|
||||
AVCOL_PRI_BT470BG = AvColorPrimaries(C.AVCOL_PRI_BT470BG)
|
||||
AVCOL_PRI_SMPTE170M = AvColorPrimaries(C.AVCOL_PRI_SMPTE170M)
|
||||
AVCOL_PRI_SMPTE240M = AvColorPrimaries(C.AVCOL_PRI_SMPTE240M)
|
||||
AVCOL_PRI_FILM = AvColorPrimaries(C.AVCOL_PRI_FILM)
|
||||
AVCOL_PRI_BT2020 = AvColorPrimaries(C.AVCOL_PRI_BT2020)
|
||||
AVCOL_PRI_SMPTE428 = AvColorPrimaries(C.AVCOL_PRI_SMPTE428)
|
||||
AVCOL_PRI_SMPTEST428_1 = AvColorPrimaries(C.AVCOL_PRI_SMPTEST428_1)
|
||||
AVCOL_PRI_SMPTE431 = AvColorPrimaries(C.AVCOL_PRI_SMPTE431)
|
||||
AVCOL_PRI_SMPTE432 = AvColorPrimaries(C.AVCOL_PRI_SMPTE432)
|
||||
AVCOL_PRI_EBU3213 = AvColorPrimaries(C.AVCOL_PRI_EBU3213)
|
||||
AVCOL_PRI_JEDEC_P22 = AvColorPrimaries(C.AVCOL_PRI_JEDEC_P22)
|
||||
AVCOL_PRI_NB = AvColorPrimaries(C.AVCOL_PRI_NB)
|
||||
)
|
||||
|
||||
// Color Transfer Characteristic.
|
||||
type AvColorTransferCharacteristic int32
|
||||
|
||||
const (
|
||||
AVCOL_TRC_RESERVED0 = AvColorTransferCharacteristic(C.AVCOL_TRC_RESERVED0)
|
||||
AVCOL_TRC_BT709 = AvColorTransferCharacteristic(C.AVCOL_TRC_BT709)
|
||||
AVCOL_TRC_UNSPECIFIED = AvColorTransferCharacteristic(C.AVCOL_TRC_UNSPECIFIED)
|
||||
AVCOL_TRC_RESERVED = AvColorTransferCharacteristic(C.AVCOL_TRC_RESERVED)
|
||||
AVCOL_TRC_GAMMA22 = AvColorTransferCharacteristic(C.AVCOL_TRC_GAMMA22)
|
||||
AVCOL_TRC_GAMMA28 = AvColorTransferCharacteristic(C.AVCOL_TRC_GAMMA28)
|
||||
AVCOL_TRC_SMPTE170M = AvColorTransferCharacteristic(C.AVCOL_TRC_SMPTE170M)
|
||||
AVCOL_TRC_SMPTE240M = AvColorTransferCharacteristic(C.AVCOL_TRC_SMPTE240M)
|
||||
AVCOL_TRC_LINEAR = AvColorTransferCharacteristic(C.AVCOL_TRC_LINEAR)
|
||||
AVCOL_TRC_LOG = AvColorTransferCharacteristic(C.AVCOL_TRC_LOG)
|
||||
AVCOL_TRC_LOG_SQRT = AvColorTransferCharacteristic(C.AVCOL_TRC_LOG_SQRT)
|
||||
AVCOL_TRC_IEC61966_2_4 = AvColorTransferCharacteristic(C.AVCOL_TRC_IEC61966_2_4)
|
||||
AVCOL_TRC_BT1361_ECG = AvColorTransferCharacteristic(C.AVCOL_TRC_BT1361_ECG)
|
||||
AVCOL_TRC_IEC61966_2_1 = AvColorTransferCharacteristic(C.AVCOL_TRC_IEC61966_2_1)
|
||||
AVCOL_TRC_BT2020_10 = AvColorTransferCharacteristic(C.AVCOL_TRC_BT2020_10)
|
||||
AVCOL_TRC_BT2020_12 = AvColorTransferCharacteristic(C.AVCOL_TRC_BT2020_12)
|
||||
AVCOL_TRC_SMPTE2084 = AvColorTransferCharacteristic(C.AVCOL_TRC_SMPTE2084)
|
||||
AVCOL_TRC_SMPTEST2084 = AvColorTransferCharacteristic(C.AVCOL_TRC_SMPTEST2084)
|
||||
AVCOL_TRC_SMPTE428 = AvColorTransferCharacteristic(C.AVCOL_TRC_SMPTE428)
|
||||
AVCOL_TRC_SMPTEST428_1 = AvColorTransferCharacteristic(C.AVCOL_TRC_SMPTEST428_1)
|
||||
AVCOL_TRC_ARIB_STD_B67 = AvColorTransferCharacteristic(C.AVCOL_TRC_ARIB_STD_B67)
|
||||
AVCOL_TRC_NB = AvColorTransferCharacteristic(C.AVCOL_TRC_NB)
|
||||
)
|
||||
|
||||
// AvColorSpace
|
||||
type AvColorSpace int32
|
||||
|
||||
const (
|
||||
AVCOL_SPC_RGB = AvColorSpace(C.AVCOL_SPC_RGB)
|
||||
AVCOL_SPC_BT709 = AvColorSpace(C.AVCOL_SPC_BT709)
|
||||
AVCOL_SPC_UNSPECIFIED = AvColorSpace(C.AVCOL_SPC_UNSPECIFIED)
|
||||
AVCOL_SPC_RESERVED = AvColorSpace(C.AVCOL_SPC_RESERVED)
|
||||
AVCOL_SPC_FCC = AvColorSpace(C.AVCOL_SPC_FCC)
|
||||
AVCOL_SPC_BT470BG = AvColorSpace(C.AVCOL_SPC_BT470BG)
|
||||
AVCOL_SPC_SMPTE170M = AvColorSpace(C.AVCOL_SPC_SMPTE170M)
|
||||
AVCOL_SPC_SMPTE240M = AvColorSpace(C.AVCOL_SPC_SMPTE240M)
|
||||
AVCOL_SPC_YCGCO = AvColorSpace(C.AVCOL_SPC_YCGCO)
|
||||
AVCOL_SPC_YCOCG = AvColorSpace(C.AVCOL_SPC_YCOCG)
|
||||
AVCOL_SPC_BT2020_NCL = AvColorSpace(C.AVCOL_SPC_BT2020_NCL)
|
||||
AVCOL_SPC_BT2020_CL = AvColorSpace(C.AVCOL_SPC_BT2020_CL)
|
||||
AVCOL_SPC_SMPTE2085 = AvColorSpace(C.AVCOL_SPC_SMPTE2085)
|
||||
AVCOL_SPC_CHROMA_DERIVED_NCL = AvColorSpace(C.AVCOL_SPC_CHROMA_DERIVED_NCL)
|
||||
AVCOL_SPC_CHROMA_DERIVED_CL = AvColorSpace(C.AVCOL_SPC_CHROMA_DERIVED_CL)
|
||||
AVCOL_SPC_ICTCP = AvColorSpace(C.AVCOL_SPC_ICTCP)
|
||||
AVCOL_SPC_NB = AvColorSpace(C.AVCOL_SPC_NB)
|
||||
)
|
||||
|
||||
// AvColorRange
|
||||
type AvColorRange int32
|
||||
|
||||
const (
|
||||
AVCOL_RANGE_UNSPECIFIED = AvColorRange(C.AVCOL_RANGE_UNSPECIFIED)
|
||||
AVCOL_RANGE_MPEG = AvColorRange(C.AVCOL_RANGE_MPEG)
|
||||
AVCOL_RANGE_JPEG = AvColorRange(C.AVCOL_RANGE_JPEG)
|
||||
AVCOL_RANGE_NB = AvColorRange(C.AVCOL_RANGE_NB)
|
||||
)
|
||||
|
||||
// AvChromaLocation
|
||||
type AvChromaLocation int32
|
||||
|
||||
const (
|
||||
AVCHROMA_LOC_UNSPECIFIED = AvChromaLocation(C.AVCHROMA_LOC_UNSPECIFIED)
|
||||
AVCHROMA_LOC_LEFT = AvChromaLocation(C.AVCHROMA_LOC_LEFT)
|
||||
AVCHROMA_LOC_CENTER = AvChromaLocation(C.AVCHROMA_LOC_CENTER)
|
||||
AVCHROMA_LOC_TOPLEFT = AvChromaLocation(C.AVCHROMA_LOC_TOPLEFT)
|
||||
AVCHROMA_LOC_TOP = AvChromaLocation(C.AVCHROMA_LOC_TOP)
|
||||
AVCHROMA_LOC_BOTTOMLEFT = AvChromaLocation(C.AVCHROMA_LOC_BOTTOMLEFT)
|
||||
AVCHROMA_LOC_BOTTOM = AvChromaLocation(C.AVCHROMA_LOC_BOTTOM)
|
||||
AVCHROMA_LOC_NB = AvChromaLocation(C.AVCHROMA_LOC_NB)
|
||||
)
|
107
avutil_rational.go
Normal file
107
avutil_rational.go
Normal file
@@ -0,0 +1,107 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/rational.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
// AvRational
|
||||
type AvRational C.struct_AVRational
|
||||
|
||||
// Custom: GetNum gets `AVRational.num` value.
|
||||
func (q *AvRational) GetNum() int32 {
|
||||
return (int32)(q.num)
|
||||
}
|
||||
|
||||
// Custom: GetDen gets `AVRational.den` value.
|
||||
func (q *AvRational) GetDen() int32 {
|
||||
return (int32)(q.den)
|
||||
}
|
||||
|
||||
// AvMakeQ creates an AVRational with numerator and denominator.
|
||||
func AvMakeQ(num, den int32) AvRational {
|
||||
return (AvRational)(C.av_make_q((C.int)(num), (C.int)(den)))
|
||||
}
|
||||
|
||||
const (
|
||||
INT_MIN = int32(C.INT_MIN)
|
||||
)
|
||||
|
||||
// AvCmpQ compares two rationals.
|
||||
// returns One of the following values:
|
||||
// 0 if `a == b`
|
||||
// 1 if `a > b`
|
||||
// -1 if `a < b`
|
||||
// `INT_MIN` if one of the values is of the form `0 / 0`
|
||||
func AvCmpQ(a, b AvRational) int32 {
|
||||
return (int32)(C.av_cmp_q((C.struct_AVRational)(a), (C.struct_AVRational)(b)))
|
||||
}
|
||||
|
||||
// AvQ2d converts an AVRational to a `float64`.
|
||||
func AvQ2d(a AvRational) float64 {
|
||||
return (float64)(C.av_q2d((C.struct_AVRational)(a)))
|
||||
}
|
||||
|
||||
// AvReduce reduces a fraction.
|
||||
func AvReduce(dstNum, dstDen *int32, num, den, max int64) int32 {
|
||||
return (int32)(C.av_reduce((*C.int)(dstNum), (*C.int)(dstDen),
|
||||
(C.int64_t)(num), (C.int64_t)(den), (C.int64_t)(max)))
|
||||
}
|
||||
|
||||
// AvMulQ multiplies two rationals.
|
||||
func AvMulQ(a, b AvRational) AvRational {
|
||||
return (AvRational)(C.av_mul_q((C.struct_AVRational)(a), (C.struct_AVRational)(b)))
|
||||
}
|
||||
|
||||
// AvDivQ divides one rational by another.
|
||||
func AvDivQ(a, b AvRational) AvRational {
|
||||
return (AvRational)(C.av_div_q((C.struct_AVRational)(a), (C.struct_AVRational)(b)))
|
||||
}
|
||||
|
||||
// AvAddQ adds two rationals.
|
||||
func AvAddQ(a, b AvRational) AvRational {
|
||||
return (AvRational)(C.av_add_q((C.struct_AVRational)(a), (C.struct_AVRational)(b)))
|
||||
}
|
||||
|
||||
// AvSubQ subtracts one rational from another.
|
||||
func AvSubQ(a, b AvRational) AvRational {
|
||||
return (AvRational)(C.av_sub_q((C.struct_AVRational)(a), (C.struct_AVRational)(b)))
|
||||
}
|
||||
|
||||
// AvInvQ invert a rational.
|
||||
// return 1 / q
|
||||
func AvInvQ(q AvRational) AvRational {
|
||||
return (AvRational)(C.av_inv_q((C.struct_AVRational)(q)))
|
||||
}
|
||||
|
||||
// AvD2Q converts a double precision floating point number to a rational.
|
||||
func AvD2Q(d float64, max int32) AvRational {
|
||||
return (AvRational)(C.av_d2q((C.double)(d), (C.int)(max)))
|
||||
}
|
||||
|
||||
// AvNearerQ finds which of the two rationals is closer to another rational.
|
||||
// return One of the following values:
|
||||
// 1 if `q1` is nearer to `q` than `q2`
|
||||
// -1 if `q2` is nearer to `q` than `q1`
|
||||
// 0 if they have the same distance
|
||||
func AvNearerQ(q, q1, q2 AvRational) int32 {
|
||||
return (int32)(C.av_nearer_q((C.struct_AVRational)(q),
|
||||
(C.struct_AVRational)(q1), (C.struct_AVRational)(q2)))
|
||||
}
|
||||
|
||||
// AvFindNearestQIdx finds the value in a list of rationals nearest a given reference rational.
|
||||
func AvFindNearestQIdx(q AvRational, qList *AvRational) int32 {
|
||||
return (int32)(C.av_find_nearest_q_idx((C.struct_AVRational)(q), (*C.struct_AVRational)(qList)))
|
||||
}
|
||||
|
||||
// AvQ2intfloat Convert an AVRational to a IEEE 32-bit `float` expressed in fixed-point format.
|
||||
func AvQ2intfloat(q AvRational) uint32 {
|
||||
return (uint32)(C.av_q2intfloat((C.struct_AVRational)(q)))
|
||||
}
|
||||
|
||||
// AvGcdQ returns the best rational so that a and b are multiple of it.
|
||||
// If the resulting denominator is larger than max_den, return def.
|
||||
func AvGcdQ(a, b AvRational, maxDen int32, def AvRational) AvRational {
|
||||
return (AvRational)(C.av_gcd_q((C.struct_AVRational)(a), (C.struct_AVRational)(b),
|
||||
(C.int)(maxDen), (C.struct_AVRational)(def)))
|
||||
}
|
131
avutil_samplefmt.go
Normal file
131
avutil_samplefmt.go
Normal file
@@ -0,0 +1,131 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/samplefmt.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// AvSampleFormat
|
||||
type AvSampleFormat int32
|
||||
|
||||
const (
|
||||
AV_SAMPLE_FMT_NONE = AvSampleFormat(C.AV_SAMPLE_FMT_NONE)
|
||||
AV_SAMPLE_FMT_U8 = AvSampleFormat(C.AV_SAMPLE_FMT_U8)
|
||||
AV_SAMPLE_FMT_S16 = AvSampleFormat(C.AV_SAMPLE_FMT_S16)
|
||||
AV_SAMPLE_FMT_S32 = AvSampleFormat(C.AV_SAMPLE_FMT_S32)
|
||||
AV_SAMPLE_FMT_FLT = AvSampleFormat(C.AV_SAMPLE_FMT_FLT)
|
||||
AV_SAMPLE_FMT_DBL = AvSampleFormat(C.AV_SAMPLE_FMT_DBL)
|
||||
AV_SAMPLE_FMT_U8P = AvSampleFormat(C.AV_SAMPLE_FMT_U8P)
|
||||
AV_SAMPLE_FMT_S16P = AvSampleFormat(C.AV_SAMPLE_FMT_S16P)
|
||||
AV_SAMPLE_FMT_S32P = AvSampleFormat(C.AV_SAMPLE_FMT_S32P)
|
||||
AV_SAMPLE_FMT_FLTP = AvSampleFormat(C.AV_SAMPLE_FMT_FLTP)
|
||||
AV_SAMPLE_FMT_DBLP = AvSampleFormat(C.AV_SAMPLE_FMT_DBLP)
|
||||
AV_SAMPLE_FMT_S64 = AvSampleFormat(C.AV_SAMPLE_FMT_S64)
|
||||
AV_SAMPLE_FMT_S64P = AvSampleFormat(C.AV_SAMPLE_FMT_S64P)
|
||||
AV_SAMPLE_FMT_NB = AvSampleFormat(C.AV_SAMPLE_FMT_NB)
|
||||
)
|
||||
|
||||
// AvGetSampleFmtName returns the name of sample_fmt, or NULL if sample_fmt is not
|
||||
// recognized.
|
||||
func AvGetSampleFmtName(sampleFmt AvSampleFormat) string {
|
||||
return C.GoString(C.av_get_sample_fmt_name((C.enum_AVSampleFormat)(sampleFmt)))
|
||||
}
|
||||
|
||||
// AvGetSampleFmt returns a sample format corresponding to name, or AV_SAMPLE_FMT_NONE
|
||||
// on error.
|
||||
func AvGetSampleFmt(name string) AvSampleFormat {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (AvSampleFormat)(C.av_get_sample_fmt((*C.char)(namePtr)))
|
||||
}
|
||||
|
||||
// AvGetAltSampleFmt returns the planar<->packed alternative form of the given sample format, or
|
||||
// AV_SAMPLE_FMT_NONE on error. If the passed sample_fmt is already in the
|
||||
// requested planar/packed format, the format returned is the same as the
|
||||
// input.
|
||||
func AvGetAltSampleFmt(sampleFmt AvSampleFormat, planar int32) AvSampleFormat {
|
||||
return (AvSampleFormat)(C.av_get_alt_sample_fmt((C.enum_AVSampleFormat)(sampleFmt), C.int(planar)))
|
||||
}
|
||||
|
||||
// AvGetPackedSampleFmt gets the packed alternative form of the given sample format.
|
||||
func AvGetPackedSampleFmt(sampleFmt AvSampleFormat) AvSampleFormat {
|
||||
return (AvSampleFormat)(C.av_get_packed_sample_fmt((C.enum_AVSampleFormat)(sampleFmt)))
|
||||
}
|
||||
|
||||
// AvGetPlanarSampleFmt gets the planar alternative form of the given sample format.
|
||||
func AvGetPlanarSampleFmt(sampleFmt AvSampleFormat) AvSampleFormat {
|
||||
return (AvSampleFormat)(C.av_get_planar_sample_fmt((C.enum_AVSampleFormat)(sampleFmt)))
|
||||
}
|
||||
|
||||
// AvGetSampleFmtString generates a string corresponding to the sample format with
|
||||
// sample_fmt, or a header if sample_fmt is negative.
|
||||
func AvGetSampleFmtString(buf *int8, bufSize int32, sampleFmt AvSampleFormat) string {
|
||||
return C.GoString(C.av_get_sample_fmt_string((*C.char)(buf), (C.int)(bufSize),
|
||||
(C.enum_AVSampleFormat)(sampleFmt)))
|
||||
}
|
||||
|
||||
// AvGetBytesPerSample returns number of bytes per sample.
|
||||
func AvGetBytesPerSample(sampleFmt AvSampleFormat) int32 {
|
||||
return (int32)(C.av_get_bytes_per_sample((C.enum_AVSampleFormat)(sampleFmt)))
|
||||
}
|
||||
|
||||
// AvSampleFmtIsPlanar checks if the sample format is planar.
|
||||
func AvSampleFmtIsPlanar(sampleFmt AvSampleFormat) int32 {
|
||||
return (int32)(C.av_sample_fmt_is_planar((C.enum_AVSampleFormat)(sampleFmt)))
|
||||
}
|
||||
|
||||
// AvSamplesGetBufferSize gets the required buffer size for the given audio parameters.
|
||||
func AvSamplesGetBufferSize(linesize *int32, nbChannels, nbSamples int32,
|
||||
sampleFmt AvSampleFormat, align int32) int32 {
|
||||
return (int32)(C.av_samples_get_buffer_size((*C.int)(linesize), (C.int)(nbChannels),
|
||||
(C.int)(nbSamples), (C.enum_AVSampleFormat)(sampleFmt), (C.int)(align)))
|
||||
}
|
||||
|
||||
// AvSamplesFillArrays fills plane data pointers and linesize for samples with sample
|
||||
// format sample_fmt.
|
||||
func AvSamplesFillArrays(audioData **uint8, linesize *int32,
|
||||
buf *uint8, nbChannels, nbSamples int32,
|
||||
sampleFmt AvSampleFormat, align int32) int32 {
|
||||
return (int32)(C.av_samples_fill_arrays((**C.uint8_t)(unsafe.Pointer(audioData)),
|
||||
(*C.int)(linesize), (*C.uint8_t)(buf),
|
||||
(C.int)(nbChannels), (C.int)(nbSamples),
|
||||
(C.enum_AVSampleFormat)(sampleFmt), (C.int)(align)))
|
||||
}
|
||||
|
||||
// AvSamplesAlloc allocates a samples buffer for nb_samples samples, and fill data pointers and
|
||||
// linesize accordingly.
|
||||
func AvSamplesAlloc(audioData **uint8, linesize *int32,
|
||||
nbChannels, nbSamples int32,
|
||||
sampleFmt AvSampleFormat, align int32) int32 {
|
||||
return (int32)(C.av_samples_alloc((**C.uint8_t)(unsafe.Pointer(audioData)),
|
||||
(*C.int)(linesize),
|
||||
(C.int)(nbChannels), (C.int)(nbSamples),
|
||||
(C.enum_AVSampleFormat)(sampleFmt), (C.int)(align)))
|
||||
}
|
||||
|
||||
// AvSamplesAllocArrayAndSamples allocates a data pointers array, samples buffer for nb_samples
|
||||
// samples, and fill data pointers and linesize accordingly.
|
||||
func AvSamplesAllocArrayAndSamples(audioData ***uint8, linesize *int32, nbChannels, nbSamples int32,
|
||||
sampleFmt AvSampleFormat, align int32) int32 {
|
||||
return (int32)(C.av_samples_alloc_array_and_samples((***C.uint8_t)(unsafe.Pointer(audioData)),
|
||||
(*C.int)(linesize), (C.int)(nbChannels), (C.int)(nbSamples),
|
||||
(C.enum_AVSampleFormat)(sampleFmt), (C.int)(align)))
|
||||
}
|
||||
|
||||
// AvSamplesCopy copies samples from src to dst.
|
||||
func AvSamplesCopy(dst, src **uint8, dstOffset, srcOffset int32,
|
||||
nbSamples, nbChannels int32, sampleFmt AvSampleFormat) int32 {
|
||||
return (int32)(C.av_samples_copy((**C.uint8_t)(unsafe.Pointer(dst)),
|
||||
(**C.uint8_t)(unsafe.Pointer(src)),
|
||||
(C.int)(dstOffset), (C.int)(srcOffset),
|
||||
(C.int)(nbSamples), (C.int)(nbChannels),
|
||||
(C.enum_AVSampleFormat)(sampleFmt)))
|
||||
}
|
||||
|
||||
// AvSamplesSetSilence fills an audio buffer with silence.
|
||||
func AvSamplesSetSilence(audioData **uint8, offset int32,
|
||||
nbSamples, nbChannels int32, sampleFmt AvSampleFormat) int32 {
|
||||
return (int32)(C.av_samples_set_silence((**C.uint8_t)(unsafe.Pointer(audioData)), (C.int)(offset),
|
||||
(C.int)(nbSamples), (C.int)(nbChannels), (C.enum_AVSampleFormat)(sampleFmt)))
|
||||
}
|
12
avutil_version.go
Normal file
12
avutil_version.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/version.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
LIBAVUTIL_VERSION_MAJOR = C.LIBAVUTIL_VERSION_MAJOR
|
||||
LIBAVUTIL_VERSION_MINOR = C.LIBAVUTIL_VERSION_MINOR
|
||||
LIBAVUTIL_VERSION_MICRO = C.LIBAVUTIL_VERSION_MICRO
|
||||
)
|
5
examples/avio-list-dir/main.go
Normal file
5
examples/avio-list-dir/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/avio-reading/main.go
Normal file
5
examples/avio-reading/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
195
examples/decode-audio/main.go
Normal file
195
examples/decode-audio/main.go
Normal file
@@ -0,0 +1,195 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
ffmpeg "github.com/qrtc/ffmpeg-dev-go"
|
||||
)
|
||||
|
||||
const (
|
||||
AUDIO_INBUF_SIZE = 20480
|
||||
AUDIO_REFILL_THRESH = 4096
|
||||
)
|
||||
|
||||
func getFormatFromSampleFmt(sampleFmt ffmpeg.AvSampleFormat) (string, int32) {
|
||||
sampleFmtEntry := []struct {
|
||||
sampleFmt ffmpeg.AvSampleFormat
|
||||
fmtBe string
|
||||
fmtLe string
|
||||
}{
|
||||
{ffmpeg.AV_SAMPLE_FMT_U8, "u8", "u8"},
|
||||
{ffmpeg.AV_SAMPLE_FMT_S16, "s16be", "s16le"},
|
||||
{ffmpeg.AV_SAMPLE_FMT_S32, "s32be", "s32le"},
|
||||
{ffmpeg.AV_SAMPLE_FMT_FLT, "f32be", "f32le"},
|
||||
{ffmpeg.AV_SAMPLE_FMT_DBL, "f64be", "f64le"},
|
||||
}
|
||||
|
||||
for _, entry := range sampleFmtEntry {
|
||||
if sampleFmt == entry.sampleFmt {
|
||||
return ffmpeg.AV_NE(entry.fmtBe, entry.fmtLe), 0
|
||||
}
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stderr, "sample format %s is not supported as output format\n",
|
||||
ffmpeg.AvGetSampleFmtName(sampleFmt))
|
||||
return "", -1
|
||||
}
|
||||
|
||||
func decode(decCtx *ffmpeg.AvCodecContext, pkt *ffmpeg.AvPacket, frame *ffmpeg.AvFrame, outfile *os.File) {
|
||||
// send the packet with the compressed data to the decoder
|
||||
ret := ffmpeg.AvCodecSendPacket(decCtx, pkt)
|
||||
if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error submitting the packet to the decoder\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// read all the output frames (in general there may be any number of them
|
||||
for ret >= 0 {
|
||||
ret = ffmpeg.AvCodecReceiveFrame(decCtx, frame)
|
||||
if ret == ffmpeg.AVERROR(int32(syscall.EAGAIN)) || ret == ffmpeg.AVERROR_EOF {
|
||||
return
|
||||
} else if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error during decoding\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
dataSize := ffmpeg.AvGetBytesPerSample(decCtx.GetSampleFmt())
|
||||
if dataSize < 0 {
|
||||
// This should not occur, checking just for paranoia
|
||||
fmt.Fprintf(os.Stderr, "Failed to calculate data size\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
for i := int32(0); i < frame.GetNbSamples(); i++ {
|
||||
for ch := 0; ch < int(decCtx.GetChannels()); ch++ {
|
||||
outfile.Write(ffmpeg.SliceWithOffset(frame.GetDataIdx(ch), dataSize*i, dataSize))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) <= 2 {
|
||||
fmt.Fprintf(os.Stdout, "Usage: %s <input file> <output file>\n", os.Args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
filename := os.Args[1]
|
||||
outfilename := os.Args[2]
|
||||
|
||||
pkt := ffmpeg.AvPacketAlloc()
|
||||
|
||||
codec := ffmpeg.AvCodecFindDecoder(ffmpeg.AV_CODEC_ID_MP2)
|
||||
if codec == nil {
|
||||
fmt.Fprintf(os.Stderr, "Codec not found\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
parser := ffmpeg.AvParserInit(codec.GetID())
|
||||
if parser == nil {
|
||||
fmt.Fprintf(os.Stderr, "Parser not found\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
avctx := ffmpeg.AvCodecAllocContext3(codec)
|
||||
if avctx == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate audio codec context\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// open it
|
||||
if ffmpeg.AvCodecOpen2(avctx, codec, nil) < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not open codec\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
f, err := os.OpenFile(filename, os.O_RDONLY, 0666)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not open %s\n", filename)
|
||||
os.Exit(1)
|
||||
}
|
||||
outfile, err := os.OpenFile(outfilename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not open %s\n", outfilename)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// decode until eof
|
||||
var decodedFrame *ffmpeg.AvFrame
|
||||
inbuf := make([]byte, AUDIO_INBUF_SIZE+ffmpeg.AV_INPUT_BUFFER_PADDING_SIZE)
|
||||
dataOffset := 0
|
||||
dataSize, err := f.Read(inbuf[:AUDIO_INBUF_SIZE])
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "%s\n", err.Error())
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for dataSize > 0 {
|
||||
if decodedFrame == nil {
|
||||
if decodedFrame = ffmpeg.AvFrameAlloc(); decodedFrame == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate audio frame\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
ret := ffmpeg.AvParserParse2(parser, avctx, pkt.GetDataAddr(), pkt.GetSizeAddr(),
|
||||
&inbuf[dataOffset], int32(dataSize),
|
||||
ffmpeg.AV_NOPTS_VALUE, ffmpeg.AV_NOPTS_VALUE, 0)
|
||||
if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error while parsing\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
dataOffset += int(ret)
|
||||
dataSize -= int(ret)
|
||||
|
||||
if pkt.GetSize() > 0 {
|
||||
decode(avctx, pkt, decodedFrame, outfile)
|
||||
}
|
||||
|
||||
if dataSize < AUDIO_REFILL_THRESH {
|
||||
copy(inbuf, inbuf[dataOffset:dataOffset+dataSize])
|
||||
dataOffset = 0
|
||||
length, _ := f.Read(inbuf[dataOffset+dataSize : AUDIO_INBUF_SIZE-dataSize])
|
||||
if length > 0 {
|
||||
dataSize += int(length)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// flush the decoder
|
||||
pkt.SetData(nil)
|
||||
pkt.SetSize(0)
|
||||
decode(avctx, pkt, decodedFrame, outfile)
|
||||
|
||||
// print output pcm infomations, because there have no metadata of pcm
|
||||
sfmt := avctx.GetSampleFmt()
|
||||
|
||||
if ffmpeg.AvSampleFmtIsPlanar(sfmt) > 0 {
|
||||
packed := ffmpeg.AvGetSampleFmtName(sfmt)
|
||||
if len(packed) == 0 {
|
||||
packed = "?"
|
||||
}
|
||||
fmt.Fprintf(os.Stdout, "Warning: the sample format the decoder produced is planar (%s)."+
|
||||
" This example will output the first channel only.\n", packed)
|
||||
sfmt = ffmpeg.AvGetPackedSampleFmt(sfmt)
|
||||
}
|
||||
|
||||
nChannels := avctx.GetChannels()
|
||||
fmtStr, ret := getFormatFromSampleFmt(sfmt)
|
||||
if ret < 0 {
|
||||
goto end
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stdout, "Play the output audio file with the command:\n"+
|
||||
"ffplay -f %s -ac %d -ar %d %s\n",
|
||||
fmtStr, nChannels, avctx.GetSampleRate(), outfilename)
|
||||
|
||||
end:
|
||||
f.Close()
|
||||
outfile.Close()
|
||||
|
||||
ffmpeg.AvCodecFreeContext(&avctx)
|
||||
ffmpeg.AvParserClose(parser)
|
||||
ffmpeg.AvFrameFree(&decodedFrame)
|
||||
ffmpeg.AvPacketFree(&pkt)
|
||||
}
|
137
examples/decode-video/main.go
Normal file
137
examples/decode-video/main.go
Normal file
@@ -0,0 +1,137 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io"
|
||||
"os"
|
||||
"syscall"
|
||||
|
||||
ffmpeg "github.com/qrtc/ffmpeg-dev-go"
|
||||
)
|
||||
|
||||
const (
|
||||
INBUF_SIZE = 4096
|
||||
)
|
||||
|
||||
func pgmSave(buf *uint8, wrap, xsize, ysize int32, filename string) {
|
||||
f, _ := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755)
|
||||
fmt.Fprintf(f, "P5\n%d %d\n%d\n", xsize, ysize, 255)
|
||||
for i := int32(0); i < ysize; i++ {
|
||||
f.Write(ffmpeg.SliceWithOffset(buf, i+wrap, xsize))
|
||||
}
|
||||
f.Close()
|
||||
}
|
||||
|
||||
func decode(decCtx *ffmpeg.AvCodecContext, frame *ffmpeg.AvFrame, pkt *ffmpeg.AvPacket, filename string) {
|
||||
ret := ffmpeg.AvCodecSendPacket(decCtx, pkt)
|
||||
if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error sending a packet for decoding\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for ret >= 0 {
|
||||
ret = ffmpeg.AvCodecReceiveFrame(decCtx, frame)
|
||||
if ret == ffmpeg.AVERROR(int32(syscall.EAGAIN)) || ret == ffmpeg.AVERROR_EOF {
|
||||
return
|
||||
} else if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error during decoding\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stdout, "saving frame %3d\n", decCtx.GetFrameNumber())
|
||||
|
||||
// the picture is allocated by the decoder. no need to free it
|
||||
fname := fmt.Sprintf("%s-%d", filename, decCtx.GetFrameNumber())
|
||||
pgmSave(frame.GetDataIdx(0), frame.GetLinesizeIdx(0), frame.GetWidth(), frame.GetHeight(), fname)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) <= 2 {
|
||||
fmt.Fprintf(os.Stdout, "Usage: %s <input file> <output file>\n", os.Args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
filename := os.Args[1]
|
||||
outfilename := os.Args[2]
|
||||
|
||||
pkt := ffmpeg.AvPacketAlloc()
|
||||
if pkt == nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
codec := ffmpeg.AvCodecFindDecoder(ffmpeg.AV_CODEC_ID_MPEG1VIDEO)
|
||||
if codec == nil {
|
||||
fmt.Fprintf(os.Stderr, "Codec not found\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
parser := ffmpeg.AvParserInit(codec.GetID())
|
||||
if parser == nil {
|
||||
fmt.Fprintf(os.Stderr, "Parser not found\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
avctx := ffmpeg.AvCodecAllocContext3(codec)
|
||||
if avctx == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate video codec context\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// For some codecs, such as msmpeg4 and mpeg4, width and height MUST be initialized
|
||||
// there because this information is not available in the bitstream.
|
||||
|
||||
// open it
|
||||
if ffmpeg.AvCodecOpen2(avctx, codec, nil) < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not open codec\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
inbuf := make([]byte, INBUF_SIZE+ffmpeg.AV_INPUT_BUFFER_PADDING_SIZE)
|
||||
|
||||
f, err := os.OpenFile(filename, os.O_RDONLY, 0666)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not open %s\n", filename)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
frame := ffmpeg.AvFrameAlloc()
|
||||
if frame == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate video frame\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for {
|
||||
// read raw data from the input file
|
||||
dataSize, err := f.Read(inbuf[:INBUF_SIZE])
|
||||
if err == io.EOF || dataSize == 0 {
|
||||
break
|
||||
}
|
||||
|
||||
data := inbuf
|
||||
// use the parser to split the data into frames
|
||||
for dataSize > 0 {
|
||||
ret := ffmpeg.AvParserParse2(parser, avctx, pkt.GetDataAddr(), pkt.GetSizeAddr(),
|
||||
&data[0], int32(dataSize), ffmpeg.AV_NOPTS_VALUE, ffmpeg.AV_NOPTS_VALUE, 0)
|
||||
if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error while parsing\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
data = data[ret:]
|
||||
dataSize -= int(ret)
|
||||
|
||||
if pkt.GetSize() > 0 {
|
||||
decode(avctx, frame, pkt, outfilename)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// flush the decoder
|
||||
decode(avctx, frame, nil, outfilename)
|
||||
|
||||
f.Close()
|
||||
|
||||
ffmpeg.AvCodecFreeContext(&avctx)
|
||||
ffmpeg.AvParserClose(parser)
|
||||
ffmpeg.AvFrameFree(&frame)
|
||||
ffmpeg.AvPacketFree(&pkt)
|
||||
}
|
5
examples/demuxing-decoding/main.go
Normal file
5
examples/demuxing-decoding/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
183
examples/encode-audio/main.go
Normal file
183
examples/encode-audio/main.go
Normal file
@@ -0,0 +1,183 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math"
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
ffmpeg "github.com/qrtc/ffmpeg-dev-go"
|
||||
)
|
||||
|
||||
// check that a given sample format is supported by the encoder
|
||||
func checkSampleFmt(codec *ffmpeg.AvCodec, sampleFmt ffmpeg.AvSampleFormat) int32 {
|
||||
for _, f := range codec.GetSampleFmts() {
|
||||
if f == sampleFmt {
|
||||
return 1
|
||||
}
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func selectSampleRate(codec *ffmpeg.AvCodec) int32 {
|
||||
var bestSamplerate int32
|
||||
ss := codec.GetSupportedSamplerates()
|
||||
if len(ss) == 0 {
|
||||
return 44100
|
||||
}
|
||||
for _, s := range ss {
|
||||
if bestSamplerate == 0 || ffmpeg.FFABS(44100-s) < ffmpeg.FFABS(44100-bestSamplerate) {
|
||||
bestSamplerate = s
|
||||
}
|
||||
}
|
||||
return bestSamplerate
|
||||
}
|
||||
|
||||
// select layout with the highest channel count
|
||||
func selectChannelLayout(codec *ffmpeg.AvCodec) uint64 {
|
||||
var bestChLayout uint64
|
||||
var bestNbChannels int32
|
||||
ls := codec.GetChannelLayouts()
|
||||
if len(ls) == 0 {
|
||||
return ffmpeg.AV_CH_LAYOUT_STEREO
|
||||
}
|
||||
|
||||
for _, l := range ls {
|
||||
nbChannels := ffmpeg.AvGetChannelLayoutNbChannels(l)
|
||||
|
||||
if nbChannels > bestNbChannels {
|
||||
bestChLayout = l
|
||||
bestNbChannels = nbChannels
|
||||
}
|
||||
}
|
||||
|
||||
return bestChLayout
|
||||
}
|
||||
|
||||
func encode(ctx *ffmpeg.AvCodecContext, frame *ffmpeg.AvFrame, pkt *ffmpeg.AvPacket, output *os.File) {
|
||||
// send the frame for encoding
|
||||
ret := ffmpeg.AvCodecSendFrame(ctx, frame)
|
||||
if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error sending the frame to the encoder\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// read all the available output packets (in general there may be any number of them
|
||||
for ret >= 0 {
|
||||
ret = ffmpeg.AvCodecReceivePacket(ctx, pkt)
|
||||
if ret == ffmpeg.AVERROR(int32(syscall.EAGAIN)) || ret == ffmpeg.AVERROR_EOF {
|
||||
return
|
||||
} else if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error encoding audio frame\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
output.Write(ffmpeg.Slice(pkt.GetData(), pkt.GetSize()))
|
||||
ffmpeg.AvPacketUnref(pkt)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func main() {
|
||||
if len(os.Args) <= 1 {
|
||||
fmt.Fprintf(os.Stdout, "Usage: %s <output file>\n", os.Args[0])
|
||||
return
|
||||
}
|
||||
filename := os.Args[1]
|
||||
|
||||
// find the MP2 encoder
|
||||
codec := ffmpeg.AvCodecFindEncoder(ffmpeg.AV_CODEC_ID_MP2)
|
||||
|
||||
if codec == nil {
|
||||
fmt.Fprintf(os.Stderr, "Codec not found\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
avctx := ffmpeg.AvCodecAllocContext3(codec)
|
||||
if avctx == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate audio codec context\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// put sample parameters
|
||||
avctx.SetBitRate(64000)
|
||||
|
||||
avctx.SetSampleFmt(ffmpeg.AV_SAMPLE_FMT_S16)
|
||||
if checkSampleFmt(codec, avctx.GetSampleFmt()) == 0 {
|
||||
fmt.Fprintf(os.Stderr, "Encoder does not support sample format %s",
|
||||
ffmpeg.AvGetSampleFmtName(avctx.GetSampleFmt()))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// select other audio parameters supported by the encoder
|
||||
avctx.SetSampleRate(selectSampleRate(codec))
|
||||
avctx.SetChannelLayout(selectChannelLayout(codec))
|
||||
avctx.SetChannels(ffmpeg.AvGetChannelLayoutNbChannels(avctx.GetChannelLayout()))
|
||||
|
||||
// open it
|
||||
if ffmpeg.AvCodecOpen2(avctx, codec, nil) < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not open codec\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not open %s\n", filename)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// packet for holding encoded output
|
||||
pkt := ffmpeg.AvPacketAlloc()
|
||||
if pkt == nil {
|
||||
fmt.Fprintf(os.Stderr, "could not allocate the packet\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
frame := ffmpeg.AvFrameAlloc()
|
||||
if frame == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate audio frame\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
frame.SetNbSamples(avctx.GetFrameSize())
|
||||
frame.SetFormat(int32(avctx.GetSampleFmt()))
|
||||
frame.SetChannelLayout(avctx.GetChannelLayout())
|
||||
|
||||
// allocate the data buffers
|
||||
if ret := ffmpeg.AvFrameGetBuffer(frame, 0); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate audio data buffers\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// encode a single tone sound
|
||||
t := float64(0)
|
||||
tincr := 2 * math.Pi * 440.0 / float64(avctx.GetSampleRate())
|
||||
for i := 0; i < 200; i++ {
|
||||
// make sure the frame is writable -- makes a copy if the encoder
|
||||
// kept a reference internally
|
||||
if ret := ffmpeg.AvFrameMakeWritable(frame); ret < 0 {
|
||||
os.Exit(1)
|
||||
}
|
||||
samples := unsafe.Slice((*uint16)(unsafe.Pointer(frame.GetDataIdx(0))), 2*avctx.GetFrameSize()+avctx.GetChannels())
|
||||
|
||||
for j := 0; j < int(avctx.GetFrameSize()); j++ {
|
||||
samples[2*j] = (uint16)(math.Sin(t) * 10000)
|
||||
|
||||
for k := 1; k < int(avctx.GetChannels()); k++ {
|
||||
samples[2*j+k] = samples[2*j]
|
||||
}
|
||||
t += tincr
|
||||
}
|
||||
encode(avctx, frame, pkt, f)
|
||||
}
|
||||
|
||||
// flush the encoder
|
||||
encode(avctx, nil, pkt, f)
|
||||
|
||||
f.Close()
|
||||
|
||||
ffmpeg.AvFrameFree(&frame)
|
||||
ffmpeg.AvPacketFree(&pkt)
|
||||
ffmpeg.AvCodecFreeContext(&avctx)
|
||||
}
|
158
examples/encode-video/main.go
Normal file
158
examples/encode-video/main.go
Normal file
@@ -0,0 +1,158 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
ffmpeg "github.com/qrtc/ffmpeg-dev-go"
|
||||
)
|
||||
|
||||
func encode(encCtx *ffmpeg.AvCodecContext, frame *ffmpeg.AvFrame, pkt *ffmpeg.AvPacket, outfile *os.File) {
|
||||
if frame != nil {
|
||||
fmt.Fprintf(os.Stdout, "Send frame %3d\n", frame.GetPts())
|
||||
}
|
||||
|
||||
ret := ffmpeg.AvCodecSendFrame(encCtx, frame)
|
||||
if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error sending a frame for encoding\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
for ret >= 0 {
|
||||
ret = ffmpeg.AvCodecReceivePacket(encCtx, pkt)
|
||||
if ret == ffmpeg.AVERROR(int32(syscall.EAGAIN)) || ret == ffmpeg.AVERROR_EOF {
|
||||
return
|
||||
} else if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Error during encoding\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stdout, "Write packet %3d (size=%5d)\n", pkt.GetPts(), pkt.GetSize())
|
||||
outfile.Write(unsafe.Slice(pkt.GetData(), pkt.GetSize()))
|
||||
ffmpeg.AvPacketUnref(pkt)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
endcode := []uint8{0x00, 0x00, 0x01, 0xb7}
|
||||
if len(os.Args) <= 2 {
|
||||
fmt.Fprintf(os.Stdout, "Usage: %s <output file> <codec name>\n", os.Args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
filename := os.Args[1]
|
||||
codecName := os.Args[2]
|
||||
|
||||
// find the mpeg1video encoder
|
||||
codec := ffmpeg.AvCodecFindEncoderByName(codecName)
|
||||
if codec == nil {
|
||||
fmt.Fprintf(os.Stderr, "Codec '%s' not found\n", codecName)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
avctx := ffmpeg.AvCodecAllocContext3(codec)
|
||||
if avctx == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate video codec context\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
pkt := ffmpeg.AvPacketAlloc()
|
||||
if pkt == nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// put sample parameters
|
||||
avctx.SetBitRate(400000)
|
||||
// resolution must be a multiple of two
|
||||
avctx.SetWidth(352)
|
||||
avctx.SetHeight(288)
|
||||
// frames per second
|
||||
avctx.SetTimeBase(ffmpeg.AvMakeQ(1, 25))
|
||||
avctx.SetFramerate(ffmpeg.AvMakeQ(25, 1))
|
||||
|
||||
// emit one intra frame every ten frames check frame pict_type before passing frame
|
||||
// to encoder, if frame->pict_type is AV_PICTURE_TYPE_I
|
||||
// then gop_size is ignored and the output of encoder
|
||||
// will always be I frame irrespective to gop_size
|
||||
avctx.SetGopSize(10)
|
||||
avctx.SetMaxBFrames(1)
|
||||
avctx.SetPixFmt(ffmpeg.AV_PIX_FMT_YUV420P)
|
||||
|
||||
if codec.GetID() == ffmpeg.AV_CODEC_ID_H264 {
|
||||
ffmpeg.AvOptSet(avctx.GetPrivData(), "preset", "slow", 0)
|
||||
}
|
||||
|
||||
// open it
|
||||
ret := ffmpeg.AvCodecOpen2(avctx, codec, nil)
|
||||
if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not open codec %s\n", ffmpeg.AvErr2str(ret))
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
f, err := os.OpenFile(filename, os.O_WRONLY|os.O_CREATE|os.O_TRUNC, 0755)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not open %s\n", filename)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
frame := ffmpeg.AvFrameAlloc()
|
||||
if frame == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate video frame\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
frame.SetFormat(int32(avctx.GetPixFmt()))
|
||||
frame.SetWidth(avctx.GetWidth())
|
||||
frame.SetHeight(avctx.GetHeight())
|
||||
|
||||
ret = ffmpeg.AvFrameGetBuffer(frame, 0)
|
||||
if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate the video frame data\n")
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// encode 1 second of video
|
||||
for i := 0; i < 25; i++ {
|
||||
// make sure the frame data is writable
|
||||
ret = ffmpeg.AvFrameMakeWritable(frame)
|
||||
if ret < 0 {
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// prepare a dummy image
|
||||
data0 := unsafe.Slice(frame.GetDataIdx(0), avctx.GetHeight()*frame.GetLinesizeIdx(0)+avctx.GetWidth())
|
||||
data1 := unsafe.Slice(frame.GetDataIdx(1), (avctx.GetHeight()/2)*frame.GetLinesizeIdx(1)+(avctx.GetWidth()/2))
|
||||
data2 := unsafe.Slice(frame.GetDataIdx(2), (avctx.GetHeight()/2)*frame.GetLinesizeIdx(2)+(avctx.GetWidth()/2))
|
||||
// Y
|
||||
for y := 0; y < int(avctx.GetHeight()); y++ {
|
||||
for x := 0; x < int(avctx.GetWidth()); x++ {
|
||||
data0[y*int(frame.GetLinesizeIdx(0))+x] = uint8(x + y + i*3)
|
||||
}
|
||||
}
|
||||
// Cb and Cr
|
||||
for y := 0; y < int(avctx.GetHeight()/2); y++ {
|
||||
for x := 0; x < int(avctx.GetWidth()/2); x++ {
|
||||
data1[y*int(frame.GetLinesizeIdx(1))+x] = uint8(128 + y + i*2)
|
||||
data2[y*int(frame.GetLinesizeIdx(2))+x] = uint8(64 + x + i*5)
|
||||
}
|
||||
}
|
||||
|
||||
frame.SetPts(int64(i))
|
||||
|
||||
// encode the image
|
||||
encode(avctx, frame, pkt, f)
|
||||
}
|
||||
|
||||
// flush the encoder
|
||||
encode(avctx, nil, pkt, f)
|
||||
|
||||
// add sequence end code to have a real MPEG file
|
||||
if codec.GetID() == ffmpeg.AV_CODEC_ID_MPEG1VIDEO || codec.GetID() == ffmpeg.AV_CODEC_ID_MPEG2VIDEO {
|
||||
f.Write(endcode)
|
||||
}
|
||||
f.Close()
|
||||
|
||||
ffmpeg.AvCodecFreeContext(&avctx)
|
||||
ffmpeg.AvFrameFree(&frame)
|
||||
ffmpeg.AvPacketFree(&pkt)
|
||||
}
|
5
examples/extract-mvs/main.go
Normal file
5
examples/extract-mvs/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/filter-audio/main.go
Normal file
5
examples/filter-audio/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/filtering-audio/main.go
Normal file
5
examples/filtering-audio/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/filtering-video/main.go
Normal file
5
examples/filtering-video/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/http-multiclient/main.go
Normal file
5
examples/http-multiclient/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/hw-decode/main.go
Normal file
5
examples/hw-decode/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/metadata/main.go
Normal file
5
examples/metadata/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/muxing/main.go
Normal file
5
examples/muxing/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/qsvdec/main.go
Normal file
5
examples/qsvdec/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/remuxing/main.go
Normal file
5
examples/remuxing/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/resampling-audio/main.go
Normal file
5
examples/resampling-audio/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/scaling-video/main.go
Normal file
5
examples/scaling-video/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
687
examples/transcode-aac/main.go
Normal file
687
examples/transcode-aac/main.go
Normal file
@@ -0,0 +1,687 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"syscall"
|
||||
"unsafe"
|
||||
|
||||
ffmpeg "github.com/qrtc/ffmpeg-dev-go"
|
||||
)
|
||||
|
||||
const (
|
||||
OUTPUT_BIT_RATE = 96000
|
||||
OUTPUT_CHANNELS = 2
|
||||
)
|
||||
|
||||
// Open an input file and the required decoder.
|
||||
func openInputFile(fileName string) (inputFormatContext *ffmpeg.AvFormatContext,
|
||||
inputCodecContext *ffmpeg.AvCodecContext, ret int32) {
|
||||
|
||||
// Open the input file to read from it.
|
||||
if ret = ffmpeg.AvFormatOpenInput(&inputFormatContext, fileName, nil, nil); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not open input file '%s' (error '%s')\n", fileName, ffmpeg.AvErr2str(ret))
|
||||
return nil, nil, ret
|
||||
}
|
||||
|
||||
// Get information on the input file (number of streams etc.).
|
||||
if ret = ffmpeg.AvFormatFindStreamInfo(inputFormatContext, nil); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not open find stream info (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
ffmpeg.AvFormatCloseInput(&inputFormatContext)
|
||||
return nil, nil, ret
|
||||
}
|
||||
|
||||
// Make sure that there is only one stream in the input file.
|
||||
if inputFormatContext.GetNbStreams() != 1 {
|
||||
fmt.Fprintf(os.Stderr, "Expected one audio input stream, but found %d\n", inputFormatContext.GetNbStreams())
|
||||
ffmpeg.AvFormatCloseInput(&inputFormatContext)
|
||||
return nil, nil, ffmpeg.AVERROR_EXIT
|
||||
}
|
||||
|
||||
// Find a decoder for the audio stream.
|
||||
inputCodec := ffmpeg.AvCodecFindDecoder(inputFormatContext.GetStreams()[0].GetCodecpar().GetCodecId())
|
||||
if inputCodec == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not find input codec\n")
|
||||
ffmpeg.AvFormatCloseInput(&inputFormatContext)
|
||||
return nil, nil, ffmpeg.AVERROR_EXIT
|
||||
}
|
||||
|
||||
// Allocate a new decoding context.
|
||||
avctx := ffmpeg.AvCodecAllocContext3(inputCodec)
|
||||
if avctx == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate a decoding context\n")
|
||||
ffmpeg.AvFormatCloseInput(&inputFormatContext)
|
||||
return nil, nil, ffmpeg.AVERROR(int32(syscall.ENOMEM))
|
||||
}
|
||||
|
||||
// Initialize the stream parameters with demuxer information.
|
||||
if ret = ffmpeg.AvCodecParametersToContext(avctx, inputFormatContext.GetStreams()[0].GetCodecpar()); ret < 0 {
|
||||
ffmpeg.AvFormatCloseInput(&inputFormatContext)
|
||||
ffmpeg.AvCodecFreeContext(&avctx)
|
||||
return nil, nil, ret
|
||||
}
|
||||
|
||||
// Open the decoder for the audio stream to use it later.
|
||||
if ret = ffmpeg.AvCodecOpen2(avctx, inputCodec, nil); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not open input codec (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
ffmpeg.AvCodecFreeContext(&avctx)
|
||||
ffmpeg.AvFormatCloseInput(&inputFormatContext)
|
||||
return nil, nil, ret
|
||||
}
|
||||
|
||||
// Save the decoder context for easier access later.
|
||||
inputCodecContext = avctx
|
||||
|
||||
return inputFormatContext, inputCodecContext, ret
|
||||
}
|
||||
|
||||
// Open an output file and the required encoder.
|
||||
func openOutputFile(filename string, inputCodecContext *ffmpeg.AvCodecContext) (outputFormatContext *ffmpeg.AvFormatContext,
|
||||
outputCodecContext *ffmpeg.AvCodecContext, ret int32) {
|
||||
|
||||
var outputIOContext *ffmpeg.AvIOContext
|
||||
var outputCodec *ffmpeg.AvCodec
|
||||
var stream *ffmpeg.AvStream
|
||||
var avctx *ffmpeg.AvCodecContext
|
||||
|
||||
// Open the output file to write to it.
|
||||
if ret = ffmpeg.AvIOOpen(&outputIOContext, filename, ffmpeg.AVIO_FLAG_WRITE); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not open output file '%s' (error '%s')\n", filename, ffmpeg.AvErr2str(ret))
|
||||
return nil, nil, ret
|
||||
}
|
||||
|
||||
// Create a new format context for the output container format.
|
||||
if outputFormatContext = ffmpeg.AvFormatAllocContext(); outputFormatContext == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate output format context\n")
|
||||
return nil, nil, ffmpeg.AVERROR(int32(syscall.ENOMEM))
|
||||
}
|
||||
|
||||
// Associate the output file (pointer) with the container format context.
|
||||
outputFormatContext.SetPb(outputIOContext)
|
||||
|
||||
// Guess the desired container format based on the file extension.
|
||||
outputFormatContext.SetOformat(ffmpeg.AvGuessFormat("", filename, ""))
|
||||
if outputFormatContext.GetOformat() == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not find output file format\n")
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
outputFormatContext.SetUrl(filename)
|
||||
if len(outputFormatContext.GetUrl()) == 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate url.\n")
|
||||
ret = ffmpeg.AVERROR(int32(syscall.ENOMEM))
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
// Find the encoder to be used by its name.
|
||||
if outputCodec = ffmpeg.AvCodecFindEncoder(ffmpeg.AV_CODEC_ID_AAC); outputCodec == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not find an AAC encoder.\n")
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
// Create a new audio stream in the output file container.
|
||||
if stream = ffmpeg.AvFormatNewStream(outputFormatContext, nil); stream == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not create new stream\n")
|
||||
ret = ffmpeg.AVERROR(int32(syscall.ENOMEM))
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
if avctx = ffmpeg.AvCodecAllocContext3(outputCodec); avctx == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate an encoding context\n")
|
||||
ret = ffmpeg.AVERROR(int32(syscall.ENOMEM))
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
// Set the basic encoder parameters.
|
||||
// The input file's sample rate is used to avoid a sample rate conversion.
|
||||
avctx.SetChannels(OUTPUT_CHANNELS)
|
||||
avctx.SetChannelLayout(uint64(ffmpeg.AvGetDefaultChannelLayout(OUTPUT_CHANNELS)))
|
||||
avctx.SetSampleRate(inputCodecContext.GetSampleRate())
|
||||
avctx.SetSampleFmt(outputCodec.GetSampleFmts()[0])
|
||||
avctx.SetBitRate(OUTPUT_BIT_RATE)
|
||||
|
||||
// Allow the use of the experimental AAC encoder.
|
||||
avctx.SetStrictStdCompliance(ffmpeg.FF_COMPLIANCE_EXPERIMENTAL)
|
||||
|
||||
// Set the sample rate for the container.
|
||||
stream.SetTimeBase(ffmpeg.AvMakeQ(inputCodecContext.GetSampleRate(), 1))
|
||||
|
||||
// Some container formats (like MP4) require global headers to be present.
|
||||
// Mark the encoder so that it behaves accordingly.
|
||||
if (outputFormatContext.GetOformat().GetFlags() & ffmpeg.AVFMT_GLOBALHEADER) != 0 {
|
||||
avctx.SetFlags(avctx.GetFlags() | ffmpeg.AV_CODEC_FLAG_GLOBAL_HEADER)
|
||||
}
|
||||
|
||||
// Open the encoder for the audio stream to use it later.
|
||||
if ret = ffmpeg.AvCodecOpen2(avctx, outputCodec, nil); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not open output codec (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
ret = ffmpeg.AvCodecParametersFromContext(stream.GetCodecpar(), avctx)
|
||||
if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not initialize stream parameters\n")
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
// Save the encoder context for easier access later.
|
||||
outputCodecContext = avctx
|
||||
|
||||
return outputFormatContext, outputCodecContext, 0
|
||||
|
||||
cleanup:
|
||||
ffmpeg.AvCodecFreeContext(&avctx)
|
||||
ffmpeg.AvIOClosep(outputFormatContext.GetPbAddr())
|
||||
if ret > 0 {
|
||||
ret = ffmpeg.AVERROR_EXIT
|
||||
}
|
||||
return nil, nil, ret
|
||||
}
|
||||
|
||||
// Initialize one data packet for reading or writing.
|
||||
func initPacket() (packet *ffmpeg.AvPacket, ret int32) {
|
||||
if packet = ffmpeg.AvPacketAlloc(); packet == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate packet\n")
|
||||
return nil, ffmpeg.AVERROR(int32(syscall.ENOMEM))
|
||||
}
|
||||
return packet, 0
|
||||
}
|
||||
|
||||
// Initialize one audio frame for reading from the input file.
|
||||
func initInputFrame() (frame *ffmpeg.AvFrame, ret int32) {
|
||||
if frame = ffmpeg.AvFrameAlloc(); frame == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate input frame\n")
|
||||
return nil, ffmpeg.AVERROR(int32(syscall.ENOMEM))
|
||||
}
|
||||
return frame, 0
|
||||
}
|
||||
|
||||
// Initialize the audio resampler based on the input and output codec settings.
|
||||
// If the input and output sample formats differ, a conversion is required
|
||||
// libswresample takes care of this, but requires initialization.
|
||||
func initResampler(inputCodecContext, outputCodecContext *ffmpeg.AvCodecContext) (
|
||||
resampleContext *ffmpeg.SwrContext, ret int32) {
|
||||
|
||||
// Create a resampler context for the conversion.
|
||||
// Set the conversion parameters.
|
||||
// Default channel layouts based on the number of channels
|
||||
// are assumed for simplicity (they are sometimes not detected
|
||||
// properly by the demuxer and/or decoder).
|
||||
if resampleContext = ffmpeg.SwrAllocSetOpts(nil,
|
||||
ffmpeg.AvGetDefaultChannelLayout(outputCodecContext.GetChannels()),
|
||||
outputCodecContext.GetSampleFmt(),
|
||||
outputCodecContext.GetSampleRate(),
|
||||
ffmpeg.AvGetDefaultChannelLayout(inputCodecContext.GetChannels()),
|
||||
inputCodecContext.GetSampleFmt(),
|
||||
inputCodecContext.GetSampleRate(),
|
||||
0, nil); resampleContext == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate resample context\n")
|
||||
return nil, ffmpeg.AVERROR(int32(syscall.ENOMEM))
|
||||
}
|
||||
|
||||
if outputCodecContext.GetSampleRate() != inputCodecContext.GetSampleRate() {
|
||||
panic("resample has to be handled differently")
|
||||
}
|
||||
|
||||
// Open the resampler with the specified parameters.
|
||||
if ret = ffmpeg.SwrInit(resampleContext); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not open resample context\n")
|
||||
ffmpeg.SwrFree(&resampleContext)
|
||||
return nil, ret
|
||||
}
|
||||
return resampleContext, 0
|
||||
}
|
||||
|
||||
// Initialize a FIFO buffer for the audio samples to be encoded.
|
||||
func initFifo(outputCodecContext *ffmpeg.AvCodecContext) (fifo *ffmpeg.AvAudioFifo, ret int32) {
|
||||
// Create the FIFO buffer based on the specified output sample format
|
||||
if fifo = ffmpeg.AvAudioFifoAlloc(outputCodecContext.GetSampleFmt(),
|
||||
outputCodecContext.GetChannels(), 1); fifo == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate FIFO\n")
|
||||
return nil, ffmpeg.AVERROR(int32(syscall.ENOMEM))
|
||||
}
|
||||
return fifo, 0
|
||||
}
|
||||
|
||||
// Write the header of the output file container.
|
||||
func writeOutputFileHeader(outputFormatContext *ffmpeg.AvFormatContext) int32 {
|
||||
if ret := ffmpeg.AvFormatWriteHeader(outputFormatContext, nil); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not write output file header (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
return ret
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Decode one audio frame from the input file.
|
||||
func decodeAudioFrame(frame *ffmpeg.AvFrame,
|
||||
inputFormatContext *ffmpeg.AvFormatContext,
|
||||
inputCodecContext *ffmpeg.AvCodecContext) (dataPresent, finished, ret int32) {
|
||||
// Packet used for temporary storage.
|
||||
inputPacket, ret := initPacket()
|
||||
if ret < 0 {
|
||||
return 0, 0, ret
|
||||
}
|
||||
|
||||
// Read one audio frame from the input file into a temporary packet.
|
||||
if ret = ffmpeg.AvReadFrame(inputFormatContext, inputPacket); ret < 0 {
|
||||
// If we are at the end of the file, flush the decoder below.
|
||||
if ret == ffmpeg.AVERROR_EOF {
|
||||
finished = 1
|
||||
} else {
|
||||
fmt.Fprintf(os.Stderr, "Could not read frame (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
goto cleanup
|
||||
}
|
||||
}
|
||||
|
||||
// Send the audio frame stored in the temporary packet to the decoder.
|
||||
// The input audio stream decoder is used to do this.
|
||||
if ret = ffmpeg.AvCodecSendPacket(inputCodecContext, inputPacket); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not send packet for decoding (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
// Receive one frame from the decoder.
|
||||
ret = ffmpeg.AvCodecReceiveFrame(inputCodecContext, frame)
|
||||
switch {
|
||||
// If the decoder asks for more data to be able to decode a frame,
|
||||
// return indicating that no data is present.
|
||||
case ret == ffmpeg.AVERROR(int32(syscall.EAGAIN)):
|
||||
ret = 0
|
||||
goto cleanup
|
||||
// If the end of the input file is reached, stop decoding.
|
||||
case ret == ffmpeg.AVERROR_EOF:
|
||||
finished = 1
|
||||
ret = 0
|
||||
goto cleanup
|
||||
case ret < 0:
|
||||
fmt.Fprintf(os.Stderr, "Could not decode frame (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
goto cleanup
|
||||
// Default case: Return decoded data.
|
||||
default:
|
||||
dataPresent = 1
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
cleanup:
|
||||
ffmpeg.AvPacketFree(&inputPacket)
|
||||
return dataPresent, finished, ret
|
||||
}
|
||||
|
||||
// Initialize a temporary storage for the specified number of audio samples.
|
||||
// The conversion requires temporary storage due to the different format.
|
||||
// The number of audio samples to be allocated is specified in frame_size.
|
||||
func initConvertedSamples(outputCodecContext *ffmpeg.AvCodecContext,
|
||||
frameSize int32) (convertedInputSamples **uint8, ret int32) {
|
||||
|
||||
// Allocate as many pointers as there are audio channels.
|
||||
// Each pointer will later point to the audio samples of the corresponding
|
||||
// channels (although it may be NULL for interleaved formats).
|
||||
if convertedInputSamples = (**uint8)(ffmpeg.AvCalloc(uint(outputCodecContext.GetChannels()),
|
||||
uint(unsafe.Sizeof(*convertedInputSamples)))); convertedInputSamples == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate converted input sample pointers\n")
|
||||
return nil, ffmpeg.AVERROR(int32(syscall.ENOMEM))
|
||||
}
|
||||
|
||||
// Allocate memory for the samples of all channels in one consecutive
|
||||
// block for convenience.
|
||||
if ret = ffmpeg.AvSamplesAlloc(convertedInputSamples, nil,
|
||||
outputCodecContext.GetChannels(),
|
||||
frameSize,
|
||||
outputCodecContext.GetSampleFmt(), 0); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate converted input samples (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
ffmpeg.AvFreep(unsafe.Pointer(&convertedInputSamples))
|
||||
return nil, ret
|
||||
}
|
||||
return convertedInputSamples, 0
|
||||
}
|
||||
|
||||
// Convert the input audio samples into the output sample format.
|
||||
// The conversion happens on a per-frame basis, the size of which is
|
||||
// specified by frame_size.
|
||||
func convertSamples(inputData, convertedData **uint8,
|
||||
frameSize int32, resampleContext *ffmpeg.SwrContext) (ret int32) {
|
||||
if ret = ffmpeg.SwrConvert(resampleContext,
|
||||
convertedData, frameSize,
|
||||
inputData, frameSize); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not convert input samples (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
return ret
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Add converted input audio samples to the FIFO buffer for later processing.
|
||||
func addSamplesToFifo(fifo *ffmpeg.AvAudioFifo, convertedInputSamples **uint8, frameSize int32) int32 {
|
||||
// Make the FIFO as large as it needs to be to hold both,
|
||||
// the old and the new samples.
|
||||
if ret := ffmpeg.AvAudioFifoRealloc(fifo, ffmpeg.AvAudioFifoSize(fifo)+frameSize); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not reallocate FIFO\n")
|
||||
return ret
|
||||
}
|
||||
|
||||
// Store the new samples in the FIFO buffer.
|
||||
if ret := ffmpeg.AvAudioFifoWrite(fifo, (*unsafe.Pointer)(unsafe.Pointer(convertedInputSamples)),
|
||||
frameSize); ret < frameSize {
|
||||
fmt.Fprintf(os.Stderr, "Could not write data to FIFO\n")
|
||||
return ffmpeg.AVERROR_EXIT
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
// Read one audio frame from the input file, decode, convert and store it in the FIFO buffer.
|
||||
func readDecodeConvertAndStore(fifo *ffmpeg.AvAudioFifo,
|
||||
inputFormatContext *ffmpeg.AvFormatContext,
|
||||
inputCodecContext *ffmpeg.AvCodecContext,
|
||||
outputCodecContext *ffmpeg.AvCodecContext,
|
||||
resamplerContext *ffmpeg.SwrContext) (finished, ret int32) {
|
||||
|
||||
// Temporary storage of the input samples of the frame read from the file.
|
||||
var inputFrame *ffmpeg.AvFrame
|
||||
// Temporary storage for the converted input samples.
|
||||
var convertedInputSamples **uint8
|
||||
var dataPresent int32
|
||||
ret = ffmpeg.AVERROR_EXIT
|
||||
|
||||
// Initialize temporary storage for one input frame.
|
||||
if inputFrame, ret = initInputFrame(); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
// Decode one frame worth of audio samples.
|
||||
if dataPresent, finished, ret = decodeAudioFrame(inputFrame,
|
||||
inputFormatContext, inputCodecContext); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
// If we are at the end of the file and there are no more samples
|
||||
// in the decoder which are delayed, we are actually finished.
|
||||
// This must not be treated as an error.
|
||||
if finished != 0 {
|
||||
ret = 0
|
||||
goto cleanup
|
||||
}
|
||||
// If there is decoded data, convert and store it.
|
||||
if dataPresent != 0 {
|
||||
// Initialize the temporary storage for the converted input samples.
|
||||
if convertedInputSamples, ret = initConvertedSamples(outputCodecContext,
|
||||
inputFrame.GetNbSamples()); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
// Convert the input samples to the desired output sample format.
|
||||
// This requires a temporary storage provided by converted_input_samples.
|
||||
if ret = convertSamples(inputFrame.GetExtendedData(),
|
||||
convertedInputSamples, inputFrame.GetNbSamples(), resamplerContext); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
// Add the converted input samples to the FIFO buffer for later processing.
|
||||
if ret = addSamplesToFifo(fifo, convertedInputSamples,
|
||||
inputFrame.GetNbSamples()); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
ret = 0
|
||||
}
|
||||
ret = 0
|
||||
|
||||
cleanup:
|
||||
if convertedInputSamples != nil {
|
||||
ffmpeg.AvFreep(unsafe.Pointer(&convertedInputSamples))
|
||||
}
|
||||
ffmpeg.AvFrameFree(&inputFrame)
|
||||
|
||||
return finished, ret
|
||||
}
|
||||
|
||||
// Initialize one input frame for writing to the output file.
|
||||
func initOutputFrame(outputcodecContext *ffmpeg.AvCodecContext,
|
||||
frameSize int32) (frame *ffmpeg.AvFrame, ret int32) {
|
||||
|
||||
// Create a new frame to store the audio samples.
|
||||
if frame = ffmpeg.AvFrameAlloc(); frame == nil {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate output frame\n")
|
||||
return nil, ffmpeg.AVERROR_EXIT
|
||||
}
|
||||
|
||||
// Set the frame's parameters, especially its size and format.
|
||||
// av_frame_get_buffer needs this to allocate memory for the
|
||||
// audio samples of the frame.
|
||||
// Default channel layouts based on the number of channels
|
||||
// are assumed for simplicity.
|
||||
frame.SetNbSamples(frameSize)
|
||||
frame.SetChannelLayout(outputcodecContext.GetChannelLayout())
|
||||
frame.SetFormat(int32(outputcodecContext.GetSampleFmt()))
|
||||
frame.SetSampleRate(outputcodecContext.GetSampleRate())
|
||||
|
||||
// Allocate the samples of the created frame. This call will make
|
||||
// sure that the audio frame can hold as many samples as specified.
|
||||
if ret = ffmpeg.AvFrameGetBuffer(frame, 0); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not allocate output frame samples (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
ffmpeg.AvFrameFree(&frame)
|
||||
return nil, ret
|
||||
}
|
||||
|
||||
return frame, 0
|
||||
}
|
||||
|
||||
// Global timestamp for the audio frames.
|
||||
var pts int64
|
||||
|
||||
// Encode one frame worth of audio to the output file.
|
||||
func encodeAudioFrame(frame *ffmpeg.AvFrame,
|
||||
outputFormatContext *ffmpeg.AvFormatContext,
|
||||
outputCodecContext *ffmpeg.AvCodecContext) (dataPresent, ret int32) {
|
||||
// Packet used for temporary storage.
|
||||
var outputPacket *ffmpeg.AvPacket
|
||||
|
||||
if outputPacket, ret = initPacket(); ret < 0 {
|
||||
return dataPresent, ret
|
||||
}
|
||||
|
||||
// Set a timestamp based on the sample rate for the container.
|
||||
if frame != nil {
|
||||
frame.SetPts(pts)
|
||||
pts += int64(frame.GetNbSamples())
|
||||
}
|
||||
|
||||
// Send the audio frame stored in the temporary packet to the encoder.
|
||||
// The output audio stream encoder is used to do this.
|
||||
ret = ffmpeg.AvCodecSendFrame(outputCodecContext, frame)
|
||||
if ret == ffmpeg.AVERROR_EOF {
|
||||
ret = 0
|
||||
goto cleanup
|
||||
} else if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not send packet for encoding (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
// Receive one encoded frame from the encoder.
|
||||
ret = ffmpeg.AvCodecReceivePacket(outputCodecContext, outputPacket)
|
||||
// If the encoder asks for more data to be able to provide an
|
||||
// encoded frame, return indicating that no data is present.
|
||||
if ret == ffmpeg.AVERROR(int32(syscall.EAGAIN)) {
|
||||
ret = 0
|
||||
goto cleanup
|
||||
} else if ret == ffmpeg.AVERROR_EOF {
|
||||
// If the last frame has been encoded, stop encoding.
|
||||
ret = 0
|
||||
goto cleanup
|
||||
} else if ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not encode frame (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
goto cleanup
|
||||
} else {
|
||||
// Default case: Return encoded data.
|
||||
dataPresent = 1
|
||||
}
|
||||
|
||||
// Write one audio frame from the temporary packet to the output file.
|
||||
if dataPresent != 0 {
|
||||
if ret = ffmpeg.AvWriteFrame(outputFormatContext, outputPacket); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not write frame (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
goto cleanup
|
||||
}
|
||||
}
|
||||
|
||||
cleanup:
|
||||
ffmpeg.AvPacketFree(&outputPacket)
|
||||
return dataPresent, ret
|
||||
}
|
||||
|
||||
// Load one audio frame from the FIFO buffer, encode and write it to the output file.
|
||||
func loadEncodeAndWrite(fifo *ffmpeg.AvAudioFifo,
|
||||
outputFormatContext *ffmpeg.AvFormatContext,
|
||||
outputCodecContext *ffmpeg.AvCodecContext) (ret int32) {
|
||||
// Temporary storage of the output samples of the frame written to the file.
|
||||
var outputFrame *ffmpeg.AvFrame
|
||||
// Use the maximum number of possible samples per frame.
|
||||
// If there is less than the maximum possible frame size in the FIFO
|
||||
// buffer use this number. Otherwise, use the maximum possible frame size.
|
||||
frameSize := ffmpeg.FFMIN(ffmpeg.AvAudioFifoSize(fifo), outputCodecContext.GetFrameSize())
|
||||
|
||||
// Initialize temporary storage for one output frame.
|
||||
if outputFrame, ret = initOutputFrame(outputCodecContext, frameSize); ret != 0 {
|
||||
return ffmpeg.AVERROR_EXIT
|
||||
}
|
||||
|
||||
// Read as many samples from the FIFO buffer as required to fill the frame.
|
||||
// The samples are stored in the frame temporarily.
|
||||
if ret = ffmpeg.AvAudioFifoRead(fifo,
|
||||
(*unsafe.Pointer)(unsafe.Pointer(outputFrame.GetData())), frameSize); ret < frameSize {
|
||||
fmt.Fprintf(os.Stderr, "Could not read data from FIFO\n")
|
||||
ffmpeg.AvFrameFree(&outputFrame)
|
||||
return ffmpeg.AVERROR_EXIT
|
||||
}
|
||||
|
||||
// Encode one frame worth of audio samples.
|
||||
if _, ret = encodeAudioFrame(outputFrame,
|
||||
outputFormatContext, outputCodecContext); ret != 0 {
|
||||
ffmpeg.AvFrameFree(&outputFrame)
|
||||
return ffmpeg.AVERROR_EXIT
|
||||
}
|
||||
ffmpeg.AvFrameFree(&outputFrame)
|
||||
return 0
|
||||
}
|
||||
|
||||
// Write the trailer of the output file container.
|
||||
func writeOutputFileTrailer(outputFormatContext *ffmpeg.AvFormatContext) int32 {
|
||||
if ret := ffmpeg.AvWriteTrailer(outputFormatContext); ret < 0 {
|
||||
fmt.Fprintf(os.Stderr, "Could not write output file trailer (error '%s')\n", ffmpeg.AvErr2str(ret))
|
||||
return ret
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
func main() {
|
||||
var ret int32 = ffmpeg.AVERROR_EXIT
|
||||
var inputFormatContext *ffmpeg.AvFormatContext
|
||||
var inputCodecContext *ffmpeg.AvCodecContext
|
||||
var outputFormatContext *ffmpeg.AvFormatContext
|
||||
var outputCodecContext *ffmpeg.AvCodecContext
|
||||
var resampleContext *ffmpeg.SwrContext
|
||||
var fifo *ffmpeg.AvAudioFifo
|
||||
|
||||
if len(os.Args) != 3 {
|
||||
fmt.Fprintf(os.Stdout, "Usage: %s <input file> <output file>\n", os.Args[0])
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Open the input file for reading.
|
||||
if inputFormatContext, inputCodecContext, ret = openInputFile(os.Args[1]); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
// Open the output file for writing.
|
||||
if outputFormatContext, outputCodecContext, ret = openOutputFile(os.Args[2],
|
||||
inputCodecContext); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
// Initialize the resampler to be able to convert audio sample formats.
|
||||
if resampleContext, ret = initResampler(inputCodecContext, outputCodecContext); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
// Initialize the FIFO buffer to store audio samples to be encoded.
|
||||
if fifo, ret = initFifo(outputCodecContext); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
// Write the header of the output file container.
|
||||
if ret = writeOutputFileHeader(outputFormatContext); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
// Loop as long as we have input samples to read or output samples
|
||||
// to write; abort as soon as we have neither.
|
||||
for {
|
||||
// Use the encoder's desired frame size for processing.
|
||||
var outputFrameSize int32 = outputCodecContext.GetFrameSize()
|
||||
var finished int32
|
||||
|
||||
// Make sure that there is one frame worth of samples in the FIFO
|
||||
// buffer so that the encoder can do its work.
|
||||
// Since the decoder's and the encoder's frame size may differ, we
|
||||
// need to FIFO buffer to store as many frames worth of input samples
|
||||
// that they make up at least one frame worth of output samples.
|
||||
for ffmpeg.AvAudioFifoSize(fifo) < outputFrameSize {
|
||||
// Decode one frame worth of audio samples, convert it to the
|
||||
// output sample format and put it into the FIFO buffer.
|
||||
if finished, ret = readDecodeConvertAndStore(fifo, inputFormatContext,
|
||||
inputCodecContext, outputCodecContext, resampleContext); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
|
||||
// If we are at the end of the input file, we continue
|
||||
// encoding the remaining audio samples to the output file.
|
||||
if finished != 0 {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// If we have enough samples for the encoder, we encode them.
|
||||
// At the end of the file, we pass the remaining samples to
|
||||
// the encoder.
|
||||
for ffmpeg.AvAudioFifoSize(fifo) >= outputFrameSize ||
|
||||
(finished != 0 && ffmpeg.AvAudioFifoSize(fifo) > 0) {
|
||||
// Take one frame worth of audio samples from the FIFO buffer,
|
||||
// encode it and write it to the output file.
|
||||
if ret = loadEncodeAndWrite(fifo, outputFormatContext, outputCodecContext); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
}
|
||||
|
||||
// If we are at the end of the input file and have encoded
|
||||
// all remaining samples, we can exit this loop and finish.
|
||||
if finished != 0 {
|
||||
var dataWritten int32
|
||||
// Flush the encoder as it may have delayed frames.
|
||||
for ok := true; ok; ok = dataWritten != 0 {
|
||||
if dataWritten, ret = encodeAudioFrame(nil,
|
||||
outputFormatContext, outputCodecContext); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
// Write the trailer of the output file container.
|
||||
if ret = writeOutputFileTrailer(outputFormatContext); ret != 0 {
|
||||
goto cleanup
|
||||
}
|
||||
ret = 0
|
||||
|
||||
cleanup:
|
||||
if fifo != nil {
|
||||
ffmpeg.AvAudioFifoFree(fifo)
|
||||
}
|
||||
ffmpeg.SwrFree(&resampleContext)
|
||||
if outputCodecContext != nil {
|
||||
ffmpeg.AvCodecFreeContext(&outputCodecContext)
|
||||
}
|
||||
if outputFormatContext != nil {
|
||||
ffmpeg.AvIOClosep(outputFormatContext.GetPbAddr())
|
||||
ffmpeg.AvFormatFreeContext(outputFormatContext)
|
||||
}
|
||||
if inputCodecContext != nil {
|
||||
ffmpeg.AvCodecFreeContext(&inputCodecContext)
|
||||
}
|
||||
if inputFormatContext != nil {
|
||||
ffmpeg.AvFormatCloseInput(&inputFormatContext)
|
||||
}
|
||||
|
||||
os.Exit(int(ret))
|
||||
}
|
5
examples/transcoding/main.go
Normal file
5
examples/transcoding/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/vaapi-encode/main.go
Normal file
5
examples/vaapi-encode/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
5
examples/vaapi-transcode/main.go
Normal file
5
examples/vaapi-transcode/main.go
Normal file
@@ -0,0 +1,5 @@
|
||||
package main
|
||||
|
||||
func main() {
|
||||
|
||||
}
|
7
ffmpeg.go
Normal file
7
ffmpeg.go
Normal file
@@ -0,0 +1,7 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#cgo CPPFLAGS: -Wno-deprecated-declarations
|
||||
#cgo pkg-config: libavdevice libavformat libavfilter libavresample libavcodec libpostproc libswscale libswresample libavutil
|
||||
*/
|
||||
import "C"
|
42
ffmpeg_helper.go
Normal file
42
ffmpeg_helper.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
type HelperInteger interface {
|
||||
HelperSingedInteger | HelperUnsingedInteger
|
||||
}
|
||||
|
||||
type HelperSingedInteger interface {
|
||||
~int | ~int8 | ~int16 | ~int32 | ~int64
|
||||
}
|
||||
|
||||
type HelperUnsingedInteger interface {
|
||||
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
|
||||
}
|
||||
|
||||
// StringCasting casts go string to c world char* with free function
|
||||
// Note: if input is a empty string will return a nil pointer.
|
||||
func StringCasting(str string) (allocPtr *C.char, freeFunc func()) {
|
||||
if len(str) == 0 {
|
||||
return nil, func() {}
|
||||
}
|
||||
allocPtr = C.CString(str)
|
||||
freeFunc = func() { C.free(unsafe.Pointer(allocPtr)) }
|
||||
return allocPtr, freeFunc
|
||||
}
|
||||
|
||||
// SliceWithOffset returns a []byte slice from a porinter with size.
|
||||
func Slice[T HelperInteger](data *uint8, size T) []byte {
|
||||
return unsafe.Slice(data, size)
|
||||
}
|
||||
|
||||
// SliceWithOffset returns a []byte slice from a porinter with offset and size.
|
||||
func SliceWithOffset[U, V HelperInteger](data *uint8, offset U, size V) []byte {
|
||||
return unsafe.Slice((*uint8)(unsafe.Add(unsafe.Pointer(uintptr(unsafe.Pointer(data))), offset)), size)
|
||||
}
|
42
ffmpeg_pointer.go
Normal file
42
ffmpeg_pointer.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <stdlib.h>
|
||||
*/
|
||||
import "C"
|
||||
import (
|
||||
"sync"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
var (
|
||||
pointerSyncMap sync.Map
|
||||
)
|
||||
|
||||
func PointerStore(v interface{}) unsafe.Pointer {
|
||||
if v == nil {
|
||||
return nil
|
||||
}
|
||||
ptr := C.malloc(C.size_t(1))
|
||||
if ptr == nil {
|
||||
panic("allocate memory failed")
|
||||
}
|
||||
pointerSyncMap.Store(ptr, v)
|
||||
return ptr
|
||||
}
|
||||
|
||||
func PointerLoad(ptr unsafe.Pointer) (v interface{}) {
|
||||
if ptr == nil {
|
||||
return nil
|
||||
}
|
||||
v, _ = pointerSyncMap.Load(ptr)
|
||||
return v
|
||||
}
|
||||
|
||||
func PointerDelete(ptr unsafe.Pointer) {
|
||||
if ptr == nil {
|
||||
return
|
||||
}
|
||||
pointerSyncMap.Delete(ptr)
|
||||
C.free(ptr)
|
||||
}
|
86
postproc.go
Normal file
86
postproc.go
Normal file
@@ -0,0 +1,86 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libpostproc/postprocess.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// PostprocVersion returns the LIBPOSTPROC_VERSION_INT constant.
|
||||
func PostprocVersion() uint32 {
|
||||
return (uint32)(C.postproc_version())
|
||||
}
|
||||
|
||||
// PostprocConfiguration returns the libpostproc build-time configuration.
|
||||
func PostprocConfiguration() string {
|
||||
return C.GoString(C.postproc_configuration())
|
||||
}
|
||||
|
||||
// PostprocLicense returns the libpostproc license.
|
||||
func PostprocLicense() string {
|
||||
return C.GoString(C.postproc_license())
|
||||
}
|
||||
|
||||
const (
|
||||
PP_QUALITY_MAX = C.PP_QUALITY_MAX
|
||||
)
|
||||
|
||||
type PpContext C.pp_context
|
||||
|
||||
type PpMode C.pp_mode
|
||||
|
||||
// PpPostprocess
|
||||
func PpPostprocess(src [3]*uint8, srcStride []int32,
|
||||
dst [3]*uint8, dstStride []int32,
|
||||
horizontalSize, verticalSize int32,
|
||||
QPStore *int8, QPStride int32,
|
||||
ppMode *PpMode, ppContext *PpContext, pictType int32) {
|
||||
C.pp_postprocess((**C.uint8_t)(unsafe.Pointer(&src[0])), (*C.int)(&srcStride[0]),
|
||||
(**C.uint8_t)(unsafe.Pointer(&dst[0])), (*C.int)(&dstStride[0]),
|
||||
(C.int)(horizontalSize), (C.int)(verticalSize),
|
||||
(*C.int8_t)(QPStore), (C.int)(QPStride),
|
||||
unsafe.Pointer(ppMode), unsafe.Pointer(ppContext), (C.int)(pictType))
|
||||
}
|
||||
|
||||
// PpGetModeByNameAndQuality returns a pp_mode or NULL if an error occurred.
|
||||
func PpGetModeByNameAndQuality(name string, quality int32) *PpMode {
|
||||
namePtr, nameFunc := StringCasting(name)
|
||||
defer nameFunc()
|
||||
return (*PpMode)(C.pp_get_mode_by_name_and_quality((*C.char)(namePtr), (C.int)(quality)))
|
||||
}
|
||||
|
||||
// PpFreeMode
|
||||
func PpFreeMode(mode *PpMode) {
|
||||
C.pp_free_mode(unsafe.Pointer(mode))
|
||||
}
|
||||
|
||||
// PpGetContext
|
||||
func PpGetContext(width, height, flags int32) *PpContext {
|
||||
return (*PpContext)(C.pp_get_context((C.int)(width), (C.int)(height), (C.int)(flags)))
|
||||
}
|
||||
|
||||
// PpFreeContext
|
||||
func PpFreeContext(mode *PpContext) {
|
||||
C.pp_free_context(unsafe.Pointer(mode))
|
||||
}
|
||||
|
||||
const (
|
||||
PP_CPU_CAPS_MMX = C.PP_CPU_CAPS_MMX
|
||||
PP_CPU_CAPS_MMX2 = C.PP_CPU_CAPS_MMX2
|
||||
PP_CPU_CAPS_3DNOW = C.PP_CPU_CAPS_3DNOW
|
||||
PP_CPU_CAPS_ALTIVEC = C.PP_CPU_CAPS_ALTIVEC
|
||||
PP_CPU_CAPS_AUTO = C.PP_CPU_CAPS_AUTO
|
||||
)
|
||||
|
||||
const (
|
||||
PP_FORMAT = C.PP_FORMAT
|
||||
PP_FORMAT_420 = C.PP_FORMAT_420
|
||||
PP_FORMAT_422 = C.PP_FORMAT_422
|
||||
PP_FORMAT_411 = C.PP_FORMAT_411
|
||||
PP_FORMAT_444 = C.PP_FORMAT_444
|
||||
PP_FORMAT_440 = C.PP_FORMAT_440
|
||||
)
|
||||
|
||||
const (
|
||||
PP_PICT_TYPE_QP2 = C.PP_PICT_TYPE_QP2
|
||||
)
|
12
postproc_version.go
Normal file
12
postproc_version.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libpostproc/version.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
LIBPOSTPROC_VERSION_MAJOR = C.LIBPOSTPROC_VERSION_MAJOR
|
||||
LIBPOSTPROC_VERSION_MINOR = C.LIBPOSTPROC_VERSION_MINOR
|
||||
LIBPOSTPROC_VERSION_MICRO = C.LIBPOSTPROC_VERSION_MICRO
|
||||
)
|
182
swresample.go
Normal file
182
swresample.go
Normal file
@@ -0,0 +1,182 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libswresample/swresample.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
const (
|
||||
SWR_FLAG_RESAMPLE = C.SWR_FLAG_RESAMPLE
|
||||
)
|
||||
|
||||
// Dithering algorithms
|
||||
type SwrDitherType int32
|
||||
|
||||
const (
|
||||
SWR_DITHER_NONE = SwrDitherType(C.SWR_DITHER_NONE)
|
||||
SWR_DITHER_RECTANGULAR = SwrDitherType(C.SWR_DITHER_RECTANGULAR)
|
||||
SWR_DITHER_TRIANGULAR = SwrDitherType(C.SWR_DITHER_TRIANGULAR)
|
||||
SWR_DITHER_TRIANGULAR_HIGHPASS = SwrDitherType(C.SWR_DITHER_TRIANGULAR_HIGHPASS)
|
||||
SWR_DITHER_NS = SwrDitherType(C.SWR_DITHER_NS)
|
||||
SWR_DITHER_NS_LIPSHITZ = SwrDitherType(C.SWR_DITHER_NS_LIPSHITZ)
|
||||
SWR_DITHER_NS_F_WEIGHTED = SwrDitherType(C.SWR_DITHER_NS_F_WEIGHTED)
|
||||
SWR_DITHER_NS_MODIFIED_E_WEIGHTED = SwrDitherType(C.SWR_DITHER_NS_MODIFIED_E_WEIGHTED)
|
||||
SWR_DITHER_NS_IMPROVED_E_WEIGHTED = SwrDitherType(C.SWR_DITHER_NS_IMPROVED_E_WEIGHTED)
|
||||
SWR_DITHER_NS_SHIBATA = SwrDitherType(C.SWR_DITHER_NS_SHIBATA)
|
||||
SWR_DITHER_NS_LOW_SHIBATA = SwrDitherType(C.SWR_DITHER_NS_LOW_SHIBATA)
|
||||
SWR_DITHER_NS_HIGH_SHIBATA = SwrDitherType(C.SWR_DITHER_NS_HIGH_SHIBATA)
|
||||
SWR_DITHER_NB = SwrDitherType(C.SWR_DITHER_NB)
|
||||
)
|
||||
|
||||
// Resampling Engines
|
||||
type SwrEngine int32
|
||||
|
||||
const (
|
||||
SWR_ENGINE_SWR = SwrEngine(C.SWR_ENGINE_SWR)
|
||||
SWR_ENGINE_SOXR = SwrEngine(C.SWR_ENGINE_SOXR)
|
||||
SWR_ENGINE_NB = SwrEngine(C.SWR_ENGINE_NB)
|
||||
)
|
||||
|
||||
// Resampling Filter Types
|
||||
type SwrFilterType int32
|
||||
|
||||
const (
|
||||
SWR_FILTER_TYPE_CUBIC = SwrFilterType(C.SWR_FILTER_TYPE_CUBIC)
|
||||
SWR_FILTER_TYPE_BLACKMAN_NUTTALL = SwrFilterType(C.SWR_FILTER_TYPE_BLACKMAN_NUTTALL)
|
||||
SWR_FILTER_TYPE_KAISER = SwrFilterType(C.SWR_FILTER_TYPE_KAISER)
|
||||
)
|
||||
|
||||
// SwrContext
|
||||
type SwrContext C.struct_SwrContext
|
||||
|
||||
// SwrGetClass gets the AVClass for SwrContext. It can be used in combination with
|
||||
// AV_OPT_SEARCH_FAKE_OBJ for examining options.
|
||||
func SwrGetClass() *AvClass {
|
||||
return (*AvClass)(C.swr_get_class())
|
||||
}
|
||||
|
||||
// SwrAlloc allocates SwrContext.
|
||||
func SwrAlloc() *SwrContext {
|
||||
return (*SwrContext)(C.swr_alloc())
|
||||
}
|
||||
|
||||
// SwrInit initializes context after user parameters have been set.
|
||||
func SwrInit(s *SwrContext) int32 {
|
||||
return (int32)(C.swr_init((*C.struct_SwrContext)(s)))
|
||||
}
|
||||
|
||||
// SwrIsInitialized checks whether an swr context has been initialized or not.
|
||||
func SwrIsInitialized(s *SwrContext) int32 {
|
||||
return (int32)(C.swr_is_initialized((*C.struct_SwrContext)(s)))
|
||||
}
|
||||
|
||||
// SwrAllocSetOpts allocates SwrContext if needed and set/reset common parameters.
|
||||
func SwrAllocSetOpts(s *SwrContext,
|
||||
outChLayout int64, outSampleFmt AvSampleFormat, outSampleRate int32,
|
||||
inChLayout int64, inSampleFmt AvSampleFormat, inSampleRate int32,
|
||||
logOffset int32, logCtx unsafe.Pointer) *SwrContext {
|
||||
return (*SwrContext)(C.swr_alloc_set_opts((*C.struct_SwrContext)(s),
|
||||
(C.int64_t)(outChLayout), (C.enum_AVSampleFormat)(outSampleFmt), (C.int)(outSampleRate),
|
||||
(C.int64_t)(inChLayout), (C.enum_AVSampleFormat)(inSampleFmt), (C.int)(inSampleRate),
|
||||
(C.int)(logOffset), logCtx))
|
||||
}
|
||||
|
||||
// SwrFree frees the given SwrContext and set the pointer to NULL.
|
||||
func SwrFree(s **SwrContext) {
|
||||
C.swr_free((**C.struct_SwrContext)(unsafe.Pointer(s)))
|
||||
}
|
||||
|
||||
// SwrClose closes the context so that SwrIsInitialized() returns 0.
|
||||
func SwrClose(s *SwrContext) {
|
||||
C.swr_close((*C.struct_SwrContext)(s))
|
||||
}
|
||||
|
||||
// SwrConvert converts audio.
|
||||
func SwrConvert(s *SwrContext, out **uint8, outCount int32, in **uint8, inCount int32) int32 {
|
||||
return (int32)(C.swr_convert((*C.struct_SwrContext)(s),
|
||||
(**C.uint8_t)(unsafe.Pointer(out)), (C.int)(outCount),
|
||||
(**C.uint8_t)(unsafe.Pointer(in)), (C.int)(inCount)))
|
||||
}
|
||||
|
||||
// SwrNextPts converts the next timestamp from input to output
|
||||
// timestamps are in 1/(in_sample_rate * out_sample_rate) units.
|
||||
func SwrNextPts(s *SwrContext, pts int64) int64 {
|
||||
return (int64)(C.swr_next_pts((*C.struct_SwrContext)(s), (C.int64_t)(pts)))
|
||||
}
|
||||
|
||||
// SwrSetCompensation activates resampling compensation ("soft" compensation).
|
||||
// This function is internally called when needed in SwrNextPts().
|
||||
func SwrSetCompensation(s *SwrContext, sampleDelta, compensationDistance int32) int32 {
|
||||
return (int32)(C.swr_set_compensation((*C.struct_SwrContext)(s),
|
||||
(C.int)(sampleDelta), (C.int)(compensationDistance)))
|
||||
}
|
||||
|
||||
// SwrSetChannelMapping sets a customized input channel mapping.
|
||||
func SwrSetChannelMapping(s *SwrContext, channelMap *int32) int32 {
|
||||
return (int32)(C.swr_set_channel_mapping((*C.struct_SwrContext)(s), (*C.int)(channelMap)))
|
||||
}
|
||||
|
||||
// SwrBuildMatrix generates a channel mixing matrix.
|
||||
func SwrBuildMatrix(inLayout, outLayout uint64,
|
||||
centerMixLevel, surroundMixLevel, lfeMixLevel float64,
|
||||
rematrixMaxval, rematrixVolume float64,
|
||||
matrix *float64, stride int32, matrixEncoding AvMatrixEncoding, logCtx unsafe.Pointer) int32 {
|
||||
return (int32)(C.swr_build_matrix((C.uint64_t)(inLayout), (C.uint64_t)(outLayout),
|
||||
(C.double)(centerMixLevel), (C.double)(surroundMixLevel), (C.double)(lfeMixLevel),
|
||||
(C.double)(rematrixMaxval), (C.double)(rematrixVolume),
|
||||
(*C.double)(matrix), (C.int)(stride), (C.enum_AVMatrixEncoding)(matrixEncoding), logCtx))
|
||||
}
|
||||
|
||||
// SwrSetMatrix sets a customized remix matrix.
|
||||
func SwrSetMatrix(s *SwrContext, matrix *float64, stride int32) int32 {
|
||||
return (int32)(C.swr_set_matrix((*C.struct_SwrContext)(s), (*C.double)(matrix), (C.int)(stride)))
|
||||
}
|
||||
|
||||
// SwrDropOutput drops the specified number of output samples.
|
||||
func SwrDropOutput(s *SwrContext, count int32) int32 {
|
||||
return (int32)(C.swr_drop_output((*C.struct_SwrContext)(s), (C.int)(count)))
|
||||
}
|
||||
|
||||
// SwrInjectSilence injects the specified number of silence samples.
|
||||
func SwrInjectSilence(s *SwrContext, count int32) int32 {
|
||||
return (int32)(C.swr_inject_silence((*C.struct_SwrContext)(s), (C.int)(count)))
|
||||
}
|
||||
|
||||
// SwrGetDelay gets the delay the next input sample will experience relative to the next output sample.
|
||||
func SwrGetDelay(s *SwrContext, base int64) int64 {
|
||||
return (int64)(C.swr_get_delay((*C.struct_SwrContext)(s), (C.int64_t)(base)))
|
||||
}
|
||||
|
||||
// SwrGetOutSamples Find an upper bound on the number of samples that the next swr_convert
|
||||
// call will output, if called with in_samples of input samples.
|
||||
func SwrGetOutSamples(s *SwrContext, inSamples int32) int32 {
|
||||
return (int32)(C.swr_get_out_samples((*C.struct_SwrContext)(s), (C.int)(inSamples)))
|
||||
}
|
||||
|
||||
// SwResampleVersion returns the LIBSWRESAMPLE_VERSION_INT constant.
|
||||
func SwResampleVersion() uint32 {
|
||||
return (uint32)(C.swresample_version())
|
||||
}
|
||||
|
||||
// SwResampleConfiguration returns the swr build-time configuration.
|
||||
func SwResampleConfiguration() string {
|
||||
return C.GoString(C.swresample_configuration())
|
||||
}
|
||||
|
||||
// SwResampleLicense returns the swr license.
|
||||
func SwResampleLicense() string {
|
||||
return C.GoString(C.swresample_license())
|
||||
}
|
||||
|
||||
// SwrConvertFrame converts the samples in the input AVFrame and write them to the output AVFrame.
|
||||
func SwrConvertFrame(s *SwrContext, output, input *AvFrame) int32 {
|
||||
return (int32)(C.swr_convert_frame((*C.struct_SwrContext)(s),
|
||||
(*C.struct_AVFrame)(output), (*C.struct_AVFrame)(input)))
|
||||
}
|
||||
|
||||
// SwrConfigFrame configures or reconfigure the SwrContext using the information provided by the AVFrames.
|
||||
func SwrConfigFrame(s *SwrContext, out, in *AvFrame) int32 {
|
||||
return (int32)(C.swr_config_frame((*C.struct_SwrContext)(s),
|
||||
(*C.struct_AVFrame)(out), (*C.struct_AVFrame)(in)))
|
||||
}
|
12
swresample_version.go
Normal file
12
swresample_version.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libswresample/version.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
LIBSWRESAMPLE_VERSION_MAJOR = C.LIBSWRESAMPLE_VERSION_MAJOR
|
||||
LIBSWRESAMPLE_VERSION_MINOR = C.LIBSWRESAMPLE_VERSION_MINOR
|
||||
LIBSWRESAMPLE_VERSION_MICRO = C.LIBSWRESAMPLE_VERSION_MICRO
|
||||
)
|
264
swscale.go
Normal file
264
swscale.go
Normal file
@@ -0,0 +1,264 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libswscale/swscale.h>
|
||||
*/
|
||||
import "C"
|
||||
import "unsafe"
|
||||
|
||||
// SwScaleVersion returns the LIBSWSCALE_VERSION_INT constant.
|
||||
func SwScaleVersion() uint32 {
|
||||
return (uint32)(C.swscale_version())
|
||||
}
|
||||
|
||||
// SwScaleConfiguration returns the libswscale build-time configuration.
|
||||
func SwScaleConfiguration() string {
|
||||
return C.GoString(C.swscale_configuration())
|
||||
}
|
||||
|
||||
// SwScaleLicense returns the libswscale license.
|
||||
func SwScaleLicense() string {
|
||||
return C.GoString(C.swscale_license())
|
||||
}
|
||||
|
||||
const (
|
||||
SWS_FAST_BILINEAR = C.SWS_FAST_BILINEAR
|
||||
SWS_BILINEAR = C.SWS_BILINEAR
|
||||
SWS_BICUBIC = C.SWS_BICUBIC
|
||||
SWS_X = C.SWS_X
|
||||
SWS_POINT = C.SWS_POINT
|
||||
SWS_AREA = C.SWS_AREA
|
||||
SWS_BICUBLIN = C.SWS_BICUBLIN
|
||||
SWS_GAUSS = C.SWS_GAUSS
|
||||
SWS_SINC = C.SWS_SINC
|
||||
SWS_LANCZOS = C.SWS_LANCZOS
|
||||
SWS_SPLINE = C.SWS_SPLINE
|
||||
)
|
||||
|
||||
const (
|
||||
SWS_SRC_V_CHR_DROP_MASK = C.SWS_SRC_V_CHR_DROP_MASK
|
||||
SWS_SRC_V_CHR_DROP_SHIFT = C.SWS_SRC_V_CHR_DROP_SHIFT
|
||||
)
|
||||
|
||||
const SWS_PARAM_DEFAULT = C.SWS_PARAM_DEFAULT
|
||||
|
||||
const SWS_PRINT_INFO = C.SWS_PRINT_INFO
|
||||
|
||||
const (
|
||||
SWS_FULL_CHR_H_INT = C.SWS_FULL_CHR_H_INT
|
||||
SWS_FULL_CHR_H_INP = C.SWS_FULL_CHR_H_INP
|
||||
SWS_DIRECT_BGR = C.SWS_DIRECT_BGR
|
||||
SWS_ACCURATE_RND = C.SWS_ACCURATE_RND
|
||||
SWS_BITEXACT = C.SWS_BITEXACT
|
||||
SWS_ERROR_DIFFUSION = C.SWS_ERROR_DIFFUSION
|
||||
)
|
||||
|
||||
const SWS_MAX_REDUCE_CUTOFF = C.SWS_MAX_REDUCE_CUTOFF
|
||||
|
||||
const (
|
||||
SWS_CS_ITU709 = C.SWS_CS_ITU709
|
||||
SWS_CS_FCC = C.SWS_CS_FCC
|
||||
SWS_CS_ITU601 = C.SWS_CS_ITU601
|
||||
SWS_CS_ITU624 = C.SWS_CS_ITU624
|
||||
SWS_CS_SMPTE170M = C.SWS_CS_SMPTE170M
|
||||
SWS_CS_SMPTE240M = C.SWS_CS_SMPTE240M
|
||||
SWS_CS_DEFAULT = C.SWS_CS_DEFAULT
|
||||
SWS_CS_BT2020 = C.SWS_CS_BT2020
|
||||
)
|
||||
|
||||
// SwsGetCoefficients returns a pointer to yuv<->rgb coefficients for the given colorspace
|
||||
// suitable for SwsSetcolorspacedetails().
|
||||
func SwsGetCoefficients(colorspace int32) *int32 {
|
||||
return (*int32)(C.sws_getCoefficients((C.int)(colorspace)))
|
||||
}
|
||||
|
||||
// SwsVector
|
||||
type SwsVector C.struct_SwsVector
|
||||
|
||||
// SwsFilter
|
||||
type SwsFilter C.struct_SwsFilter
|
||||
|
||||
// SwsContext
|
||||
type SwsContext C.struct_SwsContext
|
||||
|
||||
// SwsIsSupportedInput returns a positive value if pix_fmt is a supported input format.
|
||||
func SwsIsSupportedInput(pixFmt AvPixelFormat) int32 {
|
||||
return (int32)(C.sws_isSupportedInput((C.enum_AVPixelFormat)(pixFmt)))
|
||||
}
|
||||
|
||||
// SwsIsSupportedOutput returns a positive value if pix_fmt is a supported output format.
|
||||
func SwsIsSupportedOutput(pixFmt AvPixelFormat) int32 {
|
||||
return (int32)(C.sws_isSupportedOutput((C.enum_AVPixelFormat)(pixFmt)))
|
||||
}
|
||||
|
||||
// SwsIsSupportedEndiannessConversion returns a positive value
|
||||
// if pix_fmt is a supported endianness conversion format.
|
||||
func SwsIsSupportedEndiannessConversion(pixFmt AvPixelFormat) int32 {
|
||||
return (int32)(C.sws_isSupportedEndiannessConversion((C.enum_AVPixelFormat)(pixFmt)))
|
||||
}
|
||||
|
||||
// SwsAllocContext allocates an empty SwsContext.
|
||||
func SwsAllocContext() *SwsContext {
|
||||
return (*SwsContext)(C.sws_alloc_context())
|
||||
}
|
||||
|
||||
// SwsInitContext initializes the swscaler context sws_context.
|
||||
func SwsInitContext(sctx *SwsContext, srcFilter, dstFilter *SwsFilter) int32 {
|
||||
return (int32)(C.sws_init_context((*C.struct_SwsContext)(sctx),
|
||||
(*C.struct_SwsFilter)(srcFilter), (*C.struct_SwsFilter)(dstFilter)))
|
||||
}
|
||||
|
||||
// SwsFreecontext frees the swscaler context swsContext.
|
||||
func SwsFreecontext(sctx *SwsContext) {
|
||||
C.sws_freeContext((*C.struct_SwsContext)(sctx))
|
||||
}
|
||||
|
||||
// SwsGetcontext allocates and returns an SwsContext.
|
||||
func SwsGetcontext(srcW, srcH int32, srcFormat AvPixelFormat,
|
||||
dstW, dstH int32, dstFormat AvPixelFormat,
|
||||
flags int32, srcFilter, dstFilter *SwsFilter, param *float64) *SwsContext {
|
||||
return (*SwsContext)(C.sws_getContext((C.int)(srcW), (C.int)(srcH), (C.enum_AVPixelFormat)(srcFormat),
|
||||
(C.int)(dstW), (C.int)(dstH), (C.enum_AVPixelFormat)(dstFormat),
|
||||
(C.int)(flags), (*C.struct_SwsFilter)(srcFilter), (*C.struct_SwsFilter)(dstFilter),
|
||||
(*C.double)(param)))
|
||||
}
|
||||
|
||||
// SwsScale scales the image slice in srcSlice and put the resulting scaled
|
||||
// slice in the image in dst. A slice is a sequence of consecutive rows in an image.
|
||||
func SwsScale(sctx *SwsContext, srcSlice []*uint8, srcStride []int32,
|
||||
srcSliceY, srcSliceH int32,
|
||||
dst []*uint8, dstStride []int32) int32 {
|
||||
return (int32)(C.sws_scale((*C.struct_SwsContext)(sctx),
|
||||
(**C.uint8_t)(unsafe.Pointer(&srcSlice[0])), (*C.int)(unsafe.Pointer(&srcStride[0])),
|
||||
(C.int)(srcSliceY), (C.int)(srcSliceH),
|
||||
(**C.uint8_t)(unsafe.Pointer(&dst[0])), (*C.int)(unsafe.Pointer(&dstStride[0]))))
|
||||
}
|
||||
|
||||
// SwsSetColorspaceDetails
|
||||
func SwsSetColorspaceDetails(sctx *SwsContext, invTable [4]int32, srcRange int32,
|
||||
table [4]int32, dstRange int32, brightness, contrast, saturation int32) int32 {
|
||||
return (int32)(C.sws_setColorspaceDetails((*C.struct_SwsContext)(sctx),
|
||||
(*C.int)(unsafe.Pointer(&invTable[0])), (C.int)(srcRange),
|
||||
(*C.int)(unsafe.Pointer(&table[0])), (C.int)(dstRange),
|
||||
(C.int)(brightness), (C.int)(contrast), (C.int)(saturation)))
|
||||
}
|
||||
|
||||
// SwsGetColorspaceDetails
|
||||
func SwsGetColorspaceDetails(sctx *SwsContext, invTable [4]int32, srcRange *int32,
|
||||
table [4]int32, dstRange *int32, brightness, contrast, saturation *int32) int32 {
|
||||
invTablePtr := unsafe.Pointer(&invTable[0])
|
||||
tablePtr := unsafe.Pointer(&table[0])
|
||||
return (int32)(C.sws_getColorspaceDetails((*C.struct_SwsContext)(sctx),
|
||||
(**C.int)(unsafe.Pointer(&invTablePtr)), (*C.int)(srcRange),
|
||||
(**C.int)(unsafe.Pointer(&tablePtr)), (*C.int)(dstRange),
|
||||
(*C.int)(brightness), (*C.int)(contrast), (*C.int)(saturation)))
|
||||
}
|
||||
|
||||
// SwsAllocVec allocates and returns an uninitialized vector with length coefficients.
|
||||
func SwsAllocVec(length int32) *SwsVector {
|
||||
return (*SwsVector)(C.sws_allocVec((C.int)(length)))
|
||||
}
|
||||
|
||||
// SwsGetGaussianVec Return a normalized Gaussian curve used to filter stuff.
|
||||
func SwsGetGaussianVec(variance, quality float64) *SwsVector {
|
||||
return (*SwsVector)(C.sws_getGaussianVec((C.double)(variance), (C.double)(quality)))
|
||||
}
|
||||
|
||||
// SwsScaleVec scales all the coefficients of a by the scalar value.
|
||||
func SwsScaleVec(a *SwsVector, scalar float64) {
|
||||
C.sws_scaleVec((*C.struct_SwsVector)(a), (C.double)(scalar))
|
||||
}
|
||||
|
||||
// SwsNormalizeVec scales all the coefficients of a so that their sum equals height.
|
||||
func SwsNormalizeVec(a *SwsVector, height float64) {
|
||||
C.sws_normalizeVec((*C.struct_SwsVector)(a), (C.double)(height))
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func SwsGetConstVec(c float64, length int32) *SwsVector {
|
||||
return (*SwsVector)(C.sws_getConstVec((C.double)(c), (C.int)(length)))
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func SwsGetIdentityVec() *SwsVector {
|
||||
return (*SwsVector)(C.sws_getIdentityVec())
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func SwsConvVec(a, b *SwsVector) {
|
||||
C.sws_convVec((*C.struct_SwsVector)(a), (*C.struct_SwsVector)(b))
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func SwsAddVec(a, b *SwsVector) {
|
||||
C.sws_addVec((*C.struct_SwsVector)(a), (*C.struct_SwsVector)(b))
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func SwsSubVec(a, b *SwsVector) {
|
||||
C.sws_subVec((*C.struct_SwsVector)(a), (*C.struct_SwsVector)(b))
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func SwsShiftVec(a *SwsVector, shift int32) {
|
||||
C.sws_shiftVec((*C.struct_SwsVector)(a), (C.int)(shift))
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func SwsCloneVec(a *SwsVector) *SwsVector {
|
||||
return (*SwsVector)(C.sws_cloneVec((*C.struct_SwsVector)(a)))
|
||||
}
|
||||
|
||||
// Deprecated: No use
|
||||
func SwsPrintVec2(a *SwsVector, logCtx *AvClass, logLevel int32) {
|
||||
C.sws_printVec2((*C.struct_SwsVector)(a),
|
||||
(*C.struct_AVClass)(logCtx), (C.int)(logLevel))
|
||||
}
|
||||
|
||||
// SwsFreeVec
|
||||
func SwsFreeVec(a *SwsVector) {
|
||||
C.sws_freeVec((*C.struct_SwsVector)(a))
|
||||
}
|
||||
|
||||
// SwsGetDefaultFilter
|
||||
func SwsGetDefaultFilter(lumaGBlur, chromaGBlur float32,
|
||||
lumaSharpen, chromaSharpen float32,
|
||||
chromaHShift, chromaVShift float32, verbose int32) *SwsFilter {
|
||||
return (*SwsFilter)(C.sws_getDefaultFilter((C.float)(lumaGBlur), (C.float)(chromaGBlur),
|
||||
(C.float)(lumaSharpen), (C.float)(chromaSharpen),
|
||||
(C.float)(chromaHShift), (C.float)(chromaVShift), (C.int)(verbose)))
|
||||
}
|
||||
|
||||
// SwsFreeFilter
|
||||
func SwsFreeFilter(filter *SwsFilter) {
|
||||
C.sws_freeFilter((*C.struct_SwsFilter)(filter))
|
||||
}
|
||||
|
||||
// SwsGetCachedContext check if context can be reused, otherwise reallocate a new one.
|
||||
func SwsGetCachedContext(context *SwsContext,
|
||||
srcW, srcH int32, srcFormat AvPixelFormat,
|
||||
dstW, dstH int32, dstFormat AvPixelFormat,
|
||||
flags int32, srcFilter, dstFilter *SwsFilter, param *float64) *SwsContext {
|
||||
return (*SwsContext)(C.sws_getCachedContext((*C.struct_SwsContext)(context),
|
||||
(C.int)(srcW), (C.int)(srcH), (C.enum_AVPixelFormat)(srcFormat),
|
||||
(C.int)(dstW), (C.int)(dstH), (C.enum_AVPixelFormat)(dstFormat),
|
||||
(C.int)(flags), (*C.struct_SwsFilter)(srcFilter), (*C.struct_SwsFilter)(dstFilter),
|
||||
(*C.double)(param)))
|
||||
}
|
||||
|
||||
// SwsConvertPalette8ToPacked32 converts an 8-bit paletted frame into a frame with a color depth of 32 bits.
|
||||
func SwsConvertPalette8ToPacked32(src, dst *uint8, numPixels int32, palette *uint8) {
|
||||
C.sws_convertPalette8ToPacked32((*C.uint8_t)(src), (*C.uint8_t)(dst),
|
||||
(C.int)(numPixels), (*C.uint8_t)(palette))
|
||||
}
|
||||
|
||||
// SwsConvertPalette8ToPacked24 converts an 8-bit paletted frame into a frame with a color depth of 24 bits.
|
||||
func SwsConvertPalette8ToPacked24(src, dst *uint8, numPixels int32, palette *uint8) {
|
||||
C.sws_convertPalette8ToPacked24((*C.uint8_t)(src), (*C.uint8_t)(dst),
|
||||
(C.int)(numPixels), (*C.uint8_t)(palette))
|
||||
}
|
||||
|
||||
// SwsGetClass gets the AVClass for swsContext.
|
||||
func SwsGetClass() *AvClass {
|
||||
return (*AvClass)(C.sws_get_class())
|
||||
}
|
12
swscale_version.go
Normal file
12
swscale_version.go
Normal file
@@ -0,0 +1,12 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libswscale/version.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
LIBSWSCALE_VERSION_MAJOR = C.LIBSWSCALE_VERSION_MAJOR
|
||||
LIBSWSCALE_VERSION_MINOR = C.LIBSWSCALE_VERSION_MINOR
|
||||
LIBSWSCALE_VERSION_MICRO = C.LIBSWSCALE_VERSION_MICRO
|
||||
)
|
Reference in New Issue
Block a user