| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | use std::path::PathBuf; |
| 18 | use std::time::{Duration, Instant}; |
| 19 | |
| 20 | use engine::export::{ExportSettings, Format}; |
| 21 | use engine::project::{Lane, Speed}; |
| 22 | use engine::scratch::Scratch; |
| 23 | use engine::{AudioSession, Clip, DecodeSession, ExportHandle, Project}; |
| 24 | |
| 25 | const RATE: u32 = 44_100; |
| 26 | const FPS: f64 = 30.0; |
| 27 | |
| 28 | fn asset(name: &str) -> PathBuf { |
| 29 | PathBuf::from(env!("CARGO_MANIFEST_DIR")) |
| 30 | .join("../../assets") |
| 31 | .join(name) |
| 32 | } |
| 33 | |
| 34 | |
| 35 | |
| 36 | fn sync_project() -> (Project, engine::VideoMeta) { |
| 37 | let path = asset("test_speed_sync.mp4"); |
| 38 | let (meta, _) = engine::demux::Demuxer::open(&path).expect("open the sync fixture"); |
| 39 | (Project::single(&path, meta.frame_count), meta) |
| 40 | } |
| 41 | |
| 42 | |
| 43 | |
| 44 | fn play(project: &Project) -> Vec<f32> { |
| 45 | let sources = project.audio_sources(); |
| 46 | let segs = project.audio_segments_from(0, FPS); |
| 47 | let eqs = project.audio_eqs_from(0, FPS); |
| 48 | let speeds = project.audio_speeds_from(0, FPS); |
| 49 | let (meta, chunks) = AudioSession::open_mixed_streams_speed(&sources, &segs, &eqs, &speeds) |
| 50 | .expect("open the timeline's audio") |
| 51 | .expect("the timeline has audio"); |
| 52 | assert_eq!((meta.sample_rate, meta.channels), (RATE, 2)); |
| 53 | let mut samples = Vec::new(); |
| 54 | for chunk in chunks { |
| 55 | samples.extend(chunk.samples); |
| 56 | } |
| 57 | samples |
| 58 | } |
| 59 | |
| 60 | |
| 61 | |
| 62 | fn beep_at(samples: &[f32]) -> f64 { |
| 63 | let at = samples |
| 64 | .iter() |
| 65 | .position(|s| s.abs() > 0.1) |
| 66 | .expect("the fixture beeps"); |
| 67 | at as f64 / 2.0 / f64::from(RATE) |
| 68 | } |
| 69 | |
| 70 | |
| 71 | |
| 72 | |
| 73 | |
| 74 | fn flash_at(project: &Project) -> f64 { |
| 75 | let span = project.composite_span_at(0).expect("a span at frame 0"); |
| 76 | let (source, in_frame) = span.from.expect("the span plays a clip"); |
| 77 | let path = &project.sources()[source].path; |
| 78 | let (_, frames, _) = DecodeSession::open_range(path, in_frame, in_frame + span.source_len()) |
| 79 | .expect("open the fixture's picture"); |
| 80 | for frame in frames { |
| 81 | |
| 82 | let middle = frame.bgra.len() / 2 / 4 * 4; |
| 83 | if frame.bgra[middle] > 200 { |
| 84 | let timeline = span.start + span.speed.timeline_at(frame.index - in_frame); |
| 85 | return f64::from(timeline) / FPS; |
| 86 | } |
| 87 | } |
| 88 | panic!("the fixture flashes"); |
| 89 | } |
| 90 | |
| 91 | fn wait(handle: &ExportHandle, limit: Duration) -> engine::Result<()> { |
| 92 | let started = Instant::now(); |
| 93 | while !handle.is_finished() { |
| 94 | assert!(started.elapsed() < limit, "export did not finish"); |
| 95 | std::thread::sleep(Duration::from_millis(20)); |
| 96 | } |
| 97 | handle.result().expect("a finished export has an outcome") |
| 98 | } |
| 99 | |
| 100 | fn out_path(name: &str, ext: &str) -> Scratch { |
| 101 | Scratch::file(&format!("edith-speed-{name}"), ext) |
| 102 | } |
| 103 | |
| 104 | |
| 105 | |
| 106 | #[test] |
| 107 | fn a_clip_at_2x_takes_half_the_timeline_and_the_same_source() { |
| 108 | let (mut project, _) = sync_project(); |
| 109 | let before = project.clips()[0].clone(); |
| 110 | project |
| 111 | .set_speed(Lane::V1, 0, Speed::from_permille(2000)) |
| 112 | .expect("nothing is in the way of a clip that got shorter"); |
| 113 | let after = project.clips()[0].clone(); |
| 114 | assert_eq!( |
| 115 | (after.in_frame, after.out_frame), |
| 116 | (before.in_frame, before.out_frame), |
| 117 | "the source range a trim and a split address is untouched" |
| 118 | ); |
| 119 | assert_eq!( |
| 120 | after.frames(), |
| 121 | before.frames().div_ceil(2), |
| 122 | "half the timeline frames, rounded" |
| 123 | ); |
| 124 | assert_eq!(project.timeline_frames(), after.frames()); |
| 125 | |
| 126 | assert_eq!(project.speed_of(Lane::A1, 0).permille(), 2000); |
| 127 | assert_eq!(project.lane(Lane::A1)[0].end(), after.end()); |
| 128 | } |
| 129 | |
| 130 | |
| 131 | |
| 132 | #[test] |
| 133 | fn no_rate_ever_makes_a_clip_occupy_nothing() { |
| 134 | for permille in [250, 333, 500, 999, 1000, 1001, 1500, 2000, 3999, 4000] { |
| 135 | let speed = Speed::from_permille(permille); |
| 136 | for len in [1, 2, 3, 7, 30, 999] { |
| 137 | assert!( |
| 138 | speed.frames(len) >= 1, |
| 139 | "{len} source frames at {speed} occupies nothing" |
| 140 | ); |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | |
| 146 | |
| 147 | #[test] |
| 148 | fn a_slow_down_into_the_next_clip_is_refused_by_name() { |
| 149 | let (mut project, meta) = sync_project(); |
| 150 | let half = meta.frame_count / 2; |
| 151 | assert!(project.split(half), "cut the take in two"); |
| 152 | let before = project.clips().to_vec(); |
| 153 | let text = project |
| 154 | .set_speed(Lane::V1, 0, Speed::from_permille(500)) |
| 155 | .expect_err("the first half cannot double in length where it sits") |
| 156 | .to_string(); |
| 157 | assert!(text.contains(&half.to_string()), "{text}"); |
| 158 | assert!(text.contains("0.50x"), "{text}"); |
| 159 | assert_eq!(project.clips(), before, "nothing moved"); |
| 160 | |
| 161 | |
| 162 | assert!(project.undo(), "the split is still the last thing undone"); |
| 163 | assert_eq!(project.clips().len(), 1, "the take is whole again"); |
| 164 | assert!(!project.undo(), "and nothing else was ever pushed"); |
| 165 | } |
| 166 | |
| 167 | |
| 168 | |
| 169 | #[test] |
| 170 | fn one_speed_change_is_one_undo_for_the_whole_group() { |
| 171 | let (mut project, _) = sync_project(); |
| 172 | let (video, audio) = (project.clips().to_vec(), project.lane(Lane::A1).to_vec()); |
| 173 | project |
| 174 | .set_speed(Lane::A1, 0, Speed::from_permille(2000)) |
| 175 | .expect("room enough"); |
| 176 | |
| 177 | |
| 178 | for permille in [1500, 1750, 4000] { |
| 179 | project |
| 180 | .set_speed_live(Lane::A1, 0, Speed::from_permille(permille)) |
| 181 | .expect("room enough"); |
| 182 | } |
| 183 | assert!(project.undo(), "one press"); |
| 184 | assert_eq!(project.clips(), video, "the picture is back"); |
| 185 | assert_eq!(project.lane(Lane::A1), audio, "and its sound with it"); |
| 186 | assert!(!project.undo(), "there was only ever one step"); |
| 187 | } |
| 188 | |
| 189 | |
| 190 | |
| 191 | #[test] |
| 192 | fn speed_survives_a_split_and_a_paste() { |
| 193 | let (mut project, meta) = sync_project(); |
| 194 | project |
| 195 | .set_speed(Lane::V1, 0, Speed::from_permille(2000)) |
| 196 | .expect("room enough"); |
| 197 | let whole = project.clips()[0].frames(); |
| 198 | assert!(project.split(whole / 2), "a 2x clip cuts on any frame"); |
| 199 | let halves = project.clips().to_vec(); |
| 200 | assert_eq!(halves.len(), 2); |
| 201 | assert!( |
| 202 | halves.iter().all(|c| c.speed.permille() == 2000), |
| 203 | "both halves play at the rate the whole did" |
| 204 | ); |
| 205 | assert_eq!( |
| 206 | halves[0].frames() + halves[1].frames(), |
| 207 | whole, |
| 208 | "and they still add up to the clip that was cut" |
| 209 | ); |
| 210 | assert_eq!(halves[0].out_frame, halves[1].in_frame, "in source frames"); |
| 211 | assert_eq!(halves[1].end(), whole, "the lane is unchanged in length"); |
| 212 | |
| 213 | let copied = halves[0].clone(); |
| 214 | assert!(project.paste(whole, copied.clone()), "paste it at the end"); |
| 215 | let pasted = project.clips().last().expect("something was pasted").clone(); |
| 216 | assert_eq!(pasted.speed, copied.speed, "a copy carries the rate"); |
| 217 | assert_eq!( |
| 218 | pasted.frames(), |
| 219 | copied.frames(), |
| 220 | "and therefore the room it takes" |
| 221 | ); |
| 222 | let _ = meta; |
| 223 | } |
| 224 | |
| 225 | |
| 226 | |
| 227 | |
| 228 | |
| 229 | #[test] |
| 230 | fn the_beep_stays_on_the_flash_at_every_rate() { |
| 231 | |
| 232 | |
| 233 | let (base, _) = sync_project(); |
| 234 | let (mark, mark_beep) = (flash_at(&base), beep_at(&play(&base))); |
| 235 | println!("real time: flash at {mark:.3}s, beep at {mark_beep:.3}s"); |
| 236 | assert!( |
| 237 | (mark - mark_beep).abs() <= 1.0 / FPS && mark > 2.0 / FPS, |
| 238 | "the fixture's flash and beep are its whole point: {mark:.3}s / {mark_beep:.3}s" |
| 239 | ); |
| 240 | for permille in [2000, 500, 1500] { |
| 241 | let (mut project, _) = sync_project(); |
| 242 | let speed = Speed::from_permille(permille); |
| 243 | project |
| 244 | .set_speed(Lane::V1, 0, speed) |
| 245 | .expect("one clip on the timeline has room for any rate"); |
| 246 | let flash = flash_at(&project); |
| 247 | let beep = beep_at(&play(&project)); |
| 248 | let apart = (flash - beep).abs(); |
| 249 | println!("{speed}: flash at {flash:.3}s, beep at {beep:.3}s, {apart:.3}s apart"); |
| 250 | assert!( |
| 251 | apart <= 1.0 / FPS, |
| 252 | "{speed}: the beep is {apart:.3}s off the flash, which is more than a frame" |
| 253 | ); |
| 254 | |
| 255 | |
| 256 | let expected = mark / speed.as_f64(); |
| 257 | assert!( |
| 258 | (flash - expected).abs() <= 2.0 / FPS, |
| 259 | "{speed}: the flash should be around {expected:.3}s, not {flash:.3}s" |
| 260 | ); |
| 261 | } |
| 262 | } |
| 263 | |
| 264 | |
| 265 | |
| 266 | #[test] |
| 267 | fn a_wav_export_of_a_2x_timeline_matches_the_preview() { |
| 268 | let (mut project, meta) = sync_project(); |
| 269 | project |
| 270 | .set_speed(Lane::V1, 0, Speed::from_permille(2000)) |
| 271 | .expect("room enough"); |
| 272 | let frames = project.timeline_frames(); |
| 273 | let heard = beep_at(&play(&project)); |
| 274 | let out = out_path("wav", "wav"); |
| 275 | let handle = engine::export::start( |
| 276 | project, |
| 277 | meta, |
| 278 | &out, |
| 279 | &ExportSettings { |
| 280 | format: Format::Wav, |
| 281 | ..Default::default() |
| 282 | }, |
| 283 | None, |
| 284 | ); |
| 285 | wait(&handle, Duration::from_secs(120)).expect("wav export"); |
| 286 | let mut reader = ec_riff::WavReader::open(&out).expect("read the export back"); |
| 287 | let spec = reader.spec(); |
| 288 | let samples: Vec<f32> = reader |
| 289 | .read_all_i32() |
| 290 | .expect("the samples") |
| 291 | .into_iter() |
| 292 | .map(|s| s as f32 / f32::from(i16::MAX)) |
| 293 | .collect(); |
| 294 | let written = samples.len() / usize::from(spec.channels); |
| 295 | let expected = (f64::from(frames) / FPS * f64::from(RATE)).round() as usize; |
| 296 | assert!( |
| 297 | written.abs_diff(expected) <= spec.sample_rate as usize / 30, |
| 298 | "the file is {written} frames and the timeline is {expected}" |
| 299 | ); |
| 300 | let in_file = beep_at(&samples); |
| 301 | assert!( |
| 302 | (in_file - heard).abs() <= 1.0 / FPS, |
| 303 | "the beep is at {in_file:.3}s in the file and was at {heard:.3}s in the preview" |
| 304 | ); |
| 305 | std::fs::remove_file(&out).ok(); |
| 306 | } |
| 307 | |
| 308 | |
| 309 | |
| 310 | |
| 311 | |
| 312 | |
| 313 | |
| 314 | #[test] |
| 315 | fn an_mp4_export_resamples_a_speeded_sound_clip() { |
| 316 | let (mut project, meta) = sync_project(); |
| 317 | project |
| 318 | .set_speed(Lane::A1, 0, Speed::from_permille(2000)) |
| 319 | .expect("room enough"); |
| 320 | let heard = beep_at(&play(&project)); |
| 321 | let out = out_path("speeded", "mp4"); |
| 322 | let handle = engine::export::start(project, meta, &out, &ExportSettings::default(), None); |
| 323 | wait(&handle, Duration::from_secs(180)).expect("an mp4 of a speeded sound clip"); |
| 324 | let (audio, chunks) = AudioSession::open(&out) |
| 325 | .expect("reopen the export") |
| 326 | .expect("it has an audio track"); |
| 327 | assert_eq!(audio.sample_rate, RATE); |
| 328 | let samples: Vec<f32> = chunks.into_iter().flat_map(|c| c.samples).collect(); |
| 329 | let in_file = beep_at(&samples); |
| 330 | assert!( |
| 331 | (in_file - heard).abs() <= 1.0 / FPS, |
| 332 | "the beep is at {in_file:.3}s in the file and was at {heard:.3}s in the preview" |
| 333 | ); |
| 334 | std::fs::remove_file(&out).ok(); |
| 335 | } |
| 336 | |
| 337 | |
| 338 | |
| 339 | |
| 340 | fn tone(samples: &[f32], hz: f64) -> f64 { |
| 341 | let n = samples.len() as f64; |
| 342 | let w = 2. * std::f64::consts::PI * hz / f64::from(RATE); |
| 343 | let coeff = 2. * w.cos(); |
| 344 | let (mut s1, mut s2) = (0., 0.); |
| 345 | for &x in samples { |
| 346 | let s0 = f64::from(x) + coeff * s1 - s2; |
| 347 | s2 = s1; |
| 348 | s1 = s0; |
| 349 | } |
| 350 | 2. * (s1 * s1 + s2 * s2 - coeff * s1 * s2).sqrt() / n |
| 351 | } |
| 352 | |
| 353 | |
| 354 | |
| 355 | |
| 356 | |
| 357 | fn beep_hz(samples: &[f32], at: f64) -> f64 { |
| 358 | |
| 359 | |
| 360 | |
| 361 | let mono: Vec<f32> = samples.chunks(2).map(|f| f[0]).collect(); |
| 362 | let samples = &mono[..]; |
| 363 | |
| 364 | |
| 365 | |
| 366 | |
| 367 | let stereo = f64::from(RATE); |
| 368 | let from = (at * stereo) as usize; |
| 369 | let peak = samples[from..] |
| 370 | .iter() |
| 371 | .enumerate() |
| 372 | .max_by(|(_, a), (_, b)| a.abs().total_cmp(&b.abs())) |
| 373 | .map(|(i, _)| from + i) |
| 374 | .expect("a sample after the beep starts"); |
| 375 | let half = (stereo * 0.1) as usize; |
| 376 | let window = &samples[peak.saturating_sub(half)..(peak + half).min(samples.len())]; |
| 377 | (700..=1400) |
| 378 | .step_by(25) |
| 379 | .map(|hz| (tone(window, f64::from(hz)), hz)) |
| 380 | .max_by(|(a, _), (b, _)| a.total_cmp(b)) |
| 381 | .expect("a window to measure") |
| 382 | .1 as f64 |
| 383 | } |
| 384 | |
| 385 | |
| 386 | |
| 387 | |
| 388 | |
| 389 | |
| 390 | |
| 391 | #[test] |
| 392 | fn a_2x_clip_keeps_the_beeps_pitch() { |
| 393 | let (mut project, _) = sync_project(); |
| 394 | project |
| 395 | .set_speed(Lane::V1, 0, Speed::from_permille(2000)) |
| 396 | .expect("room for it"); |
| 397 | let played = play(&project); |
| 398 | let at = beep_at(&played); |
| 399 | let hz = beep_hz(&played, at); |
| 400 | assert!( |
| 401 | (hz - 1000.).abs() <= 1000. * 0.02, |
| 402 | "the beep measures {hz} Hz: the tape effect would put it near 2000" |
| 403 | ); |
| 404 | } |
| 405 | |
| 406 | |
| 407 | |
| 408 | |
| 409 | |
| 410 | #[test] |
| 411 | fn the_playhead_follows_the_re_rate() { |
| 412 | let path = asset("test_speed_sync.mp4"); |
| 413 | let mut session = engine::PlaybackSession::open(&path).expect("open the fixture"); |
| 414 | |
| 415 | |
| 416 | session.seek(2.0); |
| 417 | let before = session.video_source_frame_at(2.0); |
| 418 | session |
| 419 | .set_speed(Lane::V1, 0, Speed::from_permille(2000)) |
| 420 | .expect("room for it"); |
| 421 | let now = session.now(); |
| 422 | let after = session.video_source_frame_at(now); |
| 423 | assert_eq!(before, after, "the same source frame is under the playhead"); |
| 424 | assert!((now - 1.0).abs() < 2.0 / FPS, "and the minute moved to {now}"); |
| 425 | |
| 426 | |
| 427 | session |
| 428 | .set_speed(Lane::V1, 0, Speed::from_permille(1500)) |
| 429 | .expect("the bar moves"); |
| 430 | let hold = session.now(); |
| 431 | let held_frame = session.video_source_frame_at(hold); |
| 432 | session |
| 433 | .set_speed_live(Lane::V1, 0, Speed::from_permille(2500)) |
| 434 | .expect("the bar moves again"); |
| 435 | let still = session.video_source_frame_at(session.now()); |
| 436 | assert_eq!(held_frame, still, "a live sample keeps the scene"); |
| 437 | } |
| 438 | |
| 439 | |
| 440 | |
| 441 | #[test] |
| 442 | fn a_half_speed_clip_keeps_the_beeps_pitch() { |
| 443 | let (mut project, _) = sync_project(); |
| 444 | project |
| 445 | .set_speed(Lane::V1, 0, Speed::from_permille(500)) |
| 446 | .expect("room for it"); |
| 447 | let played = play(&project); |
| 448 | let at = beep_at(&played); |
| 449 | let hz = beep_hz(&played, at); |
| 450 | assert!( |
| 451 | (hz - 1000.).abs() <= 1000. * 0.02, |
| 452 | "the beep measures {hz} Hz: the tape effect would put it near 500" |
| 453 | ); |
| 454 | } |
| 455 | |
| 456 | |
| 457 | |
| 458 | |
| 459 | #[test] |
| 460 | fn a_wav_export_of_a_2x_clip_keeps_the_beeps_pitch() { |
| 461 | let (mut project, meta) = sync_project(); |
| 462 | project |
| 463 | .set_speed(Lane::V1, 0, Speed::from_permille(2000)) |
| 464 | .expect("room for it"); |
| 465 | let out = out_path("pitch", "wav"); |
| 466 | let handle = engine::export::start( |
| 467 | project, |
| 468 | meta, |
| 469 | &out, |
| 470 | &ExportSettings { |
| 471 | format: Format::Wav, |
| 472 | ..Default::default() |
| 473 | }, |
| 474 | None, |
| 475 | ); |
| 476 | wait(&handle, Duration::from_secs(120)).expect("wav export"); |
| 477 | let mut reader = ec_riff::WavReader::open(&out).expect("read the export back"); |
| 478 | let samples: Vec<f32> = reader |
| 479 | .read_all_i32() |
| 480 | .expect("the samples") |
| 481 | .into_iter() |
| 482 | .map(|s| s as f32 / f32::from(i16::MAX)) |
| 483 | .collect(); |
| 484 | let at = beep_at(&samples); |
| 485 | let hz = beep_hz(&samples, at); |
| 486 | assert!( |
| 487 | (hz - 1000.).abs() <= 1000. * 0.02, |
| 488 | "the beep in the file measures {hz} Hz, not the 1 kHz it was recorded at" |
| 489 | ); |
| 490 | std::fs::remove_file(&out).ok(); |
| 491 | } |
| 492 | |
| 493 | |
| 494 | |
| 495 | |
| 496 | |
| 497 | |
| 498 | |
| 499 | |
| 500 | |
| 501 | |
| 502 | #[test] |
| 503 | fn an_mp4_export_honours_a_speeded_picture_across_a_rate_change() { |
| 504 | engine::envcfg::set("VE_SW", "1"); |
| 505 | let (mut project, meta) = sync_project(); |
| 506 | |
| 507 | |
| 508 | assert!( |
| 509 | project.ungroup(Lane::V1, 0), |
| 510 | "take the picture off the take" |
| 511 | ); |
| 512 | project |
| 513 | .set_speed(Lane::V1, 0, Speed::from_permille(2000)) |
| 514 | .expect("room enough"); |
| 515 | assert_eq!(project.speed_of(Lane::A1, 0), Speed::NORMAL, "sound is 1x"); |
| 516 | let fast = project.lane(Lane::V1)[0].frames(); |
| 517 | assert_eq!(fast, 45, "90 source frames at 2x is 45 on the timeline"); |
| 518 | |
| 519 | let whole = project.lane(Lane::V1)[0].clone(); |
| 520 | assert!( |
| 521 | project.place( |
| 522 | Lane::V1, |
| 523 | fast, |
| 524 | Clip { |
| 525 | fade_in: 0, |
| 526 | fade_out: 0, |
| 527 | speed: Speed::NORMAL, |
| 528 | ..whole |
| 529 | } |
| 530 | ), |
| 531 | "a second, unspeeded clip of the same source" |
| 532 | ); |
| 533 | let total = project.timeline_frames(); |
| 534 | assert_eq!(total, fast + 90, "45 fast frames then 90 slow ones"); |
| 535 | |
| 536 | let out = out_path("honoured", "mp4"); |
| 537 | let handle = engine::export::start(project, meta, &out, &ExportSettings::default(), None); |
| 538 | wait(&handle, Duration::from_secs(300)).expect("an mp4 export of a speeded picture"); |
| 539 | let (_, frames) = DecodeSession::open(&out).expect("reopen the export"); |
| 540 | let frames: Vec<_> = frames.into_iter().collect(); |
| 541 | assert_eq!( |
| 542 | frames.len() as u32, |
| 543 | total, |
| 544 | "one coded picture per timeline frame" |
| 545 | ); |
| 546 | let bright: Vec<u32> = frames |
| 547 | .iter() |
| 548 | .filter(|frame| { |
| 549 | frame.bgra.iter().map(|&b| u64::from(b)).sum::<u64>() / frame.bgra.len() as u64 > 128 |
| 550 | }) |
| 551 | .map(|frame| frame.index) |
| 552 | .collect(); |
| 553 | |
| 554 | |
| 555 | |
| 556 | |
| 557 | |
| 558 | assert_eq!( |
| 559 | bright, |
| 560 | vec![15, 16, 75, 76, 77, 78], |
| 561 | "the flash halved at 2x, then whole at 1.00x" |
| 562 | ); |
| 563 | std::fs::remove_file(&out).ok(); |
| 564 | } |
| 565 | |
| 566 | |
| 567 | |
| 568 | #[test] |
| 569 | fn an_av1_export_honours_a_speeded_take_whole() { |
| 570 | let (mut project, meta) = sync_project(); |
| 571 | project |
| 572 | .set_speed(Lane::V1, 0, Speed::from_permille(2000)) |
| 573 | .expect("room enough"); |
| 574 | let total = project.timeline_frames(); |
| 575 | let out = out_path("av1", "mkv"); |
| 576 | let handle = engine::export::start( |
| 577 | project, |
| 578 | meta, |
| 579 | &out, |
| 580 | &ExportSettings { |
| 581 | format: Format::Av1, |
| 582 | ..Default::default() |
| 583 | }, |
| 584 | None, |
| 585 | ); |
| 586 | wait(&handle, Duration::from_secs(600)).expect("an AV1 export of a speeded take"); |
| 587 | assert!(out.exists(), "AV1 never refuses a rate"); |
| 588 | assert!( |
| 589 | std::fs::metadata(&out).expect("the export").len() > 0, |
| 590 | "and it wrote something" |
| 591 | ); |
| 592 | |
| 593 | assert_eq!(total, 45, "the whole take at 2x"); |
| 594 | std::fs::remove_file(&out).ok(); |
| 595 | } |