remux

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Command = &cli.Command{
	Name:      "remux",
	Usage:     "Remux a mpegts to mp4 or m4a.",
	ArgsUsage: "file",
	Flags: []cli.Flag{
		&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 {
		file := cCtx.Args().Get(0)
		if file == "" {
			logger.I.Error("arg[0] is empty?! Use --help for remux usage.")
			return errors.New("missing file path")
		}

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

		fnameMuxed := prepareFile(file, "mp4")
		fnameAudio := prepareFile(file, "m4a")

		logger.I.Info(
			"remuxing stream...",
			zap.String("output", fnameMuxed),
			zap.String("input", file),
		)
		if err := remux.Do(file, fnameMuxed, false); err != nil {
			logger.I.Error("ffmpeg remux finished with error", zap.Error(err))
		}
		if extractAudio {
			logger.I.Info(
				"extrating audio...",
				zap.String("output", fnameAudio),
				zap.String("input", file),
			)
			if err := remux.Do(file, fnameAudio, true); err != nil {
				logger.I.Error("ffmpeg audio extract finished with error", zap.Error(err))
			}
		}
		return nil
	},
}

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