node.js - ffmpeg --help, node child_process spawn trigger stderr
问题描述
所以我只是ffmpeg --help
使用 node.js 运行,为什么会有stderr
?我觉得应该只是stdout
。是 ffmpeg 还是 node.js 的问题?
代码:
import path from 'path';
import {spawn} from 'child_process';
const childProcess = spawn(path.join(__dirname, 'ffmpeg'), ['--help']);
childProcess.stderr.setEncoding('utf-8');
childProcess.stderr.on('data', data => {
console.log('stderr:');
console.log(data);
});
输出:
stderr:
ffmpeg version 4.4-tessus https://evermeet.cx/ffmpeg/ Copyright (c) 2000-2021 the FFmpeg developers
built with Apple clang version 11.0.0 (clang-1100.0.33.17)
configuration: --cc=/usr/bin/clang --prefix=/opt/ffmpeg --extra-version=tessus --enable-avisynth --enable-fontconfig --enable-gpl --enable-libaom --enable-libass --enable-libbluray --enable-libdav1d --enable-libfreetype --enable-libgsm --enable-libmodplug --enable-libmp3lame --enable-libmysofa --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-libopus --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvmaf --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-version3 --pkg-config-flags=--static --disable-ffplay
stderr:
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
libswscale 5. 9.100 / 5. 9.100
libswresample 3. 9.100 / 3. 9.100
libpostproc 55. 9.100 / 55. 9.100
解决方案
让我回答我自己的问题:ffmpeg 默认将正常输出重定向到 stderr。这很奇怪,但这就是它的设计方式
推荐阅读
- git - PowerShell 脚本未捕获 git 输出
- html - 导航栏浮动切断标题边框底部(CSS)
- java - What is the correct way to capture the Http Status code with Spring AOP?
- angular8 - 使用 API 响应数据动态更新选择
- swift - UITabBarController: UITabBarItem 更新它或重新加载它
- node.js - 'sed' is not recognized as an internal or external command in Windows
- python - 简单的 CNN 模型四个图像输入来检测两个类别
- sql - Advanced Laravel Query
- c# - Regex: finding words that end with the same letter the next word begins with
- c++ - Proper usage of QThread in loops