func (g Generator) generate(ctx *fsutil.LockContext, args []string) error {
	cmd := g.Encoder.Command(ctx, args)

	var stderr bytes.Buffer
	cmd.Stderr = &stderr

	if err := cmd.Start(); err != nil {
		return fmt.Errorf("error starting command: %w", err)
	}

	ctx.AttachCommand(cmd)

	if err := cmd.Wait(); err != nil {
		var exitErr *exec.ExitError
		if errors.As(err, &exitErr) {
			exitErr.Stderr = stderr.Bytes()
			err = exitErr
		}
		return fmt.Errorf("error running ffmpeg command <%s>: %w", strings.Join(args, " "), err)
	}

	return nil
}
// generate runs ffmpeg with the given args and waits for it to finish.
// Returns an error if the command fails. If the command fails, the return
// value will be of type *exec.ExitError.
generate runs ffmpeg with the given args and waits for it to finish.
Returns an error if the command fails. If the command fails, the return
value will be of type *exec.ExitError.
// generate runs ffmpeg with the given args and waits for it to finish . // Returns an error if the command fails . If the command fails the return // value will be of type * exec . ExitError .
func (g Generator) generate(ctx *fsutil.LockContext, args []string) error {
	cmd := g.Encoder.Command(ctx, args)
	var stderr bytes.Buffer
	cmd.Stderr = &stderr
	if err := cmd.Start(); err != nil {
		return fmt.Errorf("error starting command: %w", err)
	}
	ctx.AttachCommand(cmd)
	if err := cmd.Wait(); err != nil {
		var exitErr *exec.ExitError
		if errors.As(err, &exitErr) {
			exitErr.Stderr = stderr.Bytes()
			err = exitErr
		}
		return fmt.Errorf("error running ffmpeg command <%s>: %w", strings.Join(args, " "), err)
	}
	return nil
}
func ( g Generator ) generate ( ctx * fsutil . LockContext , args [ ] string ) error { cmd := g . Encoder . Command ( ctx , args ) var stderr bytes . Buffer cmd . Stderr = & stderr if err := cmd . Start ( ) ; err != nil { return fmt . Errorf ( " " , err ) } ctx . AttachCommand ( cmd ) if err := cmd . Wait ( ) ; err != nil { var exitErr * exec . ExitError if errors . As ( err , & exitErr ) { exitErr . Stderr = stderr . Bytes ( ) err = exitErr } return fmt . Errorf ( " " , strings . Join ( args , " " ) , err ) } return nil }
generate runs ffmpeg with the given args and waits for it to finish.
generate runs ffmpeg with the given args and waits for it to finish .