rawvideoenc: suggest YUV during format negotiation
[nihav.git] / nihav-commonfmt / src / codecs / rawvideoenc.rs
index 8847520829f0a328466f15700ee619dfddf1eb6d..c7285e668ec60be719afdb2287a066b283bbc58f 100644 (file)
@@ -23,7 +23,15 @@ impl NAEncoder for RawEncoder {
                     ..Default::default()
                 })
             },
-            NACodecTypeInfo::Video(_) => Ok(*encinfo),
+            NACodecTypeInfo::Video(_) => {
+                let mut new_info = *encinfo;
+                if let NACodecTypeInfo::Video(ref mut vinfo) = new_info.format {
+                    if !vinfo.format.model.is_yuv() {
+                        vinfo.format = YUV420_FORMAT;
+                    }
+                }
+                Ok(new_info)
+            },
             NACodecTypeInfo::Audio(_) => Err(EncoderError::FormatError),
         }
     }