gpt4 book ai didi

node.js - NodeJS 生成 FFMPEG 进程无法正确理解参数

转载 作者:太空宇宙 更新时间:2023-11-04 01:45:08 24 4
gpt4 key购买 nike

我正在编写代码以使用带有乘法器的 FFMPEG 来加速视频。 5X 表示速度快五倍的视频,0.5X 表示速度慢两倍的视频等。

此代码之前在其他用例中也有效,但 args 数组似乎有问题。

var spawn = require('child_process').spawn;
var cmd = 'node_modules\\ffmpeg-binaries\\bin\\ffmpeg.exe';

speedupFilename = tmpdir + vts + 'speedup.mp4';

var args = ['-i', filename, '-filter:v ', '"setpts=PTS/' + multiplier + '"', speedupFilename];
console.log(cmd + ' ' + args.join(' '));

var proc = spawn(cmd, args);

/* code that reads stdout and print it out to console */

这在控制台中打印出来:

node_modules\ffmpeg-binaries\bin\ffmpeg.exe -i C:\Users\User\AppData\Local\Temp\1533658543video.mp4 -filter:v  "setpts=PTS/0.10" C:\Users\User\AppData\Local\Temp\1533658543speedup.mp4
ffmpeg version 3.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)

configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib
libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.100 / 57. 64.100
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\User\AppData\Local\Temp\1533658543video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands:
script.js:337 isomiso2avc1mp41
encoder : Lavf57.56.100
Duration: 00:00:00.12, start: 0.000000, bitrate: 9398 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 9340 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler

[AVFilterGraph @ 05c67dc0] No such filter: '"setpts'
Error opening filters!

我在 FFMPEG 中设置了 setpts 过滤器,我研究了 ffmpeg -filters

如果我在控制台中运行命令(输出中的第一行),它工作正常。

如果我将 args 数组中的 -filter:v ', '"setpts=PTS/' + multiplier + '"' 更改为 -filter:v "setpts=PTS/' + multiplier + '"' (删除 ', ' 以连接这两个数组项),那么它只会显示 必须指定至少一个输出文件:

ffmpeg version 3.2 Copyright (c) 2000-2016 the FFmpeg developers
built with gcc 5.4.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-dxva2 --enable-libmfx --enable-nvenc --enable-avisynth --enable-bzlib --enable-libebur128 --enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinger --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-lzma --enable-decklink --enable-zlib

libavutil 55. 34.100 / 55. 34.100
libavcodec 57. 64.100 / 57. 64.100
libavformat 57. 56.100 / 57. 56.100
libavdevice 57. 1.100 / 57. 1.100
libavfilter 6. 65.100 / 6. 65.100
libswscale 4. 2.100 / 4. 2.100
libswresample 2. 3.100 / 2. 3.100
libpostproc 54. 1.100 / 54. 1.100
Trailing options were found on the commandline.

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'C:\Users\User\AppData\Local\Temp\1533659280video.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands:
isomiso2avc1mp41
encoder : Lavf57.56.100
Duration: 00:00:00.12, start: 0.000000, bitrate: 9398 kb/s
Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720, 9340 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
Metadata:
handler_name : VideoHandler
At least one output file must be specified

最佳答案

我终于找到了解决办法。

在数组项 '"pts=PTS/' + multiplier + '"' 中,我必须删除引号。它们是无用的,因为参数无论如何都是孤立的,不像命令行空间是不够的。

关于node.js - NodeJS 生成 FFMPEG 进程无法正确理解参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51731565/

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