FFMPEG spends 6 seconds to create first video frame after i feed first image to it? - ffmpeg

I use ffmpeg to convert a sequence of images to a video, i find that after i feed first image to it and almost 6 seconds later ffmpeg output first video frame to me.
I use command as follow:
ffmpeg -f image2pipe -r 100 -i pipe:0 -f flv -r 100 -tune zerolatency -preset ultrafast -bufsize 2M -codec:v libx264 -codec:a libmp3lame -bf 0 -muxdelay 0.001 -s 478x850 -b:v 2M pipe:1
Is my options is right?
Or others led to this result?
How can i get first video frame quickly once i feed the first frame?

Change probesize & analyzeduration options

Related

ffmpeg combine images and audio into video and loop through images until end of audio

I have found this code to combine multiple images and one audio file into video, but what I want is the images to loop until the end of audio. So what I mean, if I have 5 images and each image is shown for 5 seconds, after 25 seconds show again the first image, second image etc and this will continue until the end of audio.
ffmpeg -r 0.2 -i Scan-130802-%04d.jpg -i "1.mp3" \
-vcodec libx264 -vf scale=1920:1080 \
-crf 25 -preset slow -acodec copy video.mp4
another problem I have is that with the above code the images appear horizontally flipped for some reason.
It's more efficient to do this in two steps.
#1
ffmpeg -framerate 1/5 -i Scan-130802-%04d.jpg -vf "scale=1920:1080,setsar=1" -r 5 -c:v libx264 -crf 25 -preset slow scan-video.mp4
#2
ffmpeg -stream_loop -1 -i scan-video.mp4 -i "1.mp3" -codec copy -shortest -fflags +shortest -max_interleave_delta 200M video.mp4

ffmpeg - Convert MP4 to WebM, poor results

I am trying to encode a video to webm for playing through a HTML5 video tag. I have these settings...
ffmpeg -i input.mp4 -c:v libvpx-vp9 -b:a 128k -b:v 1M -c:a libopus output.webm
The results aren't great, video has lost lot's of it's sharpness. Looking at the original file I can see the bitrate is 1694kb/s.
Are there any settings I can add or change to improve the output? Would maybe a 2 pass encode improve things?
Try with
ffmpeg -i input.mp4 -c:v libvpx-vp9 -crf 30 -b:v 0 -b:a 128k -c:a libopus output.webm
Adjust the CRF value till the quality/size tradeoff is ok. Lower values produce bigger but better files.
Try to run two passes:
ffmpeg -i file.mp4 -b:v 0 -crf 30 -pass 1 -an -f webm -y /dev/null
ffmpeg -i file.mp4 -b:v 0 -crf 30 -pass 2 output.webm
From - https://trac.ffmpeg.org/wiki/Encode/VP9

Fade out in ffmpeg when creating a video from a still image is wonky?

