• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nomalab / stainless-ffmpeg / #97

22 May 2025 10:16AM UTC coverage: 64.789% (-0.06%) from 64.852%
#97

push

1691 of 2610 relevant lines covered (64.79%)

0.99 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

53.49
/src/order/decoder_format.rs
1
use crate::audio_decoder::AudioDecoder;
2
use crate::filter_graph::FilterGraph;
3
use crate::format_context::FormatContext;
4
use crate::order::input::Input;
5
use crate::subtitle_decoder::SubtitleDecoder;
6
use crate::tools;
7
use crate::video_decoder::VideoDecoder;
8
use ffmpeg_sys_next::AVMediaType;
9

10
#[derive(Debug)]
11
pub struct DecoderFormat {
12
  pub context: FormatContext,
13
  pub audio_decoders: Vec<AudioDecoder>,
14
  pub subtitle_decoders: Vec<SubtitleDecoder>,
15
  pub video_decoders: Vec<VideoDecoder>,
16
}
17

18
impl DecoderFormat {
19
  pub fn new(graph: &mut FilterGraph, input: &Input) -> Result<Self, String> {
1✔
20
    match input {
1✔
21
      Input::VideoFrames {
×
22
        path,
23
        frames,
24
        label,
25
        codec,
26
        width,
27
        height,
28
        ..
29
      } => {
30
        let audio_decoders = vec![];
×
31
        let subtitle_decoders = vec![];
×
32
        let mut video_decoders = vec![];
×
33
        let mut context = FormatContext::new(path)?;
×
34
        context.set_frames_addresses(frames);
×
35

36
        let identifier = if let Some(ref identifier) = label {
×
37
          identifier.clone()
×
38
        } else {
39
          tools::random_string(8)
×
40
        };
41

42
        let video_decoder =
×
43
          VideoDecoder::new_with_codec(identifier.clone(), codec, *width, *height, 0)?;
44
        graph.add_input_from_video_decoder(&identifier, &video_decoder)?;
×
45
        video_decoders.push(video_decoder);
×
46

47
        Ok(DecoderFormat {
×
48
          context,
×
49
          audio_decoders,
×
50
          subtitle_decoders,
×
51
          video_decoders,
×
52
        })
53
      }
54
      Input::Streams { path, streams, .. } => {
1✔
55
        let mut audio_decoders = vec![];
1✔
56
        let mut subtitle_decoders = vec![];
1✔
57
        let mut video_decoders = vec![];
1✔
58
        let mut context = FormatContext::new(path)?;
2✔
59
        context.open_input()?;
2✔
60

61
        for stream in streams {
3✔
62
          let identifier = if let Some(ref identifier) = stream.label {
2✔
63
            identifier.clone()
2✔
64
          } else {
65
            tools::random_string(8)
×
66
          };
67

68
          unsafe {
69
            match context.get_stream_type(stream.index as isize) {
2✔
70
              AVMediaType::AVMEDIA_TYPE_VIDEO => {
71
                let video_decoder =
2✔
72
                  VideoDecoder::new(identifier.clone(), &context, stream.index as isize)?;
73
                graph.add_input_from_video_decoder(&identifier, &video_decoder)?;
2✔
74
                video_decoders.push(video_decoder);
1✔
75
              }
76
              AVMediaType::AVMEDIA_TYPE_AUDIO => {
77
                let audio_decoder =
2✔
78
                  AudioDecoder::new(identifier.clone(), &context, stream.index as isize)?;
79
                graph.add_input_from_audio_decoder(&identifier, &audio_decoder)?;
2✔
80
                audio_decoders.push(audio_decoder);
1✔
81
              }
82
              AVMediaType::AVMEDIA_TYPE_SUBTITLE => {
83
                let subtitle_decoder =
×
84
                  SubtitleDecoder::new(identifier.clone(), &context, stream.index as isize)?;
85
                subtitle_decoders.push(subtitle_decoder);
×
86
              }
87
              _ => {}
88
            }
89
          }
90
        }
91

92
        Ok(DecoderFormat {
1✔
93
          context,
1✔
94
          audio_decoders,
1✔
95
          subtitle_decoders,
1✔
96
          video_decoders,
1✔
97
        })
98
      }
99
    }
100
  }
101
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc