File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -268,7 +268,6 @@ func (fr *FFmpegRecorder) Start(ctx context.Context) error {
268268 // ensure internal state
269269 fr .ffmpegErr = nil
270270 fr .exitCode = exitCodeInitValue
271- fr .startTime = time .Now ()
272271 fr .exited = make (chan struct {})
273272
274273 args , err := ffmpegArgs (fr .params , fr .outputPath )
@@ -287,7 +286,6 @@ func (fr *FFmpegRecorder) Start(ctx context.Context) error {
287286 cmd .SysProcAttr = & syscall.SysProcAttr {Setpgid : true }
288287 cmd .Stderr = os .Stderr
289288 cmd .Stdout = os .Stdout
290- fr .cmd = cmd
291289 fr .mu .Unlock ()
292290
293291 if err := cmd .Start (); err != nil {
@@ -299,6 +297,12 @@ func (fr *FFmpegRecorder) Start(ctx context.Context) error {
299297 fr .mu .Unlock ()
300298 return fmt .Errorf ("failed to start ffmpeg process: %w" , err )
301299 }
300+ fr .mu .Lock ()
301+ fr .cmd = cmd
302+ // Anchor recording time to ffmpeg startup so marker/chapter offsets align
303+ // with the media timeline, especially when audio inputs use input timestamps.
304+ fr .startTime = time .Now ()
305+ fr .mu .Unlock ()
302306
303307 // Launch background waiter to capture process completion.
304308 go fr .waitForCommand (ctx )
You can’t perform that action at this time.
0 commit comments