File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed
apps/desktop/src-tauri/src Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -874,7 +874,15 @@ async fn get_video_metadata(path: PathBuf) -> Result<VideoRecordingMetadata, Str
874874 let input =
875875 ffmpeg:: format:: input ( & path) . map_err ( |e| format ! ( "Failed to open video file: {e}" ) ) ?;
876876
877- let duration = input. duration ( ) as f64 / AV_TIME_BASE as f64 ;
877+ let raw_duration = input. duration ( ) ;
878+ if raw_duration <= 0 {
879+ return Err ( format ! (
880+ "Unknown or invalid duration for video file: {:?}" ,
881+ path
882+ ) ) ;
883+ }
884+
885+ let duration = raw_duration as f64 / AV_TIME_BASE as f64 ;
878886 Ok ( duration)
879887 }
880888
@@ -897,7 +905,10 @@ async fn get_video_metadata(path: PathBuf) -> Result<VideoRecordingMetadata, Str
897905 let duration = display_paths
898906 . into_iter ( )
899907 . map ( get_duration_for_path)
900- . sum :: < Result < _ , _ > > ( ) ?;
908+ . try_fold ( 0f64 , |acc, item| -> Result < f64 , String > {
909+ let d = item?;
910+ Ok ( acc + d)
911+ } ) ?;
901912
902913 let ( width, height) = ( 1920 , 1080 ) ;
903914 let fps = 30 ;
You can’t perform that action at this time.
0 commit comments