Page 1 of 1
Best way to add gif over static image
Posted: 2013-01-29T06:08:02-07:00
by agriz
I haven't done the coding part yet.
Before that i want to confirm this.
I have one gif image with transparent background.
I have one static image.
The static image is bigger than the gif.
So, I plan to resize(tile) the gif to the size of static first and then i want to mingle them.
Is it good way to do it?
Later i want to convert that gif to mp4 using ffmpeg.
I am using ffmpeg to convert gif to mp4. But the movie is not running in the same speed of the gif. Is it possible to make it run in the same speed?
Thanks
Re: Best way to add gif over static image
Posted: 2013-01-29T06:39:46-07:00
by snibgo
Resize isn't the same as tiling.
I don't know if ffmpeg can read animated GIFs. I would do it as ...
Code: Select all
convert in.gif -coalesce frame_%03d.png
ffmepg -i frame_%03d.png -r 10 out.mp4
... where "10" is the desired framerate.
Re: Best way to add gif over static image
Posted: 2013-01-29T06:45:44-07:00
by agriz
snibgo wrote:Resize isn't the same as tiling.
I don't know if ffmpeg can read animated GIFs. I would do it as ...
Code: Select all
convert in.gif -coalesce frame_%03d.png
ffmepg -i frame_%03d.png -r 10 out.mp4
... where "10" is the desired framerate.
How do i find the framerate of an gif image?
I found the scenes and delay time using identify function of imagemagick.
Re: Best way to add gif over static image
Posted: 2013-01-29T07:18:43-07:00
by snibgo
Add the delays to get the total duration. Calculate the average delay for a framerate.
GIF files don't have a steady framerate. To get an MP4 from a GIF, you should replicate frames as needed so each one is on screen for the same time. I don't know if ffmpeg can do this automatically. If not, you coud replicate frames with ImageMagick, in a suitable script.
Re: Best way to add gif over static image
Posted: 2013-01-29T07:26:36-07:00
by agriz
snibgo wrote:Add the delays to get the total duration. Calculate the average delay for a framerate.
GIF files don't have a steady framerate. To get an MP4 from a GIF, you should replicate frames as needed so each one is on screen for the same time. I don't know if ffmpeg can do this automatically. If not, you coud replicate frames with ImageMagick, in a suitable script.
If there are 10 scenes and the delay is 5, i think the average is 5 after adding 5 for every scene.
(10 * 5) / 10 = 5
Did you mean something else. I didn't clearly get the point. It will be great to get any video format. Not just mp4.
The gif images are just 4 or 5 seconds in length. So after getting the mp4, I convert them to mpg and then i duplicate the mpg for 10 times and finally i convert them to mp4 to get some 30 sec or 1 min video. Is it the right way? Or will it work more better in other formats?
Re: Best way to add gif over static image
Posted: 2013-01-29T07:43:52-07:00
by snibgo
The delay is shown as {ticks}x{ticks-per-seconds}. See
http://www.imagemagick.org/script/comma ... .php#delay
So "5x100" means 5 hundredths of a second, 0.05s. If all the frames have this delay, then you have a steady framerate, which is 100/5 = 20 frames per second.
ffmpeg can create mpg, mp4, avi or many other formats. mpg files can be directly concatenated:
Unix: cat x.mpg x.mpg x.mpg x.mpg x.mpg >x5.mpg
Windows: copy /B x.mpg+x.mpg+x.mpg+x.mpg+x.mpg x5.mpg
Re: Best way to add gif over static image
Posted: 2013-01-29T08:19:17-07:00
by agriz
As i said, I am planning to use static image and one glitter to create animated image.
Using PHP GD, Using Imagemagick which is best in resource usage wise?
Thanks
Re: Best way to add gif over static image
Posted: 2013-01-29T08:39:20-07:00
by snibgo
I don't use PHP, and don't know what "GD" is. In general, using more tools (such as a web browser with PHP interpreter) will also use more resources.