File tree 2 files changed +17
-2
lines changed 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change
1
+ # Unreleased (v0.5.2)
2
+ * Fix ffprobe duration conversion error scenarios panicking.
3
+
1
4
# v0.5.1
2
5
* Change encoded size prediction logic to estimate video stream size (or image size) only.
3
6
This should be much more consistent than the previous method.
Original file line number Diff line number Diff line change 1
1
//! ffprobe logic
2
2
use crate :: command:: args:: PixelFormat ;
3
- use anyhow:: Context ;
3
+ use anyhow:: { ensure , Context } ;
4
4
use std:: { fmt, path:: Path , time:: Duration } ;
5
5
6
6
pub struct Ffprobe {
@@ -95,7 +95,19 @@ fn read_duration(probe: &ffprobe::FfProbe) -> anyhow::Result<Duration> {
95
95
Some ( duration_s) => {
96
96
let duration_f = duration_s
97
97
. parse :: < f64 > ( )
98
- . context ( "invalid ffprobe video duration" ) ?;
98
+ . with_context ( || format ! ( "invalid ffprobe video duration: {duration_s:?}" ) ) ?;
99
+ ensure ! (
100
+ duration_f. is_sign_positive( ) ,
101
+ "invalid negative ffprobe video duration: {duration_s:?}"
102
+ ) ;
103
+ ensure ! (
104
+ duration_f. is_finite( ) ,
105
+ "invalid infinite ffprobe video duration: {duration_s:?}"
106
+ ) ;
107
+ ensure ! (
108
+ duration_f < i64 :: MAX as f64 ,
109
+ "invalid length ffprobe video duration: {duration_s:?}"
110
+ ) ;
99
111
Ok ( Duration :: from_secs_f64 ( duration_f) )
100
112
}
101
113
None => Ok ( Duration :: ZERO ) ,
You can’t perform that action at this time.
0 commit comments