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
Installation from Pypi (recommended):
pip install asciinema-scene
Installation from sources:
uv sync
After installation from sources, you can check everything is working
uv run pytest
Usage
Commandes
There are 4 types of commands:
-
content information commands:
-
commands applying to a portion of the content:
-
command applying to a single frame:
-
command modifying content via regular expressions:
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...
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, ...).
text-delete Delete frames matching the text regex between START and END.
text-merge Merge successive frames matching the regex between START...
text-replace Replace text in frames matching the regex between START...
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.
Example:
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:
-b, --line-break Add line break at end of text.
-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:
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.
Example:
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.
Example:
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'
Command text-delete
Usage: sciine text-delete [OPTIONS] TEXT
Delete frames matching the text regex between START and END.
If no START timecode is provided, delete from the beginning. If no END
timecode is provided, delete 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:
Delete the frames from 3.0 seconds that match '{server}'. View content before and after the change.
sciine show -s3 -i back.cast
3.057│ 0.20│ '\x1b[K \\ {server}\r'
3.258│ 0.21│ '\x1b[K | {server}\r'
3.463│ 0.21│ '\x1b[K / {server}\r'
3.668│ 0.20│ '\x1b[K - {server}\r'
3.871│ 0.20│ '\x1b[K \\ {server}\r'
4.073│ 0.20│ '\x1b[K | {server}\r'
4.275│ 0.21│ '\x1b[K / {server}\r'
4.480│ 0.20│ '\x1b[K - {server}\r'
4.682│ 0.18│ '\x1b[K \\ {server}\r'
4.861│ 0.00│ '\x1b[K \x1b[0m[\x1b[1mserver\x1b[0m] \x1b[32mSuccess\x1b[0m\r\n'
sciine text-delete -s3 -i back.cast '.*{server}' | sciine show -s3
3.057│ 0.00│ '\x1b[K \x1b[0m[\x1b[1mserver\x1b[0m] \x1b[32mSuccess\x1b[0m\r\n'
Command text-replace
Usage: sciine text-replace [OPTIONS] TEXT REPLACEMENT
Replace text in frames matching the regex between START and END.
If no START timecode is provided, replace from the beginning. If no END
timecode is provided, replace 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:
Replace in the frames from 3.0 seconds '. {server}' by 'box '. View content before and after the change.
sciine show -s3 -i back.cast
3.057│ 0.20│ '\x1b[K \\ {server}\r'
3.258│ 0.21│ '\x1b[K | {server}\r'
3.463│ 0.21│ '\x1b[K / {server}\r'
3.668│ 0.20│ '\x1b[K - {server}\r'
3.871│ 0.20│ '\x1b[K \\ {server}\r'
4.073│ 0.20│ '\x1b[K | {server}\r'
4.275│ 0.21│ '\x1b[K / {server}\r'
4.480│ 0.20│ '\x1b[K - {server}\r'
4.682│ 0.18│ '\x1b[K \\ {server}\r'
4.861│ 0.00│ '\x1b[K \x1b[0m[\x1b[1mserver\x1b[0m] \x1b[32mSuccess\x1b[0m\r\n'
sciine text-replace -s3 -i back.cast '. {server}' 'box' | sciine show -s3
3.057│ 0.20│ '\x1b[K box\r'
3.258│ 0.21│ '\x1b[K box\r'
3.463│ 0.21│ '\x1b[K box\r'
3.668│ 0.20│ '\x1b[K box\r'
3.871│ 0.20│ '\x1b[K box\r'
4.073│ 0.20│ '\x1b[K box\r'
4.275│ 0.21│ '\x1b[K box\r'
4.480│ 0.20│ '\x1b[K box\r'
4.682│ 0.18│ '\x1b[K box\r'
4.861│ 0.00│ '\x1b[K \x1b[0m[\x1b[1mserver\x1b[0m] \x1b[32mSuccess\x1b[0m\r\n'
Command text-merge
Usage: sciine text-merge [OPTIONS] TEXT
Merge successive frames matching the regex between START and END.
If no START timecode is provided, merge from the beginning. If no END
timecode is provided, merge 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:
Merge frames from 3.0 seconds matching '. {server}', keeping total duration. View content before and after the change.
sciine show -s3 -i back.cast
3.057│ 0.20│ '\x1b[K \\ {server}\r'
3.258│ 0.21│ '\x1b[K | {server}\r'
3.463│ 0.21│ '\x1b[K / {server}\r'
3.668│ 0.20│ '\x1b[K - {server}\r'
3.871│ 0.20│ '\x1b[K \\ {server}\r'
4.073│ 0.20│ '\x1b[K | {server}\r'
4.275│ 0.21│ '\x1b[K / {server}\r'
4.480│ 0.20│ '\x1b[K - {server}\r'
4.682│ 0.18│ '\x1b[K \\ {server}\r'
4.861│ 0.00│ '\x1b[K \x1b[0m[\x1b[1mserver\x1b[0m] \x1b[32mSuccess\x1b[0m\r\n'
sciine text-merge -s3 -i back.cast '. {server}' | sciine show -s3
3.057│ 1.80│ '\x1b[K \\ {server}\r'
4.861│ 0.00│ '\x1b[K \x1b[0m[\x1b[1mserver\x1b[0m] \x1b[32mSuccess\x1b[0m\r\n'
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
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file asciinema_scene-1.2.2.tar.gz.
File metadata
- Download URL: asciinema_scene-1.2.2.tar.gz
- Upload date:
- Size: 12.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e37fbad08435a023955c5e29904bfce5b85a51bb4c615db169ac10515f73107
|
|
| MD5 |
13669a48ae486fb1d0db93b17e58aa95
|
|
| BLAKE2b-256 |
69d990139b649360a01ffab88101f6f46c05d517e52d72aa711ae2afc41b9850
|
File details
Details for the file asciinema_scene-1.2.2-py3-none-any.whl.
File metadata
- Download URL: asciinema_scene-1.2.2-py3-none-any.whl
- Upload date:
- Size: 14.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd3d25d2c59a79bda93c465e11b06904ff4f9153d34f15fa307be9f0df21699a
|
|
| MD5 |
73187ff068312b32778b9a76d3be248f
|
|
| BLAKE2b-256 |
71747078f30ad48230e14dd912dc4cfaeae075fe71be32a16cdbb8be054c4e21
|