[GH-ISSUE #98] [CLI] See duration of recording #74

Closed
opened 2026-02-25 20:32:29 +03:00 by kerem · 3 comments
Owner

Originally created by @vvv on GitHub (May 8, 2015).
Original GitHub issue: https://github.com/asciinema/asciinema/issues/98

I'd like to know the duration a recording written to JSON file.

ttytime utility (part of ttyrec) provides this information:

TTYTIME(1)                                                    TTYTIME(1)

NAME
       ttytime  -  print  the  time  of  the  recorded  session  data by
       ttyrec(1)

SYNOPSIS
       ttytime file...

DESCRIPTION
       Ttytime tells you the time of  recorded  data  in  seconds.   For
       example:

              % ttytime *.tty
                  173 foo.tty
                 1832 bar.tty

SEE ALSO
       script(1), ttyrec(1), ttyplay(1)

                                                              TTYTIME(1)
Originally created by @vvv on GitHub (May 8, 2015). Original GitHub issue: https://github.com/asciinema/asciinema/issues/98 I'd like to know the duration a recording written to JSON file. `ttytime` utility (part of [ttyrec](http://0xcc.net/ttyrec/index.html.en)) provides this information: ``` TTYTIME(1) TTYTIME(1) NAME ttytime - print the time of the recorded session data by ttyrec(1) SYNOPSIS ttytime file... DESCRIPTION Ttytime tells you the time of recorded data in seconds. For example: % ttytime *.tty 173 foo.tty 1832 bar.tty SEE ALSO script(1), ttyrec(1), ttyplay(1) TTYTIME(1) ```
kerem closed this issue 2026-02-25 20:32:29 +03:00
Author
Owner

@vvv commented on GitHub (May 8, 2015):

Poor man's calculator:

#!/bin/sh
set -e

asciinema_time() {
    awk '/^ +[0-9]+\.[0-9]+,/ { t += $1 } END { print int(t) }'
}

if date --version >&/dev/null; then
    REL='-d@' # GNU
else
    REL='-r'  # BSD
fi

for f in "$@"; do
    date ${REL}$(cat "$f" | asciinema_time) -u +%H:%M:%S | tr \\n \\t
    echo $f
done
<!-- gh-comment-id:100198504 --> @vvv commented on GitHub (May 8, 2015): Poor man's calculator: ``` sh #!/bin/sh set -e asciinema_time() { awk '/^ +[0-9]+\.[0-9]+,/ { t += $1 } END { print int(t) }' } if date --version >&/dev/null; then REL='-d@' # GNU else REL='-r' # BSD fi for f in "$@"; do date ${REL}$(cat "$f" | asciinema_time) -u +%H:%M:%S | tr \\n \\t echo $f done ```
Author
Owner

@ku1ik commented on GitHub (May 8, 2015):

asciinema is not planning to mirror all ttyrec/ttytime/tty* features. Anyway, why not opening recording file (since asciinema 1.0 it's a simple JSON file) and looking at duration attribute? It's total duration in seconds.

<!-- gh-comment-id:100205086 --> @ku1ik commented on GitHub (May 8, 2015): asciinema is not planning to mirror all `ttyrec/ttytime/tty*` features. Anyway, why not opening recording file (since asciinema 1.0 it's a simple JSON file) and looking at `duration` attribute? It's total duration in seconds.
Author
Owner

@vvv commented on GitHub (May 8, 2015):

Gosh, indeed.
Please excuse my inattention.

<!-- gh-comment-id:100277735 --> @vvv commented on GitHub (May 8, 2015): Gosh, indeed. Please excuse my inattention.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/asciinema#74
No description provided.