Skip to content

Commit

Permalink
Add output directoy option
Browse files Browse the repository at this point in the history
  • Loading branch information
HenrySlawniak committed Sep 6, 2018
1 parent 171e234 commit e8bc1bc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion contactsheet.go
Expand Up @@ -168,7 +168,7 @@ func generateContactSheet(vid *Video, numFrames int) {

}

outFile, err := os.Create(vid.Filename + ".png")
outFile, err := os.Create(filepath.Join(*outputDir, vid.Filename+".png"))
if err != nil {
log.Error(err)
return
Expand Down
11 changes: 10 additions & 1 deletion main.go
Expand Up @@ -37,6 +37,7 @@ var (
numFrames = flag.Int("frames", 12, "The number of frames to generate")
writeInfo = flag.Bool("write-info", true, "Write info JSON to file")
frameWidth = flag.Int("frame-width", 854, "The width to generate thumbnails at")
outputDir = flag.String("o", ".", "The directory to output to")

buildTime string
commit string
Expand Down Expand Up @@ -85,6 +86,14 @@ func createDirectories() {
log.Panic(err)
}

if !FileExists(*outputDir) {
err = os.MkdirAll(*outputDir, 0755)
if err != nil {
log.Error("Cannot create output directory")
log.Panic(err)
}
}

err = ioutil.WriteFile(filepath.Join("bin", "readme.txt"), []byte(binHelp), 0644)
if err != nil {
log.Error("Error writing readme")
Expand Down Expand Up @@ -154,7 +163,7 @@ func ProcessFile(path string) {

if *writeInfo {
j, _ := json.MarshalIndent(video, "", " ")
ioutil.WriteFile(video.Filename+".json", j, 0644)
ioutil.WriteFile(filepath.Join(*outputDir, video.Filename+".json"), j, 0644)
}

generateThumbnails(&video, *numFrames)
Expand Down

0 comments on commit e8bc1bc

Please sign in to comment.