add an option to force timebase value
authorKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 12 Jul 2020 09:28:32 +0000 (11:28 +0200)
committerKostya Shishkov <kostya.shishkov@gmail.com>
Sun, 12 Jul 2020 09:28:32 +0000 (11:28 +0200)
src/main.rs

index ac5a92c91610c43738129346e38609051bae06a6..de13de930c45e3ce366e23c68b1d1e785a38c47a 100644 (file)
@@ -185,6 +185,23 @@ impl Transcoder {
             } else if oval.len() == 2 {
 //todo parse encoder options, store, init later
                 match oval[0] {
+                    "timebase" => {
+                        let mut parts = oval[1].split('/');
+                        let num = parts.next().unwrap();
+                        let den = parts.next();
+                        if let Some(den) = den {
+                            let rnum = num.parse::<u32>();
+                            let rden = den.parse::<u32>();
+                            if let (Ok(num), Ok(den)) = (rnum, rden) {
+                                ostr.enc_params.tb_num = num;
+                                ostr.enc_params.tb_den = den;
+                            } else {
+                                println!("invalid timebase value");
+                            }
+                        } else {
+                            println!("invalid timebase format (should be num/den)");
+                        }
+                    },
                     "encoder" => {
                         if enc_reg.find_encoder(oval[1]).is_some() {
                             ostr.enc_name = oval[1].to_string();