summaryrefslogtreecommitdiff
path: root/main.go
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2023-02-15 21:06:32 +0600
committerGrail Finder <wohilas@gmail.com>2023-02-15 21:06:32 +0600
commit41582a3c316acf6e446364d6a4ba43b0c3ef1cea (patch)
tree4f6571c990f352a310fb9944bf891738ace9f840 /main.go
parent9de5f6901653523b7c74b870aa8c0764af91cabc (diff)
Feat: add ffmpeg inside of go
Diffstat (limited to 'main.go')
-rw-r--r--main.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/main.go b/main.go
index 32a49e5..c82d538 100644
--- a/main.go
+++ b/main.go
@@ -46,7 +46,7 @@ func NewFileData(vttPath string) *FileData {
}
func keysToSlice(req map[string]struct{}) []string {
- resp := make([]string, len(req))
+ resp := []string{}
for k := range req {
resp = append(resp, k)
}
@@ -105,9 +105,9 @@ func readLines(filepath string) []string {
// writeLines writes the lines to the given file.
func writeLines(lines []string, path string) error {
- // file, err := os.Create(path)
- file, err := os.OpenFile(path,
- os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0666)
+ file, err := os.Create(path)
+ // file, err := os.OpenFile(path,
+ // os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0666)
if err != nil {
return err
}
@@ -160,9 +160,9 @@ func writeCSV(data [][]string) {
func buildFFmpegCall(ut *Utterance) string {
return fmt.Sprintf(
- `yes no | ffmpeg -i %s -ss %s -to %s \
+ `yes no | ffmpeg -i "%s" -ss %s -to %s \
-metadata text_source="%s" \
- -ar 22050 %s`,
+ -ar 22050 "%s"`,
ut.FD.AudioPath, ut.LeftTime, ut.RightTime,
ut.FD.VttPath, ut.OutPath,
)
@@ -217,7 +217,6 @@ func getVttList(dirpath string) []string {
func main() {
vttFilepath := flag.String("f", "", "path to a vtt file")
vttDir := flag.String("d", "", "path to a vtt dir")
- // vttFilepath := os.Args[1]
flag.Parse()
utterances := []*Utterance{}
@@ -233,10 +232,17 @@ func main() {
fmt.Println("sum of utterances:", len(utterances))
ffmpegCommands := make(map[string]struct{})
+ // // needs to be oneline command to be unique
+ // ffCommandsRaw := readLines(ffCmdOut)
+ // for _, ff := range ffCommandsRaw {
+ // ffmpegCommands[ff] = struct{}{}
+ // }
for _, ut := range utterances {
ffmpegCommands[buildFFmpegCall(ut)] = struct{}{}
}
- writeLines(keysToSlice(ffmpegCommands), ffCmdOut)
+ fflines := keysToSlice(ffmpegCommands)
+ fmt.Println("# lines: ", len(fflines))
+ writeLines(fflines, ffCmdOut)
metadata := readJson(metadataPath)
newMeta := utterancesToFileTextMap(utterances)