feat: audio audio channel count
This commit is contained in:
@ -78,16 +78,16 @@ mod tests {
|
||||
#[test]
|
||||
fn test_buffer() -> Result<()> {
|
||||
unsafe {
|
||||
let mut buf = AudioFifo::new(AVSampleFormat::AV_SAMPLE_FMT_S16, 2)?;
|
||||
let mut buf = AudioFifo::new(AVSampleFormat::AV_SAMPLE_FMT_FLTP, 2)?;
|
||||
|
||||
let mut enc = Encoder::new_with_name("libfdk_aac")?
|
||||
.with_sample_format(AVSampleFormat::AV_SAMPLE_FMT_S16)
|
||||
let mut enc = Encoder::new_with_name("aac")?
|
||||
.with_sample_format(AVSampleFormat::AV_SAMPLE_FMT_FLTP)
|
||||
.with_sample_rate(48_000)?
|
||||
.with_default_channel_layout(2)
|
||||
.open(None)?;
|
||||
|
||||
let mut demo_frame = av_frame_alloc();
|
||||
(*demo_frame).format = AVSampleFormat::AV_SAMPLE_FMT_S16 as _;
|
||||
(*demo_frame).format = AVSampleFormat::AV_SAMPLE_FMT_FLTP as _;
|
||||
(*demo_frame).ch_layout = AVChannelLayout::empty();
|
||||
av_channel_layout_default(&mut (*demo_frame).ch_layout, 2);
|
||||
(*demo_frame).nb_samples = 2048;
|
||||
|
33
src/demux.rs
33
src/demux.rs
@ -107,7 +107,7 @@ impl Demuxer {
|
||||
let ret = avformat_open_input(
|
||||
&mut self.ctx,
|
||||
if let Some(url) = url {
|
||||
cstr!(url.as_str())
|
||||
cstr!(url.as_str()) as _
|
||||
} else {
|
||||
ptr::null_mut()
|
||||
},
|
||||
@ -173,42 +173,45 @@ impl Demuxer {
|
||||
AVMediaType::AVMEDIA_TYPE_VIDEO => {
|
||||
streams.push(StreamInfo {
|
||||
stream,
|
||||
index: (*stream).index as usize,
|
||||
codec: (*(*stream).codecpar).codec_id as isize,
|
||||
index: (*stream).index as _,
|
||||
codec: (*(*stream).codecpar).codec_id as _,
|
||||
stream_type: StreamType::Video,
|
||||
width: (*(*stream).codecpar).width as usize,
|
||||
height: (*(*stream).codecpar).height as usize,
|
||||
fps: av_q2d((*stream).avg_frame_rate) as f32,
|
||||
format: (*(*stream).codecpar).format as isize,
|
||||
width: (*(*stream).codecpar).width as _,
|
||||
height: (*(*stream).codecpar).height as _,
|
||||
fps: av_q2d((*stream).avg_frame_rate) as _,
|
||||
format: (*(*stream).codecpar).format as _,
|
||||
sample_rate: 0,
|
||||
channels: 0,
|
||||
language,
|
||||
});
|
||||
}
|
||||
AVMediaType::AVMEDIA_TYPE_AUDIO => {
|
||||
streams.push(StreamInfo {
|
||||
stream,
|
||||
index: (*stream).index as usize,
|
||||
codec: (*(*stream).codecpar).codec_id as isize,
|
||||
index: (*stream).index as _,
|
||||
codec: (*(*stream).codecpar).codec_id as _,
|
||||
stream_type: StreamType::Audio,
|
||||
width: (*(*stream).codecpar).width as usize,
|
||||
height: (*(*stream).codecpar).height as usize,
|
||||
width: (*(*stream).codecpar).width as _,
|
||||
height: (*(*stream).codecpar).height as _,
|
||||
fps: 0.0,
|
||||
format: (*(*stream).codecpar).format as isize,
|
||||
sample_rate: (*(*stream).codecpar).sample_rate as usize,
|
||||
format: (*(*stream).codecpar).format as _,
|
||||
sample_rate: (*(*stream).codecpar).sample_rate as _,
|
||||
channels: (*(*stream).codecpar).ch_layout.nb_channels as _,
|
||||
language,
|
||||
});
|
||||
}
|
||||
AVMediaType::AVMEDIA_TYPE_SUBTITLE => {
|
||||
streams.push(StreamInfo {
|
||||
stream,
|
||||
index: (*stream).index as usize,
|
||||
codec: (*(*stream).codecpar).codec_id as isize,
|
||||
index: (*stream).index as _,
|
||||
codec: (*(*stream).codecpar).codec_id as _,
|
||||
stream_type: StreamType::Subtitle,
|
||||
width: 0,
|
||||
height: 0,
|
||||
fps: 0.0,
|
||||
format: 0,
|
||||
sample_rate: 0,
|
||||
channels: 0,
|
||||
language,
|
||||
});
|
||||
}
|
||||
|
@ -133,6 +133,8 @@ pub struct StreamInfo {
|
||||
pub sample_rate: usize,
|
||||
/// Subtitle / Audio language
|
||||
pub language: String,
|
||||
/// Number of audio channels
|
||||
pub channels: u8,
|
||||
|
||||
// private stream pointer
|
||||
pub(crate) stream: *mut AVStream,
|
||||
|
Reference in New Issue
Block a user