hergün instagramdan facebooktan ürün resimlerinin olduğu reklamlardan paylaşıyorum. elimde 40 adet resim var. bunların içinden randomize olarak 10 adet resim seçecek. bu 10 resme müzik ekleyecek bu resimleri instagram ve facebookta hem gönderi hem reels hemde hikaye oarak paylaşan bir workflow yapmak istiyorum. nelere dikkat etmem lazım. google drivede bir klasöre resimleri koydum. oradan randomize seçiyor ama ondan sonraki aşamada takılıyoruz.
1. Google Drive List Files
- Node: Google Drive
- Operation: List
- Folder ID: 40 resmin bulunduğu klasör
- Output: 40 adet resim dosyası (metadata + fileId)
2. Function Node Rastgele 10 dosya seç
// input: 40 Google Drive dosyası
const files = items;
const shuffled = files.sort(() => 0.5 - Math.random());
return shuffled.slice(0, 10);
3. Google Drive Download Files
- Node: Google Drive
- Operation: Download
- Input: Function nodedan gelen 10 dosya
- Output: Binary data (her biri image)
4. Function Node FFmpeg komutunu hazırla
Burada, resimleri n8nin temp dizinine kaydedip sonra ffmpege göndereceğiz.
const execList = items.map((item, index) => { const fileName = `/tmp/image${index + 1}.jpg`; require('fs').writeFile_Sync(fileName, item.binary.data, 'base64'); return fileName; });
// Slayt yapmak için: (her resim 3 saniye)
const imageListFile = '/tmp/images.txt';
require('fs').writeFile_Sync(imageListFile, execList.map(f => `file '${f}'\nduration 3`).join('\n'));
return [{ json: { imageListFile } }];5. Execute Command FFmpeg video oluştur
Node:
Execute Command
Alıntı
ffmpeg -f concat -safe 0 -i /tmp/images.txt -vf "scale=1280:720,format=yuv420p" -y /tmp/slideshow.mp4
Bu, 10 resmi sırayla 3 saniye arayla birleştirir.
6. Execute Command Müzik ekle
Müziği Google Drivedan ya da local bir dosyadan alabilirsin.
Alıntı
ffmpeg -i /tmp/slideshow.mp4 -i /tmp/music.mp3 -shortest -c:v copy -c:a aac /tmp/final_video.mp4
7. Google Drive Upload (veya paylaşım)
- Node: Google Drive
- Operation: Upload
- File Path: /tmp/final_video.mp4
- Folder: (ör. output klasörü)
- Optional: Sonucu Telegram / Email nodeuyla da gönderebilirsin.
-------------------------------------------------------------------------------
- n8nin çalıştığı ortamda ffmpeg binarysi yüklü ve PATHte olmalı.
- /tmp dizini yerine kendi data/ klasörünü de kullanabilirsin.
- FFmpeg komutlarını Execute Command nodeunda shell modunda çalıştır.