This repository was archived by the owner on Mar 2, 2025. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 211
Expand file tree
/
Copy pathextract_clips.py
More file actions
43 lines (41 loc) · 1.77 KB
/
extract_clips.py
File metadata and controls
43 lines (41 loc) · 1.77 KB
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
import time
import numpy as np
from goprocam import GoProCamera, constants
gpCam = GoProCamera.GoPro()
# Extracts clips from latest video
latestVideo = gpCam.getVideoInfo()
print("Tag count %s" % latestVideo.get(constants.Info.TagCount))
arrayLength = latestVideo[constants.Info.TagCount]
if arrayLength % 2 == 0:
print("Matching tag pairs!")
splitArray = np.array_split(
latestVideo[constants.Info.Tags], arrayLength/2)
for tag in splitArray:
startMs = tag[0]
stopMs = tag[1]
print("\n[START ms] %s\n[STOP ms] %s" %
(startMs, stopMs))
fileName = "%s/%s" % (gpCam.getMediaInfo("folder"),
gpCam.getMediaInfo("file"))
videoId = gpCam.getClip(fileName, constants.Clip.R1080p,
constants.Clip.FPS_NORMAL, str(startMs), str(stopMs))
print("On queue!\nVideo Id: %s\nStatus: %s" %
(videoId, gpCam.clipStatus(str(videoId))))
time.sleep(1)
while(gpCam.clipStatus(str(videoId)) != "complete"):
time.sleep(1)
time.sleep(2)
print("Downloading!\nVideo Id: %s\nStatus: %s" %
(videoId, gpCam.clipStatus(str(videoId))))
url = gpCam.getClipURL(str(videoId))
download = [
url.split("/")[len(url.split("/"))-1],
url.split("/")[len(url.split("/"))-2]]
print("Downloading %s" % download)
try:
gpCam.downloadLastMedia(
path=url, custom_filename="output/%s_%s_%s" % (startMs, stopMs, download[0].replace("TRV", "MP4")))
except(Exception) as e:
time.sleep(2)
gpCam.downloadLastMedia(
path=url, custom_filename="output/%s_%s_%s" % (startMs, stopMs, download[0].replace("TRV", "MP4")))