Error initializing output stream ffmpeg on Rasbpi converting jpg to video - ffmpeg

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.

Related

ffmpeg error: Unable to find a suitable output format for 'scale=1500:1000'

I am trying to convert a bunch of images into a video. The original image resolution is 6000x4000, but if I use ffmpeg to create a video with that resolution, no player can even play it because it's way to huge.
I tried to set the output resolution as such, dividing the input resolution by 4:
ffmpeg -r 60 -s 1500x1000 -start_number 3790 -i DSC_%04d.jpg -vcodec libx264 -crf 25 -pix_fmt yuv420p ../video_lowres.mp4
This had no effect and still produced 6000x4000 video. So instead, I tried this parameter: scale=1500:1000 The full command I ran:
ffmpeg -r 60 scale=1500:1000 -start_number 3790 -i DSC_%04d.jpg -vcodec libx264 -crf 25 -pix_fmt yuv420p ../video_lowres.mp4
But I got this error:
[NULL # 000002ad897bd9c0] Unable to find a suitable output format for 'scale=1500:1000'
scale=1500:1000: Invalid argument
How can I create a downscaled video from photos using ffmpeg?
You need to enter -vf before scale to tell FFmpeg that you want to use a video filter. Also, it should be specified after the filename of the image as it's an output option, not an input option. You can put it just before the output name:
ffmpeg -r 60 -start_number 3790 -i DSC_%04d.jpg -vcodec libx264 -crf 25 -pix_fmt yuv420p -vf scale=1500:1000 ../video_lowres.mp4

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

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.

Error using FFMPEG to create videos from a list of images

I have a text file that contains the path of some images(the images are in order in the text file), the file looks like this:
/home/Recording-Session-1456734351095_images/output_0001.png
/home/Recording-Session-1456734351095_images/output_0002.png
/home/annotations/rec_1456734351095/annotated_output_0003.png
.......
I want to use ffmpeg to create a video from these images. Here is the command I am using:
ffmpeg -framerate 20 -f image2 -i images.txt -c:v libx264 -r 20 -pix_fmt yuv420p out.mp4
but it gives me this error:
[image2 # 0x32ce7a0] Could not find codec parameters for stream 0 (Video: none, none): unknown codec
Consider increasing the value for the 'analyzeduration' and 'probesize' options
I tried different numbers for analyzeduration and probesize, but the error still exists, any idea what is the problem?
The images demuxer does not take a text file as input. You can use the concat demuxer or collect your images in one folder and make them consecutively named.
Using concat demuxer,
ffmpeg -r 20 -f concat -i images.txt -c:v libx264 -pix_fmt yuv420p out.mp4
Or using image2
ffmpeg -framerate 20 -i /home/Recording-Session-1456734351095_images/output_%04d.png -c:v libx264 -r 20 -pix_fmt yuv420p out.mp4
It's preferable to do the latter.

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

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