mirror of
https://github.com/crunchy-labs/crunchy-cli.git
synced 2026-01-21 12:12:00 -06:00
More ffmpeg merge fixes
This commit is contained in:
parent
3dfc69e2d9
commit
685dbc622e
1 changed files with 15 additions and 6 deletions
21
format.go
21
format.go
|
|
@ -123,17 +123,19 @@ func mergeSegmentsFFmpeg(context context.Context, tempDir string, outputFile str
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
f, err := os.CreateTemp("", "*.txt")
|
f, err := os.Create(filepath.Join(tempDir, "list.txt"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
defer os.Remove(f.Name())
|
// -1 is the list.txt file
|
||||||
for i := 0; i < len(dir); i++ {
|
for i := 0; i < len(dir)-1; i++ {
|
||||||
fmt.Fprintf(f, "file '%s.ts'\n", filepath.Join(tempDir, strconv.Itoa(i)))
|
fmt.Fprintf(f, "file '%s.ts'\n", filepath.Join(tempDir, strconv.Itoa(i)))
|
||||||
}
|
}
|
||||||
|
f.Close()
|
||||||
|
|
||||||
// predefined options ... custom options ... predefined output filename
|
// predefined options ... custom options ... predefined output filename
|
||||||
command := []string{
|
command := []string{
|
||||||
|
"-y",
|
||||||
"-f", "concat",
|
"-f", "concat",
|
||||||
"-safe", "0",
|
"-safe", "0",
|
||||||
"-i", f.Name(),
|
"-i", f.Name(),
|
||||||
|
|
@ -153,14 +155,21 @@ func mergeSegmentsFFmpeg(context context.Context, tempDir string, outputFile str
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cmdChan := make(chan error)
|
cmdChan := make(chan error, 1)
|
||||||
go func() {
|
go func() {
|
||||||
cmdChan <- cmd.Wait()
|
cmdChan <- cmd.Wait()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
select {
|
select {
|
||||||
case <-cmdChan:
|
case err = <-cmdChan:
|
||||||
return fmt.Errorf(errBuf.String())
|
if err != nil {
|
||||||
|
if errBuf.Len() > 0 {
|
||||||
|
return fmt.Errorf(errBuf.String())
|
||||||
|
} else {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
case <-context.Done():
|
case <-context.Done():
|
||||||
cmd.Process.Kill()
|
cmd.Process.Kill()
|
||||||
return context.Err()
|
return context.Err()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue