My goal is to create a gtk progress bar with the output of HandBrakeCLI using zenity --progress. I've ran into some snags and I'm wondering if someone knows of a better way or can help me with what I'm currently doing.
Normal Output:
HandBrakeCLI -i infile -o outfile --preset=iPad
Displays
Encoding: task 1 of 1, 11.97 % (72.81 fps, avg 86.78 fps, ETA 00h00m43s)
HandBrake piped to tr and cut commands so I only have the percentages that zenity will expect.
HandBrakeCLI -i infile -o outfile --preset=iPad 2>&1 | tr -s '\r' '\n' | cut -b 24-28
Results in what I would expect:
1.05
1.06
1.10
1.10
But, the output is delayed a lot and sometimes won't even display. If I only use my tr expression I get the output above on each line but it's the whole output including "Encoding: task......".
It's like the cut command can't keep up with the std out of Handbrake. I read up on using named pipes, created one and directed HandBrake's output to the pipe then in another terminal tried the tr and cut command via the pipe and it results in the same delay.
Using awk's print substring also results in the same delay.
I can't figure it out. I'm after the zenity --progress indicator because my HandBrake job is called as a MythTV job and I'd like a progress bar to pop up so I know when and an encode is in process.
tee /dev/stderr
(or /dev/tty) just before zenity. – Trochelminthtr -s '\r' '\n' | cut -b 24-28
It's fine out of tr but not out of cut. – Nabonidus