Commit ebe45af
authored
Finalize VFR Support (#540)
* [timecode] Finalize VFR support #168
* [timecode] Fix VFR timing, persistent decoder, and output command accuracy
- Fix PyAV read() to reuse persistent decoder generator, preventing the last
frame from being dropped at EOF due to B-frame buffer flush on GC
- Fix _handle_eof() to seek by PTS seconds instead of frame number (which is
now a CFR-equivalent approximation, not a decode count)
- Fix get_timecode() to skip nearest-frame snapping for Timecode-backed
FrameTimecodes, so scene boundary timecodes are PTS-accurate for VFR
- Fix FlashFilter to cache min_scene_len threshold in seconds from first frame's
framerate, avoiding incorrect thresholds when OpenCV reports wrong average fps
- Fix FCP7 XML: use seconds*fps for frame numbers, dynamic NTSC flag
- Fix OTIO: use seconds*frame_rate for RationalTime values
- Add $START_PTS and $END_PTS (ms) to split-video filename templates
- Refactor test_vfr.py: use open_video(), add EXPECTED_SCENES_VFR ground truth,
parameterize scene detection test for both pyav and opencv backends
* [save-images] Fix VFR seek accuracy for OpenCV and image position generation
OpenCV's CAP_PROP_POS_FRAMES does not map linearly to time in VFR video
(e.g. at the same timestamp, PyAV and OpenCV report frame indices that differ
by 35+ frames), causing thumbnails to land in the wrong scene.
Two fixes:
1. VideoStreamCv2.seek(): switch from CAP_PROP_POS_FRAMES to CAP_PROP_POS_MSEC
for time-accurate seeking on both CFR and VFR video. Seeking one nominal frame
before the target ensures the subsequent read() returns the frame at the target.
2. ImageSaver.generate_timecode_list(): rewrite to use seconds-based arithmetic
instead of frame-number ranges. This avoids the frame_num approximation
(round(seconds * avg_fps)) which gives wrong indices for VFR video.
* [cli] Round OTIO rational time values to 10 microsecond precision
* [backends] Fix OpenCV seeking with VFR videos
* [tests] Cleanup test imports and move deprecated import tests to test_api
* [tests] Expand VFR test coverage and rework CLI tests
Use Click's CliRunner rather than subprocesses for CLI tests.
Add CSV, EDL, and expand OTIO tests for VFR and compare that the OpenCV and PyAV backends return equal results for both CFR and VFR video.1 parent 4bcce29 commit ebe45af
File tree
21 files changed
+859
-292
lines changed- docs/cli
- scenedetect
- _cli
- backends
- detectors
- output
- tests
- website/pages
21 files changed
+859
-292
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
21 | 21 | | |
22 | 22 | | |
23 | 23 | | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | 31 | | |
30 | 32 | | |
| 33 | + | |
| 34 | + | |
31 | 35 | | |
32 | 36 | | |
33 | 37 | | |
| |||
41 | 45 | | |
42 | 46 | | |
43 | 47 | | |
| 48 | + | |
| 49 | + | |
44 | 50 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
401 | 401 | | |
402 | 402 | | |
403 | 403 | | |
| 404 | + | |
| 405 | + | |
404 | 406 | | |
405 | | - | |
| 407 | + | |
406 | 408 | | |
407 | 409 | | |
408 | | - | |
409 | | - | |
| 410 | + | |
| 411 | + | |
410 | 412 | | |
411 | 413 | | |
412 | 414 | | |
413 | | - | |
414 | | - | |
| 415 | + | |
| 416 | + | |
415 | 417 | | |
416 | 418 | | |
417 | 419 | | |
| |||
427 | 429 | | |
428 | 430 | | |
429 | 431 | | |
430 | | - | |
| 432 | + | |
431 | 433 | | |
432 | | - | |
433 | | - | |
434 | | - | |
435 | | - | |
436 | | - | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
437 | 439 | | |
438 | 440 | | |
439 | 441 | | |
| |||
485 | 487 | | |
486 | 488 | | |
487 | 489 | | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
488 | 493 | | |
489 | 494 | | |
490 | 495 | | |
| |||
501 | 506 | | |
502 | 507 | | |
503 | 508 | | |
504 | | - | |
| 509 | + | |
505 | 510 | | |
506 | 511 | | |
507 | 512 | | |
| |||
534 | 539 | | |
535 | 540 | | |
536 | 541 | | |
537 | | - | |
| 542 | + | |
538 | 543 | | |
539 | 544 | | |
540 | 545 | | |
541 | 546 | | |
542 | | - | |
| 547 | + | |
543 | 548 | | |
544 | 549 | | |
545 | 550 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
17 | 17 | | |
18 | 18 | | |
19 | 19 | | |
| 20 | + | |
20 | 21 | | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
24 | 25 | | |
25 | 26 | | |
26 | 27 | | |
27 | | - | |
| 28 | + | |
28 | 29 | | |
29 | 30 | | |
30 | 31 | | |
| |||
83 | 84 | | |
84 | 85 | | |
85 | 86 | | |
86 | | - | |
87 | | - | |
88 | | - | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
89 | 90 | | |
90 | 91 | | |
91 | 92 | | |
| |||
135 | 136 | | |
136 | 137 | | |
137 | 138 | | |
138 | | - | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
139 | 147 | | |
140 | 148 | | |
141 | 149 | | |
| |||
173 | 181 | | |
174 | 182 | | |
175 | 183 | | |
176 | | - | |
177 | | - | |
178 | | - | |
179 | | - | |
180 | 184 | | |
181 | 185 | | |
182 | 186 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
30 | | - | |
| 30 | + | |
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
| |||
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | | - | |
| 114 | + | |
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
| |||
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
147 | | - | |
| 147 | + | |
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
| |||
196 | 196 | | |
197 | 197 | | |
198 | 198 | | |
199 | | - | |
| 199 | + | |
200 | 200 | | |
201 | | - | |
202 | | - | |
203 | | - | |
204 | | - | |
205 | | - | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
206 | 206 | | |
207 | 207 | | |
208 | 208 | | |
209 | | - | |
210 | | - | |
211 | | - | |
212 | | - | |
213 | | - | |
214 | | - | |
215 | | - | |
216 | | - | |
217 | | - | |
218 | | - | |
219 | | - | |
220 | | - | |
221 | | - | |
222 | | - | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
223 | 218 | | |
224 | 219 | | |
225 | 220 | | |
| |||
235 | 230 | | |
236 | 231 | | |
237 | 232 | | |
238 | | - | |
239 | | - | |
240 | | - | |
241 | | - | |
242 | | - | |
243 | | - | |
244 | | - | |
| 233 | + | |
245 | 234 | | |
246 | | - | |
247 | | - | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
248 | 240 | | |
249 | | - | |
250 | | - | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
251 | 253 | | |
252 | 254 | | |
253 | 255 | | |
254 | 256 | | |
| 257 | + | |
| 258 | + | |
255 | 259 | | |
256 | 260 | | |
257 | 261 | | |
| |||
329 | 333 | | |
330 | 334 | | |
331 | 335 | | |
332 | | - | |
| 336 | + | |
333 | 337 | | |
334 | 338 | | |
335 | 339 | | |
336 | 340 | | |
337 | | - | |
338 | | - | |
339 | | - | |
340 | 341 | | |
341 | 342 | | |
342 | 343 | | |
| |||
378 | 379 | | |
379 | 380 | | |
380 | 381 | | |
381 | | - | |
| 382 | + | |
382 | 383 | | |
383 | 384 | | |
384 | 385 | | |
| |||
408 | 409 | | |
409 | 410 | | |
410 | 411 | | |
411 | | - | |
| 412 | + | |
412 | 413 | | |
413 | 414 | | |
414 | 415 | | |
| |||
439 | 440 | | |
440 | 441 | | |
441 | 442 | | |
442 | | - | |
443 | | - | |
444 | 443 | | |
445 | 444 | | |
446 | 445 | | |
| |||
455 | 454 | | |
456 | 455 | | |
457 | 456 | | |
458 | | - | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
459 | 463 | | |
460 | 464 | | |
461 | 465 | | |
| |||
0 commit comments