diff --git a/src/demux.rs b/src/demux.rs index c551f1c..e51325f 100644 --- a/src/demux.rs +++ b/src/demux.rs @@ -150,6 +150,12 @@ impl Demuxer { while n_stream < (*self.ctx).nb_streams as usize { let stream = *(*self.ctx).streams.add(n_stream); n_stream += 1; + let lang = av_dict_get((*stream).metadata, cstr!("language"), ptr::null_mut(), 0); + let language = if lang.is_null() { + "".to_string() + } else { + rstr!((*lang).value).to_string() + }; match (*(*stream).codecpar).codec_type { AVMediaType::AVMEDIA_TYPE_VIDEO => { streams.push(StreamInfo { @@ -162,6 +168,7 @@ impl Demuxer { fps: av_q2d((*stream).avg_frame_rate) as f32, format: (*(*stream).codecpar).format as isize, sample_rate: 0, + language, }); } AVMediaType::AVMEDIA_TYPE_AUDIO => { @@ -175,6 +182,7 @@ impl Demuxer { fps: 0.0, format: (*(*stream).codecpar).format as isize, sample_rate: (*(*stream).codecpar).sample_rate as usize, + language, }); } AVMediaType::AVMEDIA_TYPE_SUBTITLE => { @@ -188,6 +196,7 @@ impl Demuxer { fps: 0.0, format: 0, sample_rate: 0, + language, }); } AVMediaType::AVMEDIA_TYPE_ATTACHMENT => {} @@ -239,10 +248,11 @@ mod tests { use super::*; #[test] + #[ignore] fn test_stream_groups() -> Result<()> { unsafe { let mut demux = - Demuxer::new("/core/Camera/Syncthing/Camera S22/Camera/20241104_121607.heic")?; + Demuxer::new("/core/[SubsPlease] Kinoko Inu - 06 (1080p) [FECF68AF].mkv")?; let probe = demux.probe_input()?; assert_eq!(1, probe.streams.len()); assert_eq!(1, probe.groups.len()); diff --git a/src/stream_info.rs b/src/stream_info.rs index 332f77d..36607cc 100644 --- a/src/stream_info.rs +++ b/src/stream_info.rs @@ -103,16 +103,26 @@ impl Display for StreamType { #[derive(Clone, Debug, PartialEq)] pub struct StreamInfo { + /// Stream index pub index: usize, + /// Stream type video/audio/subtitle pub stream_type: StreamType, + /// Stream codec pub codec: isize, + /// Pixel format / Sample format pub format: isize, + /// Video width pub width: usize, + /// Video height pub height: usize, - + /// Video FPS pub fps: f32, + + /// Audio sample rate pub sample_rate: usize, + /// Subtitle / Audio language + pub language: String, // private stream pointer pub(crate) stream: *mut AVStream, @@ -147,7 +157,7 @@ impl Display for StreamInfo { ), StreamType::Audio => write!( f, - "{} #{}: codec={},format={},sample_rate={}", + "{} #{}: codec={},format={},sample_rate={},lang={}", self.stream_type, self.index, codec_name, @@ -157,11 +167,12 @@ impl Display for StreamInfo { ))) }, self.sample_rate, + self.language, ), StreamType::Subtitle => write!( f, - "{} #{}: codec={}", - self.stream_type, self.index, codec_name + "{} #{}: codec={},lang={}", + self.stream_type, self.index, codec_name, self.language ), } } diff --git a/src/transcode.rs b/src/transcode.rs index fc63036..8c8942d 100644 --- a/src/transcode.rs +++ b/src/transcode.rs @@ -111,7 +111,7 @@ impl Transcoder { if let Some(enc) = self.encoders.get_mut(&src_index) { for mut frame in self.decoder.decode_pkt(pkt)? { // scale video frame before sending to encoder - let mut frame = if let Some(sws) = self.scalers.get_mut(&src_index) { + let frame = if let Some(sws) = self.scalers.get_mut(&src_index) { let enc_ctx = enc.codec_context(); let new_frame = sws.process_frame( frame,