Get camera fps in a script ?

Discussions on extending SharpCap using the built in Python scripting functionality
Post Reply
Jean-Francois
Posts: 402
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Get camera fps in a script ?

#1

Post by Jean-Francois »

Hello Robin,

Is it possible to get the actual fps value of the camera in a script ?

Regards,
Jean-Francois
User avatar
admin
Site Admin
Posts: 13350
Joined: Sat Feb 11, 2017 3:52 pm
Location: Vale of the White Horse, UK
Contact:

Re: Get camera fps in a script ?

#2

Post by admin »

Hi Jean Francois,

there's no way to ask SharpCap for it, but you could intercept the FrameCaptured event on the camera and calculate it yourself. Some discussion of handling the event here :

viewtopic.php?p=5690#p5690

cheers,

Robin
Jean-Francois
Posts: 402
Joined: Sun Oct 13, 2019 10:52 am
Location: Germany

Re: Get camera fps in a script ?

#3

Post by Jean-Francois »

Hello Robin,

Concerning the fps value in a script ... I found a way to have it ...

Code: Select all

import os
import time

CameraSettingFile = SharpCap.Settings.CreateCameraSettingsFile

if (CameraSettingFile == False):
    SharpCap.Settings.CreateCameraSettingsFile = True
    SharpCap.Settings.Save()

SharpCap.SelectedCamera.PrepareToCapture()
SharpCap.SelectedCamera.RunCapture()

time.sleep(3)

SharpCap.SelectedCamera.StopCapture()
SharpCap.ShowNotification(None)

file = SharpCap.GetLastCaptureFilename()
file_settings = os.path.splitext(file)[0] + ".CameraSettings.txt"

with open(file_settings, 'r') as fp:
    for l_no, line in enumerate(fp):
        if "ActualFrameRate" in line:
            break

parts = line.split("=")[1]
framerate = float(parts.split("f")[0])
print framerate

if (CameraSettingFile == False):
    SharpCap.Settings.CreateCameraSettingsFile = False
    SharpCap.Settings.Save()

try:
    os.remove(file)
    os.remove(file_settings)
except:
    print "No file to delete"

The script starts a capture of a film.
It opens the CameraSettings.txt file and search the line with "ActualFrameRate".
It works fine and it takes in account all the transfer from the camera to the disc.

Regards,
Jean-Francois
Post Reply