Problem: Author log was causing severe UI lag and memory issues
- Unbounded string growth (entire log kept in RAM)
- Full widget rebuild on every line append
- O(n²) string concatenation performance
Solutions implemented:
1. Tail behavior - Keep only last 100 lines in UI
- Uses circular buffer (authorLogLines slice)
- Prevents unbounded memory growth
- Rebuilds text from buffer on each append
2. Copy Log button
- Copies full log from file (accurate)
- Falls back to in-memory log if file unavailable
3. View Full Log button
- Opens full log in dedicated log viewer
- No UI lag from large logs
4. Track log file path
- authorLogFilePath stored when log created
- Used by copy and view buttons
Performance improvements:
- Memory: O(1) instead of O(n) - fixed 100 line buffer
- CPU: One SetText() per line instead of concatenation
- UI responsiveness: Dramatically improved with tail behavior
UI changes:
- Label shows "Authoring Log (last 100 lines)"
- Copy/View buttons for accessing full log
DVD Authoring Fix:
- Add remultiplex step after MPEG encoding for DVD compliance
- Use ffmpeg -fflags +genpts -c copy -f dvd to fix timestamps
- Resolves "ERR: SCR moves backwards" error from dvdauthor
- FFmpeg direct encoding doesn't always create DVD-compliant streams
- Remux regenerates presentation timestamps correctly
Queue Animation Fix:
- Stop stripe animation on completed jobs
- Bug: Refresh() was always incrementing offset regardless of state
- Now only increments offset when animStop != nil (animation running)
- Completed/failed/cancelled jobs no longer show animated stripes
Testing:
- DVD authoring should now succeed on AVI files
- Completed queue jobs should show static progress bar
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Improvements:
1. Track audio active state with atomic.Bool flag
2. Handle videos without audio track gracefully
- If audio fails to start, video plays at natural frame rate
- Clear error messages indicate "video-only playback"
3. Better A/V sync logging for debugging
- Log when video ahead/behind and actions taken
- Log good sync status periodically (every ~6 seconds at 30fps)
- More granular logging for different sync states
4. Proper cleanup when audio stream ends or fails
How it works:
- audioActive flag set to true when audio starts successfully
- Set to false when audio fails to start or ends
- Video checks audioActive before syncing to audio clock
- If no audio: video just paces at natural frame rate (no sync)
- If audio active: full A/V sync with adaptive timing
Expected improvements:
- Video-only files (GIFs, silent videos) play smoothly
- Better debugging info for sync quality
- Graceful degradation when audio missing
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Priority 3 fix from PLAYER_PERFORMANCE_ISSUES.md - addresses the root
cause of A/V desync in player module.
Changes:
- Audio loop now tracks bytes written and updates master clock (audioTime)
- Audio clock calculation: bytesWritten / (sampleRate × channels × bytesPerSample)
- Video loop already syncs to audio master clock (from previous commit)
- Master clock updates happen after each audio chunk write
How it works:
- Audio is the timing master, plays at natural rate
- Video reads audio clock and adapts timing to stay in sync
- If video >3 frames behind: drop frame and resync
- If video >3 frames ahead: wait longer
- Otherwise: adjust sleep duration for gradual sync
Expected improvements:
- Rock-solid A/V sync maintained over extended playback
- No more drift between audio and video
- Adaptive recovery from temporary slowdowns
Combined with Priority 1 (larger audio buffers) and Priority 2 (FFmpeg
volume control), this completes the core A/V sync architecture.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Current state: 3 modules partially/fully extracted
- upscale_module.go: showUpscaleView + AI helpers migrated successfully
- Build syntax: ✅ Clean
- Build failing due to unrelated Fyne API issue in internal/ui/queueview.go
- Ready for next incremental extraction steps
- Move showUpscaleView() from main.go to upscale_module.go
- Remove AI helper functions (detectAIUpscaleBackend, checkAIFaceEnhanceAvailable, etc.)
- Syntax passes, ready for further migration
- Build error is unrelated Fyne API issue in internal/ui
- main.go restored from corruption (13,664 lines)
- upscale_module.go created with AI helper functions
- Ready for safer incremental extraction approach
- Create thumb_module.go with showThumbView(), buildThumbView(), executeThumbJob()
- Remove showThumbView() from main.go
- buildThumbView() and executeThumbJob() still in main.go to be removed
- Syntax check passes
- Working on large function extraction
Priority 2: FFmpeg Volume Control
- Moved volume processing from Go to FFmpeg -af volume filter
- Eliminated CPU-intensive per-sample processing loop
- Removed ~40 lines of hot-path audio processing code
- Reduced CPU usage during playback significantly
- Dynamic volume changes restart audio seamlessly
Changes:
- Build FFmpeg command with volume filter
- Remove per-sample int16 processing loop
- Remove encoding/binary import (no longer needed)
- Add restartAudio() for dynamic volume changes
- Volume changes >5% trigger audio restart with new filter
Priority 5: Adaptive Frame Timing
- Implemented drift correction for smooth video playback
- Frame dropping when >3 frames behind schedule
- Gradual catchup when moderately behind
- Maintains smooth playback under system load
Frame Timing Logic:
- Behind < 0: Sleep until next frame (ahead of schedule)
- Behind > 3 frames: Drop frame and resync (way behind)
- Behind > 0.5 frames: Catch up gradually (moderately behind)
- Otherwise: Maintain normal pace
Performance Improvements:
- Audio: No more per-chunk volume processing overhead
- Video: Adaptive timing handles temporary slowdowns
- CPU: Significant reduction in audio processing load
- Smoothness: Better handling of system hiccups
Testing Notes:
- Audio stuttering should be greatly reduced
- Volume changes have ~200ms glitch during restart
- Frame drops logged every 30 frames to avoid spam
- Works with all frame rates (24/30/60 fps)
Still TODO (Priority 3):
- Single FFmpeg process for perfect A/V sync
- Currently separate video/audio processes can drift
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>