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

**URL:** <https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928>\
**Category:** Support\
**Tags:** plus, openigtlink\
**Created:** [December 6, 2021, 2:36pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928 "2021-12-06T14:36:14Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![lb123](https://avatars.discourse-cdn.com/v4/letter/l/85e7bf/32.png) [@lb123](https://discourse.slicer.org/u/lb123)\
**Post date:** [December 6, 2021, 2:36pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/1 "2021-12-06T14:36:14Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [December 6, 2021, 4:06pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/2 "2021-12-06T16:06:14Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![lb123](https://avatars.discourse-cdn.com/v4/letter/l/85e7bf/32.png) [@lb123](https://discourse.slicer.org/u/lb123)\
**Post date:** [December 6, 2021, 4:26pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/3 "2021-12-06T16:26:53Z")

</div>

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

```auto
<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?

 ![ddd](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/b/0/b0c8e9febc8448edca7e347d0fb8736bb7433a3e.png)

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).

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [December 6, 2021, 5:53pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/4 "2021-12-06T17:53:29Z")

</div>

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:

```auto
startCommand = slicer.vtkSlicerOpenIGTLinkCommand()
startCommand.SetName("StartRecording")
startCommand.SetCommandContent('<Command Name="StartRecording" CaptureDeviceId="CaptureDevice" OutputFilename="Recording.igs.mha" EnableCompression="False"></Command>')
igtlConnectorNode.SendCommand(startCommand)

```

- Stop

```auto
stopCommand = slicer.vtkSlicerOpenIGTLinkCommand()
stopCommand.SetName("StopRecording")
stopCommand.SetCommandContent('<Command Name="StopRecording" CaptureDeviceId="CaptureDevice"></Command>')
igtlConnectorNode.SendCommand(stopCommand)

```

---

<div class="post-metadata">

**Author:** ![lb123](https://avatars.discourse-cdn.com/v4/letter/l/85e7bf/32.png) [@lb123](https://discourse.slicer.org/u/lb123)\
**Post date:** [December 6, 2021, 5:57pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/5 "2021-12-06T17:57:54Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [December 6, 2021, 7:40pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/6 "2021-12-06T19:40:42Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![lb123](https://avatars.discourse-cdn.com/v4/letter/l/85e7bf/32.png) [@lb123](https://discourse.slicer.org/u/lb123)\
**Post date:** [December 16, 2021, 4:32pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/7 "2021-12-16T16:32:10Z")

</div>

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:

```auto
 <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](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/d/6/d6fcf79fe1207626c9db63b00aa8c39b27bc1449.png)

Do you know I to solve this issue?

Thank you

---

<div class="post-metadata">

**Author:** ![J.vd.Zee](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/j.vd.zee/32/15064_2.png) [@J.vd.Zee](https://discourse.slicer.org/u/J.vd.Zee)\
**Post date:** [March 19, 2024, 8:05am UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/8 "2024-03-19T08:05:33Z")

</div>

Hi!  
Can I re-open this topic?  
I would like to make multiple streams of the same videodevice, but each with a different crop. I’m now struggling with cropping each individual stream.  
**Expected behaviour:**  
Cropping each videostream with the specific crop.

**Observerd behavior**  
Cropping each videostream with the first cropping settings.

Can someone help me out?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/5/7/57d5794f52e56ec14e512660f1ee8fdcd09bc777.png)

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [March 19, 2024, 3:00pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/9 "2024-03-19T15:00:08Z")

</div>

I’m not sure if the MmfVideo device will work with multiple data sources, but a couple of things:

- You should only include one “DataSources” element. Both “DataSource” should be in the same one.
- Same deal with “OutputChannels” and “OutputChannel”.
- A channel can only include a single image stream, so you would need to separate the two. (VideoStream1, VideoStream2). Probably using more descriptive names for each stream.

---

<div class="post-metadata">

**Author:** ![J.vd.Zee](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/j.vd.zee/32/15064_2.png) [@J.vd.Zee](https://discourse.slicer.org/u/J.vd.Zee)\
**Post date:** [March 19, 2024, 3:14pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/10 "2024-03-19T15:14:10Z")

</div>

Hi Kyle,

Thank you for your prompt reply!

I tried your adjustments (see the photo). However, it is not working. Do you have other possible adjustments?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/f/e/fefabccd7d42b9995052e5e450a660a9bdf62a18.png)

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [March 19, 2024, 3:17pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/11 "2024-03-19T15:17:18Z")

</div>

You will need to provide more information. It what way is it not working?

---

<div class="post-metadata">

**Author:** ![J.vd.Zee](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/j.vd.zee/32/15064_2.png) [@J.vd.Zee](https://discourse.slicer.org/u/J.vd.Zee)\
**Post date:** [March 20, 2024, 3:17pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/12 "2024-03-20T15:17:16Z")

</div>

In my previous post, I included the tips you mentioned.  
However, the Plus gives an error after launching:

|WARNING|61724.344000|SERVER\> vtkPlusMmfVideoSource is expecting one output channel and there are 2 channels. First output channel will be used.

Is it possible to create different VideoDevices for each videostream (same capture device) and specific crop?

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [March 20, 2024, 4:38pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/13 "2024-03-20T16:38:44Z")

</div>

Ok, thanks! Since it looks the device doesn’t currently support multiple output channels, then it is probably not currently possible. I’ll look into what is required to support it.

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [March 20, 2024, 4:54pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/14 "2024-03-20T16:54:14Z")

</div>

I’ve updated the vtkPlusMmfVideoSource device. The nightly release tomorrow should be able to support multiple video data sources at the same time, with different crop regions.

---

<div class="post-metadata">

**Author:** ![J.vd.Zee](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/j.vd.zee/32/15064_2.png) [@J.vd.Zee](https://discourse.slicer.org/u/J.vd.Zee)\
**Post date:** [March 22, 2024, 10:11am UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/15 "2024-03-22T10:11:02Z")

</div>

Hi Kyle!

Thanks for updating.  
However, the new update is not working yet. I added my configuration file in the attachments. I made two VideoDevices for each videostream, same capture device and specific crop. Can you help me out?

 ![image](https://us1.discourse-cdn.com/flex002/uploads/slicer/original/3X/2/d/2d2df8908c737afb6473a389a6df8eaf03bfd421.png)

---

<div class="post-metadata">

**Author:** ![Sunderlandkyl](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/sunderlandkyl/32/79987_2.png) [@Sunderlandkyl](https://discourse.slicer.org/u/Sunderlandkyl)\
**Post date:** [March 22, 2024, 1:35pm UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/16 "2024-03-22T13:35:55Z")

</div>

The config file should have only 1 Device that has 2 Data sources and 2 Output channels.

---

<div class="post-metadata">

**Author:** ![J.vd.Zee](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.slicer.org/j.vd.zee/32/15064_2.png) [@J.vd.Zee](https://discourse.slicer.org/u/J.vd.Zee)\
**Post date:** [March 25, 2024, 11:59am UTC](https://discourse.slicer.org/t/how-can-i-record-multiple-video-inputs-at-the-same-time-from-slicer/20928/17 "2024-03-25T11:59:54Z")

</div>

It worked!  
Thanks for helping me out @Sunderlandkyl
