diff --git a/src/AllenNeuralDynamics.Core/AindSpinnakerCapture.cs b/src/AllenNeuralDynamics.Core/AindSpinnakerCapture.cs
index c465b2d..2f26981 100644
--- a/src/AllenNeuralDynamics.Core/AindSpinnakerCapture.cs
+++ b/src/AllenNeuralDynamics.Core/AindSpinnakerCapture.cs
@@ -32,20 +32,23 @@ public AindSpinnakerCapture()
[Description("Parameter used for gamma correction. If null, gamma correction is disabled.")]
public double? Gamma { get; set; }
- [Description("Sensor pixel format.")]
- public PixelFormatEnums PixelFormat { get; set; }
+ [Description("Sensor pixel format. If null, the currently set value in the camera will be used.")]
+ public PixelFormatEnums? PixelFormat { get; set; }
[Description("Region of interest to crop the sensor with.")]
public Rect RegionOfInterest { get; set; } = new Rect(0,0,0,0);
- [Description("Sensor ADC bit depth used to acquired data.")]
+ [Description("Sensor ADC bit depth used to acquired data. If null the currently set value in the camera will be used.")]
public AdcBitDepthEnums? AdcBitDepth { get; set; }
protected override void Configure(IManagedCamera camera)
{
try { camera.AcquisitionStop.Execute(); }
catch { }
- camera.PixelFormat.Value = PixelFormat.ToString();
+ if (PixelFormat.HasValue)
+ {
+ camera.PixelFormat.Value = PixelFormat.Value.ToString();
+ }
if (AdcBitDepth.HasValue)
{
camera.AdcBitDepth.Value = AdcBitDepth.Value.ToString();
diff --git a/src/AllenNeuralDynamics.Core/AllenNeuralDynamics.Core.csproj b/src/AllenNeuralDynamics.Core/AllenNeuralDynamics.Core.csproj
index 7c0735f..f3fc22c 100644
--- a/src/AllenNeuralDynamics.Core/AllenNeuralDynamics.Core.csproj
+++ b/src/AllenNeuralDynamics.Core/AllenNeuralDynamics.Core.csproj
@@ -9,7 +9,7 @@
Bonsai Rx Core AllenNeuralDynamics
net472
strict
- 0.2.8
+ 0.2.9
diff --git a/src/AllenNeuralDynamics.Core/FfmpegVideoWriter.cs b/src/AllenNeuralDynamics.Core/FfmpegVideoWriter.cs
index 0cad6d6..a9680f3 100644
--- a/src/AllenNeuralDynamics.Core/FfmpegVideoWriter.cs
+++ b/src/AllenNeuralDynamics.Core/FfmpegVideoWriter.cs
@@ -29,7 +29,7 @@ public class FfmpegVideoWriter : Sink
[Editor(DesignTypes.MultilineStringEditor, DesignTypes.UITypeEditor)]
[Description("The optional set of command-line arguments to use for configuring the video codec.")]
- public string OutputArguments { get; set; } = @"-vf ""scale=out_color_matrix=bt709:out_range=full"" -c:v h264_nvenc -pix_fmt nv12 -color_range full -colorspace bt709 -color_trc linear -tune hq -preset p4 -rc vbr -cq 12 -b:v 0M -metadata author=""Allen Institute for Neural Dynamics"" -maxrate 700M -bufsize 350M";
+ public string OutputArguments { get; set; } = @"-vf ""scale=out_color_matrix=bt709:out_range=full:sws_dither=none,format=yuv420p10le,colorspace=ispace=bt709:all=bt709:dither=none,scale=out_range=tv:sws_dither=none,format=yuv420p"" -c:v libx264 -preset veryslow -crf 18 -pix_fmt yuv420p -metadata author=""Allen Institute for Neural Dynamics"" -movflags +faststart+write_colr";
[Editor(DesignTypes.MultilineStringEditor, DesignTypes.UITypeEditor)]
[Description("The optional set of command-line arguments to use for configuring the input video stream.")]
@@ -51,13 +51,20 @@ public override IObservable Process(IObservable source)
var writer = new ImageWriter { Path = pipe };
return writer.Process(ps).Merge(ps.Take(1).Delay(TimeSpan.FromSeconds(1)).SelectMany(image =>
{
+ string pixelFormat;
+ if (image.Channels == 1 && image.Depth==IplDepth.U8) pixelFormat = "gray";
+ else if (image.Channels == 3 && image.Depth == IplDepth.U8) pixelFormat = "bgr24";
+ else if (image.Channels == 1 && image.Depth == IplDepth.U16) pixelFormat = "gray16le";
+ else if (image.Channels == 3 && image.Depth == IplDepth.U16) pixelFormat = "bgr48le";
+ else throw new InvalidOperationException(string.Format("Unsupported image format. Got {0} channels and depth {1}", image.Channels, image.Depth));
+
var inputArguments = string.Format("-v {0} {1}", Verbosity.ToString().ToLower(), InputArguments);
var args = string.Format("-f rawvideo -vcodec rawvideo {0}-s {1}x{2} -r {3} -pix_fmt {4} {5} -i {6} {7} {8}",
overwrite ? "-y " : string.Empty,
image.Width,
image.Height,
FrameRate,
- image.Channels == 1 ? "gray" : "bgr24",
+ pixelFormat,
inputArguments,
pipe,
OutputArguments,