feat: kanal başına segment süresini panelden ayarlama

Channel.segmentTimeSec (nullable, null = global SEGMENT_TIME_SEC env
var'ı kullan) eklendi. Kanal detay sayfasından dakika cinsinden
girilebiliyor, StreamIngestJob'a taşınıp streamIngest.ts'te ffmpeg'in
-segment_time argümanına yansıyor. Sadece o kanal için bundan sonra
başlayacak yeni kayıt oturumlarını etkiler — halihazırda çalışan bir
ffmpeg process'inin segment süresi zaten sabitlenmiş durumda.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
2026-09-02 15:14:09 +03:00
co-authored by Claude Sonnet 5
parent ee79dce340
commit 3e01116729
7 changed files with 55 additions and 4 deletions
+2 -2
View File
@@ -96,7 +96,7 @@ async function processCompletedSegments(
}
async function runCapture(job: Job<StreamIngestJob>): Promise<void> {
const { sessionId, youtubeUrl } = job.data;
const { sessionId, youtubeUrl, segmentTimeSec } = job.data;
const outDir = path.join(env.sharedMediaRoot, "raw", sessionId);
await mkdir(outDir, { recursive: true });
@@ -121,7 +121,7 @@ async function runCapture(job: Job<StreamIngestJob>): Promise<void> {
"-i", "pipe:0",
"-c", "copy",
"-f", "segment",
"-segment_time", String(env.segmentTimeSec),
"-segment_time", String(segmentTimeSec ?? env.segmentTimeSec),
"-reset_timestamps", "1",
"-segment_list", segmentListPath,
"-segment_list_type", "csv",
+2
View File
@@ -19,6 +19,8 @@ export interface StreamIngestJob {
sessionId: string;
channelDbId: string;
youtubeUrl: string;
/** Kanala özel segment süresi (sn) — verilmezse env.segmentTimeSec kullanılır. */
segmentTimeSec?: number;
}
export interface SignalDetectionJob {
+8 -2
View File
@@ -85,7 +85,7 @@ async function findLiveVideoId(channelId: string): Promise<string | null> {
* force-start on a channel that's already live).
*/
export async function startCaptureSession(
channel: { id: string; name: string },
channel: { id: string; name: string; segmentTimeSec?: number | null },
youtubeUrl: string,
liveVideoId: string | null = null,
): Promise<{ started: boolean }> {
@@ -102,6 +102,7 @@ export async function startCaptureSession(
sessionId: session.id,
channelDbId: channel.id,
youtubeUrl,
segmentTimeSec: channel.segmentTimeSec ?? undefined,
});
const notifySetting = await prisma.appSetting.findUnique({ where: { key: "notify_stream_start" } });
@@ -113,7 +114,12 @@ export async function startCaptureSession(
}
/** Runs the live-check for a single channel and applies its result — the unit both `pollOnce` and the panel's manual "şimdi kontrol et" action reuse. */
export async function checkChannel(channel: { id: string; name: string; channelId: string }): Promise<{
export async function checkChannel(channel: {
id: string;
name: string;
channelId: string;
segmentTimeSec?: number | null;
}): Promise<{
liveVideoId: string | null;
error: PollError | null;
}> {