Win/ffmpeg - How to generate a video from images under ffmpeg? - image

I know this is with great possibility a duplicate of same questions, but I dont get it working. So how can I under windows generate a mp4 video with h265 codec and 30fps of a bunch of images.
What I have done so far is to try this answers from this post:
Duplicate Question
If I try this:
C:\\ffmpeg-3.4.2-win64-static\\bin\\ffmpeg -r 1/5 -i img%%03d.jpg -c:v libx264 -vf fps=25 -pix_fmt yuv420p out.mp4
I get the following output:
img%%03d.jpg: No such file or directory
I got filename like this:
img0001.jpg / img0002.jpg until img0030.jpg
So maybe I got the filename syntax wrong - I just dont know...
I have also tried this command:
C:\\ffmpeg-3.4.2-win64-static\\bin\\ffmpeg -framerate 29 -pattern_type glob -i img%%03d.jpg -c:v libx265 -crf 28 -c:a aac -b:a 128k output.mp4
but I get the same error..
Please help me I am not really into this ffmpeg stuff and need advice!
Maybe you can also show me how to set a directory of images in the ffmpeg params.
Thank you and greets!

Use
ffmpeg -framerate 30 -i "img%04d.jpg" -c:v libx265 -crf 28 output.mp4
Since your numbering has four digits (0001..), you need %04d.
Depending on how you're executing this command, you may need to escape the %
-pattern_type glob applies for wildcard matching, but your filename template is a smoothly numbered sequence so it's incorrect in this context.

You need to use img%%04d.jpg instead of img%%03d.jpg, because your filenames contain 4 digits.

Related

FFMPEG converting MP3 to MP4 is adding blank space, how to fix Terminal command?

I'm creating MP4 files from MP3 files + an image. Searching here at StackOverflow I found a Terminal command that gets me really close:
ffmpeg -loop 1 -r 1 -i pic.jpg -i input.mp3 -c:a copy -shortest -c:v libx264 output.mp4
Works almost perfectly so long as input.mp3 and pic.jpg are in the same folder. The problem is:
It frequently ends up with about 20-40seconds of blank space at the end of the resulting MP4. I can manually chop it off, but I'd love to find out if there's a way to alter this command so that the resulting MP4 file is exactly the length of the input MP3 file.
I don't know the ffmpeg commands well and know just enough Terminal to be dangerous. So I'm hoping it's something obvious haha.
This command should work for you:
ffmpeg -i input.mp3 -loop 1 -i pic.jpg -shortest -c:a copy -c:v mjpeg output.mp4
You do not need to set -r 1 with just one image and -loop 1.
I think -c:v mjpeg is more suitable to encode jpg than -c:v libx264.

Error initializing output stream ffmpeg on Rasbpi converting jpg to video

