Compare commits

..

No commits in common. "d048cb3b8223174d700a2b459626fddad3aa1507" and "e019389770dbf13c04a876569ddc54894c726c29" have entirely different histories.

2 changed files with 6 additions and 100 deletions

View File

@ -1,76 +0,0 @@
# Temporary .ts File Fix
## Overview
This document describes a temporary fix implemented to handle problematic .ts file resegmentation by redirecting .ts files to external local video players instead of attempting HLS streaming.
## Problem
The .ts resegmentation implementation for HLS streaming was causing playback issues. Instead of complex troubleshooting, a simple temporary solution was needed to make .ts files playable immediately.
## Solution
Modified `src/lib/video-format-detector.ts` to treat .ts files like other non-mp4 files that require external local video players.
## Changes Made
### 1. Updated TS_STREAM_FORMATS Array
```typescript
// BEFORE
const TS_STREAM_FORMATS = [
'ts', // MPEG Transport Stream - optimal for HLS streaming
'm2ts', // Blu-ray Transport Stream
'mts' // AVCHD Transport Stream
];
// AFTER (temporary)
const TS_STREAM_FORMATS = [
// 'ts', // TEMPORARILY DISABLED - send to local player instead
'm2ts', // Blu-ray Transport Stream
'mts' // AVCHD Transport Stream
];
```
### 2. Added Explicit .ts File Handling
```typescript
// TEMPORARY FIX: Send .ts files to local player due to resegmentation issues
if (extension === 'ts') {
console.log('[FormatDetector] .ts file detected, sending to local player (temporary fix)');
return createLocalPlayerFormat(video, extension);
}
```
### 3. Enhanced User Messaging
Added specific warning message for .ts files:
```typescript
const warningMessage = isTsFile
? 'MPEG Transport Stream (.ts) files require a local video player for optimal playback. This is a temporary solution while we fix the streaming implementation.'
: 'This format requires a local video player';
```
## User Experience
- When users click on a .ts file, they will see the Local Player Launcher
- Clear messaging explains this is a temporary solution
- Users can copy the stream URL to VLC, IINA, PotPlayer, or other local players
- Files play perfectly through the external streaming API (`/api/external-stream/[id]`)
## Technical Benefits
- ✅ Immediate fix - .ts files are now playable
- ✅ Uses existing, well-tested external streaming API
- ✅ Proper HTTP range support for seeking
- ✅ No transcoding required
- ✅ Minimal code changes
- ✅ Easy to revert when HLS implementation is fixed
## Reverting This Fix
When the .ts resegmentation implementation is fixed:
1. Remove the explicit .ts handling in `detectVideoFormat()`
2. Add 'ts' back to the `TS_STREAM_FORMATS` array
3. Remove the temporary comments and warning messages
4. Test HLS streaming with .ts files
## Files Modified
- `/src/lib/video-format-detector.ts` - Main format detection logic
## API Endpoint Used
- `/api/external-stream/[id]` - Optimized for external players with range request support
This temporary fix provides immediate .ts file playability while maintaining the overall architecture for a permanent HLS-based solution later.

View File

@ -1,10 +1,6 @@
/**
* Video format detection and support level classification
* Determines the optimal playback method for different video formats
*
* TEMPORARY FIX: .ts files are currently sent to local player instead of HLS
* due to resegmentation issues. This needs to be reverted once the HLS
* implementation for .ts files is fixed.
*/
export interface VideoFormat {
@ -60,10 +56,9 @@ const HLS_COMPATIBLE_FORMATS = [
'mts'
];
// MPEG Transport Stream formats - TEMPORARY: treat as local player required
// TODO: Fix the .ts resegmentation implementation for HLS streaming
// MPEG Transport Stream formats - can be served via HLS or converted
const TS_STREAM_FORMATS = [
// 'ts', // TEMPORARILY DISABLED - send to local player instead
'ts', // MPEG Transport Stream - optimal for HLS streaming
'm2ts', // Blu-ray Transport Stream
'mts' // AVCHD Transport Stream
];
@ -109,12 +104,6 @@ export function detectVideoFormat(video: VideoFile): VideoFormat {
return createDirectFormat(video, extension);
}
// TEMPORARY FIX: Send .ts files to local player due to resegmentation issues
if (extension === 'ts') {
console.log('[FormatDetector] .ts file detected, sending to local player (temporary fix)');
return createLocalPlayerFormat(video, extension);
}
// Tier 1.5: MPEG Transport Stream files (optimal for HLS)
if (TS_STREAM_FORMATS.includes(extension)) {
console.log('[FormatDetector] TS format detected, using HLS streaming:', extension);
@ -133,9 +122,9 @@ export function detectVideoFormat(video: VideoFile): VideoFormat {
// No more fallback to transcoding system
console.log('[FormatDetector] Using local player for format:', extension);
// Check if this is a format from LIMITED_SUPPORT_FORMATS or .ts (temporary)
if (LIMITED_SUPPORT_FORMATS.includes(extension) || extension === 'ts') {
console.log('[FormatDetector] Format in LIMITED_SUPPORT_FORMATS or .ts (temporary), forcing local player');
// Check if this is a format from LIMITED_SUPPORT_FORMATS
if (LIMITED_SUPPORT_FORMATS.includes(extension)) {
console.log('[FormatDetector] Format in LIMITED_SUPPORT_FORMATS, forcing local player');
}
return createLocalPlayerFormat(video, extension);
@ -264,7 +253,6 @@ function createTSDirectFormat(video: VideoFile, extension: string): VideoFormat
/**
* Create local player format configuration (replaces transcoding fallback)
* Enhanced for .ts files to provide better user guidance
*/
function createLocalPlayerFormat(video: VideoFile, extension: string): VideoFormat {
const contentType = getMimeType(extension);
@ -272,18 +260,12 @@ function createLocalPlayerFormat(video: VideoFile, extension: string): VideoForm
// Use the optimized external streaming endpoint
const baseUrl = `/api/external-stream/${video.id}`;
// Special handling for .ts files (temporary fix)
const isTsFile = extension === 'ts';
const warningMessage = isTsFile
? 'MPEG Transport Stream (.ts) files require a local video player for optimal playback. This is a temporary solution while we fix the streaming implementation.'
: 'This format requires a local video player';
return {
type: 'local-player',
supportLevel: 'local-player-required',
url: baseUrl, // Optimized endpoint for external players
action: 'launch-local-player',
warning: warningMessage,
warning: 'This format requires a local video player',
recommendedPlayers: getRecommendedPlayersForFormat(extension),
streamInfo: {
contentType,