gpt4 book ai didi

FFMPEG 多重过滤器(缩放视频+缩放/应用水印)

转载 作者:行者123 更新时间:2023-12-04 23:10:37 26 4
gpt4 key购买 nike

有人可以告诉我将以下过滤器组合成单个命令的正确语法吗?我似乎无法弄清楚。
以下命令用于缩放视频。

ffmpeg -i input.mp4 -c:v libx264 -preset medium -crf 23 -vf scale="'if(gt(a,4/3),1280,-1)':'if(gt(a,4/3),-1,720)'" -movflags +faststart output.mp4 2>&1
然后,我使用以下代码来缩放和应用水印。
ffmpeg -i input.mp4 -vf "movie=logo.png, scale=200:-1 [wm]; [in][wm] overlay=5:main_h-overlay_h-5 [out]" output.mp4 2>&1
它们独立工作正常,但我为组合过滤器命令所做的每一次尝试都没有成功。一些帮助将不胜感激。
日志
# ffmpeg -i /var/www/html/site/public_html/media/input.mp4 \
> -i /var/www/html/site/public_html/media/logo.png \
> -c:v libx264 -preset medium -crf 23 -filter_complex "[0]scale='if(gt(a,4/3),1280,-1)':'if(gt(a,4/3),-1,720)'[main];[1]scale=200:-1[wm];[main][wm]overlay=5:main_h-overlay_h-5" -movflags +faststart \
> /var/www/html/site/public_html/media/output.mp4
ffmpeg version git-2015-04-08-b926f02 Copyright (c) 2000-2015 the FFmpeg developers
built with gcc 4.4.7 (GCC) 20120313 (Red Hat 4.4.7-11)
configuration: --prefix=/root/ffmpeg_build --extra-cflags=-I/root/ffmpeg_build/include --extra-ldflags=-L/root/ffmpeg_build/lib --bindir=/usr/bin --enable-gpl --enable-nonfree --enable-libfdk_aac --enable-libmp3lame --enable-libopus --enable-libvorbis --enable-libvpx --enable-libx264 --enable-libfreetype --enable-libtheora
libavutil 54. 22.101 / 54. 22.101
libavcodec 56. 34.100 / 56. 34.100
libavformat 56. 30.100 / 56. 30.100
libavdevice 56. 4.100 / 56. 4.100
libavfilter 5. 13.101 / 5. 13.101
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/var/www/html/site/public_html/media/input.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
creation_time : 2021-10-17 22:26:58
Duration: 00:00:02.40, start: 0.047891, bitrate: 2614 kb/s
Stream #0:0(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 81 kb/s (default)
Metadata:
creation_time : 2021-10-17 22:26:58
handler_name : Core Media Data Handler
Stream #0:1(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 716x1280, 2521 kb/s, 30 fps, 30 tbr, 600 tbn, 1200 tbc (default)
Metadata:
creation_time : 2021-10-17 22:26:58
handler_name : Core Media Data Handler
encoder : H.264
Input #1, png_pipe, from '/var/www/html/site/public_html/media/logo.png':
Duration: N/A, bitrate: N/A
Stream #1:0: Video: png, rgba, 468x100, 25 tbr, 25 tbn, 25 tbc
File '/var/www/html/site/public_html/media/output.mp4' already exists. Overwrite ? [y/N] y
[libx264 @ 0x30008a0] width not divisible by 2 (403x720)
Output #0, mp4, to '/var/www/html/site/public_html/media/output.mp4':
Metadata:
major_brand : qt
minor_version : 0
compatible_brands: qt
Stream #0:0: Video: h264, none, q=2-31, 128 kb/s, 30 fps (default)
Metadata:
encoder : Lavc56.34.100 libx264
Stream #0:1(und): Audio: aac, 0 channels, 128 kb/s (default)
Metadata:
creation_time : 2021-10-17 22:26:58
handler_name : Core Media Data Handler
encoder : Lavc56.34.100 libfdk_aac
Stream mapping:
Stream #0:1 (h264) -> scale (graph 0)
Stream #1:0 (png) -> scale (graph 0)
overlay (graph 0) -> Stream #0:0 (libx264)
Stream #0:0 -> #0:1 (aac (native) -> aac (libfdk_aac))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

最佳答案

组合命令:

ffmpeg -i input.mp4 -i logo.png -c:v libx264 -preset medium -crf 23 -filter_complex "[0]scale='if(gt(a,4/3),1280,-2)':'if(gt(a,4/3),-2,720)'[main];[1]scale=200:-1[wm];[main][wm]overlay=5:main_h-overlay_h-5" -c:a copy -movflags +faststart output.mp4
FFmpeg Filtering Intro .

关于FFMPEG 多重过滤器(缩放视频+缩放/应用水印),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69648914/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com