Opened 5 months ago
Last modified 5 months ago
#11044 new defect
Frustrated "pad" usage per poor documentation
Reported by: | elias tsolis | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | documentation |
Version: | unspecified | Keywords: | |
Cc: | MasterQuestionable | Blocked By: | |
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
I found it very frustrating to center a video
the original dimensions was: Width 1920 pixels and Height : 1080 pixels. I wanted to make new dimensions with padding as: (h)3840x(w)2160
I found these problems
if i put height/2 or iw/2 or ow/2 are not recognised.
I could not understand when iw ow or height can be interpret and when not. There are not taken automatically from videofile? I must define explicity somewhere these variables?
What is the diff between "=" and ":"?
for eg.
this works
"pad=width=2160:height=3840:x=3840/2:y=2160/2:color=red"
this does not work
"pad=width=2160:height=3840:x=width/2:y=height/2:color=red"
"pad=width=2160:height=3840:x=iw/2:y=ih/2:color=red"
"pad=iw=2160:ih=3840:x=iw/2:y=ih/2:color=red"
"pad=iw:2160:ih:3840:x=iw/2:y=ih/2:color=red"
This was very frustrated for me.
you explicity says in your manual:
"in_w
in_h
The input video width and height.
iw
ih
These are the same as in_w and in_h.
"
Also i cant understand when to use "()" for expressions and when not.
You must explicity explain in your manual these things.
I spent almost 4 hours+ to nothing.
This works:
rm a_t.mp4; for vids in *.mkv; do ffmpeg -i "$vids" -ss 0:00:00 -to 00:00:01 -vf "pad=width=2160:height=3840:x=3840/2:y=2160/2:color=red" -video_track_timescale 90000 -crf 19 -vcodec libx265 -an "a_${vids/.*}.mp4"; done; this does not: rm a_t.mp4; for vids in *.mkv; do ffmpeg -i "$vids" -ss 0:00:00 -to 00:00:01 -vf "pad=width=2160:height=3840:x=height/2:y=width/2:color=red" -video_track_timescale 90000 -crf 19 -vcodec libx265 -an "a_${vids/.*}.mp4"; done;
ffmpeg --version ffmpeg version N-115575-g4e120fbbbd Copyright (c) 2000-2024 the FFmpeg developers built with gcc 13 (Debian 13.2.0-25) configuration: --prefix=/home/eros/ffmpeg_build --pkg-config-flags=--static --extra-cflags=-I/home/eros/ffmpeg_build/include --extra-ldflags=-L/home/eros/ffmpeg_build/lib --extra-libs='-lpthread -lm' --ld=g++ --bindir=/home/eros/bin --enable-gpl --enable-gnutls --enable-libaom --enable-libass --enable-libfreetype --enable-libmp3lame --enable-libopus --enable-libsvtav1 --enable-libdav1d --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libx265 --enable-nonfree libavutil 59. 21.100 / 59. 21.100 libavcodec 61. 6.100 / 61. 6.100 libavformat 61. 3.104 / 61. 3.104 libavdevice 61. 2.100 / 61. 2.100 libavfilter 10. 2.102 / 10. 2.102 libswscale 8. 2.100 / 8. 2.100 libswresample 5. 2.100 / 5. 2.100 libpostproc 58. 2.100 / 58. 2.100
Change History (7)
comment:1 by , 5 months ago
comment:2 by , 5 months ago
You can simplify the command if you specify the parameters in the correct order (as listed in the documentation):
"pad=2160:3840:iw/2:ih/2:red"
comment:3 by , 5 months ago
Cc: | added |
---|---|
Component: | undetermined → documentation |
Summary: | padding is very frustrating. → Frustrated "pad" usage per poor documentation |
͏ In filter description:
͏ ":" as the separator of options.
͏ "=" as the name-value separator of each option.
͏ See also:
͏ https://ffmpeg.org/ffmpeg-filters.html#Filtergraph-syntax-1
͏ Usage of parentheses mostly follows their typical definition in other programming languages: merely as priority/associativity override.
͏ The doc is indeed horrible to some extent.
͏ However due to the framed choice of rendering scheme (Texinfo) that few would understand how to properly write:
͏ Fix may not be easy.
comment:4 by , 5 months ago
weird what worked for you not worked for me and what didnt work for you worked for me.
What ffmpeg edition you have and in what software? Linux?
comment:6 by , 5 months ago
why in the example of link uses double parenthensis?
pad=320:240:(( (ow - iw)/2 )):(( (oh - ih)/2 ))
comment:7 by , 5 months ago
͏ Why don't we write everything in one-liner and get rid of comments?..
͏ The "(( ... ))" concept is derived from Unix "$(( ... ))":
͏ https://pubs.opengroup.org/onlinepubs/9699919799.2018edition/utilities/V3_chap02.html#tag_18_06_04
͏ https://www.google.com/search?hl=en&gl=ca&num=100&q=site:pubs.opengroup.org/onlinepubs/9699919799+-intitle:%22Index+of+/onlinepubs%22+-inurl:idx+-inurl:contents.html+-inurl:toc.html+-inurl:9699919799.orig+-inurl:2008edition+-inurl:2013edition+-inurl:2016edition+-inurl:2018edition+%22Arithmetic+Expansion%22
Replying to elias tsolis:
Your second example has the correct syntax and works for me:
ffmpeg -f lavfi -i testsrc2=s=1920x1080 -vf "pad=width=2160:height=3840:x=iw/2:y=ih/2:color=red" -y out.png