Skip to content

Commit

Permalink
add video resolution/framerate sort to gopro connect
Browse files Browse the repository at this point in the history
  • Loading branch information
KonradIT committed Sep 12, 2021
1 parent 65926bc commit 768eb8d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/gopro/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,14 +157,23 @@ func ImportConnect(in, out string, sortOptions SortOptions) (*utils.Result, erro
filename := fmt.Sprintf("%s%s-%s.%s", x[:2], x[4:][:4], x[2:][:2], strings.Split(x, ".")[1])
color.Green(">>> %s", x)

if _, err := os.Stat(filepath.Join(dayFolder, "videos")); os.IsNotExist(err) {
err = os.MkdirAll(filepath.Join(dayFolder, "videos"), 0755)
var gpFileInfo = &goProMediaMetadata{}
err = caller(in, fmt.Sprintf("gp/gpMediaMetadata?p=%s/%s&t=v4info", folder.D, goprofile.N), gpFileInfo)
if err != nil {
return nil, err
}

framerate := gpFileInfo.Fps / gpFileInfo.FpsDenom
rfpsFolder := fmt.Sprintf("%sx%s %d", gpFileInfo.W, gpFileInfo.H, framerate)

if _, err := os.Stat(filepath.Join(dayFolder, "videos", rfpsFolder)); os.IsNotExist(err) {
err = os.MkdirAll(filepath.Join(dayFolder, "videos", rfpsFolder), 0755)
if err != nil {
log.Fatal(err.Error())
}
}

err := utils.DownloadFile(filepath.Join(dayFolder, "videos", filename), fmt.Sprintf("http://%s:8080/videos/DCIM/%s/%s", in, folder.D, goprofile.N))
err := utils.DownloadFile(filepath.Join(dayFolder, "videos", rfpsFolder, filename), fmt.Sprintf("http://%s:8080/videos/DCIM/%s/%s", in, folder.D, goprofile.N))
if err != nil {
result.Errors = append(result.Errors, err)
result.FilesNotImported = append(result.FilesNotImported, goprofile.N)
Expand Down
24 changes: 24 additions & 0 deletions pkg/gopro/structs.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,3 +137,27 @@ type GoProConnectDevice struct {
IP string
Info cameraInfo
}

type goProMediaMetadata struct {
Cre string `json:"cre"`
S string `json:"s"`
Us string `json:"us"`
Mos []interface{} `json:"mos"`
Eis string `json:"eis"`
Pta string `json:"pta"`
Ao string `json:"ao"`
Tr string `json:"tr"`
Mp string `json:"mp"`
Gumi string `json:"gumi"`
Ls string `json:"ls"`
Cl string `json:"cl"`
Hc string `json:"hc"`
Hi []interface{} `json:"hi"`
Dur string `json:"dur"`
W string `json:"w"`
H string `json:"h"`
Fps int `json:"fps,string"`
FpsDenom int `json:"fps_denom,string"`
Prog string `json:"prog"`
Subsample string `json:"subsample"`
}

0 comments on commit 768eb8d

Please sign in to comment.