Skip to content
This repository was archived by the owner on Mar 2, 2025. It is now read-only.

Commit ce52bf8

Browse files
authored
Merge pull request #108 from KonradIT/dev
Big Refactor - Part 1
2 parents cc3192e + e283a8f commit ce52bf8

File tree

10 files changed

+1615
-1267
lines changed

10 files changed

+1615
-1267
lines changed

examples/extract_clips.py

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import time
2+
import numpy as np
3+
from goprocam import GoProCamera, constants
4+
gpCam = GoProCamera.GoPro()
5+
6+
# Extracts clips from latest video
7+
8+
latestVideo = gpCam.getVideoInfo()
9+
print("Tag count %s" % latestVideo.get(constants.Info.TagCount))
10+
arrayLength = latestVideo[constants.Info.TagCount]
11+
if arrayLength % 2 == 0:
12+
print("Matching tag pairs!")
13+
splitArray = np.array_split(
14+
latestVideo[constants.Info.Tags], arrayLength/2)
15+
for tag in splitArray:
16+
startMs = tag[0]
17+
stopMs = tag[1]
18+
print("\n[START ms] %s\n[STOP ms] %s" %
19+
(startMs, stopMs))
20+
fileName = "%s/%s" % (gpCam.getMediaInfo("folder"),
21+
gpCam.getMediaInfo("file"))
22+
videoId = gpCam.getClip(fileName, constants.Clip.R1080p,
23+
constants.Clip.FPS_NORMAL, str(startMs), str(stopMs))
24+
print("On queue!\nVideo Id: %s\nStatus: %s" %
25+
(videoId, gpCam.clipStatus(str(videoId))))
26+
time.sleep(1)
27+
while(gpCam.clipStatus(str(videoId)) != "complete"):
28+
time.sleep(1)
29+
time.sleep(2)
30+
print("Downloading!\nVideo Id: %s\nStatus: %s" %
31+
(videoId, gpCam.clipStatus(str(videoId))))
32+
url = gpCam.getClipURL(str(videoId))
33+
download = [
34+
url.split("/")[len(url.split("/"))-1],
35+
url.split("/")[len(url.split("/"))-2]]
36+
print("Downloading %s" % download)
37+
try:
38+
gpCam.downloadLastMedia(
39+
path=url, custom_filename="output/%s_%s_%s" % (startMs, stopMs, download[0].replace("TRV", "MP4")))
40+
except(Exception) as e:
41+
time.sleep(2)
42+
gpCam.downloadLastMedia(
43+
path=url, custom_filename="output/%s_%s_%s" % (startMs, stopMs, download[0].replace("TRV", "MP4")))

0 commit comments

Comments
 (0)