gopro

package
v0.0.0-...-7800a05 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: BSD-3-Clause Imports: 15 Imported by: 0

Documentation

Overview

Package gopro provides tools for manipulating GoPro videos including combining videos split into multiple chapters while maintaining metadata. It requires a working install of ffmpeg which provides the video processing.

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrNoMatch is returned by a matcher if no match is found.
	ErrNoMatch = errors.New("no match")

	// ErrNoFiles is returned if no files were found.
	ErrNoFiles = errors.New("no files found")
)
View Source
var (
	Hero5  = NewMatcherMust("hero5", `^(?i)GOPR([0-9]{4})\.mp4$`, `^(?i)GP([0-9]{2})([0-9]{4}).mp4$`)
	Hero10 = NewMatcherMust("hero10", `^(?i)G[HX]([0-9]{2})([0-9]{4})\.mp4$`)
)

Formats are determined from: https://community.gopro.com/s/article/GoPro-Camera-File-Naming-Convention?language=en_US

View Source
var (
	// DefaultConfig is the default configuration if not specified.
	DefaultConfig = &Config{
		Binary: "ffmpeg",
		Args: []string{
			"-y",
			"-safe", "0",
			"-f", "concat",
			"-i", "",
			"-c:a", "copy",
			"-c:d", "copy",
			"-c:v", "libx264",
			"-vf", "scale=1920:1080",
			"-copy_unknown",
			"-map_metadata", "0",
			"-movflags", "use_metadata_tags",
			"-map", "0:v",
			"-map", "0:a",
			"-map", "0:m:handler_name:\tGoPro TCD",
			"-map", "0:m:handler_name:\tGoPro MET",
			"-map", "0:m:handler_name:\tGoPro SOS",
		},
		SourceDir:      ".",
		OutputTemplate: "{{.Name}}-JOINED{{.Ext}}",
		LogLevel:       "warn",
	}
)

Functions

func DefaultHandler

func DefaultHandler(exe string, args ...string) error

DefaultHandler is the default Handler function which runs ffmpeg wiring up Stdout and Stderr.

Types

type Config

type Config struct {
	LogLevel       string
	SourceDir      string
	Binary         string
	Args           []string
	SkipNames      []string
	OutputTemplate string
	OutputDir      string
	Overwrite      bool
	// contains filtered or unexported fields
}

Config represents a GoPro video processing configuration.

func (*Config) Load

func (c *Config) Load(file string) error

Load loads a json configuration from file.

func (*Config) Output

func (c *Config) Output(name string) (string, error)

Output returns the output filename calculated from .OutputTmpl and name.

func (Config) Skip

func (c Config) Skip(name string) bool

Skip returns true if name should be skipped, false otherwise.

func (*Config) Validate

func (c *Config) Validate() error

Validate validates c calculating internal values.

type File

type File struct {
	// Name is the raw filename.
	Name string

	// Chapter is the chapter of the video typically a two character number.
	// Depending on generation the first chapter may be 00 or 01.
	Chapter string

	// Index is video index of the video typically a 4 character number.
	Index string
}

File represents a GoPro video file.

type FileSet

type FileSet struct {
	Number   string
	Chapters FileSlice
}

FileSet represents a set of files for a single GoPro video.

func (*FileSet) Chapter

func (s *FileSet) Chapter(f *File)

Chapter adds file as a chapter ensuring correct order.

type FileSlice

type FileSlice []File

FileSlice attaches the methods of sort.Interface to []File, sorting in increasing chapter order.

func (FileSlice) Len

func (s FileSlice) Len() int

Len implements sort.Interface.

func (FileSlice) Less

func (s FileSlice) Less(i, j int) bool

Less implements sort.Interface by Chapter.

func (FileSlice) Swap

func (s FileSlice) Swap(i, j int)

Swap implements sort.Interface.

func (FileSlice) Validate

func (s FileSlice) Validate() error

Validate validates the FileSlice.

type Log

type Log interface {
	Println(v ...interface{})
}

Log is implemented by types which can act as Processor logger.

type Matcher

type Matcher struct {
	// contains filtered or unexported fields
}

Matcher provides the ability to identify GoPro video files.

func NewMatcher

func NewMatcher(name, first string, others ...string) (*Matcher, error)

NewMatcher returns a fully initialised Matcher.

func NewMatcherMust

func NewMatcherMust(name, first string, others ...string) *Matcher

NewMatcherMust returns a fully initialised Matcher and panics if any error occurs.

func (*Matcher) Match

func (m *Matcher) Match(file string) (*File, error)

Match checks file if matches and returns the decoded File. If no match is found ErrNoMatch is returned.

type Option

type Option func(*Processor) error

Option represents an configuration option for Processor.

func Cfg

func Cfg(cfg Config) Option

Cfg sets the config for the Processor. Either CfgFile or Cfg must be specified.

func CfgFile

func CfgFile(file string) Option

CfgFile loads the config from file for the Processor. Either CfgFile or Cfg must be specified.

func Handler

func Handler(f func(exe string, args ...string) error) Option

Handler sets a custom handler for running ffmpeg. Default is DefaultHandler.

func Output

func Output(w io.Writer) Option

Output sets output for log message for processor. Default is os.Stderr.

type OutputFile

type OutputFile struct {
	// Name excluding extension.
	Name string

	// Extension including the dot.
	Ext string
}

OutputFile represents the template used for output file processing.

type Processor

type Processor struct {
	// contains filtered or unexported fields
}

Processor provides the ability to process GoPro video files. If it finds chaptered files they are joined during processing.

func NewProcessor

func NewProcessor(options ...Option) (*Processor, error)

NewProcessor creates and returns a configured Processor.

func (*Processor) Process

func (p *Processor) Process() ([]string, error)

Process finds and processes video files according to the Processor Config returning the resultant files. Files can be returned even if an error occurs.

Directories

Path Synopsis
Package gpmf provides GoPro metadata parsing as defined by: https://github.com/gopro/gpmf-parser
Package gpmf provides GoPro metadata parsing as defined by: https://github.com/gopro/gpmf-parser
geo
Package geo implements gnomonic projection centered at an arbitrary position C on the ellipsoid.
Package geo implements gnomonic projection centered at an arbitrary position C on the ellipsoid.

Jump to

Keyboard shortcuts

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