gpt4 book ai didi

node.js - ffmpeg:当输入缩放到某些尺寸时,xstack 不起作用

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

我正在使用 ffmpeg 使用 xstack 创建视频马赛克筛选。输入视频可能有不同的尺寸,所以我使用 scale过滤以预先缩放它们,我正在使用 force_original_aspect_ratio选项,然后是 pad过滤以保持每个视频的原始纵横比,并在两侧添加黑条以使每个视频具有正确的尺寸。

我有一个有效的命令 - 但是,它是不一致的。对于某些维度,它有效,而对于其他维度则无效。

我正在使用 fluent-ffmpeg Node.js 模块调用 ffmpeg来自 Node.js。为此,我将一个字符串数组传递给 complexFilter()功能。

复杂过滤器的以下字符串有效:

"[0:v]scale=400:250:force_original_aspect_ratio=decrease,pad=400:250:(ow-iw)/2:(oh-ih)/2 [s0]"
"[1:v]scale=400:250:force_original_aspect_ratio=decrease,pad=400:250:(ow-iw)/2:(oh-ih)/2 [s1]"
"[s0][s1]xstack=inputs=2:fill='black':layout=0_0|w0_0[v]"
"[0:a][1:a]amix=inputs=2[a]"

但是,如果我将每个视频的输出尺寸更改为 400:225 而不是 400:250,则会失败。
"[0:v]scale=400:225:force_original_aspect_ratio=decrease,pad=400:225:(ow-iw)/2:(oh-ih)/2 [s0]"
"[1:v]scale=400:225:force_original_aspect_ratio=decrease,pad=400:225:(ow-iw)/2:(oh-ih)/2 [s1]"
"[s0][s1]xstack=inputs=2:fill='black':layout=0_0|w0_0[v]"
"[0:a][1:a]amix=inputs=2[a]"

给出以下错误:
An error occurred: ffmpeg exited with code 1: Error reinitializing filters!
Failed to inject frame into filter network: Invalid argument
Error while processing the decoded data for stream #1:1
Conversion failed!

如果相关,第一个视频的尺寸为 1280x720,而第二个视频的尺寸为 320x240。

任何人都知道为什么一组尺寸有效而另一组尺寸无效?

编辑:这是失败时的完整 ffmpeg 日志:
ffmpeg version git-2020-05-13-b12b053 Copyright (c) 2000-2020 the FFmpeg developers
built with gcc 9.3.1 (GCC) 20200513
configuration: --enable-gpl --enable-version3 --enable-sdl2 --enable-fontconfig --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d --enable-libbluray --enable-libfreetype --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libsrt --enable-libtheora --enable-libtwolame --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib --enable-gmp --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvo-amrwbenc --enable-libmysofa --enable-libspeex --enable-libxvid --enable-libaom --disable-w32threads --enable-libmfx --enable-ffnvcodec --enable-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
libavutil 56. 45.100 / 56. 45.100
libavcodec 58. 84.100 / 58. 84.100
libavformat 58. 43.100 / 58. 43.100
libavdevice 58. 9.103 / 58. 9.103
libavfilter 7. 80.100 / 7. 80.100
libswscale 5. 6.101 / 5. 6.101
libswresample 3. 6.100 / 3. 6.100
libpostproc 55. 6.100 / 55. 6.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:/Users/user_name/Desktop/vids/vid1.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
creation_time : 2020-05-21T15:52:20.000000Z
Duration: 00:00:10.76, start: 0.000000, bitrate: 8385 kb/s
Stream #0:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc), 1280x720 [SAR 1:1 DAR 16:9], 8237 kb/s, 29.99 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2020-05-21T15:52:20.000000Z
handler_name : VideoHandler
encoder : AVC Coding
Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 165 kb/s (default)
Metadata:
creation_time : 2020-05-21T15:52:20.000000Z
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'C:/Users/user_name/Desktop/vids/vid2.mp4':
Metadata:
major_brand : mp42
minor_version : 0
compatible_brands: mp41isom
creation_time : 2020-05-21T15:54:37.000000Z
Duration: 00:00:11.01, start: 0.000000, bitrate: 836 kb/s
Stream #1:0(und): Video: h264 (Main) (avc1 / 0x31637661), yuvj420p(pc), 320x240 [SAR 1:1 DAR 4:3], 669 kb/s, 29.88 fps, 30 tbr, 30k tbn, 60 tbc (default)
Metadata:
creation_time : 2020-05-21T15:54:37.000000Z
handler_name : VideoHandler
encoder : AVC Coding
Stream #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 163 kb/s (default)
Metadata:
creation_time : 2020-05-21T15:54:37.000000Z
handler_name : SoundHandler
Stream mapping:
Stream #0:0 (h264) -> scale
Stream #0:1 (aac) -> amix:input0
Stream #1:0 (h264) -> scale
Stream #1:1 (aac) -> amix:input1
xstack -> Stream #0:0 (libx264)
amix -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
[swscaler @ 000001343fefc200] deprecated pixel format used, make sure you did set range correctly
[Parsed_pad_1 @ 000001343f8dc3c0] Padded dimensions cannot be smaller than input dimensions.
[Parsed_pad_1 @ 000001343f8dc3c0] 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:1
Conversion failed!

Done in 0.66s.

最佳答案

我找到了一种解决方法,如果不一定是解决方案。

以下消息显示在问题中发布的日志中。

Padded dimensions cannot be smaller than input dimensions.

我发现如果我减少传递给 scale 的每个维度1(这样它们总是小于传递给 pad 的尺寸),然后我似乎不再收到错误了。

以下复杂的过滤器字符串起作用:
"[0:v]scale=399:224:force_original_aspect_ratio=decrease,pad=400:225:(ow-iw)/2:(oh-ih)/2 [s0]"
"[1:v]scale=399:224:force_original_aspect_ratio=decrease,pad=400:225:(ow-iw)/2:(oh-ih)/2 [s1]"
"[s0][s1]xstack=inputs=2:fill='black':layout=0_0|w0_0[v]"
"[0:a][1:a]amix=inputs=2[a]"

这并不理想,我仍然不明白为什么它以前不起作用。我猜想有一种更优雅的方式来解决这个问题,但至少这是可行的。

关于node.js - ffmpeg:当输入缩放到某些尺寸时,xstack 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62164109/

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