4D48
4D48

Reputation: 21

NodeJS spawning FFMPEG process does not understand arguments right

I am writing code to speed up video using FFMPEG with multiplier. 5X for five times faster video, 0.5X for twice slower video etc.

This code has worked previously in other use case, but it looks like there is something wrong with args array.

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 */

This prints out in 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!

I have setpts filter in my FFMPEG, I have looked into ffmpeg -filters.

If I run command (first line in output) in console, it works fine.

If I change -filter:v ', '"setpts=PTS/' + multiplier + '"' to -filter:v "setpts=PTS/' + multiplier + '"' in args array (remove ', ' to connect those two array items), then it just says At least one output file must be specified:

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

Upvotes: 1

Views: 949

Answers (1)

4D48
4D48

Reputation: 21

I finally figured out the solution.

In the array item '"pts=PTS/' + multiplier + '"' I had to remove quotation marks. They are useless, because argument is anyways isolated unlike in command line space is not enough.

Upvotes: 1

Related Questions