I'm creating a video that:
uses a still image as a source
has a text overlay
fades in and out
has a silent stereo audio track.
So far, I have this, and it (almost) works correctly:
ffmpeg -f lavfi -i "aevalsrc=0|0" -loop 1 -i turtle-2.jpg -c:v libx264 -t 5 -r 30 -s 1920x1080 -aspect 16:9 -pix_fmt yuv420p -filter:v drawtext="fontsize=130:fontfile=comic.ttf:text='hello world':x=(w-text_w)*.25:y=(h-text_h)*.75",fade=in:0:60,fade=out:90:60 -acodec aac turtle11.mp4
The only problem is that the fade out doesn't seem to be going to black, even tho this is a 150 frame video and I believe I am following the ffmpeg documentation correctly.
The resulting video is here:
http://video.blivenyc.com/vid-from-image/turtle11.mp4
Any thoughts?
Well, I'm not sure why but this works, even tho it appears to be equivalent:
ffmpeg -f lavfi -i "aevalsrc=0|0" -loop 1 -i turtle-2.jpg -c:v libx264 -t 5 -r 30 -s 1920x1080 -aspect 16:9 -pix_fmt yuv420p -filter:v drawtext="fontsize=130:fontfile=comic.ttf:text='hello world':x=(w-text_w)*.25:y=(h-text_h)*.75",fade=t=in:st=0:d=1,fade=t=out:st=4:d=1 -acodec aac turtle12.mp4
Basically, frame-based syntax:
fade=in:0:60,fade=out:90:60
gets substitued with time-based:
fade=t=in:st=0:d=1,fade=t=out:st=4:d=1
And somehow it works. Not sure why this is.
The video stream on which the fade filter operates is not 150 frames long. Input and output framerates are different here. The use of -r to set output rate happens after all filtering is done. At that stage, ffmpeg will drop or duplicate frames to obtain the output rate.
The input rate for an image or image sequence is 25, unless expressly set otherwise. In your command, since there is no override, it's 25. So fade out of 60 frames starting at frame 90, will end at frame 125 (5 seconds x 25). ffmpeg will duplicate 5 frames of each input second to get it to 30.
To get the desired result, use
ffmpeg -f lavfi -i "aevalsrc=0|0" -loop 1 -framerate 30 -i turtle-2.jpg -c:v libx264 -t 5 -s 1920x1080 -aspect 16:9 -pix_fmt yuv420p -filter:v drawtext="fontsize=130:fontfile=comic.ttf:text='hello world':x=(w-text_w)*.25:y=(h-text_h)*.75",fade=in:0:60,fade=out:90:60 -acodec aac turtle11.mp4

ffmpeg rtmp stream taking 100% CPU

I am creating a small script to stream a images on rtmp server but FFMPEG command taking 100% CPU. Please have a look on my code.
ffmpeg -f lavfi -i anullsrc=channel_layout=stereo:sample_rate=44100 -loop 1 -i "Digital-Wallet-.jpg" -t 00:30:00 -r 1 -c:v libx264 -c:a aac -preset:v ultrafast -pix_fmt yuv420p -f flv "rtmp://rtmpserver"
Encoding is CPU intensive. Remove -r 1 and add -framerate 1, -re, and -shortest.
ffmpeg -f lavfi -i anullsrc -loop 1 -framerate 1 -re -i "Digital-Wallet-.jpg" -t 00:30:00 -c:v libx264 -c:a aac -preset:v ultrafast -pix_fmt yuv420p -shortest -f flv "rtmp://rtmpserver"
The default image demuxer frame rate is 25, so your command was unnecessarily converting 25 frames per second to 1 frame per second which is inefficient. The above changes fixes that.
-re will slow down the reading of the input to the native frame rate of the input. It is useful for real-time output and live streaming. Otherwise ffmpeg will attempt to encode as fast as possible.
I added -shortest to end the output when the shortest stream ends (the image) because anullsrc was set to encode indefinitely.

FFMPEG (windows7) can't get the output video to show more than 3 out of 10 jpgs

I have 10 jpg files (image0.jpg, image1.jpg, image2.jpg ... image9.jpg) and one .mp3 and I'm trying to create a video but I can't get it to show more than the first 3 images in the output.
I played with the output -r option and for example if I change it to 30 it shows all of them but very fast so the whole video plays for under a second.
This is my code:
ffmpeg -i image%d.jpg -i audio.mp3 -r 1 -c:v libx264 -tune stillimage -c:a aac -strict experimental -b:a 192k -r 1/5 -pix_fmt yuv420p -shortest out.mp4
What am I doing wrong ?
The image file demuxer by default uses a frame rate of 25 fps if you do not tell it otherwise. Since you used -r 1/5 as an output option the frame rate will be converted resulting in duplicated or, as in your case, dropped frames to compensate. To change this use -framerate as an input option (this is a private option of the image file demuxer):
ffmpeg -framerate 1/5 -i image%d.jpg output
Some crappy players may not like a "non-standard" frame rate, so you can add an output frame rate to change it while keeping the "timing" of the input:
ffmpeg -framerate 1/5 -i image%d.jpg -r 25 output

Resources