Overview
Some videos may experience progressive audio/video desynchronization (drift) during playback, especially in longer sessions. Platzi Viewer includes adaptive A/V sync correction and a compatibility mode using FFmpeg to address these issues.Understanding A/V Sync Problems
What Causes Desynchronization?
- Damaged timestamps in the video file - Incorrect or inconsistent PTS (Presentation Time Stamps)
- Network jitter - Unstable streaming causing buffering delays
- Container format issues - MP4 files with improper interleaving
- Browser decoding quirks - Different browsers handle malformed videos differently
Symptoms
- Audio plays ahead of video (or vice versa)
- Drift increases over time (e.g., 2 seconds off after 10 minutes)
- Frequent automatic corrections or “jumps” in playback
- Compatibility mode prompt appears
Adaptive Sync Correction
Platzi Viewer includes automatic drift detection and correction:How It Works
- Frame-based monitoring - Continuously tracks A/V offset
- Soft corrections - Small adjustments (< 200ms) via playback rate changes
- Hard corrections - Large adjustments (≥ 200ms) via seeking
- Automatic mode switching - Offers compatibility mode if issues persist
Viewing Sync Statistics
Open browser console and check:Compatibility Mode
When a video has persistent sync issues, the player may automatically suggest compatibility mode.What Is Compatibility Mode?
Compatibility mode uses FFmpeg on the server to re-process the video stream in real-time:- Copy mode (default): Re-muxes the stream without re-encoding (fast, low CPU)
- Reencode mode: Transcodes video to fix timestamp issues (slower, higher CPU)
Switching to Compatibility Mode
Manual switch:- Open the video player
- Look for the compatibility mode prompt (appears if drift detected)
- Click “Switch to Compatibility Mode”
Checking Compatibility Mode Status
Query the health endpoint:FFmpeg Configuration
FFmpeg not available
FFmpeg not available
Error in Impact: Compatibility mode will not work.Solution:1. Install FFmpeg:Windows:macOS:2. Verify installation:3. Custom FFmpeg path:
/api/health:- Download from ffmpeg.org
- Extract to
C:\ffmpeg\bin\ffmpeg.exeorC:\Program Files\ffmpeg\bin\ffmpeg.exe - Or add to PATH
Force reencode mode for all videos
Force reencode mode for all videos
When to use: Copy mode improves some videos but others remain out of sync.Enable reencode mode:What it does:
- Transcodes video with
libx264(CPU-based encoding) - Regenerates all timestamps (
+genpts) - Fixes audio sample rate to 48kHz
- Uses
veryfastpreset to balance speed and quality
FFmpeg compatibility stream failed
FFmpeg compatibility stream failed
Symptom: Video won’t load in compatibility mode.Check Common errors:1. “Invalid data found when processing input”
/api/health for lastError:- File may be corrupted in Google Drive
- Try downloading and re-uploading the file
- Network issue between server and Drive
- Retry the request
- Generic FFmpeg error
- Try reencode mode:
PLATZI_COMPAT_FORCE_REENCODE=1
- Video file is too large for real-time processing
- Check
lastSpeedMBps- should be > 5 MB/s - Consider using VLC external player instead
GPU Acceleration (Windows)
Hardware Acceleration in Browser
Browsers use GPU acceleration by default for video decoding. Forcing dedicated GPU can improve performance: Windows Settings:- Open Settings > System > Display > Graphics
- Click Browse and add:
- Your browser executable (Chrome, Firefox, Edge)
- Or
PlatziViewerDesktop.exefor desktop app
- Select the app and click Options
- Choose High performance (uses dedicated GPU)
- Restart the application
Desktop App GPU Acceleration
The desktop app (PlatziViewerDesktop.exe) automatically requests hardware acceleration for Chromium-based rendering.
Note: GPU acceleration helps with decoding performance but does not fix videos with damaged timestamps. Use compatibility mode for those.
Diagnostic Matrix
Use this reproducible test matrix to isolate desynchronization causes:Test Procedure
For each problematic video, test all combinations:| # | Mode | Platform | Duration | Network |
|---|---|---|---|---|
| 1 | Normal | Web Browser | 10-15 min | Stable (Ethernet/WiFi) |
| 2 | Normal | Desktop App | 10-15 min | Stable |
| 3 | Compatibility | Web Browser | 10-15 min | Stable |
| 4 | Compatibility | Desktop App | 10-15 min | Stable |
| 5 | Normal | Web Browser | 10-15 min | Unstable (VPN/Mobile) |
| 6 | Compatibility | Web Browser | 10-15 min | Unstable |
Data to Record
For each test:-
Drift at checkpoints:
- Minute 1: ___ ms
- Minute 5: ___ ms
- Minute 10: ___ ms
-
Sync corrections:
- Soft corrections: ___
- Hard corrections: ___
-
Mode switches:
- Prompted to switch mode? Yes/No
- Did automatic quality changes occur? Yes/No
-
Health snapshot:
- Check
http://localhost:8080/api/health - Record:
lastMode,lastError,lastSpeedMBps,failedStreams
- Check
Interpreting Results
Pattern 1: All modes fail → Video file is likely corrupted in Drive. Re-upload the file. Pattern 2: Normal mode fails, compatibility mode works → Video has timestamp issues. Use compatibility mode or VLC. Pattern 3: Only unstable network fails → Network jitter is the cause, not the video file. Improve network connection. Pattern 4: Desktop app works, web browser fails → Browser-specific decoding issue. Use desktop app or try a different browser. Pattern 5: Copy mode fails, reencode mode works → EnablePLATZI_COMPAT_FORCE_REENCODE=1 for this video type.
External Player (VLC)
If all else fails, open the video in VLC:From the Player
- Click the “Open in VLC” button in the video player
- The video URL is sent to VLC automatically (Windows only)
- VLC must be installed at:
C:\Program Files\VideoLAN\VLC\vlc.exe, orC:\Program Files (x86)\VideoLAN\VLC\vlc.exe, or- Available in PATH as
vlc
Manual VLC Playback
- Get the video file ID from browser DevTools Network tab
- Open VLC
- Media > Open Network Stream
- Enter URL:
- Click Play
Why VLC Works Better
VLC has more robust handling of:- Damaged timestamps
- Incomplete/corrupted frames
- Various codecs and container formats
Advanced: Server Streaming Metrics
The server logs streaming performance for diagnostics: Example log output:- Speed < 1 MB/s - Network bottleneck or Drive API throttling
- Duration > 10s for small files - Server or Drive performance issue
- Frequent errors - Check Drive API quota and authentication
See Also
- Common Issues - General troubleshooting
- Google Drive Errors - API rate limiting and connectivity
- Installation Guide - Environment variables for video streaming