// Yeni video workflow: T2V + first/last frame guide — app kodu → ComfyUI. import 'dart:io'; import 'package:dio/dio.dart'; import '../lib/comfy/workflow/video_workflow.dart'; Future main() async { const base = 'http://127.0.0.1:8188'; final dio = Dio(BaseOptions(baseUrl: base, receiveTimeout: const Duration(minutes: 10))); // ComfyUI output'tan bir png al, input'a yükle (frame guide için) final dir = Directory(r'D:\Comfy\App\ComfyUI_windows_portable\ComfyUI\output\fikoyt'); final png = dir.listSync().whereType().firstWhere( (f) => f.path.endsWith('.png'), orElse: () => File('')); String? inputAdi; if (png.existsSync()) { final form = FormData.fromMap({ 'image': await MultipartFile.fromFile(png.path, filename: png.uri.pathSegments.last), 'overwrite': 'true', }); inputAdi = (await dio.post('/upload/image', data: form)).data['name'] as String; stdout.writeln('Guide görseli: $inputAdi'); } Future calistir(VideoParametreleri p, String etiket) async { final r = await dio.post('/prompt', data: {'prompt': videoWorkflowOlustur(p), 'client_id': 'fikoyt-vg'}); final pid = r.data['prompt_id'] as String; for (var i = 0; i < 200; i++) { await Future.delayed(const Duration(seconds: 3)); final h = (await dio.get('/history/$pid')).data as Map; if (h[pid] != null) { final st = (h[pid] as Map)['status'] as Map?; if (st?['status_str'] == 'error') { final msgs = st?['messages'] as List?; stdout.writeln('$etiket HATA: ${msgs?.lastWhere((m) => m[0] == 'execution_error', orElse: () => ['', {}])[1]}'); return false; } if (st?['completed'] == true) { stdout.writeln('$etiket BASARILI'); return true; } } } stdout.writeln('$etiket ZAMAN ASIMI'); return false; } // 1) T2V (rehbersiz) final t2v = await calistir( VideoParametreleri(prompt: 'a calm ocean wave, cinematic', genislik: 512, yukseklik: 320, uzunluk: 49, steps: 14), 'T2V'); // 2) First + Last frame guide var guide = true; if (inputAdi != null) { guide = await calistir( VideoParametreleri(prompt: 'smooth camera motion, cinematic', genislik: 512, yukseklik: 320, uzunluk: 49, steps: 14, ilkKare: inputAdi, sonKare: inputAdi), 'FIRST+LAST GUIDE'); } else { stdout.writeln('GUIDE testi atlandi (png yok)'); } exit(t2v && guide ? 0 : 1); }