11use std:: { thread, time:: Duration } ;
22
3- use cap_media_info:: { Pixel , VideoInfo } ;
3+ use cap_media_info:: { Pixel , VideoInfo , ensure_even } ;
44use ffmpeg:: {
55 Dictionary ,
66 codec:: { codec:: Codec , context, encoder} ,
@@ -9,7 +9,7 @@ use ffmpeg::{
99 frame,
1010 threading:: Config ,
1111} ;
12- use tracing:: { debug, error, trace} ;
12+ use tracing:: { debug, error, trace, warn } ;
1313
1414use crate :: base:: EncoderBase ;
1515
@@ -89,15 +89,21 @@ impl HevcEncoderBuilder {
8989 output : & mut format:: context:: Output ,
9090 ) -> Result < HevcEncoder , HevcEncoderError > {
9191 let input_config = self . input_config ;
92- let ( output_width , output_height ) = self
92+ let ( raw_width , raw_height ) = self
9393 . output_size
9494 . unwrap_or ( ( input_config. width , input_config. height ) ) ;
9595
96- if output_width == 0 || output_height == 0 {
97- return Err ( HevcEncoderError :: InvalidOutputDimensions {
98- width : output_width,
99- height : output_height,
100- } ) ;
96+ let output_width = ensure_even ( raw_width) ;
97+ let output_height = ensure_even ( raw_height) ;
98+
99+ if raw_width != output_width || raw_height != output_height {
100+ warn ! (
101+ raw_width,
102+ raw_height,
103+ output_width,
104+ output_height,
105+ "Auto-adjusted odd dimensions to even for HEVC encoding"
106+ ) ;
101107 }
102108
103109 let candidates = get_codec_and_options ( & input_config, self . preset ) ;
0 commit comments