Something went wrong. Try again.
A concatenating Youtube uploader
Something went wrong. Try again.
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859package pkg
import ( "errors" "fmt" "os/exec")
// FFmpeg describes how to invoke ffmpeg. Args are prepended to the arguments// passed by ytcat, which allows ffmpeg to be launched through a wrapper such as// nix.type FFmpeg struct { Command string Args []string}
// ResolveFFmpeg determines how to invoke ffmpeg.//// The order is:// 1. the executable given by the -ffmpeg flag, if set; it must exist// 2. ffmpeg from PATH// 3. ffmpeg from nix, if nix is availablefunc ResolveFFmpeg(configured string) (FFmpeg, error) { if configured != "" { path, err := exec.LookPath(configured) if err != nil { return FFmpeg{}, fmt.Errorf("configured ffmpeg %q is not available: %w", configured, err) }
return FFmpeg{Command: path}, nil }
if path, err := exec.LookPath("ffmpeg"); err == nil { return FFmpeg{Command: path}, nil }
return ffmpegFromNix()}
// ffmpegFromNix runs ffmpeg straight out of nixpkgs so that ytcat does not// require ffmpeg in the user or system environment. It only applies when nix is// installed: on systems without nix the lookup fails and the caller reports// that ffmpeg is missing.func ffmpegFromNix() (FFmpeg, error) { nix, err := exec.LookPath("nix") if err != nil { return FFmpeg{}, errors.New("ffmpeg not found in PATH and nix is not available; install ffmpeg or pass -ffmpeg") }
return FFmpeg{ Command: nix, Args: []string{ "--extra-experimental-features", "nix-command flakes", "shell", "nixpkgs#ffmpeg", "-c", "ffmpeg", }, }, nil}