# Debugging Media File Skips - Guide ## Summary Your playlist has been analyzed and all 3 media files are present and valid: - ✅ music.jpg (36,481 bytes) - IMAGE - 15s - ✅ 130414-746934884.mp4 (6,474,921 bytes) - VIDEO - 23s - ✅ IMG_0386.jpeg (592,162 bytes) - IMAGE - 15s ## Enhanced Logging Added The application has been updated with detailed logging to track: - When each media file starts playing - File path validation - File size and existence checks - Media type detection - Widget creation steps - Scheduling of next media - Any errors or skips ## How to See Detailed Logs ### Method 1: Run with log output ```bash cd /home/pi/Desktop/Kiwy-Signage source .venv/bin/activate cd src python3 main.py 2>&1 | tee playback.log ``` ### Method 2: Check Kivy logs location Kivy logs are typically stored in: - Linux: `~/.kivy/logs/` - Check with: `ls -lth ~/.kivy/logs/ | head` ## Common Reasons Media Files Get Skipped ### 1. **File Not Found** **Symptom**: Log shows "❌ Media file not found" **Cause**: File doesn't exist at expected path **Solution**: Run diagnostic tool ```bash python3 diagnose_playlist.py ``` ### 2. **Unsupported File Type** **Symptom**: Log shows "❌ Unsupported media type" **Supported formats**: - Videos: .mp4, .avi, .mkv, .mov, .webm - Images: .jpg, .jpeg, .png, .bmp, .gif **Solution**: Convert files or check extension ### 3. **Video Codec Issues** **Symptom**: Video file exists but doesn't play **Cause**: Video codec not supported by ffpyplayer **Check**: Look for error in logs about codec **Solution**: Re-encode video with H.264 codec: ```bash ffmpeg -i input.mp4 -c:v libx264 -preset fast -crf 23 output.mp4 ``` ### 4. **Corrupted Media Files** **Symptom**: File exists but throws error when loading **Check**: Try playing file with external player ```bash # For images feh media/music.jpg # For videos vlc media/130414-746934884.mp4 # or ffplay media/130414-746934884.mp4 ``` ### 5. **Memory/Performance Issues** **Symptom**: First few files play, then skipping increases **Cause**: Memory leak or performance degradation **Check**: Look for "consecutive_errors" in logs **Solution**: - Reduce resolution setting in settings popup - Optimize video files (lower bitrate/resolution) ### 6. **Timing Issues** **Symptom**: Files play too fast or skip immediately **Cause**: Duration set too low or scheduler issues **Check**: Verify durations in playlist.json **Current durations**: 15s (images), 23s (video) ### 7. **Permission Issues** **Symptom**: "Permission denied" in logs **Check**: File permissions ```bash ls -la media/ ``` **Solution**: Fix permissions ```bash chmod 644 media/* ``` ## What to Look For in Logs ### Successful Playback Pattern: ``` SignagePlayer: ===== Playing item 1/3 ===== SignagePlayer: File: music.jpg SignagePlayer: Duration: 15s SignagePlayer: Full path: /path/to/media/music.jpg SignagePlayer: ✓ File exists (size: 36,481 bytes) SignagePlayer: Extension: .jpg SignagePlayer: Media type: IMAGE SignagePlayer: Creating AsyncImage widget... SignagePlayer: Adding image widget to content area... SignagePlayer: Scheduled next media in 15s SignagePlayer: ✓ Image displayed successfully SignagePlayer: ✓ Media started successfully (consecutive_errors reset to 0) ``` ### Skip Pattern (File Not Found): ``` SignagePlayer: ===== Playing item 2/3 ===== SignagePlayer: File: missing.mp4 SignagePlayer: Full path: /path/to/media/missing.mp4 SignagePlayer: ❌ Media file not found: /path/to/media/missing.mp4 SignagePlayer: Skipping to next media... SignagePlayer: Transitioning to next media (was index 1) ``` ### Video Loading Error: ``` SignagePlayer: Loading video file.mp4 for 23s SignagePlayer: Video provider: ffpyplayer [ERROR ] [Video ] Error reading video [ERROR ] SignagePlayer: Error playing video: ... ``` ## Testing Tools Provided ### 1. Diagnostic Tool ```bash python3 diagnose_playlist.py ``` Checks: - Playlist file exists and is valid - All media files exist - File types are supported - No case sensitivity issues ### 2. Playback Simulation ```bash python3 test_playback_logging.py ``` Simulates the playback sequence without running the GUI ## Monitoring Live Playback To see live logs while the app is running: ```bash # Terminal 1: Start the app ./run_player.sh # Terminal 2: Monitor logs tail -f ~/.kivy/logs/kivy_*.txt ``` ## Quick Fixes to Try ### 1. Clear any stuck state ```bash rm -f src/*.pyc rm -rf src/__pycache__ ``` ### 2. Test with simpler playlist Create `playlists/test_playlist_v9.json`: ```json { "playlist": [ { "file_name": "music.jpg", "url": "media/music.jpg", "duration": 5 } ], "version": 9 } ``` ### 3. Check video compatibility ```bash # Install ffmpeg tools if not present sudo apt-get install ffmpeg # Check video info ffprobe media/130414-746934884.mp4 ``` ## Getting Help When reporting issues, please provide: 1. Output from `python3 diagnose_playlist.py` 2. Last 100 lines of Kivy log file 3. Any error messages from console 4. What you observe (which files skip? pattern?) ## Next Steps 1. **Run the app** and observe the console output 2. **Check logs** for error patterns 3. **Run diagnostic** if files are skipping 4. **Test individual files** with external players if needed 5. **Re-encode videos** if codec issues found The enhanced logging will now tell you exactly why each file is being skipped!