mirror of
https://github.com/R0m1k3/xtremflow.git
synced 2026-10-22 22:48:04 +02:00
feat: implement SimpleRecorder service for FFmpeg-based stream recording and scheduling
This commit is contained in:
1 parent
ce695b7e43
commit
1b4321d84a
1 file changed
+13
-4
@@ -55,6 +55,7 @@ class SimpleRecorder {
|
|||||||
try {
|
try {
|
||||||
final ffmpeg = await Process.start('ffmpeg', [
|
final ffmpeg = await Process.start('ffmpeg', [
|
||||||
'-y',
|
'-y',
|
||||||
|
'-fflags', '+genpts+igndts', // FORCE generation of missing timestamps for MKV/MP4 compatibility
|
||||||
'-i',
|
'-i',
|
||||||
streamUrl,
|
streamUrl,
|
||||||
'-c',
|
'-c',
|
||||||
@@ -75,10 +76,18 @@ class SimpleRecorder {
|
|||||||
db.updateRecordingStatus(recordingId, 'recording', filePath: filepath);
|
db.updateRecordingStatus(recordingId, 'recording', filePath: filepath);
|
||||||
|
|
||||||
// Auto-stop when time is up or process ends
|
// Auto-stop when time is up or process ends
|
||||||
ffmpeg.exitCode.then((_) {
|
ffmpeg.exitCode.then((code) {
|
||||||
db.updateRecordingStatus(recordingId, 'completed');
|
if (code == 0 || code == 255) { // 255 is usually returned when gracefully stopped via q/SIGTERM
|
||||||
|
db.updateRecordingStatus(recordingId, 'completed');
|
||||||
|
} else {
|
||||||
|
db.updateRecordingStatus(
|
||||||
|
recordingId,
|
||||||
|
'failed',
|
||||||
|
errorReason: 'FFmpeg crashed with exit code $code',
|
||||||
|
);
|
||||||
|
}
|
||||||
_active.remove(channelId);
|
_active.remove(channelId);
|
||||||
print('✅ Recording done: $title');
|
print('✅ Recording finished: $title (Code: $code)');
|
||||||
}).catchError((e) {
|
}).catchError((e) {
|
||||||
db.updateRecordingStatus(
|
db.updateRecordingStatus(
|
||||||
recordingId,
|
recordingId,
|
||||||
@@ -203,7 +212,7 @@ class SimpleRecorder {
|
|||||||
final safe = title.replaceAll(RegExp(r'[^a-zA-Z0-9_-]'), '_');
|
final safe = title.replaceAll(RegExp(r'[^a-zA-Z0-9_-]'), '_');
|
||||||
final timestamp =
|
final timestamp =
|
||||||
DateTime.now().toIso8601String().replaceAll(':', '').split('.')[0];
|
DateTime.now().toIso8601String().replaceAll(':', '').split('.')[0];
|
||||||
return '${safe}_$timestamp.mkv';
|
return '${safe}_$timestamp.mkv'; // The user explicitly mandated MKV or MP4.
|
||||||
}
|
}
|
||||||
|
|
||||||
void dispose() {
|
void dispose() {
|
||||||
|
|||||||
Reference in new issue
Block a user