Documentation
¶
Overview ¶
Package avpipe has four main interfaces that has to be implemented by the client code:
InputOpener: is the input factory interface that needs an implementation to generate an InputHandler.
InputHandler: is the input handler with Read/Seek/Size/Close methods. An implementation of this interface is needed by ffmpeg to process input streams properly.
OutputOpener: is the output factory interface that needs an implementation to generate an OutputHandler.
OutputHandler: is the output handler with Write/Seek/Close methods. An implementation of this interface is needed by ffmpeg to write encoded streams properly.
TODO: Call C.free for every C.CString to not leak memory.
- Defines various audio/video transcoding errors.
Index ¶
- Constants
- Variables
- func AVPipeCloseInput(fd C.int64_t) C.int
- func AVPipeCloseMuxOutput(fd C.int64_t) C.int
- func AVPipeCloseOutput(handler C.int64_t, fd C.int64_t) C.int
- func AVPipeCloseOutputGo(handler int64, fd int64) int
- func AVPipeOpenInput(url *C.char, size *C.int64_t) C.int64_t
- func AVPipeOpenInputGo(url string) (fd, size int64)
- func AVPipeOpenMuxInput(out_url, url *C.char, size *C.int64_t) C.int64_t
- func AVPipeOpenMuxOutput(url *C.char, stream_type C.int) C.int64_t
- func AVPipeOpenOutput(handler C.int64_t, stream_index, seg_index C.int, pts C.int64_t, ...) C.int64_t
- func AVPipeOpenOutputGo(handler int64, stream_index, seg_index int, pts int64, ...) int64
- func AVPipeReadInput(fd C.int64_t, buf *C.uint8_t, sz C.int) C.int
- func AVPipeSeekInput(fd C.int64_t, offset C.int64_t, whence C.int) C.int64_t
- func AVPipeSeekMuxOutput(fd C.int64_t, offset C.int64_t, whence C.int) C.int64_t
- func AVPipeSeekOutput(handler C.int64_t, fd C.int64_t, offset C.int64_t, whence C.int) C.int64_t
- func AVPipeStatInput(fd C.int64_t, stream_index C.int, avp_stat C.avp_stat_t, ...) C.int
- func AVPipeStatInputGo(fd int64, streamIndex int, t goavpipe.AVStatType, args any) (err error)
- func AVPipeStatMuxOutput(fd C.int64_t, stream_index C.int, avp_stat C.avp_stat_t, ...) C.int
- func AVPipeStatOutput(handler C.int64_t, fd C.int64_t, stream_index C.int, ...) C.int
- func AVPipeWriteMuxOutput(fd C.int64_t, buf *C.uint8_t, sz C.int) C.int
- func AVPipeWriteOutput(handler C.int64_t, fd C.int64_t, buf *C.uint8_t, sz C.int) C.int
- func AVPipeWriteOutputGo(handler int64, fd int64, buf []byte, allowTake bool) int
- func AssociateCThreadWithHandle(handle C.int32_t) C.int
- func CDebug(msg *C.char) C.int
- func CError(msg *C.char) C.int
- func CInfo(msg *C.char) C.int
- func CLog(msg *C.char) C.int
- func CWarn(msg *C.char) C.int
- func ChannelLayout(name string) (mask int)
- func ChannelLayoutName(nbChannels, channelLayout int) string
- func GenerateAndRegisterHandle() C.int32_t
- func GetPixelFormatName(pixFmt int) string
- func GetProfileName(codecId int, profile int) string
- func H264GuessLevel(profile int, bitrate int64, framerate, width, height int) int
- func H264GuessProfile(bitdepth, width, height int) int
- func Mux(params *goavpipe.XcParams) error
- func NewAVPipeSequentialOutWriter(inFd int64, streamIndex int, streamType goavpipe.AVType) mpegts.SequentialOpener
- func Probe(params *goavpipe.XcParams) (*goavpipe.ProbeInfo, error)
- func SetCLoggers()
- func Version() string
- func Xc(params *goavpipe.XcParams) error
- func XcCancel(handle int32) error
- func XcFini(handle int32) error
- func XcInit(params *goavpipe.XcParams) (handle int32, retErr error)
- func XcRun(handle int32) (runErr error)
- type EncodingFrameStats
- type IOHandler
- type SeekReadWriteCloser
Constants ¶
const MaxAudioMux = C.MAX_STREAMS
Variables ¶
var EAV_AUDIO_SAMPLE = errors.New("EAV_AUDIO_SAMPLE")
EAV_AUDIO_SAMPLE is the error returned when avpipe fails to convert audio samples.
var EAV_BAD_HANDLE = errors.New("EAV_BAD_HANDLE")
EAV_BAD_HANDLE is the error returned when the transcoding session handle is not valid
var EAV_CANCELLED = errors.New("EAV_CANCELLED")
EAV_CANCELLED is the error returned when a transcoding session is cancelled. This error is returned from Tx() or TxRun() if transcoding session is cancelled by calling TxCancel() and TxCancel() was successful.
var EAV_CANCEL_FAILED = errors.New("EAV_CANCEL_FAILED")
EAV_CANCEL_FAILED is the error returned when cancelling a transcoding session fails. This error is returned from TxCancel() if cancelling a transcoding fails.
var EAV_CODEC_CONTEXT = errors.New("EAV_CODEC_CONTEXT")
EAV_CODEC_CONTEXT is the error returned when - codec context doesn't exist for a stream index or - avpipe fails to find codec context for a stream or - avpipe fails to allocate codec format context
var EAV_CODEC_PARAM = errors.New("EAV_CODEC_PARAM")
EAV_CODEC_PARAM is the error returned when avpipe fails - to copy codec params to codec context for output stream or - codec parameters are not correct
var EAV_FILTER_INIT = errors.New("EAV_FILTER_INIT")
EAV_FILTER_INIT is the error returned when avpipe fails to initialize a filter.
var EAV_FILTER_STRING_INIT = errors.New("EAV_FILTER_STRING_INIT")
EAV_FILTER_STRING_INIT is the error returned when avpipe fails to obtain filter string.
var EAV_IO_TIMEOUT = errors.New("EAV_IO_TIMEOUT")
EAV_IO_TIMEOUT is the error returned when there is a timeout in network/disk io
var EAV_MEM_ALLOC = errors.New("EAV_MEM_ALLOC")
EAV_MEM_ALLOC is the error returned when avpipe fails to allocate memory for a frame, or a packet, or a context (i.e format context).
var EAV_NUM_STREAMS = errors.New("EAV_NUM_STREAMS")
EAV_NUM_STREAMS is the error returned when the number of streams are wrong while avpipe does transcoding
var EAV_OPEN_CODEC = errors.New("EAV_OPEN_CODEC")
EAV_OPEN_CODEC is the error returned when avpipe fails to open the codec.
var EAV_OPEN_INPUT = errors.New("EAV_OPEN_INPUT")
EAV_OPEN_INPUT is the error returned when avpipe fails to open the input or stream container due to invalid/corrupted data
var EAV_PARAM = errors.New("EAV_PARAM")
EAV_PARAM is the error returned when one of the transcoding params is not correct.
var EAV_PTS_WRAPPED = errors.New("EAV_PTS_WRAPPED")
EAV_PTS_WRAPPED is the error returned when PTS is wrapped in the source/input.
var EAV_READ_INPUT = errors.New("EAV_READ_INPUT")
EAV_READ_INPUT is the error returned when avpipe fails to read input packets.
var EAV_RECEIVE_FILTER_FRAME = errors.New("EAV_RECEIVE_FILTER_FRAME")
EAV_RECEIVE_FILTER_FRAME is the error returned when avpipe fails to receive frame from filter.
var EAV_RECEIVE_FRAME = errors.New("EAV_RECEIVE_FRAME")
EAV_RECEIVE_FRAME is the error returned when avpipe fails to receive frame from decoder or audio fifo.
var EAV_RECEIVE_PACKET = errors.New("EAV_RECEIVE_PACKET")
EAV_RECEIVE_PACKET is the error returned when avpipe fails to receive packets from encoder.
var EAV_SEEK = errors.New("EAV_SEEK")
EAV_SEEK is the error returned when avpipe fails to seek.
var EAV_SEND_PACKET = errors.New("EAV_SEND_PACKET")
EAV_SEND_PACKET is the error returned when avpipe fails to send packet to decoder. This error means the packet is invalid.
var EAV_STREAM_INDEX = errors.New("EAV_STREAM_INDEX")
EAV_STREAM_INDEX is the error returned when stream index is not correct.
var EAV_STREAM_INFO = errors.New("EAV_STREAM_INFO")
EAV_STREAM_INFO is the error returned when avpipe fails to obtain stream info.
var EAV_TIMEBASE = errors.New("EAV_TIMEBASE")
EAV_TIMEBASE is the error returned when the timebase is not correct. This can happen if the calculated codec context timebase doesn't match with output stream timebase.
var EAV_UNKNOWN = errors.New("EAV_UNKNOWN")
EAV_UNKNOWN is the error returned when error code doesn't exist in avpipeErrors table (below).
var EAV_WRITE_FRAME = errors.New("EAV_WRITE_FRAME")
EAV_WRITE_FRAME is the error returned when avpipe fails to write the frame into output stream or audio fifo.
var EAV_WRITE_HEADER = errors.New("EAV_WRITE_HEADER")
EAV_WRITE_HEADER is the error returned when avpipe fails to write the output stream header.
var EAV_XC_TABLE = errors.New("EAV_XC_TABLE")
EAV_XC_TABLE is the error returned when avpipe fails to find xc context in the xc_table.
Functions ¶
func AVPipeCloseOutputGo ¶ added in v1.23.0
func AVPipeOpenInputGo ¶ added in v1.30.7
func AVPipeOpenOutput ¶
func AVPipeOpenOutputGo ¶ added in v1.23.0
func AVPipeSeekMuxOutput ¶
func AVPipeSeekOutput ¶
func AVPipeStatInput ¶
func AVPipeStatInputGo ¶ added in v1.30.7
func AVPipeStatMuxOutput ¶
func AVPipeStatOutput ¶
func AVPipeWriteOutput ¶
func AVPipeWriteOutputGo ¶ added in v1.23.0
AVPipeWriteOutputGo writes the given buffer to the goavpipe.OutputHandler pointed to by fd in the table of handler. The allowTake parameter when true commits the caller to no modification of the buffer thus allowing the callee to take ownership of the buffer.
func ChannelLayout ¶
func ChannelLayoutName ¶
func GetPixelFormatName ¶
func GetProfileName ¶
func H264GuessLevel ¶
func H264GuessProfile ¶
func Mux ¶
Mux remuxes/packages an already-encoded stream into a container format. Equivalent to Xc but forces XcType = XcMux and calls C.mux instead of C.xc. Not cancellable.
func NewAVPipeSequentialOutWriter ¶ added in v1.23.0
func Probe ¶
Probe runs the C libavformat probe and optionally enhances the output with mp4 specific codec info PENDING(SS) Should move this function to avpipe_probe.go
func SetCLoggers ¶
func SetCLoggers()
func Xc ¶
Xc runs a one-shot transcode job and blocks until it completes. Use this for short-lived or non-cancellable operations such as DASH/HLS segment serving and image extraction. For long-running jobs that need mid-flight cancellation (e.g. mezzanine creation), use XcInit + XcRun + XcCancel instead.
func XcCancel ¶
XcCancel interrupts a transcode job started with XcInit + XcRun. Safe to call from a different goroutine while XcRun is blocking.
func XcFini ¶ added in v1.30.7
XcFini releases job state for jobs created with XcInit. Every successful XcInit must be paired with XcFini, including when XcRun fails or is cancelled with XcCancel.
func XcInit ¶
XcInit initializes a transcode job and returns a handle for it. The actual transcoding is started by XcRun(handle) and can be interrupted at any time via XcCancel(handle). Every successful XcInit must be paired with XcFini after XcRun returns. Use this two-phase form instead of Xc when the caller needs cancellation support (e.g. mezzanine creation driven by an LRO). Also sets up the MPEGTS sequential opener for live-stream inputs when params.UseCustomLiveReader is set.
Types ¶
type EncodingFrameStats ¶
type IOHandler ¶
type IOHandler interface {
InReader(buf []byte) (int, error)
InSeeker(offset C.int64_t, whence C.int) error
InCloser() error
InStat(stream_index C.int, avp_stat C.avp_stat_t, stat_args *C.void) error
OutWriter(fd C.int, buf []byte) (int, error)
OutSeeker(fd C.int, offset C.int64_t, whence C.int) (int64, error)
OutCloser(fd C.int) error
OutStat(stream_index C.int, avp_stat C.avp_stat_t, stat_args *C.void) error
}
IOHandler defines handlers that will be called from the C interface functions
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
broadcastproto
|
|
|
cmd
|
|
|
codec-info
command
|
|
|
fmp4-validate
command
|
|
|
mez-validator
command
|
|
|
mvhevc/mvhevc
command
|
|
|
cmd
This module is designed to generate stress load on one/multiple avpipe server persistent cache.
|
This module is designed to generate stress load on one/multiple avpipe server persistent cache. |
|
Package goavpipe contains the parts of the avpipe library that may be used by other go packages without relying on the actual libavpipe that does the transcoding.
|
Package goavpipe contains the parts of the avpipe library that may be used by other go packages without relying on the actual libavpipe that does the transcoding. |
|
internal
|
|
|
pkg
|
|
|
parse_ts
command
|
|
|
file_io_handlers.go provides local-file implementations of the avpipe I/O interfaces (goavpipe.InputOpener / OutputOpener) for use in tests.
|
file_io_handlers.go provides local-file implementations of the avpipe I/O interfaces (goavpipe.InputOpener / OutputOpener) for use in tests. |