annotate src/main.rs @ 2:1a2852861d8b default tip

Log which video stream has been selected.
author Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
date Thu, 19 Nov 2020 21:38:08 +0100
parents 4adea0a8c8dd
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
1 use std::num::ParseIntError;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
2 use std::str::FromStr;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
3 use std::fmt;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
4 use std::fs::File;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
5 use std::io::{Read, BufReader, Seek, SeekFrom, Write, BufWriter};
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
6 use std::error::Error;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
7 use std::env;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
8 use std::process;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
9
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
10 #[derive(Debug)]
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
11 pub enum ParseError {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
12 Int(ParseIntError),
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
13 WrongResolution,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
14 UnknownCodec,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
15 Custom(String),
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
16 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
17
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
18 impl fmt::Display for ParseError {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
19 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
20 write!(fmt, "{}", self)
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
21 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
22 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
23
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
24 impl Error for ParseError {}
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
25
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
26 impl From<ParseIntError> for ParseError {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
27 fn from(e: ParseIntError) -> ParseError {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
28 ParseError::Int(e)
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
29 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
30 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
31
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
32 #[derive(Debug)]
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
33 enum Codec {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
34 H264,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
35 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
36
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
37 impl FromStr for Codec {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
38 type Err = ParseError;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
39
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
40 fn from_str(s: &str) -> Result<Codec, ParseError> {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
41 if s == "H.264" {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
42 Ok(Codec::H264)
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
43 } else {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
44 Err(ParseError::UnknownCodec)
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
45 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
46 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
47 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
48
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
49 #[derive(Debug, PartialEq)]
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
50 struct Resolution {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
51 width: u16,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
52 height: u16,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
53 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
54
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
55 impl FromStr for Resolution {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
56 type Err = ParseError;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
57
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
58 fn from_str(s: &str) -> Result<Resolution, ParseError> {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
59 let values: Vec<_> = s.split('x').collect();
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
60 if let [width, height] = values.as_slice() {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
61 let width = width.parse()?;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
62 let height = height.parse()?;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
63 Ok(Resolution {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
64 width,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
65 height,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
66 })
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
67 } else {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
68 Err(ParseError::WrongResolution)
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
69 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
70 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
71 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
72
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
73 impl fmt::Display for Resolution {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
74 fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
75 write!(fmt, "{}×{}", self.width, self.height)
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
76 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
77 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
78
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
79 #[derive(Debug)]
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
80 pub struct VxSeekLine {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
81 timestamp: u64,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
82 video_name: String,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
83 codec: Codec,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
84 resolution: Resolution,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
85 unknown: u8,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
86 length: u32,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
87 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
88
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
89 pub fn parse_vxseek(vxseek: &str) -> Result<Vec<VxSeekLine>, ParseError> {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
90 let mut content = Vec::new();
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
91 for line in vxseek.lines() {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
92 let fields: Vec<_> = line.split(':').collect();
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
93 match fields.as_slice() {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
94 [timestamp, video_name, codec, resolution, unknown, length] => {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
95 let timestamp = timestamp.parse()?;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
96 let video_name = video_name.to_string();
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
97 let codec = codec.parse()?;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
98 let resolution = resolution.parse()?;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
99 let unknown = unknown.parse()?;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
100 let length = length.parse()?;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
101 content.push(VxSeekLine {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
102 timestamp,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
103 video_name,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
104 codec,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
105 resolution,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
106 unknown,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
107 length,
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
108 });
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
109 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
110 _ => return Err(ParseError::Custom(String::from("Invalid line in vxseek"))),
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
111 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
112 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
113 Ok(content)
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
114 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
115
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
116 fn main() -> Result<(), Box<dyn Error>> {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
117 let args: Vec<_> = env::args().collect();
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
118 if args.len() != 5 {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
119 eprintln!("Usage: {} <input.vxseek> <input.vxvideo> <resolution> <output.h264>", args[0]);
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
120 process::exit(1);
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
121 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
122 let vxseek_filename = &args[1];
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
123 let vxvideo_filename = &args[2];
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
124 let wanted_resolution: Resolution = args[3].parse()?;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
125 let output_filename = &args[4];
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
126
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
127 let vxseek = {
1
4adea0a8c8dd Remove all unwraps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
128 let mut vxseek = File::open(vxseek_filename)?;
0
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
129 let mut contents = String::new();
1
4adea0a8c8dd Remove all unwraps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
130 vxseek.read_to_string(&mut contents)?;
4adea0a8c8dd Remove all unwraps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
131 parse_vxseek(&contents)?
0
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
132 };
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
133 {
1
4adea0a8c8dd Remove all unwraps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
134 let vxvideo = File::open(vxvideo_filename)?;
0
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
135 let mut vxvideo = BufReader::new(vxvideo);
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
136
1
4adea0a8c8dd Remove all unwraps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
137 let output = File::create(output_filename)?;
0
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
138 let mut output = BufWriter::new(output);
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
139
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
140 let mut name: Option<String> = None;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
141 for VxSeekLine { timestamp, video_name, codec, resolution, unknown, length } in vxseek {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
142 if let Some(ref name) = &name {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
143 if &video_name != name {
1
4adea0a8c8dd Remove all unwraps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
144 vxvideo.seek(SeekFrom::Current(length as i64))?;
0
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
145 continue;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
146 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
147 } else {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
148 if resolution != wanted_resolution {
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
149 println!("Skipping {} due to resolution {}", video_name, resolution);
1
4adea0a8c8dd Remove all unwraps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
150 vxvideo.seek(SeekFrom::Current(length as i64))?;
0
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
151 continue;
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
152 }
2
1a2852861d8b Log which video stream has been selected.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 1
diff changeset
153 println!("Picking {}", video_name);
0
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
154 name = Some(video_name);
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
155 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
156 let mut buf = Vec::with_capacity(length as usize);
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
157 unsafe { buf.set_len(length as usize) };
1
4adea0a8c8dd Remove all unwraps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
158 vxvideo.read_exact(&mut buf)?;
4adea0a8c8dd Remove all unwraps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
159 output.write_all(&buf)?;
4adea0a8c8dd Remove all unwraps.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 0
diff changeset
160 output.flush()?;
0
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
161 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
162 }
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
163 Ok(())
57b200fad67e Hello world!
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
diff changeset
164 }