-3

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.

Erlja Jkdf.
  • 171
  • 2
  • 12

1 Answers1

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
  • `-lavfi` isn't a virtual device. It's an alias for `-filter_complex`. – Gyan Feb 05 '16 at 04:44