Old thread but I think still worth addressing the questions.
Modern terminal emulators typically support:
- 8 or 16 color palette, where colors are numbered from 0-7 (0-15), and have known meaning, e.g. 1 is red, 2 is green, 3 is yellow, 4 is blue, etc - this is the color palette defined by popular color schemes
- predefined 6x6x6 color cube (color numbers 17-255)
- true color / RGB
When programs in a terminal use the indexed (palette) colors then what asciinema sees and records are the symbolic numbers (1, 3, 6, …), not actual RGB values. Those are probably the colors where you sometimes see a mismatch when replaying in a browser.
When programs emit the higher indexed colors (17-…) or true color values then asciinema can capture those accurately and render them properly. The ones used in Emacs may be of this type.
Either way, asciinema CLI 2.x wasn’t able to capture the actual color palette of a terminal so the playback in a browser often used a different palette (one of the available themes).
Good news is, the upcoming asciinema 3.0 does capture the original terminal palette (16 colors), embeds it in the cast file under “theme” entry in the header, and the web player correctly uses the original theme.
If you’d like to test this then there are precompiled binaries for Linux and macOS Release v3.0.0-rc.1 · asciinema/asciinema · GitHub, or you can build from source as described here: Testing the new Rust version of the asciinema CLI - #10 by ku1ik