mirror of
https://github.com/immich-app/immich.git
synced 2026-05-18 03:10:24 +03:00
hls_ prefix
This commit is contained in:
@@ -225,7 +225,9 @@ export const HLS_BACKPRESSURE_RESUME_SEGMENTS = 15;
|
||||
export const HLS_CLEANUP_INTERVAL_MS = 60 * 1000;
|
||||
export const HLS_INACTIVITY_TIMEOUT_MS = 5 * 60 * 1000;
|
||||
export const HLS_LEASE_DURATION_MS = 30 * 60 * 1000;
|
||||
export const HLS_PLAYLIST_CONTENT_TYPE = 'application/vnd.apple.mpegurl';
|
||||
export const HLS_SEGMENT_DURATION = 2;
|
||||
export const HLS_SEGMENT_FILENAME_REGEX = /^seg_(\d+)\.m4s$/;
|
||||
export const HLS_VARIANTS = [
|
||||
{ resolution: 480, codec: VideoCodec.Av1, bitrate: 1_000_000, codecString: 'av01.0.04M.08' },
|
||||
{ resolution: 480, codec: VideoCodec.Hevc, bitrate: 1_200_000, codecString: 'hvc1.1.6.L90.B0' },
|
||||
@@ -241,5 +243,3 @@ export const HLS_VARIANTS = [
|
||||
{ resolution: 1440, codec: VideoCodec.H264, bitrate: 16_000_000, codecString: 'avc1.640032' },
|
||||
];
|
||||
export const HLS_VERSION = 6;
|
||||
export const PLAYLIST_CONTENT_TYPE = 'application/vnd.apple.mpegurl';
|
||||
export const SEGMENT_FILENAME_REGEX = /^seg_(\d+)\.m4s$/;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Controller, Delete, Get, Header, HttpCode, HttpStatus, Next, Param, Res } from '@nestjs/common';
|
||||
import { ApiProduces, ApiTags } from '@nestjs/swagger';
|
||||
import { NextFunction, Response } from 'express';
|
||||
import { PLAYLIST_CONTENT_TYPE } from 'src/constants';
|
||||
import { HLS_PLAYLIST_CONTENT_TYPE } from 'src/constants';
|
||||
import { Endpoint, HistoryBuilder } from 'src/decorators';
|
||||
import { AuthDto } from 'src/dtos/auth.dto';
|
||||
import { HlsSegmentParamDto, HlsSessionParamDto, HlsVariantParamDto } from 'src/dtos/streaming.dto';
|
||||
@@ -23,8 +23,8 @@ export class VideoStreamController {
|
||||
@Get(':id/video/stream/main.m3u8')
|
||||
@Authenticated({ permission: Permission.AssetView, sharedLink: true })
|
||||
@Header('Cache-Control', 'no-cache')
|
||||
@Header('Content-Type', PLAYLIST_CONTENT_TYPE)
|
||||
@ApiProduces(PLAYLIST_CONTENT_TYPE)
|
||||
@Header('Content-Type', HLS_PLAYLIST_CONTENT_TYPE)
|
||||
@ApiProduces(HLS_PLAYLIST_CONTENT_TYPE)
|
||||
@Endpoint({
|
||||
summary: 'Get HLS main playlist',
|
||||
description: 'Returns an HLS main playlist with all available variants for the asset.',
|
||||
@@ -37,8 +37,8 @@ export class VideoStreamController {
|
||||
@Get(':id/video/stream/:sessionId/:variantIndex/playlist.m3u8')
|
||||
@Authenticated({ permission: Permission.AssetView, sharedLink: true })
|
||||
@Header('Cache-Control', 'no-cache')
|
||||
@Header('Content-Type', PLAYLIST_CONTENT_TYPE)
|
||||
@ApiProduces(PLAYLIST_CONTENT_TYPE)
|
||||
@Header('Content-Type', HLS_PLAYLIST_CONTENT_TYPE)
|
||||
@ApiProduces(HLS_PLAYLIST_CONTENT_TYPE)
|
||||
@Endpoint({
|
||||
summary: 'Get HLS media playlist',
|
||||
description: 'Returns an HLS media playlist for one variant of the streaming session.',
|
||||
|
||||
@@ -3,9 +3,9 @@ import { constants } from 'node:fs';
|
||||
import { join } from 'node:path';
|
||||
import {
|
||||
HLS_SEGMENT_DURATION,
|
||||
HLS_SEGMENT_FILENAME_REGEX,
|
||||
HLS_VARIANTS,
|
||||
HLS_VERSION,
|
||||
SEGMENT_FILENAME_REGEX,
|
||||
SUPPORTED_HWA_CODECS,
|
||||
} from 'src/constants';
|
||||
import { StorageCore } from 'src/cores/storage.core';
|
||||
@@ -175,7 +175,7 @@ export class HlsService extends BaseService {
|
||||
if (filename.endsWith('.mp4')) {
|
||||
return (existing?.lastRequestedSegment ?? -1) + 1;
|
||||
}
|
||||
const segmentIndex = Number.parseInt(SEGMENT_FILENAME_REGEX.exec(filename)![1]);
|
||||
const segmentIndex = Number.parseInt(HLS_SEGMENT_FILENAME_REGEX.exec(filename)![1]);
|
||||
if (existing) {
|
||||
existing.lastRequestedSegment = segmentIndex;
|
||||
} else {
|
||||
|
||||
@@ -8,8 +8,8 @@ import {
|
||||
HLS_INACTIVITY_TIMEOUT_MS,
|
||||
HLS_LEASE_DURATION_MS,
|
||||
HLS_SEGMENT_DURATION,
|
||||
HLS_SEGMENT_FILENAME_REGEX,
|
||||
HLS_VARIANTS,
|
||||
SEGMENT_FILENAME_REGEX,
|
||||
} from 'src/constants';
|
||||
import { StorageCore } from 'src/cores/storage.core';
|
||||
import { OnEvent, OnJob } from 'src/decorators';
|
||||
@@ -267,7 +267,7 @@ export class TranscodingService extends BaseService {
|
||||
if (eventType !== 'rename' || !filename || session.process !== process) {
|
||||
return;
|
||||
}
|
||||
const match = SEGMENT_FILENAME_REGEX.exec(filename);
|
||||
const match = HLS_SEGMENT_FILENAME_REGEX.exec(filename);
|
||||
if (!match) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user