Init
This commit is contained in:
parent
264c97183e
commit
3faede7b1c
74 changed files with 6228 additions and 1 deletions
35
util/av/remux.go
Normal file
35
util/av/remux.go
Normal file
|
@ -0,0 +1,35 @@
|
|||
package av
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
ffmpeg "github.com/u2takey/ffmpeg-go"
|
||||
)
|
||||
|
||||
func RemuxFile(
|
||||
inputFile string,
|
||||
) error {
|
||||
tempFileName := inputFile + ".temp"
|
||||
outputFile := inputFile
|
||||
err := os.Rename(inputFile, tempFileName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to rename file: %v", err)
|
||||
}
|
||||
err = ffmpeg.
|
||||
Input(tempFileName).
|
||||
Output(outputFile, ffmpeg.KwArgs{
|
||||
"c": "copy",
|
||||
}).
|
||||
Silent(true).
|
||||
OverWriteOutput().
|
||||
Run()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to remux file: %v", err)
|
||||
}
|
||||
err = os.Remove(tempFileName)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to remove temp file: %v", err)
|
||||
}
|
||||
return nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue