more customisation, more QoL improvements
an all-around good time!
This commit is contained in:
parent
2954689784
commit
45db651388
9 changed files with 315 additions and 147 deletions
|
|
@ -20,7 +20,7 @@ type (
|
|||
}
|
||||
)
|
||||
|
||||
func ConcatVideo(video *youtube.Video, vodFiles []string, verbose bool) error {
|
||||
func ConcatVideo(video *youtube.Video, vodFiles []string, verbose bool) (int64, error) {
|
||||
fileListPath := path.Join(
|
||||
path.Dir(video.Filename),
|
||||
"files.txt",
|
||||
|
|
@ -32,13 +32,13 @@ func ConcatVideo(video *youtube.Video, vodFiles []string, verbose bool) error {
|
|||
fileListString += fmt.Sprintf("file '%s'\n", file)
|
||||
jsonProbe, err := ffmpeg.Probe(path.Join(path.Dir(video.Filename), file))
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to probe file `%s`: %v", file, err)
|
||||
return 0, fmt.Errorf("failed to probe file `%s`: %v", file, err)
|
||||
}
|
||||
probe := probeData{}
|
||||
json.Unmarshal([]byte(jsonProbe), &probe)
|
||||
duration, err := strconv.ParseFloat(probe.Format.Duration, 64)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to parse duration of file `%s`: %v", file, err)
|
||||
return 0, fmt.Errorf("failed to parse duration of file `%s`: %v", file, err)
|
||||
}
|
||||
totalDuration += duration
|
||||
}
|
||||
|
|
@ -48,7 +48,7 @@ func ConcatVideo(video *youtube.Video, vodFiles []string, verbose bool) error {
|
|||
0644,
|
||||
)
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to write file list: %v", err)
|
||||
return 0, fmt.Errorf("failed to write file list: %v", err)
|
||||
}
|
||||
|
||||
stream := ffmpeg.Input(fileListPath, ffmpeg.KwArgs{
|
||||
|
|
@ -61,8 +61,11 @@ func ConcatVideo(video *youtube.Video, vodFiles []string, verbose bool) error {
|
|||
err = stream.Run()
|
||||
|
||||
if err != nil {
|
||||
return fmt.Errorf("ffmpeg error: %v", err)
|
||||
return 0, fmt.Errorf("ffmpeg error: %v", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
fileInfo, err := os.Stat(video.Filename)
|
||||
if err != nil { return 0, fmt.Errorf("failed to read output file: %v", err) }
|
||||
|
||||
return fileInfo.Size(), nil
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue