I'm using FFmpeg with DirectoryMonitor, a folder watching program. When a webm is added to the folder i want to execute a script to convert all webm files in that folder to gif, and then delete those webm files.
Asked
Active
Viewed 1,297 times
-3
-
1What is your question ? – Paul R Feb 02 '16 at 10:57
-
What's the correct command to convert all webm files in a folder to gif, and then delete those webm files? – Erlja Jkdf. Feb 02 '16 at 10:58
-
2This doesn't sound like a programming question - you might be better off asking on http://superuser.com. – Paul R Feb 02 '16 at 11:00
1 Answers
2
Ffmpeg can often deduce the output type by its file extension, so just write to a .gif and you're usually good.
#!/bin/bash
for w in ./*.webm; do
ffmpeg -i $w ${w%.*}.gif && rm $w
done

Harald Nordgren
- 11,693
- 6
- 41
- 65
-
OP can do it in two passes: first pass generates optimum palette i.e. `ffmpeg -i $w -vf palettegen ${w%.*}.png` and 2nd pass generates GIF i.e. `ffmpeg -i $w -i ${w%.*}.png -vf paletteuse ${w%.*}.gif` – Gyan Feb 03 '16 at 08:45
-
I noticed that I had to specify the .png file as a virtual device (`-lavfi`) in order to get this to work. So the second command would be `ffmpeg -i $w -i ${w%.*}.png -lavfi paletteuse ${w%.*}.gif`. – Harald Nordgren Feb 05 '16 at 03:14
-