cirocosta / asciinema-edit

asciinema casts post-production tools
https://ops.tips
MIT License
316 stars 22 forks source link

Quantize doesn't behave how I'm expecting it to #2

Closed rmoff closed 6 years ago

rmoff commented 6 years ago

First off, thanks for a great tool! Perfect for what I need!

I'm trying to cut some long (~20 second) pauses from my cast (here)

I tried this:

~/go/bin/asciinema-edit quantize --range 2 /var/folders/q9/2tg_lt9j6nx29rvr5r5jn_bw0000gp/T/tmpkeskvzmm-ascii.cast 

But this didn't affect the length at all (147.826334 still the last frame).

If I specify additional ranges, it shortens it to ~130, but still with long pauses (over the 2 seconds max that I'm expecting)

~/go/bin/asciinema-edit quantize        --range 0.3,1        --range 1,2        --range 2 /var/folders/q9/2tg_lt9j6nx29rvr5r5jn_bw0000gp/T/tmpkeskvzmm-ascii.cast

I ended up using speed with start and end to isolate a particularly long pause to speed that up:

~/go/bin/asciinema-edit quantize        --range 0.3,1        --range 1,2        --range 2 /var/folders/q9/2tg_lt9j6nx29rvr5r5jn_bw0000gp/T/tmpkeskvzmm-ascii.cast | ~/go/bin/asciinema-edit speed --factor 0.1 --start 3.888742 --end 23.160987000000002

Am I using the parameters wrong?

Thanks!

cirocosta commented 6 years ago

Hey @rmoff , I'm glad it's being useful for you! 😁

hmmmm I guess that's because in the first scenario it's not picking a default value for the case when you don't specify the end of the quantization range.

For instance, if you try --range 2,100000, it should work as you expect.

To solve that, the code could do something similar to what we do in speed:

https://github.com/cirocosta/asciinema-edit/blob/3cbd998b27c84072674908886a21a1183a601ec0/commands/speed.go#L68-L76

But then for quantize, instead, do something like:

func (t *quantizeTransformation) Transform(c *cast.Cast) (err error) {
         // for each t.range, if no upper bound specified, make it `math.MaxFloat64`
    err = editor.Quantize(c, t.ranges)
    return
}

Wdyt?

thx!


Update: here's your cast piped to asciinema-edit quantize --range 2,100000: cast

cirocosta commented 6 years ago

Hey @rmoff ,

I just pushed #5 , it should work fine now 😁 I released it under 0.0.4.

Please let me know if it still doesn't work properly.

thx!