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

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

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

Merge one audio file and one image file to create a video with ffmpeg

I first tried:
ffmpeg -y -i image.jpg -i audio.mp3 -c:a copy output.mp4
but when I uploaded to video sharing websites (bilibili.com), it says "no video track", so I tried:
ffmpeg -r 1 -loop 1 -i image.jpg -i audio.mp3 -acodec copy -r 1 -shortest output.mp4
The file was successfully uploaded, but when I watched it on the website, the image disappeared and it turned grey. I merged 6 videos and only one of them can be normally played back.
What should I do?
Problems with your command #2:
Frame rate is too low. Most players are unable to play 1 fps. Use 10 fps or higher for output, or set input -framerate to 10 fps or higher.
Chroma subsampling. Most players can only play 4:2:0, so use the format filter to force it to 4:2:0.
MP3 in MP4. Some players are unable to play MP3 in MP4. For highest compatibility use AAC. ffmpeg will choose AAC by default for MP4.
Faststart (optional). Add -movflags +faststart so MP4 can begin playback faster.
Command:
ffmpeg -framerate 1 -loop 1 -i image.jpg -i audio.mp3 -vf format=yuv420p -r 10 -shortest -movflags +faststart output.mp4

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

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

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

encoding jpeg as h264 video

I am using the following command to encode an AVI to an H264 video for use in an HTML5 video tag:
ffmpeg -y -i "test.avi" -vcodec libx264 -vpre slow -vpre baseline -g 30 "out.mp4"
And this works just fine. But I also want to create a placeholder video (long story) from a single still image, so I do this:
ffmpeg -y -i "test.jpg" -vcodec libx264 -vpre slow -vpre baseline -g 30 "out.mp4"
And this doesn't work. What gives?
EDIT: After trying LordNeckbeards answer, here is my full output: http://pastebin.com/axhKpkLx
Example for a 10 second output:
ffmpeg -loop 1 -framerate 24 -i input.jpg -c:v libx264 -preset slow -tune stillimage -crf 24 -vf format=yuv420p -t 10 -movflags +faststart output.mp4
Same thing but with audio. The output duration will match the input audio duration:
ffmpeg -loop 1 -framerate 24 -i input.jpg -i audio.mp3 -c:v libx264 -preset slow -tune stillimage -crf 24 -vf format=yuv420p -c:a aac -shortest -movflags +faststart output.mp4
-loop 1 loops the image input.
-framerate sets the frame rate of the image input. Default is 25. Some players have issues with low frame rates so a value over 6 or so is recommended.
-i input.jpg the input.
-c:v libx264 the H.264 video encoder.
-preset x264 encoding preset. Use the slowest one you can.
-tune x264 tuning for various adjustments to fit specific situations.
-crf for quality. A lower value results in higher quality. Use the highest value that still provides an acceptable quality to you. Default is 23.
-vf format=yuv420p outputs the pixel format as yuv420p. This ensures the output uses a widely acceptable chroma sub-sampling scheme. Recommended for libx264 when encoding from images.
-c:a aac the AAC audio encoder. If your input is already AAC or M4A then use -c:a copy instead to stream copy instead of re-encode.
-t 10 (in the first example) makes a 10 second output. Needed because the image is looping indefinitely.
-shortest (in the second example) makes the output the same duration as the shortest input. In this case it is the audio since the image is looping indefinitely.
-movflags +faststart relocates the moov atom to the beginning of the file after encoding is finished. Allows playback to begin faster in progressive download playing; otherwise the whole video must be downloaded before playing.
-profile:v main (optional) some devices can't handle High profile.
See FFmpeg Wiki: H.264 for more info.

Resources