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.7.0.tar.gz
.
File metadata
- Download URL: asciinema_scene-0.7.0.tar.gz
- Upload date:
- Size: 13.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6e13e5be81e2c70b79b3020b8c24f25ec804f750f6ca0f624ec3ebbe8e5d865d |
|
MD5 | 7afb75cb958ae925f3eaf38bf375ea85 |
|
BLAKE2b-256 | c967eed43a65c704e555a8403cb25346935bb4ef5b2ddabdd570ffd6dd6539e6 |
File details
Details for the file asciinema_scene-0.7.0-py3-none-any.whl
.
File metadata
- Download URL: asciinema_scene-0.7.0-py3-none-any.whl
- Upload date:
- Size: 12.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.10.11
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7385e8276dd025adcb7318615c5352ca3ce5cae7cb5b5643854d7eca3c24e5ce |
|
MD5 | 0c89e6a822abf8c68cd88ef8939fb633 |
|
BLAKE2b-256 | 48da4b69ab726efed6856f68260b911163cc1087d8c226d6554e3e37018b9487 |