@@ -3,8 +3,8 @@ use image::{ImageBuffer, Rgb};
33use mp4m:: mp4_processor:: {
44 AudioConfig , Mp4Processor , Mp4ProcessorConfigBuilder , VideoConfig , VideoFrameType ,
55} ;
6- use recorder:: { EncodedFrame , FPS , VideoEncoderConfig } ;
76use std:: { path:: PathBuf , thread, time:: Duration } ;
7+ use video_encoder:: { EncodedFrame , VideoEncoderConfig } ;
88
99fn main ( ) -> Result < ( ) , Box < dyn std:: error:: Error > > {
1010 env_logger:: init ( ) ;
@@ -13,8 +13,8 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
1313 let audio_file2 = "data/input.wav" ;
1414 let output_file = "data/tmp/output.mp4" ;
1515 let ( width, height) = ( 1920 , 1080 ) ;
16- let ( fps, duration_seconds) = ( FPS :: Fps25 , 10 ) ;
17- let total_frames = fps. to_u32 ( ) * duration_seconds;
16+ let ( fps, duration_seconds) = ( 25 , 10 ) ;
17+ let total_frames = fps * duration_seconds;
1818
1919 // Create red, green, blue images (RGB format)
2020 let red_frame = create_color_frame ( width, height, 255 , 0 , 0 ) ;
@@ -63,11 +63,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
6363 // Create video config
6464 let config = Mp4ProcessorConfigBuilder :: default ( )
6565 . save_path ( PathBuf :: from ( output_file) )
66- . video_config ( VideoConfig {
67- width,
68- height,
69- fps : fps. to_u32 ( ) ,
70- } )
66+ . video_config ( VideoConfig { width, height, fps } )
7167 . build ( ) ?;
7268
7369 let mut processor = Mp4Processor :: new ( config) ;
@@ -178,14 +174,14 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
178174
179175 // Generate and send video frames
180176 let config = VideoEncoderConfig :: new ( width, height) . with_fps ( fps) ;
181- let mut h264_encoder = recorder :: video_encoder_new ( config) ?;
177+ let mut h264_encoder = video_encoder :: new ( config) ?;
182178 let headers_data = h264_encoder. headers ( ) ?;
183179 if let Err ( e) = video_sender. send ( VideoFrameType :: Frame ( headers_data) ) {
184180 panic ! ( "video sender h264 header failed: {e}" ) ;
185181 }
186182
187183 for frame_num in 0 ..total_frames {
188- let img = match ( frame_num / fps. to_u32 ( ) ) % 3 {
184+ let img = match ( frame_num / fps) % 3 {
189185 0 => & red_frame,
190186 1 => & green_frame,
191187 2 => & blue_frame,
0 commit comments