escapi
escapi copied to clipboard
Getting list of supported formats / resolutions / framerates
Would it be possible for escapi to allow querying for the supported formats of a camera, and then query for the supported resolutions of a given format? Similar to how it's possible with the rscam Rust crate:
extern crate rscam;
use std::io::prelude::*;
use std::fs;
fn main() -> rscam::Result<()> {
let mut cam = rscam::new("/dev/video2").unwrap();
for fmt in cam.formats() {
let fmt = fmt?;
println!("{:?}", fmt);
if let rscam::ResolutionInfo::Discretes(v) = cam.resolutions(&fmt.format)? {
for res in v {
println!("{:?} {:?}", res, cam.intervals(&fmt.format, res)?);
}
}
}
cam.start(&rscam::Config {
interval: (1, 30), // 30 fps.
resolution: (1920, 1080),
format: b"MJPG",
..Default::default()
}).unwrap();
for i in 0..30 {
let frame = cam.capture().unwrap();
let mut file = fs::File::create(&format!("frame-{}.jpg", i)).unwrap();
file.write_all(&frame[..]).unwrap();
}
Ok(())
}
which prints:
YUYV (YUYV 4:2:2)
(1920, 1080) Discretes: 5fps
(160, 120) Discretes: 30fps, 25fps, 20fps, 15fps
(176, 144) Discretes: 30fps, 25fps, 20fps, 15fps
(320, 240) Discretes: 30fps, 25fps, 20fps, 15fps
(352, 288) Discretes: 30fps, 25fps, 20fps, 15fps
(640, 360) Discretes: 30fps, 25fps, 20fps, 15fps
(640, 480) Discretes: 30fps, 25fps, 20fps, 15fps
(800, 600) Discretes: 10fps, 5fps
(848, 480) Discretes: 10fps, 5fps
(1024, 768) Discretes: 10fps, 5fps
(1280, 800) Discretes: 10fps, 5fps
(1280, 720) Discretes: 10fps, 5fps
MJPG (Motion-JPEG, compressed)
(1920, 1080) Discretes: 30fps, 25fps, 20fps, 5fps
(160, 120) Discretes: 30fps, 25fps, 20fps, 15fps
(176, 144) Discretes: 30fps, 25fps, 20fps, 15fps
(320, 240) Discretes: 30fps, 25fps, 20fps, 15fps
(352, 288) Discretes: 30fps, 25fps, 20fps, 15fps
(640, 360) Discretes: 30fps, 25fps, 20fps, 5fps
(640, 480) Discretes: 30fps, 25fps, 20fps, 15fps
(800, 600) Discretes: 30fps, 25fps, 20fps, 5fps
(848, 480) Discretes: 30fps, 25fps, 20fps, 5fps
(1024, 768) Discretes: 30fps, 25fps, 20fps, 5fps
(1280, 800) Discretes: 30fps, 25fps, 20fps, 5fps
(1280, 720) Discretes: 30fps, 25fps, 20fps, 5fps
RGB3 (RGB3, emulated)
(1920, 1080) Discretes: 30fps, 25fps, 20fps, 5fps
(160, 120) Discretes: 30fps, 25fps, 20fps, 15fps
(176, 144) Discretes: 30fps, 25fps, 20fps, 15fps
(320, 240) Discretes: 30fps, 25fps, 20fps, 15fps
(352, 288) Discretes: 30fps, 25fps, 20fps, 15fps
(640, 360) Discretes: 30fps, 25fps, 20fps, 15fps
(640, 480) Discretes: 30fps, 25fps, 20fps, 15fps
(800, 600) Discretes: 30fps, 25fps, 20fps, 5fps
(848, 480) Discretes: 10fps, 5fps
(1024, 768) Discretes: 30fps, 25fps, 20fps, 5fps
(1280, 800) Discretes: 30fps, 25fps, 20fps, 5fps
(1280, 720) Discretes: 30fps, 25fps, 20fps, 5fps
BGR3 (BGR3, emulated)
(1920, 1080) Discretes: 30fps, 25fps, 20fps, 5fps
(160, 120) Discretes: 30fps, 25fps, 20fps, 15fps
(176, 144) Discretes: 30fps, 25fps, 20fps, 15fps
(320, 240) Discretes: 30fps, 25fps, 20fps, 15fps
(352, 288) Discretes: 30fps, 25fps, 20fps, 15fps
(640, 360) Discretes: 30fps, 25fps, 20fps, 15fps
(640, 480) Discretes: 30fps, 25fps, 20fps, 15fps
(800, 600) Discretes: 30fps, 25fps, 20fps, 5fps
(848, 480) Discretes: 10fps, 5fps
(1024, 768) Discretes: 30fps, 25fps, 20fps, 5fps
(1280, 800) Discretes: 30fps, 25fps, 20fps, 5fps
(1280, 720) Discretes: 30fps, 25fps, 20fps, 5fps
YU12 (YU12, emulated)
(1920, 1080) Discretes: 30fps, 25fps, 20fps, 5fps
(160, 120) Discretes: 30fps, 25fps, 20fps, 15fps
(176, 144) Discretes: 30fps, 25fps, 20fps, 15fps
(320, 240) Discretes: 30fps, 25fps, 20fps, 15fps
(352, 288) Discretes: 30fps, 25fps, 20fps, 15fps
(640, 360) Discretes: 30fps, 25fps, 20fps, 15fps
(640, 480) Discretes: 30fps, 25fps, 20fps, 15fps
(800, 600) Discretes: 30fps, 25fps, 20fps, 5fps
(848, 480) Discretes: 10fps, 5fps
(1024, 768) Discretes: 30fps, 25fps, 20fps, 5fps
(1280, 800) Discretes: 30fps, 25fps, 20fps, 5fps
(1280, 720) Discretes: 30fps, 25fps, 20fps, 5fps
YV12 (YV12, emulated)
(1920, 1080) Discretes: 30fps, 25fps, 20fps, 5fps
(160, 120) Discretes: 30fps, 25fps, 20fps, 15fps
(176, 144) Discretes: 30fps, 25fps, 20fps, 15fps
(320, 240) Discretes: 30fps, 25fps, 20fps, 15fps
(352, 288) Discretes: 30fps, 25fps, 20fps, 15fps
(640, 360) Discretes: 30fps, 25fps, 20fps, 15fps
(640, 480) Discretes: 30fps, 25fps, 20fps, 15fps
(800, 600) Discretes: 30fps, 25fps, 20fps, 5fps
(848, 480) Discretes: 10fps, 5fps
(1024, 768) Discretes: 30fps, 25fps, 20fps, 5fps
(1280, 800) Discretes: 30fps, 25fps, 20fps, 5fps
(1280, 720) Discretes: 30fps, 25fps, 20fps, 5fps
http://loyd.github.io/rscam/rscam/struct.Camera.html
I'm asking because I often encounter the case where a 30 FPS FullHD capture is only possible with MJPEG, like in this case. (The emulated modes are done by v4l2 in software afaik.) When I open this camera with escapi, it chooses the slow 5 FPS YUYV mode :(
In my modified version of escapi I added MJPEG as a supported format and then pass through the undecoded MJPEG buffer to my Rust application where I use the mozjpeg-sys crate to decode the frames. But it's very blind (not querying what's supported) & hardcoded to my webcam, I want it to work for any webcam. So what I would ideally want to do with escapi is: find the highest resolution with at least 20 fps and use that format (and when it's MJPEG I can decode it myself).
Is there any plan to allow querying for supported formats / resolutions / framerates like this? :)
Hi,
Escapi is supposed to be simple. You can naturally do whatever you wish in a forked version.
On Sun, Jun 3, 2018, 22:33 Boscop [email protected] wrote:
Would it be possible for escapi to allow querying for the supported formats of a camera, and then query for the supported resolutions of a given format? Similar to how it's possible with the rscam Rust crate:
extern crate rscam; use std::io::prelude::*;use std::fs; fn main() -> rscam::Result<()> { let mut cam = rscam::new("/dev/video2").unwrap(); for fmt in cam.formats() { let fmt = fmt?; println!("{:?}", fmt); if let rscam::ResolutionInfo::Discretes(v) = cam.resolutions(&fmt.format)? { for res in v { println!("{:?} {:?}", res, cam.intervals(&fmt.format, res)?); } } }
cam.start(&rscam::Config { interval: (1, 30), // 30 fps. resolution: (1920, 1080), format: b"MJPG", ..Default::default() }).unwrap();
for i in 0..30 { let frame = cam.capture().unwrap(); let mut file = fs::File::create(&format!("frame-{}.jpg", i)).unwrap(); file.write_all(&frame[..]).unwrap(); } Ok(()) }
which prints:
YUYV (YUYV 4:2:2) (1920, 1080) Discretes: 5fps (160, 120) Discretes: 30fps, 25fps, 20fps, 15fps (176, 144) Discretes: 30fps, 25fps, 20fps, 15fps (320, 240) Discretes: 30fps, 25fps, 20fps, 15fps (352, 288) Discretes: 30fps, 25fps, 20fps, 15fps (640, 360) Discretes: 30fps, 25fps, 20fps, 15fps (640, 480) Discretes: 30fps, 25fps, 20fps, 15fps (800, 600) Discretes: 10fps, 5fps (848, 480) Discretes: 10fps, 5fps (1024, 768) Discretes: 10fps, 5fps (1280, 800) Discretes: 10fps, 5fps (1280, 720) Discretes: 10fps, 5fps MJPG (Motion-JPEG, compressed) (1920, 1080) Discretes: 30fps, 25fps, 20fps, 5fps (160, 120) Discretes: 30fps, 25fps, 20fps, 15fps (176, 144) Discretes: 30fps, 25fps, 20fps, 15fps (320, 240) Discretes: 30fps, 25fps, 20fps, 15fps (352, 288) Discretes: 30fps, 25fps, 20fps, 15fps (640, 360) Discretes: 30fps, 25fps, 20fps, 5fps (640, 480) Discretes: 30fps, 25fps, 20fps, 15fps (800, 600) Discretes: 30fps, 25fps, 20fps, 5fps (848, 480) Discretes: 30fps, 25fps, 20fps, 5fps (1024, 768) Discretes: 30fps, 25fps, 20fps, 5fps (1280, 800) Discretes: 30fps, 25fps, 20fps, 5fps (1280, 720) Discretes: 30fps, 25fps, 20fps, 5fps RGB3 (RGB3, emulated) (1920, 1080) Discretes: 30fps, 25fps, 20fps, 5fps (160, 120) Discretes: 30fps, 25fps, 20fps, 15fps (176, 144) Discretes: 30fps, 25fps, 20fps, 15fps (320, 240) Discretes: 30fps, 25fps, 20fps, 15fps (352, 288) Discretes: 30fps, 25fps, 20fps, 15fps (640, 360) Discretes: 30fps, 25fps, 20fps, 15fps (640, 480) Discretes: 30fps, 25fps, 20fps, 15fps (800, 600) Discretes: 30fps, 25fps, 20fps, 5fps (848, 480) Discretes: 10fps, 5fps (1024, 768) Discretes: 30fps, 25fps, 20fps, 5fps (1280, 800) Discretes: 30fps, 25fps, 20fps, 5fps (1280, 720) Discretes: 30fps, 25fps, 20fps, 5fps BGR3 (BGR3, emulated) (1920, 1080) Discretes: 30fps, 25fps, 20fps, 5fps (160, 120) Discretes: 30fps, 25fps, 20fps, 15fps (176, 144) Discretes: 30fps, 25fps, 20fps, 15fps (320, 240) Discretes: 30fps, 25fps, 20fps, 15fps (352, 288) Discretes: 30fps, 25fps, 20fps, 15fps (640, 360) Discretes: 30fps, 25fps, 20fps, 15fps (640, 480) Discretes: 30fps, 25fps, 20fps, 15fps (800, 600) Discretes: 30fps, 25fps, 20fps, 5fps (848, 480) Discretes: 10fps, 5fps (1024, 768) Discretes: 30fps, 25fps, 20fps, 5fps (1280, 800) Discretes: 30fps, 25fps, 20fps, 5fps (1280, 720) Discretes: 30fps, 25fps, 20fps, 5fps YU12 (YU12, emulated) (1920, 1080) Discretes: 30fps, 25fps, 20fps, 5fps (160, 120) Discretes: 30fps, 25fps, 20fps, 15fps (176, 144) Discretes: 30fps, 25fps, 20fps, 15fps (320, 240) Discretes: 30fps, 25fps, 20fps, 15fps (352, 288) Discretes: 30fps, 25fps, 20fps, 15fps (640, 360) Discretes: 30fps, 25fps, 20fps, 15fps (640, 480) Discretes: 30fps, 25fps, 20fps, 15fps (800, 600) Discretes: 30fps, 25fps, 20fps, 5fps (848, 480) Discretes: 10fps, 5fps (1024, 768) Discretes: 30fps, 25fps, 20fps, 5fps (1280, 800) Discretes: 30fps, 25fps, 20fps, 5fps (1280, 720) Discretes: 30fps, 25fps, 20fps, 5fps YV12 (YV12, emulated) (1920, 1080) Discretes: 30fps, 25fps, 20fps, 5fps (160, 120) Discretes: 30fps, 25fps, 20fps, 15fps (176, 144) Discretes: 30fps, 25fps, 20fps, 15fps (320, 240) Discretes: 30fps, 25fps, 20fps, 15fps (352, 288) Discretes: 30fps, 25fps, 20fps, 15fps (640, 360) Discretes: 30fps, 25fps, 20fps, 15fps (640, 480) Discretes: 30fps, 25fps, 20fps, 15fps (800, 600) Discretes: 30fps, 25fps, 20fps, 5fps (848, 480) Discretes: 10fps, 5fps (1024, 768) Discretes: 30fps, 25fps, 20fps, 5fps (1280, 800) Discretes: 30fps, 25fps, 20fps, 5fps (1280, 720) Discretes: 30fps, 25fps, 20fps, 5fps
http://loyd.github.io/rscam/rscam/struct.Camera.html
I'm asking because I often encounter the case where a 30 FPS FullHD capture is only possible with MJPEG, like in this case. (The emulated modes are done by v4l2 in software afaik.) When I open this camera with escapi, it chooses the slow 5 FPS YUYV mode :(
In my modified version of escapi I added MJPEG as a supported format and then pass through the undecoded MJPEG buffer to my Rust application where I use the mozjpeg-sys crate to decode the frames. But it's very blind (not querying what's supported) & hardcoded to my webcam, I want it to work for any webcam. So what I would ideally want to do with escapi is: find the highest resolution with at least 20 fps and use that format (and when it's MJPEG I can decode it myself).
Is there any plan to allow querying for supported formats / resolutions / framerates like this? :)
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/jarikomppa/escapi/issues/14, or mute the thread https://github.com/notifications/unsubscribe-auth/AEQ_R2pn3Yz0IJuH7xVFoARZRM-6_Apnks5t5DoOgaJpZM4UYNSe .
Hi Boscop, Since we talked about this earlier you might be interested in my repo. It's a (small fork) of libdshowcapture to build a Windows dll with a C interface to use it. With it, I am able to retrieve the camera list and properties (using Json with Protobuff). Also, I am able to get a buffer and use it from another end (C# for Unity in my case). It is not pretty but it may answer some questions of yours. Also, you may be able to follow the code in libshowcapture to understand the API call to the Windows SDK to see what it is doing under the hood.