progress, ncurses (?)

37 views
Skip to first unread message

Andreas Reuleaux

unread,
Jul 25, 2014, 1:16:54 PM7/25/14
to shake-bui...@googlegroups.com
Hi Neil, Hi list,

I am using shake to do some video conversion with avconv.

While the exact params of avconv are not important here, they
may nevertheless be useful to illustrate my point / use case:

Some of the videos of this years OPLSS are recorded in stereo, but
sound can really be heard just on the left ear, which is annoying
when listening to the video with earphones (I can choose Audio > Stereo Mode > Left
in vlc, but find it tiring to do so at the beginning of every video part,
and therefore prefer to convert the videos beforehand) :

Load any of the videos from Stephanie Weirich's Lecture e.g.
from

https://www.cs.uoregon.edu/research/summerschool/summer14/curriculum.html

This is how I help myself:

avconv -y -i Stephanie2-2.mp4 -vcodec copy -f mp4 -acodec aac -ac 1 -strict experimental Stephanie2-2.mono.mp4

The resulting Stephanie2-2.mono.mp4 I can comfortably hear with
earphones.

Now when I do this kind of conversion with a redo script

default.mono.mp4.do
--------------------
# -*- shell-script -*-



redo-ifchange "$2.mp4"



avconv -y -i "$2.mp4" -vcodec copy -f mp4 -acodec aac -ac 1 -strict experimental "$3"


--------------------

I can see avconv's progress when calling


$ redo Stephanie3-1.mono.mp4


i.e. the last line

frame=10452 fps=404 q=-1.0 Lsize= 14437kB time=348.72 bitrate= 339.2kbits/s

changes every second or so - I assume avconv uses ncurses (but am not sure).

Anyway, it would be nice to see this kind of progress as well when using
shake (replace from missingh > Data.String.Utils ):



--------------------

"*.mono.mp4" *> \mono -> do

let mp4 = replace ".mono.mp4" ".mp4" mono

need [mp4]


() <- cmd Shell $ [

"avconv -y -i", mp4

, "-vcodec copy -f mp4 -acodec aac -ac 1 -strict experimental"
, mono

]

return ()

--------------------

Currently I cannot see this kind of ncurses (?) progress, but
maybe it's already possible, and I am just not aware how to
switch it on?

Anyway, would be nice to have, something for the wishlist therefore,
if it's not already possible somehow?

Thanks.

-Andreas


Neil Mitchell

unread,
Jul 26, 2014, 4:14:03 PM7/26/14
to Andreas Reuleaux, shake-bui...@googlegroups.com
Hi Andreas,

I would be slightly surprised if avconv was using ncurses for a 1 line
progress bar, since you can do the same thing quite easily with escape
characters - just write out the characters, then use \b to backspace
over them and write out again. This is a technique used by both wget
and the Haskell library QuickCheck. I don't have avconv on my system,
so using wget (which I suspect is similar), I needed to do a couple of
things to get it to work.

1) wget detects that Shake isn't a console output (since cmd captures
all pipes), and turns off it's progress bar. With wget, you can turn
that back on with --progress=bar:force.

2) Once I've done that, the progress bar doesn't actually display,
because Shake turns on line buffering by default (it helps separate
parallel commands overlap less) and a progress bar only updates within
one line. You can fix that by setting the option
shakeLineBuffering=False.

All in all, I can get progress messages if I run:

shake shakeOptions{shakeLineBuffering=False} $
action
(cmd "wget http://hackage.haskell.org/packages/index.tar.gz
--progress=bar:force" :: Action ())

Thanks, Neil

Andreas Reuleaux

unread,
Jul 26, 2014, 4:50:29 PM7/26/14
to shake-bui...@googlegroups.com
Hi Neil,

yes, you are right, just adding shakeLineBuffering=False
to the shakeOptions was enough in my case of avconv:

shakeOptions {
...
, shakeLineBuffering=False
}


Thanks a lot.


-Andreas
Reply all
Reply to author
Forward
0 new messages