I have a folder with thousands of jpgs at 1024x768 that I want to convert into a single video for playback.
The error I get is Error initializing output stream 73:0 -- Error while opening encoder for output stream #73:0 - maybe incorrect parameters such as bit_rate, rate, width or height Conversion failed!
Here's my input $ ffmpeg -i Timelapse/*.jpg -c:v libx264 -preset ultrafast -crf 0 output.mkv -y
What is strange is it errors on a specific numbered output stream. It seems to be either 71:0, 72:0, or 73:0. I thought it was something wrong with the file it is attempting to process in the given stream but the resolution is all the same (as I've seen errors when its not divisible by 2). I've deleted the 71st-73rd image in hopes it was somehow messed up but that doesn't help either. I've ensured my libx264 is installed correctly as well.
Any suggestions?
Terminal output example
Problem
You forgot the -pattern_type glob input option. As a result ffmpeg expanded the wildcard (*) and interpreted image0000.jpg as the only input and all of the following images as outputs. The command was executed as:
ffmpeg -i Timelapse/image0000.jpg Timelapse/image0001.jpg Timelapse/image0002.jpg Timelapse/image0003.jpg [...] -c:v libx264 -preset ultrafast -crf 0 output.mkv -y
Because you used -y it overwrote all of the output images without asking you for confirmation.
Solution
Using the glob pattern:
ffmpeg -pattern_type glob -i 'Timelapse/*.jpg' -c:v libx264 -preset ultrafast -crf 0 output.mkv
Or using the sequence pattern which can also be used on Windows:
ffmpeg -i Timelapse/image%04d.jpg -c:v libx264 -preset ultrafast -crf 0 output.mkv
See FFmpeg image demuxer documentation for more info.

FFmpeg how generate a sequence of videos with bash

i try to write an .sh that read a folder create a playlist of mp4 files and then generate an only big video with a sequence of all videos find in the folder, and encode it for dash:
printf "file '%s'\n" ./*.mp4 > playlist.sh
ffmpeg -f concat -safe 0 -i playlist.sh -c copy concat.mp4
Till now i follow the demux concat official guido to ffmpeg website.
Without result, also the following give me "more than 1000 frames duplicated between videos of the sequence"
ffmpeg -f concat -i playlist.sh -c:a aac -b:a 384k -ar 48000 -ac 2 -c:v libx264 -x264opts 'keyint=50:min-keyint=50:no-scenecut' -r 25 -b:v 2400k -maxrate 2400k -bufsize 1200k -vf "scale=-1:432 " out.mp4
Thanks a lot
Sry, cannot comment (yet)...
Your commands are correct, I could just concat some sample videos.
Do you always get the mentioned error, or also something else? And is the video working, or no video is created?
In most cases, the input video is incorrect. Wrong input format (not fitting to file extension) or worse like ending at wrong frame.
Perhaps you can make the video available?
PS: Needed to add -safe 0 to the second command to avoid error [concat # 0x7fbfd1000000] Unsafe file name './small.mp4'
Hint: Do not use file extension .sh for your list of video files. This extension is used for shell scripts, so it can be confusing. Just use .txt.
UPDATE #Massimo Vantaggio
We should not create new answers, but I cannot comment yours and I also don't know how to continue our discussion, so I edit my answer.
Your videos don't look very different. Can't see, what's wrong with the first one.
Perhaps you could use ffprobe -report input.mp4 to get more informations. Look for errors or warnings.
My assumption is still that the video was cut in a hard way (by conversion software), so keyframes are messed up or something else.
You can also try to first reencode your video with ffmpeg. After that, it should be complete compatible with ffmpeg ;)
Something like this:
ffmpeg -i small.mp4 -acodec aac -ab 192k -vcodec libx264 -vb 1024k -f mp4 output.mp4
Use -ab and -vb from your input video, or at least the bitrate from input. Quality will decrease a little bit and file size increase, but it should be okay.

FFMPEG - Chaining commands for time lapse, size, and h.264 recursively through a directory

Working on converting videos over a directory structure. Currently I tried this:
for i in *.mov; do
ffmpeg -i "$i" -filter:v "setpts=0.1*PTS" -an -c:v libx264 -preset slow -crf 20 -c:a libvo_aacenc -b:a 128k "${i/-lapse.mov}"
done
Didn't get to the resizing but already realize this won't work this way.
Trying to make it work in this order: Timelapse video, convert size to X x Y, and make sure quality is decent.
Haven't worked too much with FFMPEG so any help is appreciated.
thanks.
Are you trying in windows? Is it MS-DOS command? If that is the case, you need to correct your command as below:
for %%i in (*.mov) do (
ffmpeg -i "%%i" -filter:v "setpts=0.1*PTS" -an -c:v libx264 -preset slow -crf 20 -c:a libvo_aacenc -b:a 128k "%%i-lapse.mov")
If it is anything to do with ffmpeg errors, rather than dos command format errors, please do post the error that you observe

JPG join MP3 to FLV

How to convert image and music to video? I would like YouTube video. I like FFMPEG command or other Ubuntu free software. I would like: *.mp3 + *.jpg = *.flv
Here is an example using a recent ffmpeg syntax:
ffmpeg -loop 1 -i image.jpg -i music.mp3 -shortest -c:v libx264 -crf 20 -tune stillimage -c:a copy output.mkv
This example will copy the audio instead of re-encoding to preserve quality. Adjust quality if desired with the CRF option. See the FFmpeg and x264 Encoding Guide for more information.
Super User (another StackExchange site) is a better place for ffmpeg usage questions since Stack Overflow is programming specific.
Today I was in need of merging an image and an audio file into a video file. Since none of the answers that I found on SO worked for me, I'm leaving here what worked for me after trial and error:
ffmpeg -loop 1 -t 205 -i audio.mp3 -i image.jpg -crf 20 test.flv
Where 205 is the duration of the input mp3 file in seconds -> 3:25 minutes.
(Tested with FFmpeg SVN-r13582)

Resources