concat

package
v1.6.4 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package concat implements the concatenation of streams.

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:      "concat",
	Usage:     "Concat multiple file to another container. Order is important.",
	ArgsUsage: "...files",
	Flags: []cli.Flag{
		&cli.StringFlag{
			Name:        "output-format",
			Value:       "mp4",
			Usage:       "Output format of the container.",
			Aliases:     []string{"format", "f"},
			Destination: &outputFormat,
		},
		&cli.BoolFlag{
			Name:        "extract-audio",
			Value:       false,
			Usage:       "Generate an audio-only copy of the stream.",
			Aliases:     []string{"x"},
			Destination: &extractAudio,
		},
	},
	Action: func(cCtx *cli.Context) error {
		files := cCtx.Args().Slice()
		if len(files) == 0 {
			log.Error().Msg("arg[0] is empty")
			return errors.New("missing file path")
		}

		for _, file := range files {
			if _, err := os.Stat(file); err != nil {
				return err
			}
		}

		fnameMuxed := prepareFile(files[0], strings.ToLower(outputFormat))
		fnameAudio := prepareFile(files[0], "m4a")

		log.Info().
			Str("output", fnameMuxed).
			Strs("input", files).
			Msg("concat and remuxing streams...")
		if err := concat.Do(fnameMuxed, files); err != nil {
			log.Error().
				Str("output", fnameMuxed).
				Strs("input", files).
				Err(err).
				Msg("ffmpeg concat finished with error")
		}
		if extractAudio {
			log.Error().Str("output", fnameAudio).Strs("input", files).Msg("extrating audio...")
			if err := concat.Do(fnameAudio, files, concat.WithAudioOnly()); err != nil {
				log.Error().
					Str("output", fnameAudio).
					Strs("input", files).
					Err(err).
					Msg("ffmpeg audio extract finished with error")
			}
		}
		return nil
	},
}

Command is the command for concating multiple files to another container.

Functions

This section is empty.

Types

This section is empty.

Jump to

Keyboard shortcuts

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