Skip to content

FFmpeg error with Logitech C925e #48

@TJYSunset

Description

@TJYSunset

Initializing camera with default settings

When initializing the camera without an explicit format requirement, I get the following exception on calling TryGetFrame():

System.ApplicationException: End of file
   at SeeShark.FFmpeg.FFmpegHelper.ThrowExceptionIfError(Int32 error)
   at SeeShark.Decode.VideoStreamDecoder.TryDecodeNextFrame(Frame& nextFrame)
   at SeeShark.Device.VideoDevice.TryGetFrame(Frame& frame)
   at <MY CODE>

Soon the program would crash with another ApplicationException:

Unhandled exception. System.ApplicationException: Invalid data found when processing input
   at SeeShark.FFmpeg.FFmpegHelper.ThrowExceptionIfError(Int32 error)
   at SeeShark.Decode.VideoStreamDecoder.TryDecodeNextFrame(Frame& nextFrame)
   at SeeShark.Device.VideoDevice.TryGetFrame(Frame& frame)
   at SeeShark.Device.VideoDevice.DecodeLoop()
Initialization code
var cameraInfo = CameraManager.Devices.FirstOrDefault(
    x => x.Name?.Contains(cameraNameSegment) ?? false
);
if (ReferenceEquals(cameraInfo, null))
    return;
Camera = CameraManager.GetDevice(cameraInfo);
Camera.StartCapture();

Initializing with yuyv422 640x480

If I instead specify the format to be yuyv422 640x480 (I already dumped AvailableVideoInputOptions so I know for sure it's supported), GetDevice() will fail with the following:

System.ApplicationException: I/O error
   at SeeShark.FFmpeg.FFmpegHelper.ThrowExceptionIfError(Int32 error)
   at SeeShark.Decode.VideoStreamDecoder..ctor(String url, AVInputFormat* inputFormat, IDictionary`2 options)
   at SeeShark.Device.VideoDevice..ctor(VideoDeviceInfo info, DeviceInputFormat inputFormat, VideoInputOptions options)
   at SeeShark.Device.CameraManager.GetDevice(CameraInfo info, VideoInputOptions options)
   at <MY CODE>
Initialization code
Camera = CameraManager.GetDevice(
    cameraInfo,
    cameraInfo.AvailableVideoInputOptions!.First(
        x => x.InputFormat == "yuyv422" && x.VideoSize == (640, 480)
    )
);

Initializing with mjpeg 640x480

Interestingly, using mjpeg will throw a different exception:

System.ApplicationException: Invalid argument
   at SeeShark.FFmpeg.FFmpegHelper.ThrowExceptionIfError(Int32 error)
   at SeeShark.Decode.VideoStreamDecoder..ctor(String url, AVInputFormat* inputFormat, IDictionary`2 options)
   at SeeShark.Decode.VideoStreamDecoder..ctor(String url, DeviceInputFormat inputFormat, IDictionary`2 options)
   at SeeShark.Device.VideoDevice..ctor(VideoDeviceInfo info, DeviceInputFormat inputFormat, VideoInputOptions options)
   at SeeShark.Device.Camera..ctor(VideoDeviceInfo info, DeviceInputFormat inputFormat, VideoInputOptions options)
   at SeeShark.Device.CameraManager.GetDevice(CameraInfo info, VideoInputOptions options)
   at <MY CODE>
Initialization code
Camera = CameraManager.GetDevice(
    cameraInfo,
    cameraInfo.AvailableVideoInputOptions!.First(
        x => x.InputFormat == "mjpeg" && x.VideoSize == (640, 480)
    )
);

Initializing with yuyv422 1920x1080

... And if I use the full resolution the program crashes with a memory error...

Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at FFmpeg.AutoGen.ffmpeg.av_read_frame(FFmpeg.AutoGen.AVFormatContext*, FFmpeg.AutoGen.AVPacket*)
   at SeeShark.Decode.VideoStreamDecoder.TryDecodeNextFrame(SeeShark.Frame ByRef)
   at SeeShark.Device.VideoDevice.TryGetFrame(SeeShark.Frame ByRef)
   at SeeShark.Device.VideoDevice.DecodeLoop()

Maybe another minor issue?

Also unrelated, but Microsoft officially discourages the use of ApplicationException.

Environment Info

Windows 11 22H2 (22621.963)
Logitech C925e
net7.0 with Microsoft.NET.Sdk.Web, AnyCPU or x64, Debug or Release
prebuilt FFmpeg binaries from https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2023-05-23-12-46/ffmpeg-n5.1.3-10-g33ed503e59-win64-gpl-shared-5.1.zip or https://www.gyan.dev/ffmpeg/builds/packages/ffmpeg-5.1.2-full_build-shared.7z

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingffmpegProblem with FFmpegplatform:windowsSpecific to Windowsseeshark 4Relevant to SeeShark 4

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions