So I am using handbrake and python to encode videos based on a schedule. I need to monitor the progress because I use it to estimate the encoding time. Then I can fit it to my scheduler.
I am having an issue getting the ETA and % complete from the process. Here is what I have so far
profile = ["HandBrakeCLI","-i",input,"-o","output","-e","x264"]
cp = subprocess.Popen(profile, stderr=subprocess.PIPE, bufsize=1)
for line in iter(cp.stderr.readline, b''):
# regex match for % complete and ETA
matches = re.match( r'.*(\d+\.\d+)\s%.*ETA\s(\d+)h(\d+)m(\d+)s', line.decode('utf-8') )
if matches:
print( matches.group() )
print(line),
cp.stderr.close()
cp.wait()
It does not match, in fact I'm not entirely sure what is going on. When I run my script, I see the ETA and % complete print out
Encoding: task 1 of 1, 1.19 % (45.57 fps, avg 62.74 fps, ETA 00h08m01s)
I've tried using stdout but it doesn't work either.
You need to read from stdout, not stderr.
Using a progress wrapper (using clint.textui.progress.Bar) and read byte by byte (works for me):
Did not test the code, rewrote it to match the threads initial post.
Hope that helps.