Take the clip's dimensions by position
Browse files at this commitd04b63e8667d71f53ebbe5dec05eb1b5f283b176Parent: f5dbd0b- test
- take the clip's dimensions by position
1 changed file +11 -5
crates/ec-h265/tests/encode.rsmodified+11 -5
| @@ -740,11 +740,17 @@ fn clip_sources(path: &std::ffi::OsStr, want: usize) -> (usize, usize, Vec<Plane | |||
| 740 | String::from_utf8_lossy(&dims.stderr) | 740 | String::from_utf8_lossy(&dims.stderr) |
| 741 | ); | 741 | ); |
| 742 | let csv = String::from_utf8_lossy(&dims.stdout); | 742 | let csv = String::from_utf8_lossy(&dims.stdout); |
| 743 | - let (w, h) = csv | 743 | + // ffprobe prints one comma-separated line per stream, and recent builds |
| 744 | - .trim() | 744 | + // end it with a trailing separator, so the fields are taken by position |
| 745 | - .split_once(',') | 745 | + // rather than by splitting the line in two. |
| 746 | - .and_then(|(w, h)| Some((w.parse::<usize>().ok()?, h.parse::<usize>().ok()?))) | 746 | + let mut fields = csv.lines().next().unwrap_or_default().split(','); |
| 747 | - .expect("ffprobe returned dimensions"); | 747 | + let (w, h) = (|| { |
| 748 | + Some(( | ||
| 749 | + fields.next()?.trim().parse::<usize>().ok()?, | ||
| 750 | + fields.next()?.trim().parse::<usize>().ok()?, | ||
| 751 | + )) | ||
| 752 | + })() | ||
| 753 | + .unwrap_or_else(|| panic!("ffprobe returned dimensions, got {csv:?}")); | ||
| 748 | // Pictures to pass over before sampling: the head of a film is titles and | 754 | // Pictures to pass over before sampling: the head of a film is titles and |
| 749 | // fades, which are not what a codec is measured on. | 755 | // fades, which are not what a codec is measured on. |
| 750 | let skip: usize = std::env::var("EC_H265_CLIP_SKIP") | 756 | let skip: usize = std::env::var("EC_H265_CLIP_SKIP") |