Skip to content

On Linux first time call the method StartAsync() threw a Exception #173

@zhangjiarener

Description

@zhangjiarener

As stated in the title, when I called the method StartAsync() threw a Exception. The abnormal information is as follows:

System.ArgumentException: FlashCap: Couldn't set video format [3]: DevicePath=/dev/video0
at FlashCap.Devices.V4L2Device.b__18_0() in //FlashCap.Core/Devices/V4L2Device.cs:line 198
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
--- End of stack trace from previous location ---
at System.Threading.ExecutionContext.RunFromThreadPoolDispatchLoop(Thread threadPoolThread, ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.Tasks.Task.ExecuteWithThreadLocal(Task& currentTaskSlot, Thread threadPoolThread)
--- End of stack trace from previous location ---
at FlashCap.CaptureDevice.InternalStartAsync(CancellationToken ct) in /
/FlashCap.Core/CaptureDevice.cs:line 93
at CameraDemo.Views.MainWindow.Window_Loaded(Object sender, RoutedEventArgs e) in /data/usershare/csharp_workspace/CameraDemo/CameraDemo/Views/MainWindow.axaml.cs:line 39

The dev info:
Nuget Package: FlashCap 1.11.0
NET SDK: net8.0
Avalonia: 11.3.8

Here is my code:

CaptureDevices devices = new ();
CaptureDeviceDescriptor descriptor0 = devices.EnumerateDescriptors().ElementAt(1);
VideoCharacteristics characteristics = new (PixelFormats.YUYV, 800, 600, Fraction.Create(30));
_device = await descriptor0.OpenAsync(characteristics, bufferScope => {});

try
{
    await _device.StartAsync();
}
catch (Exception ex)
{
    await _device.StopAsync();
    await _device.DisposeAsync();
    Console.WriteLine(ex);
}

And camera info:

Driver Info:
Driver name : uvcvideo
Card type : Web Camera: Web Camera
Bus info : usb-0000:04:00.3-1.3
Driver version : 5.4.18
Capabilities : 0x84a00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:
Driver name : uvcvideo
Model : Web Camera: Web Camera
Serial : V0001
Bus info : usb-0000:04:00.3-1.3
Media version : 5.4.18
Hardware revision: 0x00000100 (256)
Driver version : 5.4.18
Interface Info:
ID : 0x03000002
Type : V4L Video
Entity Info:
ID : 0x00000001 (1)
Name : Web Camera: Web Camera
Function : V4L2 I/O
Flags : default
Pad 0x01000007 : 0: Sink
Link 0x02000010: from remote pad 0x100000a of entity 'Processing 7': Data, Enabled, Immutable
Priority: 2
Video input : 0 (Camera 1: ok)
Format Video Capture:
Width/Height : 800/600
Pixel Format : 'YUYV' (YUYV 4:2:2)
Field : None
Bytes per Line : 1600
Size Image : 960000
Colorspace : sRGB
Transfer Function : Default (maps to sRGB)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Limited Range)
Flags :
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 800, Height 600
Default : Left 0, Top 0, Width 800, Height 600
Pixel Aspect: 1/1
Selection Video Capture: crop_default, Left 0, Top 0, Width 800, Height 600, Flags:
Selection Video Capture: crop_bounds, Left 0, Top 0, Width 800, Height 600, Flags:
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 20.000 (20/1)
Read buffers : 0
brightness 0x00980900 (int) : min=0 max=10 step=1 default=5 value=5
contrast 0x00980901 (int) : min=0 max=20 step=1 default=10 value=10
saturation 0x00980902 (int) : min=0 max=40 step=1 default=20 value=20
white_balance_temperature_auto 0x0098090c (bool) : default=1 value=1
gain 0x00980913 (int) : min=0 max=255 step=1 default=0 value=0
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1
0: Disabled
1: 50 Hz
2: 60 Hz
white_balance_temperature 0x0098091a (int) : min=1 max=5 step=1 default=4 value=4 flags=inactive
sharpness 0x0098091b (int) : min=0 max=255 step=1 default=48 value=48
backlight_compensation 0x0098091c (int) : min=0 max=64 step=1 default=0 value=0
exposure_auto 0x009a0901 (menu) : min=0 max=3 default=0 value=0
1: Manual Mode
exposure_absolute 0x009a0902 (int) : min=1 max=12287 step=1 default=78 value=78 flags=inactive
focus_absolute 0x009a090a (int) : min=0 max=1023 step=1 default=512 value=155 flags=inactive
focus_auto 0x009a090c (bool) : default=1 value=1

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions