3122 Commits

Author SHA1 Message Date
Jonathan Thomas
9b042a3dc6 Merge pull request #1038 from OpenShot/fix-recursive-paint
Improving InvalidFile error handling to be unique, include file names
2026-02-24 22:31:55 -06:00
Jonathan Thomas
1a44a6582c Fixing mac unit test failures due to filesystem dependency again,ughh. 2026-02-24 13:05:39 -06:00
Jonathan Thomas
89350a0419 Setting has_static_image correctly when FFmpegReader opens image formats and a video_length == 1, so we have consistent behavior in OpenShot regardless of QtImageReader or FFmpegReader, when opening images. 2026-02-24 12:06:42 -06:00
Jonathan Thomas
f83802bdc0 Removing some code that re-inits readers and re-opens readers after SetJsonValue is called. I don't think this is needed anymore, but let's mark this as Experimental and risky commit though. 2026-02-23 22:51:32 -06:00
Jonathan Thomas
9d3a3f18e5 Protecting Mask GetFrame from failure opening reader (Experimental for windows crash we are debugging) 2026-02-23 22:40:44 -06:00
Jonathan Thomas
18b08fe7c6 Fixing unit test paths for mac builders, crashing due to filesystem import (I think) 2026-02-23 17:41:18 -06:00
Jonathan Thomas
7c65748187 Fixing unit test paths for windows builders 2026-02-23 17:25:23 -06:00
Jonathan Thomas
7efc48006a Modify all throw InvalidFile(...) callsites: each now has a distinct message string, and adding unit tests to verify this.
So a crash line will now be more like:
  what(): FFmpegReader could not open media file. for file C:\...\TitleFileName%04d.png
  instead of only File could not be opened.
2026-02-23 16:55:49 -06:00
Jonathan Thomas
9d38ee10b5 Merge pull request #1037 from OpenShot/pts-offset-fix
Fixes to PTS offsets when audio and video are not aligned - to prevent black initial frames
2026-02-15 23:49:06 -06:00
Jonathan Thomas
b7c37b84e4 - Fix FFmpegReader first-frame black regression by anchoring PTS offset to video start (and correcting video offset to use packet PTS), so AAC preroll/skip-samples no longer shifts frame 1.
- Add examples/test_aac_preroll.mp4 fixture (small, deterministic AAC-preroll sample) for reproducing and testing the regression.
2026-02-15 15:22:11 -06:00
Jonathan Thomas
22c808c2bb Merge pull request #1035 from OpenShot/caching-protections
Harden playback/cache path for malformed media and concurrent timeline updates
2026-02-13 20:25:15 -06:00
Jonathan Thomas
a7e9ba1d55 - src/FFmpegReader.cpp
- Disable audio when decoder sample format is invalid (AV_SAMPLE_FMT_NONE).
      - Only synthesize channel layout when reported channels are actually valid (> 0).
  - src/AudioReaderSource.cpp
      - Added progress/validity guards in getNextAudioBlock() to prevent infinite loops on corrupt/empty audio frames.
2026-02-13 12:13:44 -06:00
Jonathan Thomas
429826be36 Fixing a few nitpicks in caching function to use local variables when available (instead of the atomic ones) 2026-02-13 11:48:33 -06:00
Jonathan Thomas
c43092eaa5 Merge branch 'develop' into caching-protections
# Conflicts:
#	src/Qt/VideoCacheThread.cpp
2026-02-13 11:29:32 -06:00
Jonathan Thomas
8c4db9ac0b Merge pull request #1036 from OpenShot/timeline-playback-length
Fix VideoCacheThread::isReady() when near the max frame of a timeline
2026-02-13 11:01:34 -06:00
Jonathan Thomas
fb41a3c479 • - Fix VideoCacheThread::isReady() so preroll readiness is clamped by frames actually available to the timeline boundary (end/start), preventing playback from stalling in PLAY near the end.
- Add regression coverage in tests/VideoCacheThread.cpp (isReady: clamps preroll requirement at timeline boundaries) for forward-near-end and backward-near-start cases.
2026-02-12 23:41:51 -06:00
Jonathan Thomas
d70e80eac4 Harden playback/cache path for malformed media and concurrent timeline updates
- Invalidate timeline cache on ApplyJsonDiff() clip insert (remove affected frame range).
  - Add lock in Timeline::ClearAllCache() for safe concurrent access.
  - Make VideoCacheThread cross-thread state safe (atomics + seek-state mutex).
  - Lock CacheMemory::Contains() to avoid races.
  - Handle malformed audio streams in FFmpegReader by disabling invalid audio and continuing video-only.
  - Add FPS/timebase safety fallbacks in FFmpeg frame/PTS math.
  - Guard Frame::GetSamplesPerFrame() against invalid inputs.
  - Add/adjust regression tests for cache invalidation and invalid rate handling.
2026-02-11 20:11:47 -06:00
Jonathan Thomas
57c1fb2ec3 Merge pull request #1034 from OpenShot/sparse-vfr-support
Fix sparse-VFR stall and stabilize missing-frame image fallback
2026-02-10 12:02:07 -06:00
Jonathan Thomas
149456d13f Merge pull request #1032 from OpenShot/cache-before-playhead
VideoCacheThread: Add Directional Pre-roll
2026-02-10 11:51:21 -06:00
Jonathan Thomas
2e4e12d2c7 Setting a minimum # of frames (floor) in Timeline, FFmpegReader, and FrameMapper - so low cpu/thread systems don't end up with a tiny # that makes passing our unit tests difficult. 2026-02-09 22:10:32 -06:00
Jonathan Thomas
6f63254c08 More changes to seek logic to pass unit tests on Windows. 2026-02-09 21:35:06 -06:00
Jonathan Thomas
d6b54091d7 Adding minimum cache size floor, for systems with very few cores. This is required to fix a failure running unit tests on our GitLab runners. 2026-02-09 21:14:45 -06:00
Jonathan Thomas
367d21affe Fix FFmpeg seek fallback to avoid overshoot frame mismatches. Harden FFmpegReader::CheckSeek() when seek retries are exhausted. 2026-02-09 20:51:24 -06:00
Jonathan Thomas
01e60463db FFmpegReader: fix sparse-VFR stall and stabilize missing-frame image fallback
- prevent ReadStream() infinite loop when packet counters stall at EOF with no packet/hold state by detecting no-progress and forcing EOF completion
  - improve missing-frame handling on sparse timelines by preferring chronological image sources:
      - previous finalized frame (f->number - 1)
      - last finalized video frame (last_final_video_frame)
      - last decoded video frame only if not from the future
      - black frame only as last resort
  - use the same finalized/decoded fallback when largest_frame_processed is no longer cached
  - track/reset last_final_video_frame across finalize/seek/close lifecycle

  Fixes:

  - hard stall around gap frames
  - black flashing from cache churn on sparse streams
  - out-of-order jitter caused by reusing future-decoded frames
2026-02-07 22:40:43 -06:00
Jonathan Thomas
f3c4504662 Improve benchmark regression caused by aggressive memory trimming, and caches that were too small. A new debounce strategy for memory trimming (1 time max per 30 seconds). 2026-02-06 23:11:00 -06:00