more customisation, more QoL improvements

an all-around good time!
This commit is contained in:
ari melody 2026-01-30 14:14:54 +00:00
parent 2954689784
commit 45db651388
Signed by: ari
GPG key ID: CF99829C92678188
9 changed files with 315 additions and 147 deletions

View file

@ -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
}