我们正在尝试让此 pad 滤镜将背景白色扩展到视频的整个宽度,同时保持视频居中,而不会破坏其宽高比。我们尝试过的所有方法都没有奏效。
使用的命令:
ffmpeg -y -ss 0 -to 14 -i video-input.mp4 -t 14 -preset ultrafast -crf 18 -filter_complex "[0:v]scale=878:494:force_original_aspect_ratio=increase,pad=width=878:height=494:x=(ow-iw)/2:y=(oh-ih)/2:color=white,settb=expr=1/25,fps=25,format=yuv420p[v]" -codec:v libx264 -r 25 -map [v] video.mp4
命令日志:
ffmpeg version 4.4-1ubuntu0~20.04.sav0.1 Copyright (c) 2000-2021 the FFmpeg developers
built with gcc 9 (Ubuntu 9.3.0-17ubuntu1~20.04)
configuration: --prefix=/usr --extra-version='1ubuntu0~20.04.sav0.1' --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocketsphinx --enable-librsvg --enable-libdav1d --enable-libzimg --enable-crystalhd --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 --enable-shared
libavutil 56. 70.100 / 56. 70.100
libavcodec 58.134.100 / 58.134.100
libavformat 58. 76.100 / 58. 76.100
libavdevice 58. 13.100 / 58. 13.100
libavfilter 7.110.100 / 7.110.100
libavresample 4. 0. 0 / 4. 0. 0
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video-input.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
Duration: 00:00:14.93, start: 0.000000, bitrate: 4029 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 878x494 [SAR 1171:3700 DAR 514069:913900], 4026 kb/s, SAR 2223:7024 DAR 9:16, 23.98 fps, 23.98 tbr, 24k tbn, 47.95 tbc (default)
Metadata:
handler_name : ETI ISO Video Media Handler
vendor_id : [0][0][0][0]
Input #1, mp3, from 'audio.mp3':
Metadata:
encoder : Lavf58.29.100
Duration: 00:04:47.22, start: 0.025057, bitrate: 128 kb/s
Stream #1:0: Audio: mp3, 44100 Hz, stereo, fltp, 128 kb/s
Metadata:
encoder : Lavc58.54
Stream mapping:
Stream #0:0 (h264) -> scale
format -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[libx264 @ 0x55711e821b40] using SAR=1171/3700
[libx264 @ 0x55711e821b40] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x55711e821b40] profile Constrained Baseline, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x55711e821b40] 264 - core 161 r3039 544c61f - H.264/MPEG-4 AVC codec - Copyleft 2003-2021 - http://www.videolan.org/x264.html - options: cabac=0 ref=1 deblock=0:0:0 analyse=0:0 me=dia subme=0 psy=1 psy_rd=1.00:0.00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=0 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=15 lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=0 weightp=0 keyint=250 keyint_min=25 scenecut=0 intra_refresh=0 rc=crf mbtree=0 crf=18.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=0
Output #0, mp4, to 'video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
encoder : Lavf58.76.100
Stream #0:0: Video: h264 (avc1 / 0x31637661), yuv420p(tv, bt709, progressive), 878x494 [SAR 2223:7024 DAR 9:16], q=2-31, 25 fps, 12800 tbn (default)
Metadata:
encoder : Lavc58.134.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame= 1 fps=0.0 q=0.0 size= 0kB time=00:00:00.00 bitrate=N/A speed= frame= 350 fps=0.0 q=-1.0 Lsize= 14022kB time=00:00:13.96 bitrate=8228.2kbits/s speed=31.9x
video:14019kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.016606%
[libx264 @ 0x55711e821b40] frame I:2 Avg QP:16.00 size:106657
[libx264 @ 0x55711e821b40] frame P:348 Avg QP:20.22 size: 40638
[libx264 @ 0x55711e821b40] mb I I16..4: 100.0% 0.0% 0.0%
[libx264 @ 0x55711e821b40] mb P I16..4: 20.6% 0.0% 0.0% P16..4: 65.3% 0.0% 0.0% 0.0% 0.0% skip:14.1%
[libx264 @ 0x55711e821b40] coded y,uvDC,uvAC intra: 99.0% 98.0% 89.1% inter: 63.2% 54.4% 32.8%
[libx264 @ 0x55711e821b40] i16 v,h,dc,p: 1% 88% 5% 5%
[libx264 @ 0x55711e821b40] i8c dc,h,v,p: 12% 81% 2% 5%
[libx264 @ 0x55711e821b40] kb/s:8203.02
我们尝试过增加/减少或缩放到不同的分辨率,但无法成功。谢谢!