automatically upload nearby thumbnail.png
This commit is contained in:
parent
fc1d6b20c1
commit
2fcbc31f77
4 changed files with 75 additions and 19 deletions
|
|
@ -7,6 +7,7 @@ import (
|
|||
"os"
|
||||
"path"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"arimelody.space/vodular/youtube"
|
||||
ffmpeg "github.com/u2takey/ffmpeg-go"
|
||||
|
|
@ -23,15 +24,15 @@ type (
|
|||
|
||||
func ConcatVideo(video *youtube.Video, vodFiles []string, verbose bool) (int64, error) {
|
||||
fileListPath := path.Join(
|
||||
path.Dir(video.Filename),
|
||||
path.Dir(video.Filepath),
|
||||
"files.txt",
|
||||
)
|
||||
|
||||
totalDuration := float64(0.0)
|
||||
fileListString := ""
|
||||
fileListString := strings.Builder{}
|
||||
for _, file := range vodFiles {
|
||||
fileListString += fmt.Sprintf("file '%s'\n", file)
|
||||
jsonProbe, err := ffmpeg.Probe(path.Join(path.Dir(video.Filename), file))
|
||||
fmt.Fprintf(&fileListString, "file '%s'\n", file)
|
||||
jsonProbe, err := ffmpeg.Probe(path.Join(path.Dir(video.Filepath), file))
|
||||
if err != nil {
|
||||
return 0, fmt.Errorf("failed to probe file `%s`: %v", file, err)
|
||||
}
|
||||
|
|
@ -45,7 +46,7 @@ func ConcatVideo(video *youtube.Video, vodFiles []string, verbose bool) (int64,
|
|||
}
|
||||
err := os.WriteFile(
|
||||
fileListPath,
|
||||
[]byte(fileListString),
|
||||
[]byte(fileListString.String()),
|
||||
0644,
|
||||
)
|
||||
if err != nil {
|
||||
|
|
@ -55,7 +56,7 @@ func ConcatVideo(video *youtube.Video, vodFiles []string, verbose bool) (int64,
|
|||
stream := ffmpeg.Input(fileListPath, ffmpeg.KwArgs{
|
||||
"f": "concat",
|
||||
"safe": "0",
|
||||
}).Output(video.Filename, ffmpeg.KwArgs{
|
||||
}).Output(video.Filepath, ffmpeg.KwArgs{
|
||||
"c": "copy",
|
||||
}).OverWriteOutput()
|
||||
if verbose { stream = stream.ErrorToStdOut() }
|
||||
|
|
@ -70,7 +71,7 @@ func ConcatVideo(video *youtube.Video, vodFiles []string, verbose bool) (int64,
|
|||
// not the end of the world; move along
|
||||
}
|
||||
|
||||
fileInfo, err := os.Stat(video.Filename)
|
||||
fileInfo, err := os.Stat(video.Filepath)
|
||||
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