How can I record multiple video inputs at the same time from Slicer?

Hi,

I’m broadcasting 2 acquired videos through OpenIGTLink from Plus Server to Slicer 4.13.0.
The videos consist in live data coming from 2 epiphan frame grabbers.

I can correctly see both the live videos on Slicer.

I would like to record both them from Slicer.

I tried to record adding a CaptureDevice in the plus server configuration file:

<Device
  Id="CaptureDevice"
  Type="VirtualCapture"
  BaseFilename="RecordingTest.igs.mha"
  EnableCapturingOnStart="FALSE" >
  <InputChannels>
    <InputChannel Id="VideoStream1" />
<InputChannel Id="VideoStream2" />
  </InputChannels>
</Device>

Then I tried to start a recording from Slicer using the recording button of Plus Remote (IGT module) but only the VideoStream1 is recorded.

Can you please tell me what I am doing wrong?

Each VirtualCapture device can only record a single video stream, you’ll need to have one for each.

Thank you for your reply. So I should add a second VirtualCaputure device like shown below, right?

<Device
  Id="CaptureDevice1"
  Type="VirtualCapture"
  BaseFilename="RecordingTest1.igs.mha"
  EnableCapturingOnStart="FALSE" >
  <InputChannels>
    <InputChannel Id="VideoStream1" />
  </InputChannels>
</Device>

<Device
  Id="CaptureDevice2"
  Type="VirtualCapture"
  BaseFilename="RecordingTest2.igs.mha"
  EnableCapturingOnStart="FALSE" >
  <InputChannels>
    <InputChannel Id="VideoStream2" />
  </InputChannels>
</Device>

But then how is it possible to run 2 recordings at the same time?

As you can see from the attached image it is possibile to select just one capture device at a time

Is it possible to do it just coding or is there the possibility to do it from the Slicer GUI?

Maybe the most immediate way is just to set EnableCapturingOnStart=“TRUE”, right?

Also, is it possible to reduce the size of .mha files? Huge files are generated (several GB for a few seconds of recording).

There doesn’t seem to be a way to do this from the GUI currently.

EnableCapturingOnStart=“TRUE” will work if you’re ok with recording everything once the server is started.

You can also start recording from python like this:

  • Start:
startCommand = slicer.vtkSlicerOpenIGTLinkCommand()
startCommand.SetName("StartRecording")
startCommand.SetCommandContent('<Command Name="StartRecording" CaptureDeviceId="CaptureDevice" OutputFilename="Recording.igs.mha" EnableCompression="False"></Command>')
igtlConnectorNode.SendCommand(startCommand)
  • Stop
stopCommand = slicer.vtkSlicerOpenIGTLinkCommand()
stopCommand.SetName("StopRecording")
stopCommand.SetCommandContent('<Command Name="StopRecording" CaptureDeviceId="CaptureDevice"></Command>')
igtlConnectorNode.SendCommand(stopCommand)

Thank you a lot for your explanation!

Do you know if there is any way to decrease the size of the recordings?
Huge files are generated (several GB for a few seconds of recording).

Couple of ways:

  • Can you post the epiphan device config? If the image is in color, then it will increase the size of the files.
  • You can add "EnableCompression=“TRUE” to the command to use compression when saving.
  • In tomorrow’s nightly Plus build, you can change the file name extension from “.igs.mha” to “mkv”. Even if the video is color, this should reduce file size by saving as a Matroska file (using VP9 compression).

Not sure if you are aware, but you can also record images and transforms in Slicer using the Sequences module. Let me know if you have any questions.

Thank you, I tried to save to “mkv” and the size is really smaller now!

So, following your suggestions I recorded 2 videos in mkv format. But now I would like to replay them but I am facing some issues.

This is the configuration file I am using to replay the 2 videos:

 <PlusConfiguration version="2.1">

  <DataCollection StartupDelaySec="1.0" >
    <DeviceSet
      Name="test_multi_replay_mkv___"
      Description="Broadcasting acquired video through OpenIGTLink"
    />
	<Device
		Id="VideoDevice"
		Type="SavedDataSource"
		SequenceFile="RecordingFristVideo21-12-16-10-20-46.mkv"
		UseData="IMAGE"
		UseOriginalTimestamps="TRUE"
		ToolReferenceFrame="Reference"
		RepeatEnabled="TRUE" >
		<DataSources>
		<DataSource Type="Video" Id="Video" BufferSize="100" />
		</DataSources>
		<OutputChannels>
		<OutputChannel Id="VideoStream" VideoDataSourceId="Video" />
		</OutputChannels>
    </Device>
	
	<Device
		Id="VideoDevice2"
		Type="SavedDataSource"
		SequenceFile="RecordingSecondVideo21-12-16-10-20-46.mkv"
		UseData="IMAGE"
		UseOriginalTimestamps="TRUE"
		ToolReferenceFrame="Reference"
		RepeatEnabled="TRUE" >
		<DataSources>
		<DataSource Type="Video" Id="Video2" BufferSize="100" />
		</DataSources>
		<OutputChannels>
		<OutputChannel Id="VideoStream2" VideoDataSourceId="Video2" />
		</OutputChannels>
    </Device>
	
  </DataCollection>

  <CoordinateDefinitions>
    <Transform From="Image" To="Reference"
      Matrix="
        1 0.0 0.0 0.0
        0.0 1 0.0 0.0
        0.0 0.0 1 0.0
        0 0 0 1" />
		
	<Transform From="Image2" To="Reference"
      Matrix="
        1 0.0 0.0 0.0
        0.0 1 0.0 0.0
        0.0 0.0 1 0.0
        0 0 0 1" />
  </CoordinateDefinitions>

  <PlusOpenIGTLinkServer
    MaxNumberOfIgtlMessagesToSend="1"
    MaxTimeSpentWithProcessingMs="50"
    ListeningPort="18944"
    SendValidTransformsOnly="true"
    OutputChannelId="VideoStream" >
    <DefaultClientInfo>
      <MessageTypes>
        <Message Type="IMAGE" />
      </MessageTypes>
      <ImageNames>
        <Image Name="Image" EmbeddedTransformToFrame="Reference" />
      </ImageNames>
    </DefaultClientInfo>
  </PlusOpenIGTLinkServer>
  
    <PlusOpenIGTLinkServer
    MaxNumberOfIgtlMessagesToSend="1"
    MaxTimeSpentWithProcessingMs="50"
    ListeningPort="18945"
    SendValidTransformsOnly="true"
    OutputChannelId="VideoStream2" >
    <DefaultClientInfo>
      <MessageTypes>
        <Message Type="IMAGE" />
      </MessageTypes>
      <ImageNames>
        <Image Name="Image2" EmbeddedTransformToFrame="Reference" />
      </ImageNames>
    </DefaultClientInfo>
  </PlusOpenIGTLinkServer>

</PlusConfiguration>

When I run the OpenIGTLink clients in Slicer as you can see in the screenshot below there isn’t any vector volume on the “IGTLConnector” but only on the “IGTLConnector_1”:
image

Do you know I to solve this issue?

Thank you