go_ffmpeg_core

package module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 6, 2022 License: MIT Imports: 3 Imported by: 0

README

go-ffmpeg-core

ffmpeg core for golang

基于ffmpeg命令封装简单功能,因此运行环境需事先安装有ffmpeg命令。

ffmpeg官方下载地址: http://ffmpeg.org/download.html

1. 剥离视频文件的音频/视频
package main

import (
  go_ffmepg_core "github.com/Resynz/go-ffmpeg-core"
  "log"
)

func main () {
  resourcePath:="./test.mp4" // 原视频路径
  outputPath:="./test-peel-audio.m4a" // 文件输出路径
  peel:=&go_ffmpeg_core.Peel{
    Command: "ffmpeg",
    ResourcePath: resourcePath,
    OutputPath: outputPath,
    Type: go_ffmpeg_core.PeelTypeAudio, // 指定剥离类型为音频/视频
    Stream: "", // 如果该视频文件中有存在多条音轨,可指定音轨编号
  }
  err:=peel.Execute()
  if err!=nil{
    log.Fatalf("peel failed! error:%s\n",err)
  }
  log.Println("peel done.")
}
2. 合并音频、视频
package main

import (
  go_ffmepg_core "github.com/Resynz/go-ffmpeg-core"
  "log"
)

func main () {
  merge:=&go_ffmpeg_core.MergeAV{
  	Command:    "ffmpeg",
	VideoPath:  "./test-v.mp4", // 纯视频文件路径
	AudioPath:  "./test-a.m4a", // 纯音频文件路径
	OutputPath: "./merge.mp4",  // 结果输出路径
  }
  if err:=merge.Execute();err!=nil{
	log.Fatalf("merge failed! error:%s\n",err.Error())
  }
  log.Println("merge done.")
}
3. 转换格式
package main

import (
  go_ffmepg_core "github.com/Resynz/go-ffmpeg-core"
  "log"
)

func main () {
  transform:=&go_ffmpeg_core.Transform{
		Command:      "ffmpeg",
		ResourcePath: "./test.mp4",
		OutputPath:   "./test.mkv",
  }
  if err:=transform.Execute();err!=nil{
	log.Fatalf("tranform failed! error:%s\n",err.Error())
  }
  log.Println("transform done.")
}

Documentation

Overview

*

  • @Author: Resynz
  • @Date: 2021/11/25 11:16

*

  • @Author: Resynz
  • @Date: 2022/8/3 17:17

*

  • @Author: Resynz
  • @Date: 2021/11/25 11:38

*

  • @Author: Resynz
  • @Date: 2021/11/25 11:48

*

  • @Author: Resynz
  • @Date: 2021/11/25 10:40

*

  • @Author: Resynz
  • @Date: 2021/11/25 13:57

*

  • @Author: Resynz
  • @Date: 2022/12/6 09:27

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleError

func HandleError(output []byte) error

Types

type Hls added in v0.0.3

type Hls struct {
	Command         string
	InputPath       string
	KeyInfoFile     string
	BaseUrl         string
	HLSTime         uint64
	SegmentFilename string
	OutputPath      string
}

func (*Hls) Execute added in v0.0.3

func (s *Hls) Execute() error

type MergeAV

type MergeAV struct {
	Command    string
	VideoPath  string
	AudioPath  string
	OutputPath string
}

MergeAV 合并音视频

func (*MergeAV) Execute

func (s *MergeAV) Execute() error

type Peel

type Peel struct {
	ResourcePath string // 资源路径
	Command      string
	OutputPath   string
	Type         PeelType
	Stream       string
}

Peel 剥离音视频

func (*Peel) Execute

func (s *Peel) Execute() error

type PeelType

type PeelType uint8
const (
	PeelTypeUnknown PeelType = iota
	PeelTypeVideo
	PeelTypeAudio
)

type Transform

type Transform struct {
	Command      string
	ResourcePath string
	OutputPath   string
}

func (*Transform) Execute

func (s *Transform) Execute() error

type WebM added in v0.0.5

type WebM struct {
	Command      string
	ResourcePath string
	OutputPath   string
}

func (*WebM) Execute added in v0.0.5

func (s *WebM) Execute() error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL