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
Related
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.
i tried to scale the video to 375x500 using ffmpeg.
ffmpeg -i input.mp4 -s 375x500 -c:a copy output.mp4
Getting this error, [libx264 # 0x5639d358ad60] width not divisible by 2 (375x500)
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.
I tried so many commands but i didnt get my solution.
libx264 requires width/height to be divisible by 2 when using the standard yuv420p pixel format. Refer to the many suggestions regarding how to fix the not divisible by 2 error with scale/pad/crop:
FFMPEG (libx264) “height not divisible by 2”
ffmpeg : width not divisible by 2 (when keep proportions)
ffmpeg add watermark libx264 width not divisible by 2 (853x480)
However, if you must have exactly 375x500 then you have to use a pixel format that supports this size:
ffmpeg -i input.mp4 -vf "format=yuv444p,scale=375:500" -c:a copy output.mp4
Drawback is that almost no player or device will be able to play it (unless it uses FFmpeg).
See the format and scale filter documentation and the output of ffmpeg -pix_fmts for more info.
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
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"
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