FFMPEG has not managed to vstack - ffmpeg

Can somebody tell me what's wrong with this ffmpeg line? I'm getting error:
Input 1 width 619 does not match input 0 width 618.
Failed to configure output pad on Parsed_vstack_3
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #2:0
The width of white solid was set correctly to 619.
ffmpeg -i image_1.jpg -i image_2.jpg -f lavfi -i "color=c=white:s=619x800" -filter_complex "[0][1]scale2ref=w=oh*mdar:h='max(ih,main_h)'[0max][1ref];[1ref][0max]scale2ref=w=oh*mdar:h='max(ih,main_h)'[1max][0max];[2][0max]overlay=x=132[overl];[overl][1max]vstack" -frames:v 1 -q:v 1 -y combined.jpg
View error screenshot
ERROR with format=yuv444p
Became gray

Default pixel format for color filter is yuv420p, which only accepts even numbers, so ffmpeg is actually outputting 618 as width.
Use
-f lavfi -i "color=c=white:s=619x800,format=yuv444p"

Related

FFmpeg more than 1000 frames duplicated and input height doesn't match

I'm currently using this code to record two windows side by side:
ffmpeg -f gdigrab -framerate 30 -i title="" -f gdigrab -framerate 30 -i title="" -c:v h264_nvenc -qp 0 -filter_complex hstack=inputs=2 2.mp4
However it throw this error after execution:
More than 1000 frames duplicated
Error Log: https://pastebin.com/gREVrKVK
The first window mostly time is the same frame, maybe 1 frame change in each 3 sec.
Another error in console is when the first window have a different height than second window, error:
[Parsed_hstack_0 # 000002491166fd00] Input 1 height 500 does not match input 0 height 488.
[Parsed_hstack_0 # 000002491166fd00] Failed to configure output pad on Parsed_hstack_0
Error log: https://pastebin.com/vqdBPfpv
Looks like is not possible to record when they have different dimensions, so, if possible I would like to ask how to scale the first window to the same height (doesn't need to keep aspect ratio) of the second window, considering low CPU use above the video quality.
Question 1: How to match input heights?
Original images
scale2ref
Make input0 height match input1 height with the scale2ref filter:
ffmpeg -i input0 -i input1 -filter_complex "[0][1]scale2ref=w=oh*mdar:h=ih[left][right];[left][right]hstack" output
Fit into specific size
Make each input fit into 175x100 with gray background:
ffmpeg -i input0 -i input1 -filter_complex "[0]scale=175:100:force_original_aspect_ratio=decrease,pad=175:100:-1:-1:color=gray,setsar=1[left];[1]scale=175:100:force_original_aspect_ratio=decrease,pad=175:100:-1:-1:color=gray,setsar=1[right];[left][right]hstack" output
More examples: Resizing videos with ffmpeg to fit into static size.
Question 2: More than 1000 frames duplicated
Refer to the warning in your log:
[mp4 # 0000026082276400] Frame rate very high for a muxer not efficiently supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
Add the -vsync 2 output option, or output to a different format such as .mkv.

ffmpeg - why does hstack fail with " width not divisible by 2" When both of my inputs have even heights?

Here's the command I'm using to horizontally stack 2 mp4's together:
ffmpeg -y -i input1.mp4 -i input2.mp4 -filter_complex "[0:v][1:v]hstack[v]" -map "[v]" -vsync 0 stacked.mp4
input1.mp4 has dimensions 594x512, and input2.mp4 has dimensions 512x512. I get this error in return:
width not divisible by 2 (1113x512)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
The confusing thing is that 1113 is such an odd number - it is not 1024, and not even 512+594 (1106). What is causing the assumed width to be such a strange value?
Windows Explorer is incorrect. It does not properly support yuvj444p, so it is giving a wrong width.

FFMPEG Input area failure

I'm trying to convert an input clip to a fixed, padded output and applying an overlay on it.
This command works fine for resizing:
ffmpeg -y -i clip.mp4 -vf scale="min(iw*375/ih\,500):min(375\,ih*500/iw),pad=500:375:(500-iw)/2:(375- ih)/2" output.mp4
I created the following one to make sure the overlay would be created:
ffmpeg -y -i clip.mp4 -i clip_overlay.png -strict -2 -filter_complex "[0]scale=min(iw*375/ih\,500):min(375\,ih*500/iw),pad=500:375:(500-iw)/2:(375-ih)/2[v];[v][1]overlay=x=W-w-5:y=H-h-5" output.mp4
I cannot find the error, but ffmpeg returns:
[Parsed_pad_1 # 0x2eae8e0] Input area 144:0:355:375 not within the padded area 0:0:500:374 or zero-sized
[Parsed_pad_1 # 0x2eae8e0] Failed to configure input pad on Parsed_pad_1
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #1:0
[aac # 0x2eb3020] Qavg: 102.113
[aac # 0x2eb3020] 2 frames left in the queue on closing
Why does that upper command work, and combined with the second one, it doesn't?
The most common pixel format in a typical MP4 video stream is yuv420p and the default encoder (x264) requires that the dimensions be even.
So, set pad to use even dimensions,
ffmpeg -y -i clip.mp4 -i clip_overlay.png -strict -2 -filter_complex "[0]scale=min(iw*375/ih\,500):min(375\,ih*500/iw),pad=500:376:(500-iw)/2:(376-ih)/2[v];[v][1]overlay=x=W-w-5:y=H-h-5" output.mp4

FFMPEG - height not divisible by 2

i have an problem with ffmpeg. i would like to format a image sequence into a video. I use the followed command for this:
ffmpeg -framerate 24 -i image%04d.jpeg Project.mp4 -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2"
i have 4 pictures:
image0001.jpeg
image0002.jpeg
image0003.jpeg
image0004.jpeg
With this command, i get the following error:
[libx264 # 000001f12e7a0540] height not divisible by 2 (1200x1599)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0 - maybe
incorrect parameters such as bit_rate, rate, width or height
Conversion failed!
Can someone tell me why this mistake comes and how can I fix it?
Thanks
Option placement matters:
ffmpeg [input options] -i input [output options] output
Any trailing options (ones after the output), such as your -vf, may be ignored.
Corrected command:
ffmpeg -framerate 24 -i image%04d.jpeg -vf "pad=ceil(iw/2)*2:ceil(ih/2)*2" Project.mp4

Getting Exception while merging two file with ffmpeg

I am trying to merge two mp4 files using ffmpeg command. My input files are not in same encoding so they are not merge with normal command. I have use below command but got exception.
Command: -
ffmpeg -i File_1.mp4 -i File_2.mp4 -filter_complex "[0:v]setsar=1[0v];[1:v]scale=720:576:force_original_aspect_ratio=decrease,setsar=1,pad=720:576:(ow-iw)/2:(oh-ih)/2[1v];[0v][0:a][1v][1:a]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" -c:v libx264 -crf 23 ffmpeg1.mp4
Exception I have got: -
[Parsed_concat_4 # 00000000067ea380] Input link in1:v0 parameters (size 720x576, SAR 1:1) do not match the corresponding
output link in0:v0 parameters (320x240, SAR 1:1)
[Parsed_concat_4 # 00000000067ea380] Failed to configure output pad on
Parsed_concat_4
Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #1:0
Conversion failed!
Please tell me what is the solution for that or any command which can help me out with merge any two mp4 file in windows using cmd.
The concat filter requires all its video inputs to have the same resolution and sample aspect ratio. The framerate and pixel format can differ, though the output may not be what you want.
So, in this command, alter the filtering of the first video input to match the second.
ffmpeg -i File_1.mp4 -i File_2.mp4 -filter_complex "[0:v]scale=720:576:force_original_aspect_ratio=decrease,setsar=1,pad=720:576:(ow-iw)/2:(oh-ih)/2[0v];[1:v]scale=720:576:force_original_aspect_ratio=decrease,setsar=1,pad=720:576:(ow-iw)/2:(oh-ih)/2[1v];[0v][0:a][1v][1:a]concat=n=2:v=1:a=1[outv][outa]" -map "[outv]" -map "[outa]" -c:v libx264 -crf 23 ffmpeg1.mp4

Resources