Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add duration and bit_rate from container #86

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions ac-ffmpeg/src/format/demuxer.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ int ffw_demuxer_init(Demuxer* demuxer, AVIOContext* io_context, AVInputFormat* f
int ffw_demuxer_set_initial_option(Demuxer* demuxer, const char* key, const char* value);
int ffw_demuxer_set_option(Demuxer* demuxer, const char* key, const char* value);
int ffw_demuxer_find_stream_info(Demuxer* demuxer, int64_t max_analyze_duration);
int ffw_demuxer_get_bit_rate(Demuxer* demuxer);
int ffw_demuxer_get_duration(Demuxer* demuxer);
unsigned ffw_demuxer_get_nb_streams(const Demuxer* demuxer);
AVStream* ffw_demuxer_get_stream(Demuxer* demuxer, unsigned stream_index);
const AVInputFormat* ffw_demuxer_get_input_format(const Demuxer* demuxer);
Expand Down Expand Up @@ -130,6 +132,14 @@ int ffw_demuxer_find_stream_info(Demuxer* demuxer, int64_t max_analyze_duration)
return avformat_find_stream_info(demuxer->fc, NULL);
}

int ffw_demuxer_get_bit_rate(Demuxer* demuxer) {
return demuxer->fc->bit_rate;
}

int ffw_demuxer_get_duration(Demuxer* demuxer) {
return demuxer->fc->duration;
}

unsigned ffw_demuxer_get_nb_streams(const Demuxer* demuxer) {
return demuxer->fc->nb_streams;
}
Expand Down
14 changes: 14 additions & 0 deletions ac-ffmpeg/src/format/demuxer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ extern "C" {
fn ffw_demuxer_get_nb_streams(demuxer: *const c_void) -> c_uint;
fn ffw_demuxer_get_stream(demuxer: *mut c_void, index: c_uint) -> *mut c_void;
fn ffw_demuxer_get_input_format(demuxer: *const c_void) -> *const c_void;
fn ffw_demuxer_get_bit_rate(demuxer: *const c_void) -> c_int;
fn ffw_demuxer_get_duration(demuxer: *const c_void) -> c_int;
fn ffw_demuxer_read_frame(
demuxer: *mut c_void,
packet: *mut *mut c_void,
Expand Down Expand Up @@ -334,6 +336,18 @@ impl<T> Demuxer<T> {
Ok(res)
}

pub fn get_bit_rate(&self) -> Result<i32, Error> {
let ret = unsafe { ffw_demuxer_get_bit_rate(self.ptr) };

Ok(ret)
}

pub fn get_duration(&self) -> Result<i32, Error> {
let ret = unsafe { ffw_demuxer_get_duration(self.ptr) };

Ok(ret)
}

pub fn input_format(&self) -> InputFormat {
// XXX: This is potentially very ugly as we rely on the fact that the
// input formats are statically allocated by FFmpeg and not owned by
Expand Down