How to convert video to GIF using FFmpeg

2

2

I installed FFmpeg on my XAMPP for converting stream of video to GIF images.

I used the below code but it doesn't work.

ffmpeg -ss 00:00:05.0 -t 00:00:10.0 -i input.wmv -acodec copy -vcodec copy -async 1 output.gif

Ramkumar

Posted 2013-02-07T11:07:00.113

Reputation: 53

Answers

4

Your problem is: You cannot simply copy the input video and audio streams to a GIF. GIFs need to be encoded differently. Basically you're telling FFmpeg to actually not convert anything.

Try this instead:

ffmpeg -ss 5 -i input.wmv -t 10 -pix_fmt rgb24 output.gif

Notes:

  • I shortened the timestamps. If you just need seconds, it's enough to specify those.
  • -t is an output option and should go between -i and your output file name.
  • GIFs need an RGB pixel format, which you have to specify as well.
  • You may need to downscale your video so the GIF doesn't become unnecessarily large. Try adding -filter:v "scale=-1:320" or similar to downscale the output to 320 pixels height (and adjust the width automatically (-1).

Tip: "It doesn't work" is not a specific enough problem description. Please always include the full, uncut FFmpeg command output when asking FFmpeg questions.

slhck

Posted 2013-02-07T11:07:00.113

Reputation: 182 472

thanks its works :) you save my life :) but it seems blurred image how can i get the gif image as like as video – Ramkumar – 2013-02-07T11:28:39.370

You probably can't. GIFs were never meant to be used for video. Why would you want the videos to be GIFs in the first place, if I may ask? – slhck – 2013-02-07T11:34:31.033