mirror of
https://github.com/qrtc/ffmpeg-dev-go.git
synced 2025-10-05 15:47:33 +08:00
2023-10-26 13:54:33 CST W43D4
This commit is contained in:
153
avutil_timecode.go
Normal file
153
avutil_timecode.go
Normal file
@@ -0,0 +1,153 @@
|
||||
package ffmpeg
|
||||
|
||||
/*
|
||||
#include <libavutil/timecode.h>
|
||||
*/
|
||||
import "C"
|
||||
|
||||
const (
|
||||
AV_TIMECODE_STR_SIZE = C.AV_TIMECODE_STR_SIZE
|
||||
)
|
||||
|
||||
type AVTimecodeFlag = C.enum_AVTimecodeFlag
|
||||
|
||||
const (
|
||||
AV_TIMECODE_FLAG_DROPFRAME = AVTimecodeFlag(C.AV_TIMECODE_FLAG_DROPFRAME)
|
||||
AV_TIMECODE_FLAG_24HOURSMAX = AVTimecodeFlag(C.AV_TIMECODE_FLAG_24HOURSMAX)
|
||||
AV_TIMECODE_FLAG_ALLOWNEGATIVE = AVTimecodeFlag(C.AV_TIMECODE_FLAG_ALLOWNEGATIVE)
|
||||
)
|
||||
|
||||
type AVTimecode C.AVTimecode
|
||||
|
||||
// Custom: GetStart gets `AVTimecode.start` value.
|
||||
func (tc *AVTimecode) GetStart() int32 {
|
||||
return (int32)(tc.start)
|
||||
}
|
||||
|
||||
// Custom: SetStart sets `AVTimecode.start` value.
|
||||
func (tc *AVTimecode) SetStart(v int32) {
|
||||
tc.start = (C.int)(v)
|
||||
}
|
||||
|
||||
// Custom: GetStartAddr gets `AVTimecode.start` address.
|
||||
func (tc *AVTimecode) GetStartAddr() *int32 {
|
||||
return (*int32)(&tc.start)
|
||||
}
|
||||
|
||||
// Custom: GetFlags gets `AVTimecode.flags` value.
|
||||
func (tc *AVTimecode) GetFlags() uint32 {
|
||||
return (uint32)(tc.flags)
|
||||
}
|
||||
|
||||
// Custom: SetFlags sets `AVTimecode.flags` value.
|
||||
func (tc *AVTimecode) SetFlags(v uint32) {
|
||||
tc.flags = (C.uint32_t)(v)
|
||||
}
|
||||
|
||||
// Custom: GetFlagsAddr gets `AVTimecode.flags` address.
|
||||
func (tc *AVTimecode) GetFlagsAddr() *uint32 {
|
||||
return (*uint32)(&tc.flags)
|
||||
}
|
||||
|
||||
// Custom: GetRate gets `AVTimecode.rate` value.
|
||||
func (tc *AVTimecode) GetRate() AVRational {
|
||||
return (AVRational)(tc.rate)
|
||||
}
|
||||
|
||||
// Custom: SetRate sets `AVTimecode.rate` value.
|
||||
func (tc *AVTimecode) SetRate(v AVRational) {
|
||||
tc.rate = (C.struct_AVRational)(v)
|
||||
}
|
||||
|
||||
// Custom: GetRateAddr gets `AVTimecode.rate` address.
|
||||
func (tc *AVTimecode) GetRateAddr() *AVRational {
|
||||
return (*AVRational)(&tc.rate)
|
||||
}
|
||||
|
||||
// Custom: GetFps gets `AVTimecode.fps` value.
|
||||
func (tc *AVTimecode) GetFps() uint32 {
|
||||
return (uint32)(tc.fps)
|
||||
}
|
||||
|
||||
// Custom: SetFps sets `AVTimecode.fps` value.
|
||||
func (tc *AVTimecode) SetFps(v uint32) {
|
||||
tc.fps = (C.uint)(v)
|
||||
}
|
||||
|
||||
// Custom: GetFpsAddr gets `AVTimecode.fps` address.
|
||||
func (tc *AVTimecode) GetFpsAddr() *uint32 {
|
||||
return (*uint32)(&tc.fps)
|
||||
}
|
||||
|
||||
// AvTimecodeAdjustNtscFramenum2 adjusts frame number for NTSC drop frame time code.
|
||||
func AvTimecodeAdjustNtscFramenum2(framenum, fps int32) int32 {
|
||||
return (int32)(C.av_timecode_adjust_ntsc_framenum2((C.int)(framenum), (C.int)(fps)))
|
||||
}
|
||||
|
||||
// AvTimecodeGetSmpteFromFramenum converts frame number to SMPTE 12M binary representation.
|
||||
func AvTimecodeGetSmpteFromFramenum(tc *AVTimecode, framenum int32) uint32 {
|
||||
return (uint32)(C.av_timecode_get_smpte_from_framenum((*C.AVTimecode)(tc), (C.int)(framenum)))
|
||||
}
|
||||
|
||||
// AvTimecodeGetSmpte converts sei info to SMPTE 12M binary representation.
|
||||
func AvTimecodeGetSmpte(rate AVRational, drop, hh, mm, ss, ff int32) int32 {
|
||||
return (int32)(C.av_timecode_get_smpte((C.struct_AVRational)(rate),
|
||||
(C.int)(drop), (C.int)(hh), (C.int)(mm), (C.int)(ss), (C.int)(ff)))
|
||||
}
|
||||
|
||||
// AvTimecodeMakeString loads timecode string in buf.
|
||||
func AvTimecodeMakeString(tc *AVTimecode, framenum int32) (buf, bufPar string) {
|
||||
b := make([]C.char, AV_TIMECODE_STR_SIZE+1)
|
||||
ret := C.av_timecode_make_string((*C.AVTimecode)(tc), (*C.char)(&b[0]), (C.int)(framenum))
|
||||
return C.GoString(&b[0]), C.GoString(ret)
|
||||
}
|
||||
|
||||
// AvTimecodeMakeSmpteTcString2 gets the timecode string from the SMPTE timecode format.
|
||||
func AvTimecodeMakeSmpteTcString2(rate AVRational, tcsmpte uint32, preventDf, skipField int32) (buf, bufPar string) {
|
||||
b := make([]C.char, AV_TIMECODE_STR_SIZE+1)
|
||||
ret := C.av_timecode_make_smpte_tc_string2((*C.char)(&b[0]),
|
||||
(C.AVRational)(rate), (C.uint32_t)(tcsmpte), (C.int)(preventDf), (C.int)(skipField))
|
||||
return C.GoString(&b[0]), C.GoString(ret)
|
||||
}
|
||||
|
||||
// AvTimecodeMakeSmpteTcString gets the timecode string from the SMPTE timecode format.
|
||||
func AvTimecodeMakeSmpteTcString(tcsmpte uint32, preventDf int32) (buf, bufPar string) {
|
||||
b := make([]C.char, AV_TIMECODE_STR_SIZE+1)
|
||||
ret := C.av_timecode_make_smpte_tc_string((*C.char)(&b[0]), (C.uint32_t)(tcsmpte), (C.int)(preventDf))
|
||||
return C.GoString(&b[0]), C.GoString(ret)
|
||||
}
|
||||
|
||||
// AvTimecodeMakeMpegTcString gets the timecode string from the 25-bit timecode format (MPEG GOP format).
|
||||
func AvTimecodeMakeMpegTcString(tc25bit uint32) (buf, bufPar string) {
|
||||
b := make([]C.char, AV_TIMECODE_STR_SIZE+1)
|
||||
ret := C.av_timecode_make_mpeg_tc_string((*C.char)(&b[0]), (C.uint32_t)(tc25bit))
|
||||
return C.GoString(&b[0]), C.GoString(ret)
|
||||
}
|
||||
|
||||
// AvTimecodeInit initializes a timecode struct with the passed parameters.
|
||||
func AvTimecodeInit(tc *AVTimecode, rate AVRational, flags, frameStart int32, logCtx CVoidPointer) int32 {
|
||||
return (int32)(C.av_timecode_init((*C.AVTimecode)(tc), (C.struct_AVRational)(rate),
|
||||
(C.int)(flags), (C.int)(frameStart), VoidPointer(logCtx)))
|
||||
}
|
||||
|
||||
// AvTimecodeInitFromComponents initializes a timecode struct from the passed timecode components.
|
||||
func AvTimecodeInitFromComponents(tc *AVTimecode, rate AVRational,
|
||||
flags, hh, mm, ss, ff int32, logCtx CVoidPointer) int32 {
|
||||
return (int32)(C.av_timecode_init_from_components((*C.AVTimecode)(tc),
|
||||
(C.struct_AVRational)(rate), (C.int)(flags),
|
||||
(C.int)(hh), (C.int)(mm), (C.int)(ss), (C.int)(ff),
|
||||
VoidPointer(logCtx)))
|
||||
}
|
||||
|
||||
// AvTimecodeInitFromString parses timecode representation (hh:mm:ss[:;.]ff).
|
||||
func AvTimecodeInitFromString(tc *AVTimecode, rate AVRational, str string, logCtx CVoidPointer) int32 {
|
||||
strPtr, strFunc := StringCasting(str)
|
||||
defer strFunc()
|
||||
return (int32)(C.av_timecode_init_from_string((*C.AVTimecode)(tc), (C.struct_AVRational)(rate),
|
||||
(*C.char)(strPtr), VoidPointer(logCtx)))
|
||||
}
|
||||
|
||||
// AvTimecodeCheckFrameRate checks if the timecode feature is available for the given frame rate
|
||||
func AvTimecodeCheckFrameRate(rate AVRational) int32 {
|
||||
return (int32)(C.av_timecode_check_frame_rate((C.struct_AVRational)(rate)))
|
||||
}
|
Reference in New Issue
Block a user