Javascript mplayer流stdin到文件

Javascript mplayer流stdin到文件,javascript,sockets,mplayer,Javascript,Sockets,Mplayer,我用tellojs从由DJI无人机驱动的Ryze Tello录制。我从无人机接收视频数据作为十六进制缓冲区(例如,)。我将其传输到stdin,在那里我有一个子进程运行mplayer,参数为['-gui','-noirc','-fps',35','-',] 它可以实时显示视频 但是,我的目标是能够将视频保存到文件中,而不是实时播放。我怎样才能做到这一点?我尝试使用以下参数作为mplayer['-gui'、'-noirc'、'-fps'、'-35'、'--'、'-dumpstream'、'-dump

我用tellojs从由DJI无人机驱动的Ryze Tello录制。我从无人机接收视频数据作为十六进制缓冲区(例如,
)。我将其传输到stdin,在那里我有一个子进程运行mplayer,参数为
['-gui','-noirc','-fps',35','-',]

它可以实时显示视频

但是,我的目标是能够将视频保存到文件中,而不是实时播放。我怎样才能做到这一点?我尝试使用以下参数作为mplayer
['-gui'、'-noirc'、'-fps'、'-35'、'--'、'-dumpstream'、'-dumpfile'、'file.mp4']
,但生成的文件长度始终为0

以下是我用来写入文件的完整代码:

const {spawn} = require('child_process')
const sdk = require('tellojs')

const bindVideo = async () => {
    const mplayer = {
        "command": 'mplayer',
        "args": ['-gui', '-nolirc', '-fps', '35', '-', '-dumpstream', '-dumpfile', 'file.mp4']
    }
    const h264encoder = spawn(mplayer.command, mplayer.args)
    const videoEmitter = await sdk.receiver.video.bind()
    videoEmitter.on('message', msg => {
        console.log(msg)
        h264encoder.stdin.write(msg)
    })
}

module.exports = {
    bindVideo
}
每次我收到无人机发来的信息时,我都会把它写到stdin上,由mplayer读取

如何将视频保存到文件中