Animated GIF to video with ffmpeg - wrong timing - ffmpeg

I'm trying to convert an animated GIF to video with ffmpeg, but there's a strange problem: the time delays of each frame seem to be off by one frame.
For example, if the frame #1 is supposed to be shown for 2000 ms and the frames from #2 to #10 are supposed to be shown for 100 ms each, in the resulting video it immediately skips to the frame #2 which is shown for 2000 ms instead :P
Is this some kind of a bug? Or am I doing something wrong?
Here's my command line:
ffmpeg –i Mnozenie_anim_deop.gif Mnozenie_anim.mp4
(Aside: why doesn't the "-" show up in code blocks unless I replace it with "–"?)
so nothing extraordinary, just the defaults. (Unless this is the root of the problem? Maybe my defaults are bad, and I need to specify some magic options?)
This problem seems to appear for any video formats except MKV, and when I play these files in mplayer, they all behave that way except MKV.
But when I open them in kdenlive (a non-linear video editing program), the problem appears in all of them, including MKV (which is strange, because it plays back just fine in mplayer :q ).
I tried converting the same exact file with this online converter here:
https://ezgif.com/gif-to-mp4
and there is no problem with its output – it plays back fine both in mplayer and when imported to kdenlive, so I guess they must have been using some magic command line options that I'm missing.
Any ideas what can be wrong and how to track down the culprit?
Edit: Here's a sample animated GIF file I'm trying to convert:
http://nauka.mistu.info/Matematyka/Algebra/Szeregi/Mnozenie_anim.gif
and the MP4 file that I generated from it which demonstrates this problem:
http://sasq.comyr.com/Stuff/Mnozenie_anim.mp4
As you can see, the fade in starts prematurely but stops for a couple of seconds instead of waiting for a couple of seconds BEFORE the fade in begins.

Related

Set specific frame as thumbnail for video?

I just want some confirmation, because I have the sneaking suspicion that I wont be able to do what I want to do, given that I already ran into some errors about ffmpeg not being able to overwrite the input file. I still have some hope that what I want to do is some kind of exception, but I doubt it.
I already used ffmpeg to extract a specific frame into its own image file, I've set the thumbnail of a video with an existing image file, but I can't seem to figure out how to set a specific frame from the video as the thumbnail. I want to do this without having to extract the frame into a separate file and I don't want to create an output file, I want to edit the video directly and change the thumbnail using a frame from the video itself. Is that possible?
You're probably better off asking it in IRC zeronode #ffmpeg-devel.
I'd look at "-ss 33.5" or a more precise filter "-vf 'select=gte(n,1000)'" both will give same or very similar result at 30 fps video.
You can pipe the image out to your own process via pipe if you like of course without saving it : "ffmpeg ... -f jpeg -|..."

How to add a Poster Frame to an MP4 video by timecode?

The mvhd atom or box of the original Quicktime MOV format supports a poster time variable for a timecode to use as a poster frame that can be used in preview scenarios as a thumbnail image or cover picture. As far as I can tell, the ISOBMFF-based MP4 format (.m4v) has inherited this feature, but I cannot find a way to set it using FFmpeg or MP4box or similar cross-platform CLI software. Edit: Actually, neither ISOBMFF nor MP4 imports this feature from MOV. Is there any other way to achieve this, e.g. using something like HEIFʼs derived images with a thmb (see Amendment 2) role?
The original Apple Quicktime (Pro) editor did have a menu option for doing just that. (Apple Compressor and Photos could do it, too).
To be clear, I do not want to attach a separate image file, which could possibly be a screenshot grabbed from a movie still, as a separate track to the multimedia container. I know how to do that:
Stackoverflow #54717175
Superuser #597945
I also know that some people used to copy the designated poster frame from its original position to the very first frame, but many automatically generated previews use a later time index, e.g. from 10 seconds, 30 seconds, 10% or 50% into the video stream.

How to preserve transparency when using png to make video with ffmpeg

I have a series of png's that have an alpha channel as a background. Each file is named like file_name.0001.png and so on, in subsequent order. I'd like to join these png's into a video with ffmpeg and maintain the transparency.
I've tried a couple of things but I suspect I'm running into a codec issue. When I run ffmpeg, the video is created but the background is black.
If it makes a difference, I'm wanting to use the video in Microsoft Powerpoint. Thanks!
Edit
The suggested duplicate is very close to what I was looking for, thank you! The only reason it's not a complete solution is none of the options presented in the other thread work well with Microsoft Powerpoint. None of the codecs used in the suggested solution play well with Powerpoint. This is not the fault of ffmpeg, but of Powerpoint.
Though ffmpeg doesn't seem to be able to do what I need, I found that imagemagick did the trick. I was able to create a gif from the images and the alpha channel was preserved. I used the following:
convert -dispose 3 -coalesce images.*.png gif_file_name.gif
The -dispose 3 is critical as it tells imagemagick to clear the image prior to overlay, otherwise, you can see each image overlaid on each other (since they have the transparent background).
I couldn't get ffmpeg to create a video that preserved the alpha channel and was Powerpoint friendly (not the fault of ffmpeg). Though ffmpeg doesn't seem to be able to do what I need, I found that imagemagick did the trick. I was able to create a gif from the images and the alpha channel was preserved. I used the following:
convert -dispose 3 -coalesce images.*.png gif_file_name.gif
The -dispose 3 is critical as it tells imagemagick to clear the image prior to overlay, otherwise, you can see each image overlaid on each other (since they have the transparent background).

avformat_write_header produces invalid header (resulting MPG broken)

I am rendering a video file from input pictures that come from a 3D engine at runtime (I don't pass an actual picture file, just RGB memory).
This works perfectly when outputting MP4 using CODEC_ID_H264 as video codec.
But when I want to create an MPG file using CODEC_ID_MPEG2VIDEO, the resulting file is simply broken. No player can play the video correctly and when I then want to concatenate that MPG with another MPG file, and transform the result MP4 in another step, the resulting .mp4 file has both videos, but many frames from the original MPG video (and only video! Sound works fine) are simply skipped.
At first I thought the MPG -> MP4 conversion was the problem, but then I noticed that the initial MPG, which comes from the video render engine, is already broken, which would speak for broken headers. Not sure if it is the system or sequence headers that are broken, though.
Or if it could be something totally different.
If you want to have a look, here is the file:
http://www.file-upload.net/download-7093306/broken.mpg.html
Again, the exact same muxing code works perfectly fine when directly creating an MP4 from the video render engine, so I'm pretty sure the input data, swscale(), etc. is correct. The only difference is that CODEC_ID_H264 is used and some additional variables (like qmin, qmax, etc.) are set, which are all specific to H264 so should not have an impact.
Also, neither avformat_write_header nor av_write_trailer report an error.
As an additional info, when viewing the codec data of the MPG in VLC player, it is not able to show the FPS, resolution and format (should show 640x360, 30 fps and 4:2:0 YUV).
I am using a rather new (2-3 months old, maybe) FFmpeg version, which I compiled from sources with MinGW.
Any ideas on how to resolve this would be welcome. Currently, I am out of those :)
Alright, the problem was not the avformat_write_header, but that I did not set the PTS value of each written video packet to AV_NOPTS_VALUE.
Once I do set it for each video packet, everything works fine.
I assumed that AV_NOPTS_VALUE was the default, as I never needed to set any special PTS value.

convert swf to video in Flash Pro CS5.5

I have searched the web and here for answers but so far, the links are dead, the how-tos no longer work for the version I have, or there are no answers.
I have a swf animation with full sound and scripting that I'd like to convert into a video or an flv. For some reason, the site I post on screws with my timeline somehow (the timing is off, sounds no longer match up properly with the text) so I thought a video would work better.
I tried using File>Export>Export to movie to resolve this. I tried to export to an AVI. When it's scaled down to 300x400 it works just fine (though it looks like total crap). However when I export at the full size, using full colors no compression, I get this.
I'm not sure what to do with it. It's slanted with lines through it and grayscale. VLC player is the only thing that will run it too. WMP dies with errors, saying it's an invalid or corrupt format. Funny thing is, the thumbnail for the video is exactly what it should look like.
I'm not sure what to do with it. Converting it to an .flv is just fine. I have a video converter for that. I just can't get it to convert to flv or even a movie type properly.
Why is it doing this to my video? Is there something better to use to convert? Is there a good one that won't plaster a giant watermark over it?
image being totally screwed up.
Flabaco is an online SWF to video converter. To answer your questions: It's free, doesn't impose banners or watermarks.
I have a swf animation with full sound and scripting that I'd like to
convert into a video or an flv.
Flabaco converts scripted content. It preserves the frame rate (fps) & color. It's capable of generating professional quality HD content.
It doesn't convert sound. Nonetheless the converted quality is good and you might be able to get by using another video tool to add sound to the converted video.
You can use the online converter app here: www.Flash-Banner-Converter.com
PS: There are some older posts on StackOverflow related to your question. Just search SWF to video / Flabaco.
Kayo,
FLABACO (FLAshBAnnerCOnverter)

Resources