LoginSignup
1
1

More than 3 years have passed since last update.

[WinForms(unsafe)] USBカメラの列挙

Last updated at Posted at 2020-07-15
public unsafe void ListDevices()
{
    AVFormatContext* camera;
    AVDictionary* option = null;

    ffmpeg.av_log_set_level(ffmpeg.AV_LOG_VERBOSE);
    av_log_set_callback_callback logCallback = (p0, level, format, vl) =>
    {
        if (level > ffmpeg.av_log_get_level()) return;

        var lineSize = 1024;
        var lineBuffer = stackalloc byte[lineSize];
        var printPrefix = 1;
        ffmpeg.av_log_format_line(p0, level, format, vl, lineBuffer, lineSize, &printPrefix);
        var line = Marshal.PtrToStringAnsi((IntPtr)lineBuffer);
        Console.Write(line);
    };
    ffmpeg.av_log_set_callback(logCallback);

    ffmpeg.avdevice_register_all();
    ffmpeg.av_dict_set(&option, "list_devices", "true", 0);
    ffmpeg.avformat_open_input(&camera, null, ffmpeg.av_find_input_format("dshow"), &option);
}

FFmpeg.AutoGen @Ruslan-B

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1