Using CasparCG for replay/slowmo/EVS replacement

Here’s a small heads-up on what I’m currently working on!

A couple of months ago I got some hints that my now-favorite program CasparCG could (maybe) be used to play replays of live-streaming media. This is something that has traditionally been out of scope for productions with smaller budgets.

So, if one could be able to control Caspar to do it, that would be really neat, right?

There has been some an ongoing thread in the caspar forum about this, but it has been focused on creating a really-good, and by doing that creating custom consumers in Caspar and, to be honest, that’s a bit out of my league right now..

So, out of curiosity, I’ve followed the development last year and made some own tests on different solutions on my own:

Try 1: VLC and CasparCG

The idea is to use Caspar to record video files in ffvhuff-format (because of the big advantage of being able to read from the file at the same time as writing to it), and playback the file using VLC (because it can play back videos at slow-motion rates, and seek in good ways). I created a web-interface to VLC and managed to get the whole thing working quite okay, with some drawbacks:

  • The video and sound got out-of-sync after a while
  • The vide files seemed to get corrupt sometimes. That’s NOT a good thing, when you’ve recorded several hours of video and suddenly lose it all…
  • The video file got HUGE really fast, about 2GB/min. But that’s okay I guess…
  • It took lots of CPU to record and playback, I never even began with working on several record channels.

I never was able to solve these problems, so eventually I moved on with other projects.

Try 2: Vanilla CasparCG and a good controller

A couple of weeks ago I put together some requirements a replay/slowmo solution would need to have to be usable:

  1. Be able to record several channels at the same time, in real time. The ideal would be 4, but 3 or 2 would be okay too.
  2. Playback a channel a any rate, backwards and forwards, and to be able to seek any specified time in the channel.
  3. For interviews: Playback sound in sync with video.
  4. Be able to run it on an ordinary (well, somewhat ordinary…) computer.

My idea was to use a vanilla (unaltered) version of caspar, because it would be; a) easier to develop just a controller, and b) it would problably be more stable than a separate, custom-coded version.

This time I’ll try to get Caspar to record the input-channels to h264, and then play back these files. Because h264-files can’t be read from when writing to them I’ve come up with a rather clever solution, if I may say so! 🙂

So instead of recording each frame as a jpeg, (where you need to code the record/playback-code ourselves, and need to worry about audio-sync) or use ffvhuff (which turned out to be unreliable) I’m writing h264-files, and when the play-head needs to access a file that is currently being written to, the record-head finishes writing to that file and begins recording to a new file!

I’ve managed to create a Caspar controller that together with a completely unaltered version of Caspar fulfills my requirements-list above, with some exceptions:

  1. Yeah, with some drawbacks:
    * There is a slight gap (ca 200ms) between the recorded files, but to cope with that I’ve implemented an “exclusive record” feature, so that when doing interviews and such, the recording won’t be interrupted.
    * Another drawback is of course that we shouldn’t be playing-back anywhere to close to real-time, as this would divide the recording into many small pieces, with gaps between them. But if we’re 10s+ behind, no problem!
  2. Yeah, somewhat. Caspar can SEEK to any place in the h264-files, but Caspar doesn’t support playback at any other rate than 1. If we want to do slowmo’s or go backwards we can SEEK the playhead to the correct position in the timeline many times per second, and we’ll get an acceptable smooth playback at any speed and direction.
  3. Yes! Output is with synced audio!
  4. Yes! On my somewhat beefy computer (Intel i7 4770k, that’s 4 cores @ 3.5GHz) I’m running simultaneous record (on 4 channels) and playback (1 channel) for 720p25 input, CPU running steadily at ~50%, which is fine. It’s the CPU that’s limiting here, and I’m recording and playing from an ordinary mechanical hard-drive. The video takes up about 4GB per channel and hour.

Here’s a screenshot of when I’m recording on 4 channels (the 4 lower windows), and playing back the 3rd channel simultaneously, on channel 1.

creplay_1

 

So to sum it up, this is a replay/slowmo/EVS-replacement solution that’s using:

Software:

  • CasparCG
  • Controller-client programmed in Flash

Hardware:

  • A PC with good CPU. 4 channels 720p25 is proved to work on i7 4770k, lower speced pc:s should be able to run great with fewer channels as well.
  • Mechanichal hard drive – no SSD-disks needed!
  • Decklink cards for video in/output.

I’m planning on releasing the client, source code and more specs in a couple of weeks, but I’m going to try this out in some real productions first! 🙂

 

Published by

Johan Nyman

Cross-country skier, orienteerer, mechanical engineer, web developer, media application developer etc...

7 thoughts on “Using CasparCG for replay/slowmo/EVS replacement”

  1. Hey will you release the client? Maybe just demo version so we can see how it works? Thank you very much, this helped me a lot!

    Like

    1. Unfortunately, since Caspar doesn’t support variable playback rates, slow-mo is achieved by sending a LOT of LOAD – commands repeatedly, effectively causing a slow-mo effect, however quite stuttering..

      Like

    1. The config I usually go for looks something like this (dependding on how many recording channels I want)
      […]

      <channels>

      <channel>
      <!-- The output channel -->
      <video-mode>720p5000</video-mode>
      <consumers>
      <screen></screen>
      <decklink>
      <device>1</device>
      </decklink>
      </consumers>
      </channel>
      <channel>
      <!-- Recording channel 1 -->
      <video-mode>720p2500</video-mode>
      <consumers>
      <screen></screen>
      </consumers>
      </channel>
      <channel>
      <!-- Recording channel 2 -->
      <video-mode>720p2500</video-mode>
      <consumers>
      <screen></screen>
      </consumers>
      </channel>
      <channel>
      <!-- Recording channel 3 -->
      <video-mode>720p2500</video-mode>
      <consumers>
      <screen></screen>
      </consumers>
      </channel>
      <channel>
      <!-- Recording channel 4 -->
      <video-mode>720p2500</video-mode>
      <consumers>
      <screen></screen>
      </consumers>
      </channel>

      </channels>

      […]

      Like

Leave a comment