Skip to content

Commit

Permalink
Introduce of command that adds extra output flags to ffmpeg
Browse files Browse the repository at this point in the history
  • Loading branch information
rexim committed Oct 29, 2023
1 parent 8ea223c commit de8f4ad
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion markut.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ type EvalContext struct {
VideoBitrate string
AudioCodec string
AudioBitrate string

ExtraOutFlags []string
}

func (context EvalContext) PrintSummary() {
Expand Down Expand Up @@ -210,6 +212,16 @@ func evalMarkutFile(path string) (context EvalContext, ok bool) {
return
}
context.AudioBitrate = string(args[0].Text)
case "of":
args, err, argsStack = typeCheckArgs(token.Loc, argsStack, TokenString)
if err != nil {
fmt.Printf("%s: ERROR: type check failed for %s\n", token.Loc, command)
fmt.Printf("%s\n", err)
ok = false
return
}
outFlag := args[0]
context.ExtraOutFlags = append(context.ExtraOutFlags, string(outFlag.Text))
case "input":
args, err, argsStack = typeCheckArgs(token.Loc, argsStack, TokenString)
if err != nil {
Expand Down Expand Up @@ -455,8 +467,10 @@ func ffmpegCutChunk(context EvalContext, chunk Chunk, y bool) error {
if len(context.AudioBitrate) > 0 {
args = append(args, "-ab", context.AudioBitrate)
}

args = append(args, "-t", strconv.FormatFloat(chunk.Duration(), 'f', -1, 64))
for _, outFlag := range context.ExtraOutFlags {
args = append(args, outFlag)
}
args = append(args, chunk.Name)

logCmd(ffmpeg, args...)
Expand Down

0 comments on commit de8f4ad

Please sign in to comment.