feat(transcoding): add FFmpeg HLS transcoding support
- Introduced `TranscodeManager` for managing on-demand transcoding of local video files. - Added configuration options for transcoding in `Config` and `LocalFilesConfig`. - Implemented new API routes for managing transcoding settings, stats, and cache. - Updated `LocalFilesProvider` to support transcoding capabilities. - Created frontend components for managing transcode settings and displaying stats. - Added database migration for transcode settings. - Enhanced existing routes and DTOs to accommodate new transcoding features.
This commit is contained in:
43
k-tv-frontend/hooks/use-transcode.ts
Normal file
43
k-tv-frontend/hooks/use-transcode.ts
Normal file
@@ -0,0 +1,43 @@
|
||||
"use client";
|
||||
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { api } from "@/lib/api";
|
||||
import { useAuthContext } from "@/context/auth-context";
|
||||
import type { TranscodeSettings } from "@/lib/types";
|
||||
|
||||
export function useTranscodeSettings() {
|
||||
const { token } = useAuthContext();
|
||||
return useQuery({
|
||||
queryKey: ["transcode-settings"],
|
||||
queryFn: () => api.transcode.getSettings(token!),
|
||||
enabled: !!token,
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateTranscodeSettings() {
|
||||
const { token } = useAuthContext();
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (data: TranscodeSettings) =>
|
||||
api.transcode.updateSettings(data, token!),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["transcode-settings"] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useTranscodeStats() {
|
||||
const { token } = useAuthContext();
|
||||
return useQuery({
|
||||
queryKey: ["transcode-stats"],
|
||||
queryFn: () => api.transcode.getStats(token!),
|
||||
enabled: !!token,
|
||||
});
|
||||
}
|
||||
|
||||
export function useClearTranscodeCache() {
|
||||
const { token } = useAuthContext();
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: () => api.transcode.clearCache(token!),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["transcode-stats"] }),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user