FlantasticDan / pyperdeck

Python interface for Blackmagic Design HyperDeck recorders.
http://pyperdeck.readthedocs.io
MIT License
1 stars 3 forks source link

Time remaining for current clip playing #1

Open flyingfaders opened 2 years ago

flyingfaders commented 2 years ago

Hey FlantasticDan! Is there an equivalent 'remaining_time' for playback? I was hoping to return the time remaining on a clip playing back.

FlantasticDan commented 2 years ago

Playback is more convoluted than I would like on these devices because everything is based around a relatively opaque idea of a timeline that I haven't fully implemented or documented.

The playback timeline automatically appends each recording to it in the order they were recorded but places your playhead a bit less predictably. That's further complicated by the fact that the timeline has in and out points that you can set, or may be set invisibly by the device if it's played in "single clip" mode.

With the library as it is now, I think you could determine the remaining time left on the timeline:

from pyperdeck import Hyperdeck

deck = Hyperdeck('192.168.0.100')
deck.output()

def get_remaining_timeline_time():
    '''Returns the number of frames left to be played in the timeline'''
    if timeline_out == 0:
        return deck.timeline.duration - deck.timeline_playhead
    return deck.timeline_out - deck.timeline_playhead

This is untested, I don't have any Hyperdecks set up to test with right now, but I hope it points you in the right direction...

You can take a look at the internal workings of the timeline object accessed at deck.timeline here: https://github.com/FlantasticDan/pyperdeck/blob/430ade151917879fab3c1248deba9570d45f3627/pyperdeck/_internals.py#L73 It's not as fully featured as I want it to be yet but digging into it may be useful to you. If there's anything else please let me know, I'm excited to see someone else using this library!