Skip to content

Commit

Permalink
logging hack taken out. still needs looping functionality and pausing
Browse files Browse the repository at this point in the history
  • Loading branch information
paddywwoof committed Dec 27, 2024
1 parent 0c1f1a2 commit 07a8c20
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/picframe/video_streamer.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@


class VideoInfo:
def __init__(self, video_path):
probe_cmd = f"ffmpeg -i {video_path}"
def __init__(self, video_path): # TODO put whole thing in try/catch in case of different formats?
probe_cmd = f"ffmpeg -i {video_path}" # more comprehensive and reliable info than ffinfo
proc = subprocess.Popen(probe_cmd, shell=True, text=True, stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
(output, error) = proc.communicate()
probe_result = (output if proc.returncode == 0 else error).split("\n")
probe_result = (output if proc.returncode == 0 else error).split("\n") # usually stderr as expects dest file

self.width = self.height = self.fps = self.duration = None
err_msg = ""
Expand All @@ -23,19 +23,17 @@ def __init__(self, video_path):
if "Video:" in ln:
str_split = ln.split(",")
for v_info in str_split:
if "x" in v_info:
if "x" in v_info: # only seen one in a small sample, but checking for 1 char a bit risky
try:
(self.width, self.height) = (int(x) for x in v_info.split()[0].split("x"))
except:
(self.width, self.height) = (240, 180)
elif "tbr" in v_info:
elif "tbr" in v_info: # fps sometimes contains unreliable values such as 1k
try:
self.fps = int(v_info.split()[0])
except:
self.fps = 24

with open("/home/pi/log2.txt", "a") as f:
f.write(f"{self.width}, {self.height}, {self.fps}, {self.duration}, {err_msg} == {video_path}\n")

class VideoStreamer:
def __init__(self, video_path):
Expand Down Expand Up @@ -76,6 +74,7 @@ def pipe_thread(self):
elif paused and not self.pause_thread: # continue thread running
paused = False
pipe.send_signal(signal.SIGCONT)

if not paused:
st_tm = time.time()
self.flag = False
Expand Down

0 comments on commit 07a8c20

Please sign in to comment.