Skip to content

Free Motion Capture for Everyone πŸ’€βœ¨

TypeScript

set 'cap_prop_fourcc' to 'mjpg' which seems to massively improve performace?!

Jon Matthiscc1d79579db3
diff --git a/freemocap/webcam/camsetup.py b/freemocap/webcam/camsetup.py
index 655c7496..7b25e263 100644
--- a/freemocap/webcam/camsetup.py
+++ b/freemocap/webcam/camsetup.py
@@ -40,8 +40,9 @@ class VideoSetup(threading.Thread):
cap.set(cv2.CAP_PROP_FRAME_WIDTH, resWidth)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, resHeight)
cap.set(cv2.CAP_PROP_EXPOSURE, exposure)
+ cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'))
- # showing values of the properties
+ # showing values of the properties
print("__________________________________________")
print("cv2::videocapture properties for Camera# {}".format(self.camID))
print("CV_CAP_PROP_FRAME_WIDTH: '{}'".format(cap.get(cv2.CAP_PROP_FRAME_WIDTH)))
@@ -108,6 +109,7 @@ class MediaPipeVideoSetup(threading.Thread):
cap.set(cv2.CAP_PROP_FRAME_WIDTH, resWidth)
cap.set(cv2.CAP_PROP_FRAME_HEIGHT, resHeight)
cap.set(cv2.CAP_PROP_EXPOSURE, exposure)
+ cap.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'))
# showing values of the properties
print("__________________________________________")
diff --git a/freemocap/webcam/startcamrecording.py b/freemocap/webcam/startcamrecording.py
index 49453b4d..0ef0732c 100644
--- a/freemocap/webcam/startcamrecording.py
+++ b/freemocap/webcam/startcamrecording.py
@@ -73,15 +73,15 @@ def CamRecording(
cam.set(cv2.CAP_PROP_FRAME_WIDTH, resWidth)
cam.set(cv2.CAP_PROP_FRAME_HEIGHT, resHeight)
cam.set(cv2.CAP_PROP_EXPOSURE, exposure)
+ cam.set(cv2.CAP_PROP_FOURCC, cv2.VideoWriter_fourcc('M', 'J', 'P', 'G'))
fourcc = cv2.VideoWriter_fourcc(*codec)
# rawPath = filepath/'RawVideos' #creating a RawVideos folder
# rawPath.mkdir(parents = True, exist_ok = True)
width = cam.get(cv2.CAP_PROP_FRAME_WIDTH)
height = cam.get(cv2.CAP_PROP_FRAME_HEIGHT)
print("width:", width, "height:", height)
- saveRawVidPath = str(
- rawVidPath / videoName
- ) # create a save path for each video to the RawVideos folders
+ saveRawVidPath = str( rawVidPath / videoName) # create a save path for each video to the RawVideos folders
+
out = cv2.VideoWriter(saveRawVidPath, fourcc, framerate, (resWidth, resHeight))
timeStamps = [] # holds the timestamps