Support v4l2 #81
Answered
by
tpoisonooo
tpoisonooo
asked this question in
Q&A
-
Hi, I'd like to open ubuntu camera with pub fn input_v4l2<P: AsRef<Path>>(path: &P) -> Result<context::Input, Error> {
unsafe {
let mut ps = ptr::null_mut();
let path = from_path(path);
let format = CString::new("v4l2").unwrap();
let x = av_find_input_format(format.as_ptr());
match avformat_open_input(&mut ps, path.as_ptr(), x, ptr::null_mut()) {
0 => match avformat_find_stream_info(ps, ptr::null_mut()) {
r if r >= 0 => Ok(context::Input::wrap(ps)),
e => {
avformat_close_input(&mut ps);
Err(Error::from(e))
}
},
e => Err(Error::from(e)),
}
}
} I have tried
but x is still nullptr 155 let x = av_find_input_format(format.as_ptr());
(gdb) n
157 match avformat_open_input(&mut ps, path.as_ptr(), x, ptr::null_mut()) {
(gdb) p x
$1 = (ffmpeg_sys_next::AVInputFormat *) 0x0 Would you please give me an example to open linux camera which dev is "/dev/video0" ? |
Beta Was this translation helpful? Give feedback.
Answered by
tpoisonooo
Nov 21, 2021
Replies: 1 comment
-
linux v4l2 feature has been implement on this repo : https://github.com/tpoisonooo/rust-ffmpeg-sys To compile with the feature, some dep must be installed: $ sudo apt install libv4l-dev lzma-dev |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
tpoisonooo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
linux v4l2 feature has been implement on this repo : https://github.com/tpoisonooo/rust-ffmpeg-sys
To compile with the feature, some dep must be installed: