mirror of
https://github.com/encounter/rust-ffmpeg-zmwangx.git
synced 2026-07-10 21:18:40 -07:00
skip avio_open when flags of output is AVFMT_NOFILE
This commit is contained in:
+14
-4
@@ -275,9 +275,15 @@ pub fn output_as<P: AsRef<Path>>(path: &P, format: &str) -> Result<context::Outp
|
||||
format.as_ptr(),
|
||||
path.as_ptr(),
|
||||
) {
|
||||
0 => match avio_open(&mut (*ps).pb, path.as_ptr(), AVIO_FLAG_WRITE) {
|
||||
0 => Ok(context::Output::wrap(ps)),
|
||||
e => Err(Error::from(e)),
|
||||
0 => {
|
||||
let output = context::Output::wrap(ps);
|
||||
if (output.format().flags() & flag::Flags::NO_FILE) == flag::Flags::NO_FILE {
|
||||
return Ok(output);
|
||||
}
|
||||
match avio_open(&mut (*ps).pb, path.as_ptr(), AVIO_FLAG_WRITE) {
|
||||
0 => Ok(output),
|
||||
e => Err(Error::from(e)),
|
||||
}
|
||||
},
|
||||
|
||||
e => Err(Error::from(e)),
|
||||
@@ -303,6 +309,10 @@ pub fn output_as_with<P: AsRef<Path>>(
|
||||
path.as_ptr(),
|
||||
) {
|
||||
0 => {
|
||||
let output = context::Output::wrap(ps);
|
||||
if (output.format().flags() & flag::Flags::NO_FILE) == flag::Flags::NO_FILE {
|
||||
return Ok(output);
|
||||
}
|
||||
let res = avio_open2(
|
||||
&mut (*ps).pb,
|
||||
path.as_ptr(),
|
||||
@@ -314,7 +324,7 @@ pub fn output_as_with<P: AsRef<Path>>(
|
||||
Dictionary::own(opts);
|
||||
|
||||
match res {
|
||||
0 => Ok(context::Output::wrap(ps)),
|
||||
0 => Ok(output),
|
||||
e => Err(Error::from(e)),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user