This repository has been archived by the owner on Oct 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
86 lines (65 loc) · 1.5 KB
/
main.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
package main
import (
"flag"
"fmt"
"os"
"strings"
"github.com/elboletaire/remuxing/models"
)
const gray = 13
func parseArgs() (
output string,
inputs []string,
languages []string,
verbose bool,
) {
flag.StringVar(&output, "output", "", "The output file.")
var lang string
flag.StringVar(&lang, "languages", "", "Languages to be taken from inputs. Order matters, first one will be marked as default track.")
var help bool
flag.BoolVar(&help, "h", false, "This help.")
flag.BoolVar(&verbose, "v", false, "Verbose.")
flag.Parse()
if help || len(os.Args) == 1 {
flag.Usage = func() {
usage()
flag.PrintDefaults()
}
flag.Usage()
os.Exit(0)
}
if len(output) == 0 {
syntaxError("-output path missing")
}
inputs = flag.Args()
if len(inputs) < 2 {
syntaxError("at least two inputs are expected")
}
if len(lang) > 0 {
languages = strings.Split(lang, ",")
}
return
}
func main() {
output, inputs, languages, verbose := parseArgs()
tracks := models.BuildTracks(inputs)
video := tracks.GetBestVideo()
audios := tracks.GetBestAudios(languages)
subtitles := tracks.GetBestSubtitles(languages)
command := CommandArguments(output, video, audios, subtitles)
if verbose {
title("VIDEOS")
printTrack(video)
printTracks("AUDIOS", audios)
printTracks("SUBTITLES", subtitles)
printCommand(command)
}
result, err := Command(command)
if err != nil {
panic(fmt.Sprint(err) + ": " + string(result))
}
if verbose {
title("OUTPUT")
fmt.Println(string(result))
}
}