feat: add format to demuxer info

This commit is contained in:
kieran 2024-12-16 17:02:55 +00:00
parent b358b3e420
commit 76333375d8
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
4 changed files with 11 additions and 0 deletions

View File

@ -221,6 +221,8 @@ impl Demuxer {
let info = DemuxerInfo {
duration: (*self.ctx).duration as f32 / AV_TIME_BASE as f32,
bitrate: (*self.ctx).bit_rate as usize,
format: rstr!((*(*self.ctx).iformat).name).to_string(),
mime_types: rstr!((*(*self.ctx).iformat).mime_type).to_string(),
streams,
#[cfg(feature = "avformat_version_greater_than_60_19")]
groups: stream_groups,

View File

@ -52,6 +52,7 @@ macro_rules! bail_ffmpeg {
#[macro_export]
macro_rules! cstr {
($str:expr) => {
// TODO: leaky
std::ffi::CString::new($str).unwrap().into_raw()
};
}

View File

@ -10,8 +10,15 @@ use std::intrinsics::transmute;
#[derive(Clone, Debug, PartialEq)]
pub struct DemuxerInfo {
/// Average bitrate of the media
pub bitrate: usize,
/// Duration of the media in seconds
pub duration: f32,
/// Comma separated list of formats supported by the demuxer
pub format: String,
/// Comma separated list of mime-types used during probing
pub mime_types: String,
/// List of streams contained in the media
pub streams: Vec<StreamInfo>,
#[cfg(feature = "avformat_version_greater_than_60_19")]
pub groups: Vec<StreamGroupInfo>,

View File

@ -172,6 +172,7 @@ mod tests {
"test_output/test_transcode.mkv",
)?;
let info = transcoder.prepare()?;
assert!(!info.format.is_empty());
for c in info.streams {
transcoder.copy_stream(c)?;
}