66 "github.com/goextension/log"
77 "github.com/google/uuid"
88 "os"
9+ "strings"
910 "sync"
1011)
1112
@@ -23,7 +24,7 @@ type MpegOption struct {
2324}
2425
2526// RunOptions ...
26- type RunOptions func (cfg * Config )
27+ type RunOptions func (cfg * Config ) * Config
2728
2829// Name ...
2930func (ff FFMpeg ) Name () string {
@@ -42,7 +43,7 @@ func (ff FFMpeg) Run(ctx context.Context, input string, opts ...RunOptions) (e e
4243
4344 config .processID = pid
4445 for _ , opt := range opts {
45- opt (config )
46+ config = opt (config )
4647 }
4748 if config .processID == "" {
4849 config .processID = pid
@@ -66,12 +67,28 @@ func (ff FFMpeg) Run(ctx context.Context, input string, opts ...RunOptions) (e e
6667 }
6768 args := outputArgs (config , input )
6869
70+ var outLog chan string
71+ if config .LogOutput {
72+ outLog = make (chan string )
73+ }
74+
75+ log .Infow ("runmsg" , "init" , outLog == nil )
76+
6977 wg := & sync.WaitGroup {}
7078 wg .Add (1 )
7179 go func () {
7280 defer wg .Done ()
73- e = ff .cmd .RunContext (ctx , args , config . LogOutput )
81+ e = ff .cmd .RunContext (ctx , args , outLog )
7482 }()
83+
84+ if config .LogOutput {
85+ for i2 := range outLog {
86+ ss := strings .Split (i2 , "\r " )
87+ for _ , i3 := range ss {
88+ log .Infow ("runmsg" , "outLog" , strings .TrimSpace (i3 ))
89+ }
90+ }
91+ }
7592 wg .Wait ()
7693 return e
7794}
0 commit comments