CasparCG 2.3.0 DEV with added replay module created by Jan Starzak (@jstarpl)
Release:
Quick and dirty client (for reference only):
This is now my free time project but I will try to polish it. Please fill free to submit ideas, issues or pull requests.
Original idea (copied from old forum post by @jstarpl)
I’d like to share with the community (and quite frankly, also seek some help here) my project which is a replay system based on CasparCG (version 2.0.3, because 2.1.0 would blue-screen my machine). In order to be truly replay-worthy, I decided to add my own consumer and producer to the Caspar framework. The producer and consumer are based on the libjpeg-turbo library, and as such use JPEG as a codec. This produces large files, but is easy to handle in terms of software development and works quickly enough to allow doing multiple input and output channels on the same machine.
The system uses “replay buffers” that are split into two pieces: the video essence file and an index file. This allows simultaneous access to the buffer by a single input and multiple outputs. The video essence file is a stream of JPEG images (one image per every field/frame) and the index is simply a short header and a stream of byte offsets in the video essence file for each field/frame.
Other than that, the rest of the Caspar server is relatively unchanged (I had to modify the code a little bit to make MAV files show up after “CLS” command) - I think that shows Caspar’s remarkable flexibility.
I have tested the system in both PAL and 1080i50, and it does work - with some quirks (more on that later). I haven’t tested this for systems other than 50Hz (59.94Hz and LFF modes might be tricky). Hardware performance is key here, but I believe all servers to spec to the SVT hardware recommendations should handle easily at leas one input and one output channel.
Here is how to use the custom “MAV” version
The minimal configuration for the MAV edition requires at least two channels: one for ingest and another one for output. This usually means two Decklink cards (or a Decklink DUO/QUAD): one for input, and another one for output. Beyond that you can have multiple input and output channels, in various configurations. Always have only one replay buffer per ingest channel.
In the configuration file:
Configure all ingest channels as empty channels with proper system modes (f.g. PAL or 1080i50000). Leave the consumers tag empty.
Configure all output channels as porper channels, like you normally would, f.g. with Decklink consumers.
Start the server
Play the input from your ingest decklink card on your ingest channel:
play 1 decklink 1
Add the replay consumer to your ingest channel:
add 1 replay test-replay
The “test-replay” is a file-name for your replay buffer. Two files will be created in your CasparCG “media” folder: a TEST-REPLAY.MAV file and a TEST-REPLAY.IDX file. The first one is the video essence, and the second one is a manifest and index file. Should you copy your replay buffers, always copy both files.
Play your replay buffer on your output channel:
play 2 test-replay
Voila! You have your own replay system.
You can seek within your replay buffer using the CALL ACMP 2.0 command:
This will seek to the 100th frame in the replay buffer:
call 2 seek 100
This will seek to the 100th frame counting from the end of the replay buffer:
call 2 seek |100
This will move the playhead of your replay 50 frames forward:
call 2 seek +50
This will move the playhead of your replay 50 frames backward:
call 2 seek -50
You can also change the speed of your playback:
Will make the playback go at normal speed
call 2 speed 1
Will make the playback go backwards at twice the normal speed
call 2 speed -2
Will make the playback go at half the speed
call 2 speed 0.5
Will make the playback go at 3/4 of normal speed
call 2 speed 0.75
The consumer can use custom subsampling and JPEG quality settings. Use sytanx:
ADD 1 REPLAY FILE_NAME [QUALITY (int:1-100)] [SUBSAMPLING (444|422|420|411)]
You can also use CasparCG’s auto-play feature along with transitions by using the LENGTH param. You can combine SEEK, LENGTH, SPEED and AUDIO in the PLAY/LOAD/LOADBG command:
This will make the playback start at 100th frame from the begining, play at 0.75x speed, and end playback after 100 frames (buffer time). Any transition (if specified using a f.g. LOADBG (…) AUTO MIX 25) to another clip will happen in the last 25 frames (output time):
play 2 test-replay seek 100 speed 0.5 length 100 audio 1
File format
For every replay there are two files.
Index file has 52 bytes of header followed by 64-bit indexes - one for every frame.
Data file contains (for every frame): 32-bit length of audio data, then raw audio data, then JPEG compressed video data.