0

This is the Request I get from an BMD Hyperdeck, it contains the Video-files on the SD-Cards an the lengths of the Videos. I need the lengths of every file, separate in a List for my Code. What would be the right way to something like this?

b'206 disk list:\r\nslot id: 1\r\n1: Timecode.mp4 H.264 1080p25 00:01:00:00\r\n2: Video_1.mp4 H.264 1080p25 00:00:09:07\r\n3: Video_2.mp4 H.264 1080p25 00:00:07:04\r\n4: Video_3.mp4 H.264 1080p25 00:00:10:19\r\n5: Video_4.mp4 H.264 1080p25 00:00:04:16\r\n6: Video_5.mp4 H.264 1080p25 00:00:05:21\r\n\r\n'
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
Robert
  • 1
  • Where are the file lengths? Do you mean the video lengths like `00:00:09:07`? – Barmar Apr 14 '22 at 15:50
  • Split the string into lines. Remove the first two header lines. Then you can split each line into words and get the word you want with the length. – Barmar Apr 14 '22 at 15:52

1 Answers1

0

This can be achieved using the regular expressions and findall:

import re

a = b"206 disk list:\r\nslot id: 1\r\n1: Timecode.mp4 H.264 1080p25 00:01:00:00\r\n2: Video_1.mp4 H.264 1080p25 00:00:09:07\r\n3: Video_2.mp4 H.264 1080p25 00:00:07:04\r\n4: Video_3.mp4 H.264 1080p25 00:00:10:19\r\n5: Video_4.mp4 H.264 1080p25 00:00:04:16\r\n6: Video_5.mp4 H.264 1080p25 00:00:05:21\r\n\r\n"
str_a = str(a)
length = re.findall(r"[0-9]{2}:[0-9]{2}:[0-9]{2}:[0:9]{2}", str_a)
print(length)
Floh
  • 745
  • 3
  • 16