ffmpeg GIF to WebM decoding issue - ffmpeg

I'm trying to convert GIF files into WebM (ffmpeg, libvpx) and getting some strange ffmpeg behaviour.
ffmpeg is installed on my mac from MacPorts.
Converting with:
ffmpeg -i srcFilename.gif -b:v 600K -qmin 0 -qmax 50 -crf 5 destFilename.webm
if my GIF file has some frame(s) with 1-2s duration somewhere in the middle of animation like this, conversion result is fine - it's playing with the "pause" in the middle.
But if I have GIF like this with "pause" in the last frame, ffmpeg decodes it without a delay.
Have no idea why, spent some time reading ffmpeg manual, trying different conversion options with no success.
Any ideas? Thanks in advance!

I wrote an email to GIF decoder author and he answered me that he knows about this issue. It's located somewhere deep inside of ffmpeg and he has no idea how to fix it right now.
So, I'm using "dirty hack" in my project - just adding copy of last frame with zero delay to GIF file before encoding.

Related

Morphing images into each other using ffmpeg

I have a directory containing jpegs. Using ffmpeg I want to read the images and create a video out of it. The images should morph into each other, every image should be visible ~2 seconds.
So far, I came up with this:
ffmpeg -i %d.jpg -c:v libx264 -pix_fmt yuv420p ./bla.mp4
Now what I'm missing is the morping part. I know there is a "morph" filter, however no matter how I try it, I either get an error that No such filter: 'morph' (even tho I compiled ffmpeg on own, making sure the needed libs are included) or I get a random 0xfff something error.

How to fix "moov atom not found" when extracting an image from partial video mp4 file?

I think the problem is relatively common, but I can't find any good solution to my problem.
Well, I need to create a preview of the video while it uploads. It can be a very big video, so I decided to use only the first 10 Mb of video to make image extraction with ffmpeg.
The command-line looks like this
ffmpeg -ss 00:00:00 -i "src.mp4" -frames:v 1 -q:v 2 "preview.jpg"
It works fine for lots of video files, but for mp4 it always failed with the error message "Moov atom not found". I guess the mp4 format is not streamable and the cut file looks like a broken video for the FFmpeg.
But there should be a solution to this. Could you help me?

ffmpeg record screen file formats

Good day,
I'm currently writing a bash script which records the screen under certain conditions. The problem is that only avi works as a file extension for recording the screen. This script is going to be used on an Raspberry Pi and currently I get on a decent virtual machine only 10-20 fps (goal would be around 30 fps). I think .avi is not suited for my project. But .mpeg and .mp4 are not working for recording. I tried recording with .avi and then converting it in .mp4, but I have limited memory and .avi ist just too big in size. I use currently the following command:
ffmpeg -f x11grab -y -r 30 -s 960x750 -i :0.0+0,100 -vcodec huffyuv ./Videos/out_$now.avi
//$now is the current date and time
So I wanted to know if I need some special packages from ffmpeg to record with for example .mp4 or if there are other file formats available for ffmpeg screen recording.
Edit:
I found that the codec libx264 for mp4 works, but the fps drop until they hit5 fps, which is definetly too low. The recorded video appeared like being a fast forward version of the recorded screen.
With mpeg4 for mpeg I reached over 30 fps, but the video qualitywas very bad.
It appears that even my big avi-files look like being played fast forward. Is there something I do wrong?
Is there a good middle way, where I get a decend video quality, good fps (20+) and a file which isn't too big?
Edit 2:
I tried recording it with .avi and converting it afterwards. Just converting with ffmpeg -i test.avi -c:a aac -b:a 128k -c:v libx264 -crf 23 output.mp4
resulted in the same framedrops as if I was recording with .mp4. But when I cut a littlebit of the beginning of the video and named the outputfile .mp4, the size became much smaller. But when I started the cutting at 0:00:00 (so tried just converting), it just changed the file format without converting it (so the size stayed the same). Any ideas?

Extracting thumbnails from a video for creating sprite is really slow on large videos

I have to create 'preview' on video progress hover. I'm doing with a sprite image and WebVTT file. Using ffmpeg and imagemagick. However generating thumbnails from a mp4 video is really damn slow (20-30 minutes for 2hrs and 20 min long video). The video is Full HD, H246 encoded, 2GB big. The command used
"ffmpeg.exe -i largevideo.mp4 -f image2 -bt 20M -vf fps=1/5 thumbs-%03d.jpg"
Which means thumb for every 5 secs of the video. Is there a way to make it faster? Videos in prod can be even bigger.
OS: Win10, ImageMagick is used later to create the sprite from all the thumbnails created with ffmpeg.
Skip everything except keyframes:
ffmpeg -skip_frame nokey -i input.mp4 -vsync passthrough thumbs-%03d.jpg
Also see:
Get keyframe intervals
Control JPG quality

ffmpeg: concatenating mp4 files. Video freezes for few seconds on first frame on output mp4

I created several MP4 files using ffmpeg. All of the videos have same settings and codec. Only difference is frames per second and duration. I then concatenated the videos using command below.
ffmpeg -f concat myList.txt -c copy output.mp4
I notice that when launching/opening the output.mp4 file in windows media player, it stops/freezes on the first frame of the video for about three four seconds and then starts playing, rest of the videos has correct fps and runs smoothly. Has anyone encountered this issue. I would like the video to start as soon as it is launched. Any suggestions to mitigate this issue?
Update: So far, I have found that the video length is exactly what I expect it to be.
ffprobe -i output.mp4
When i ffplay the video, it runs smoothly, but when I use windows media player, it gets stuck in first frame for about 4-5 seconds then plays smoothly. So I am going to assume that this issue is related to media players (buffers/loading before playing). Can't be sure though.
I solved this problem by converting my input files to avi and resizing them to the same size.
And then run
ffmpeg -i "concat:file1.avi|file2.avi|" -c copy out.avi

Resources