MCPcopy Create free account
hub / github.com/diffgram/diffgram / get_length

Method get_length

walrus/methods/video/video_preprocess.py:136–156  ·  view source on GitHub ↗

https://stackoverflow.com/questions/3844430/how-to-get-the-duration-of-a-video-in-python

(self, filename)

Source from the content-addressed store, hash-verified

134 return True
135
136 def get_length(self, filename):
137 """
138 https://stackoverflow.com/questions/3844430/how-to-get-the-duration-of-a-video-in-python
139
140 """
141 try:
142 duration_in_seconds = subprocess.run([
143 "ffprobe", "-v", "error", "-show_entries",
144 "format=duration", "-of",
145 "default=noprint_wrappers=1:nokey=1",
146 filename],
147 stdout = subprocess.PIPE,
148 stderr = subprocess.STDOUT)
149
150 # print("get_length", float(duration_in_seconds.stdout))
151
152 return float(duration_in_seconds.stdout)
153
154 except Exception as exception:
155 print("get_length exception ", exception)
156 return None
157
158 def split(self, i: int):
159 """

Callers 1

check_ok_to_splitMethod · 0.95

Calls 1

runMethod · 0.45

Tested by

no test coverage detected