FFmpeg的Golang绑定

用于 FFmpeg 的 Golang 绑定。(Golang bindings for FFmpeg)

Github星跟踪图

goav

FFmpeg 的 Golang 绑定。

全面绑定到 ffmpeg 视频/音频操作库。

文档

https://godoc.org/github.com/giorgisio/goav

用法

import "github.com/giorgisio/goav/avformat"
func main() {
    filename := "sample.mp4"
    // Register all formats and codecs
    avformat.AvRegisterAll()
    ctx := avformat.AvformatAllocContext()
    // Open video file
    if avformat.AvformatOpenInput(&ctx, filename, nil, nil) != 0 {
        log.Println("Error: Couldn't open file.")
        return
    }
    // Retrieve stream information
    if ctx.AvformatFindStreamInfo(nil) < 0 {
        log.Println("Error: Couldn't find stream information.")
        // Close input file and free context
        ctx.AvformatCloseInput()
        return
    }
    //...
}


  • avcodec 对应于 ffmpeg 库:libavcodec [提供更多编解码器的实现]
  • avformat 对应于 ffmpeg 库:libavformat [实现流媒体协议、容器格式和基本的I/O访问]。
  • avutil 对应于 ffmpeg 库:libavutil [包括哈希器、解压器和其他实用功能] 。
  • avfilter 对应于 ffmpeg 库:libavfilter [提供了一种通过过滤器链来改变已解码的音频和视频的方法]。
  • avdevice 对应于 ffmpeg 库:libavdevice [提供了一个访问捕获和播放设备的抽象概念] 。
  • swresample 对应 ffmpeg 库:libswresample [实现音频混合和重采样例程]。
  • swscale 对应于 ffmpeg 库:libswscale [实现颜色转换和缩放例程]。

安装

FFMPEG 安装说明

sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texi2html zlib1g-dev
sudo apt install -y libavdevice-dev libavfilter-dev libswscale-dev libavcodec-dev libavformat-dev libswresample-dev libavutil-dev
sudo apt-get install yasm
export FFMPEG_ROOT=$HOME/ffmpeg
export CGO_LDFLAGS="-L$FFMPEG_ROOT/lib/ -lavcodec -lavformat -lavutil -lswscale -lswresample -lavdevice -lavfilter"
export CGO_CFLAGS="-I$FFMPEG_ROOT/include"
export LD_LIBRARY_PATH=$HOME/ffmpeg/lib

go get github.com/giorgisio/goav

更多例子

编码示例可在 examples/ 目录下找到。

说明

贡献

  • Fork 这个 Repo 并创建你自己的特性分支。
  • 遵循标准的 Go 惯例
  • 测试您的代码。
  • 创建拉请求

待办事项

  • 返回错误
  • 垃圾收集
  • 审查每个库中包含/排除的函数
  • Go 测试
  • 重组包的可能性
  • Tutorial01.c
  • 更多教程

许可证

该库采用 MIT 许可。


(The first version translated by vz on 2020.09.09)

主要指标

概览
名称与所有者giorgisio/goav
主编程语言Go
编程语言Go (语言数: 1)
平台Linux, Mac, Windows
许可证MIT License
所有者活动
创建于2015-05-21 05:31:14
推送于2022-05-19 23:28:55
最后一次提交2022-05-19 19:28:55
发布数1
最新版本名称v0.1.0 (发布于 )
第一版名称v0.1.0 (发布于 )
用户参与
星数2.1k
关注者数50
派生数364
提交数58
已启用问题?
问题数0
打开的问题数0
拉请求数19
打开的拉请求数11
关闭的拉请求数14
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?

goav

Golang binding for FFmpeg

A comprehensive binding to the ffmpeg video/audio manipulation library.

GoDoc

Usage


import "github.com/giorgisio/goav/avformat"

func main() {

	filename := "sample.mp4"

	// Register all formats and codecs
	avformat.AvRegisterAll()

	ctx := avformat.AvformatAllocContext()

	// Open video file
	if avformat.AvformatOpenInput(&ctx, filename, nil, nil) != 0 {
		log.Println("Error: Couldn't open file.")
		return
	}

	// Retrieve stream information
	if ctx.AvformatFindStreamInfo(nil) < 0 {
		log.Println("Error: Couldn't find stream information.")

		// Close input file and free context
		ctx.AvformatCloseInput()
		return
	}

	//...

}

Libraries

  • avcodec corresponds to the ffmpeg library: libavcodec [provides implementation of a wider range of codecs]
  • avformat corresponds to the ffmpeg library: libavformat [implements streaming protocols, container formats and basic I/O access]
  • avutil corresponds to the ffmpeg library: libavutil [includes hashers, decompressors and miscellaneous utility functions]
  • avfilter corresponds to the ffmpeg library: libavfilter [provides a mean to alter decoded Audio and Video through chain of filters]
  • avdevice corresponds to the ffmpeg library: libavdevice [provides an abstraction to access capture and playback devices]
  • swresample corresponds to the ffmpeg library: libswresample [implements audio mixing and resampling routines]
  • swscale corresponds to the ffmpeg library: libswscale [implements color conversion and scaling routines]

Installation

FFMPEG INSTALL INSTRUCTIONS

sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libxcb1-dev libxcb-shm0-dev libxcb-xfixes0-dev pkg-config texi2html zlib1g-dev

sudo apt install -y libavdevice-dev libavfilter-dev libswscale-dev libavcodec-dev libavformat-dev libswresample-dev libavutil-dev

sudo apt-get install yasm

export FFMPEG_ROOT=$HOME/ffmpeg
export CGO_LDFLAGS="-L$FFMPEG_ROOT/lib/ -lavcodec -lavformat -lavutil -lswscale -lswresample -lavdevice -lavfilter"
export CGO_CFLAGS="-I$FFMPEG_ROOT/include"
export LD_LIBRARY_PATH=$HOME/ffmpeg/lib
go get github.com/giorgisio/goav

More Examples

Coding examples are available in the examples/ directory.

Note

  • Function names in Go are consistent with that of the libraries to help with easy search
  • cgo: Extending Go with C
  • goav comes with absolutely no warranty.

Contribute

  • Fork this repo and create your own feature branch.
  • Follow standard Go conventions
  • Test your code.
  • Create pull request

TODO

  • Returning Errors
  • Garbage Collection
  • Review included/excluded functions from each library
  • Go Tests
  • Possible restructuring packages
  • Tutorial01.c
  • More Tutorial

License

This library is under the MIT License