Skip to content

Commit 4ea2951

Browse files
committed
Implement chunk_outf func
1 parent 70b3be1 commit 4ea2951

1 file changed

Lines changed: 41 additions & 9 deletions

File tree

markut.go

Lines changed: 41 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,14 @@ type ChatMessageGroup struct {
6262
}
6363

6464
type Chunk struct {
65-
Start Millis
66-
End Millis
67-
Loc Loc
68-
InputPath string
69-
ChatLog []ChatMessageGroup
70-
Blur bool
71-
Unfinished bool
65+
Start Millis
66+
End Millis
67+
Loc Loc
68+
InputPath string
69+
ChatLog []ChatMessageGroup
70+
Blur bool
71+
Unfinished bool
72+
ExtraOutFlags []Token
7273
}
7374

7475
const ChunksFolder = "chunks"
@@ -81,6 +82,9 @@ func (chunk Chunk) Name() string {
8182
if chunk.Blur {
8283
sb.WriteString("-blur")
8384
}
85+
for _, outFlag := range chunk.ExtraOutFlags {
86+
sb.WriteString(strings.ReplaceAll(string(outFlag.Text), "/", "_"))
87+
}
8488
sb.WriteString(".mp4")
8589
return sb.String()
8690
}
@@ -270,6 +274,7 @@ func (context EvalContext) PrintSummary() error {
270274
checkMark = "[x]"
271275
}
272276
fmt.Printf("%s: %s Chunk %d - %s -> %s (Duration: %s)\n", chunk.Loc, checkMark, index, millisToTs(chunk.Start), millisToTs(chunk.End), millisToTs(chunk.Duration()))
277+
// TODO: Print extra output flags of the chunk
273278
}
274279
fmt.Println()
275280
fmt.Printf(">>> YouTube Chapters (%d):\n", len(context.chapters))
@@ -583,6 +588,9 @@ func ffmpegCutChunk(context EvalContext, chunk Chunk) error {
583588
for _, outFlag := range context.ExtraOutFlags {
584589
args = append(args, string(outFlag.Text))
585590
}
591+
for _, outFlag := range chunk.ExtraOutFlags {
592+
args = append(args, string(outFlag.Text))
593+
}
586594
unfinishedChunkName := "unfinished-chunk.mp4"
587595
args = append(args, unfinishedChunkName)
588596

@@ -1555,8 +1563,32 @@ func main() {
15551563
return true
15561564
},
15571565
},
1566+
"chunk_outf": {
1567+
Description: "Append extra output flag to the last defined chunk",
1568+
Signature: "<flag:String> --",
1569+
Category: "FFmpeg Arguments",
1570+
Run: func(context *EvalContext, command string, token Token) bool {
1571+
if len(context.chunks) == 0 {
1572+
fmt.Printf("%s: ERROR: no chunks defined to add extra output flag to\n", token.Loc)
1573+
return false
1574+
}
1575+
1576+
args, err := context.typeCheckArgs(token.Loc, TokenString)
1577+
if err != nil {
1578+
fmt.Printf("%s: ERROR: type check failed for %s\n", token.Loc, command)
1579+
fmt.Printf("%s\n", err)
1580+
return false
1581+
}
1582+
outFlag := args[0]
1583+
1584+
chunk := &context.chunks[len(context.chunks)-1];
1585+
chunk.ExtraOutFlags = append(chunk.ExtraOutFlags, outFlag)
1586+
1587+
return true
1588+
},
1589+
},
15581590
"outf": {
1559-
Description: "Append extra output flag",
1591+
Description: "Append extra output flag for every chunk",
15601592
Signature: "<flag:String> --",
15611593
Category: "FFmpeg Arguments",
15621594
Run: func(context *EvalContext, command string, token Token) bool {
@@ -1572,7 +1604,7 @@ func main() {
15721604
},
15731605
},
15741606
"inf": {
1575-
Description: "Append extra input flag",
1607+
Description: "Append extra input flag for every chunk",
15761608
Signature: "<flag:String> --",
15771609
Category: "FFmpeg Arguments",
15781610
Run: func(context *EvalContext, command string, token Token) bool {

0 commit comments

Comments
 (0)