Toolbox to edit asciinema screencasts (sciine).
Project description
asciinema-scene
asciinema-scene
provides the sciine
command line toolkit for editing screen casts produced by asciinema.
sciine
takes as input the content of a screencast, apply a unitary transformation and returns the transformed content.
Installation
asciinema-scene
is a python package:
pip install asciinema-scene
Usage
Commandes
There are 3 types of commands:
-
content information commands:
-
commands applying to a portion of the content:
-
command applying to a single frame:
Usage: sciine [OPTIONS] COMMAND [ARGS]...
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
copy Copy content between START and END timecodes.
cut Cut content between START and END timecodes.
delete Delete the frame with timecode >= TIMECODE.
header Print the header field of the content.
include Include the content of a .cast file at the timecode position.
insert Insert a frame at the TIMECODE position.
maximum Set maximum duration of each frame.
minimum Set minimum duration of each frame.
quantize Set the duration of frames in duration range to DURATION.
replace Replace the text of frame with timecode >= TIMECODE by TEXT.
show Print detail of frames, from START to END (max LINES).
speed Change the speed of the screen cast.
status Print informations about the content (duration, ...).
Input / output
By default, sciine
reads content from standard input and returns the result to standard output. The --input
and --output
options allow reading/writing from files (sciine
can also read from a compressed .zip
or .gz
file). sciine
does not modify the input file.
-i, --input PATH Input .cast file, default is stdin.
-o, --output PATH Output .cast file, default is stdout.
Example:
Speed up a screencast and play a sub-part of it, using pipe redirection.
sciine speed 2.0 --input short.cast | sciine copy --start 1.4 --end 2.4| asciinema play -
Command status
Usage: sciine status [OPTIONS]
Print informations about the content (duration, ...).
Options:
-i, --input PATH Input .cast file, default is stdin.
--help Show this message and exit.
Example:
Use status
to see the number of frames and the duration of the screecast.
sciine status --input short.cast
Input: short.cast
Date: 2023-05-28 11:15:06+00:00
Frames: 22
Duration: 6.135993
Command header
Usage: sciine header [OPTIONS]
Print the header field of the content.
Options:
-i, --input PATH Input .cast file, default is stdin.
--help Show this message and exit.
Example:
Display the original header.
sciine header -i short.cast
{'env': {'SHELL': '/bin/bash', 'TERM': 'linux'},
'height': 36,
'timestamp': 1685272506,
'version': 2,
'width': 133}
Command show
Usage: sciine show [OPTIONS]
Print detail of frames, from START to END (max LINES).
Each line prints the timecode, duration and text of the frame. If no START
timecode is provided, start from the beginning. If no END timecode is
provided, display all lines until the end, or LINES lines
Options:
-s, --start FLOAT Start timecode (sec), default is 0.0.
-e, --end FLOAT End timecode (sec), default is EOF.
-l, --lines INTEGER Number of lines to show.
-p, --precise Show all digits of time codes.
-t, --text Show message field as plain text.
-i, --input PATH Input .cast file, default is stdin.
--help Show this message and exit.
Example:
Display the first 5 lines and the precise duration of the frames.
sciine show --lines 5 --precise -i short.cast
0.000000│ 0.894038│ 'e'
0.894038│ 0.104510│ 'c'
0.998548│ 0.164761│ 'h'
1.163309│ 0.300601│ 'o'
1.463910│ 0.392259│ ' '
Command copy
Usage: sciine copy [OPTIONS]
Copy content between START and END timecodes.
Options:
-s, --start FLOAT Start timecode (sec), default is 0.0.
-e, --end FLOAT End timecode (sec), default is EOF.
-i, --input PATH Input .cast file, default is stdin.
-o, --output PATH Output .cast file, default is stdout.
--help Show this message and exit.
Example:
Play content between 0.05 and 1.2 seconds.
sciine copy --start 0.05 --end 1.2 -i short.cast | asciinema play -
Command cut
Usage: sciine cut [OPTIONS]
Cut content between START and END timecodes.
If no START timecode is provided, cut from the beginning. If no END timecode
is provided, cut until the end.
Options:
-s, --start FLOAT Start timecode (sec), default is 0.0.
-e, --end FLOAT End timecode (sec), default is EOF.
-a, --adjust Adjust durations of frames at precise cut values.
-i, --input PATH Input .cast file, default is stdin.
-o, --output PATH Output .cast file, default is stdout.
--help Show this message and exit.
Example:
Cut end of content after 1.2 seconds.
sciine cut --start 1.2 < short.cast | asciinema play -
Command speed
Usage: sciine speed [OPTIONS] SPEED
Change the speed of the screen cast.
SPEED is the factor of acceleration. Use number below 1.0 to to slow down.
If no START timecode is provided, modify speed from the beginning. If no END
timecode is provided, modify speed until the end.
Options:
-s, --start FLOAT Start timecode (sec), default is 0.0.
-e, --end FLOAT End timecode (sec), default is EOF.
-i, --input PATH Input .cast file, default is stdin.
-o, --output PATH Output .cast file, default is stdout.
--help Show this message and exit.
Example:
Doubles the speed and displays the new duration.
sciine speed 2.0 -i short.cast|sciine status
Input: sys.stdin
Date: 2023-06-03 11:10:23+00:00
Frames: 22
Duration: 3.067996
Command minimum
Usage: sciine minimum [OPTIONS] DURATION
Set minimum duration of each frame.
The minimum duration of frames will be set to DURATION seconds, the
timecodes will be adjusted accordingly. If no START timecode is provided,
apply from the beginning. If no END timecode is provided, apply until the
end.
Options:
-s, --start FLOAT Start timecode (sec), default is 0.0.
-e, --end FLOAT End timecode (sec), default is EOF.
-i, --input PATH Input .cast file, default is stdin.
-o, --output PATH Output .cast file, default is stdout.
--help Show this message and exit.
Example:
Set the frame duration to a minimum of 0.2s and display the new durations.
sciine minimum 0.2 -i short.cast | sciine show -l 5 -p
0.000000│ 0.894038│ 'e'
0.894038│ 0.200000│ 'c'
1.094038│ 0.200000│ 'h'
1.294038│ 0.300601│ 'o'
1.594639│ 0.392259│ ' '
Command maximum
Usage: sciine maximum [OPTIONS] DURATION
Set maximum duration of each frame.
The duration of frames will be limited to DURATION seconds, the timecodes
will be adjusted accordingly. If no START timecode is provided, apply from
the beginning. If no END timecode is provided, apply until the end.
Options:
-s, --start FLOAT Start timecode (sec), default is 0.0.
-e, --end FLOAT End timecode (sec), default is EOF.
-i, --input PATH Input .cast file, default is stdin.
-o, --output PATH Output .cast file, default is stdout.
--help Show this message and exit.
Example:
Set the frame duration to a maximum of 0.2s and display the new durations.
sciine maximum 0.2 -i short.cast | sciine show -l 5 -p
0.000000│ 0.200000│ 'e'
0.200000│ 0.104510│ 'c'
0.304510│ 0.164761│ 'h'
0.469271│ 0.200000│ 'o'
0.669271│ 0.200000│ ' '
Command quantize
Usage: sciine quantize [OPTIONS] RANGE_MIN RANGE_MAX DURATION
Set the duration of frames in duration range to DURATION.
Set the duration of frames to DURATION if their current duration is between
RANGE_MIN and RANGE_MAX. If no START timecode is provided, apply from the
beginning. If no END timecode is provided, apply until the end.
Options:
-s, --start FLOAT Start timecode (sec), default is 0.0.
-e, --end FLOAT End timecode (sec), default is EOF.
-i, --input PATH Input .cast file, default is stdin.
-o, --output PATH Output .cast file, default is stdout.
--help Show this message and exit.
Example:
Set the frame duration to 0.2s for all frames lasting between 0.1 and 0.4s.
sciine quantize 0.1 0.4 0.2 -i short.cast | sciine show -l 5 -p
0.000000│ 0.894038│ 'e'
0.894038│ 0.200000│ 'c'
1.094038│ 0.200000│ 'h'
1.294038│ 0.200000│ 'o'
1.494038│ 0.200000│ ' '
Command include
Usage: sciine include [OPTIONS] TIMECODE INCLUDE_FILE
Include the content of a .cast file at the timecode position.
All frames of the INCLUDE_FILE .cast file will be copied in the current
screen cast. The timecodes will be adjusted as required.
Options:
-i, --input PATH Input .cast file, default is stdin.
-o, --output PATH Output .cast file, default is stdout.
--help Show this message and exit.
Add the content of long.cast
to the beginning of the screencast, and display the final duration.
sciine include 0.0 long.cast.gz -i short.cast|sciine status
Input: sys.stdin
Date: 2023-06-03 12:14:22+00:00
Frames: 71391
Duration: 22.925312
Command insert
Usage: sciine insert [OPTIONS] TIMECODE DURATION TEXT [ETYPE]
Insert a frame at the TIMECODE position.
The frame will display TEXT during DURATION seconds. By default the event
type ETYPE is set to "o".
Options:
-i, --input PATH Input .cast file, default is stdin.
-o, --output PATH Output .cast file, default is stdout.
--help Show this message and exit.
Insert the string 'xyz' at position 2.0 for a duration of 0.1s. View content before and after the change.
sciine show -l 8 -p -i short.cast
0.000000│ 0.894038│ 'e'
0.894038│ 0.104510│ 'c'
0.998548│ 0.164761│ 'h'
1.163309│ 0.300601│ 'o'
1.463910│ 0.392259│ ' '
1.856169│ 0.356967│ '"'
2.213136│ 0.150277│ 'a'
2.363413│ 0.511288│ ' '
sciine insert 2.0 0.1 "xyz" -i short.cast | sciine show -l 8 -p
0.000000│ 0.894038│ 'e'
0.894038│ 0.104510│ 'c'
0.998548│ 0.164761│ 'h'
1.163309│ 0.300601│ 'o'
1.463910│ 0.392259│ ' '
1.856169│ 0.356967│ '"'
2.213136│ 0.100000│ 'xyz'
2.313136│ 0.150277│ 'a'
Command replace
Usage: sciine replace [OPTIONS] TIMECODE TEXT
Replace the text of frame with timecode >= TIMECODE by TEXT.
Options:
-i, --input PATH Input .cast file, default is stdin.
-o, --output PATH Output .cast file, default is stdout.
--help Show this message and exit.
Replace the string 'xyz' at position 2.0 for a duration of 0.1s. View content before and after the change.
sciine show -l 8 -p -i short.cast
0.000000│ 0.894038│ 'e'
0.894038│ 0.104510│ 'c'
0.998548│ 0.164761│ 'h'
1.163309│ 0.300601│ 'o'
1.463910│ 0.392259│ ' '
1.856169│ 0.356967│ '"'
2.213136│ 0.150277│ 'a'
2.363413│ 0.511288│ ' '
sciine replace 2.0 "xyz" -i short.cast | sciine show -l 8 -p
0.000000│ 0.894038│ 'e'
0.894038│ 0.104510│ 'c'
0.998548│ 0.164761│ 'h'
1.163309│ 0.300601│ 'o'
1.463910│ 0.392259│ ' '
1.856169│ 0.356967│ '"'
2.213136│ 0.150277│ 'xyz'
2.363413│ 0.511288│ ' '
Command delete
Usage: sciine delete [OPTIONS] TIMECODE
Delete the frame with timecode >= TIMECODE.
Options:
-i, --input PATH Input .cast file, default is stdin.
-o, --output PATH Output .cast file, default is stdout.
--help Show this message and exit.
Delete the frame at position 2.0. View content before and after the change.
sciine show -l 8 -p -i short.cast
0.000000│ 0.894038│ 'e'
0.894038│ 0.104510│ 'c'
0.998548│ 0.164761│ 'h'
1.163309│ 0.300601│ 'o'
1.463910│ 0.392259│ ' '
1.856169│ 0.356967│ '"'
2.213136│ 0.150277│ 'a'
2.363413│ 0.511288│ ' '
sciine delete 2.0 -i short.cast | sciine show -l 8 -p
0.000000│ 0.894038│ 'e'
0.894038│ 0.104510│ 'c'
0.998548│ 0.164761│ 'h'
1.163309│ 0.300601│ 'o'
1.463910│ 0.392259│ ' '
1.856169│ 0.356967│ '"'
2.213136│ 0.511288│ ' '
2.724424│ 0.237965│ 's'
Code source
Github repository: https://github.com/jdum/asciinema-scene/
License
This project is licensed under the MIT License (see the LICENSE file for details).
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file asciinema_scene-0.8.2.tar.gz
.
File metadata
- Download URL: asciinema_scene-0.8.2.tar.gz
- Upload date:
- Size: 13.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9a349698a3822e9322ed7286b53b200b3a05410c7385cc211c3188b6f1b7899a |
|
MD5 | eec9e93ebed18d08bd75dea57458804f |
|
BLAKE2b-256 | ecde4b89129b5c97d07b4adc3922e0e71778833bd0f014db89c7f0e31535074b |
File details
Details for the file asciinema_scene-0.8.2-py3-none-any.whl
.
File metadata
- Download URL: asciinema_scene-0.8.2-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.12.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8360b2e4a0fc18f6d0cd3428b39aa369365558922718e45792f8ba6c9e166ba3 |
|
MD5 | 5a682ec25af960ce2d994390a163bac1 |
|
BLAKE2b-256 | 461b33b9cbd9f83f341495e343c022c56c65557c5211273ee297a4df95904ad5 |