Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/amazon-s3/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 无法读取属性';isStream';使用fluent ffmpeg定义未定义的_Node.js_Amazon S3_Ffmpeg - Fatal编程技术网

Node.js 无法读取属性';isStream';使用fluent ffmpeg定义未定义的

Node.js 无法读取属性';isStream';使用fluent ffmpeg定义未定义的,node.js,amazon-s3,ffmpeg,Node.js,Amazon S3,Ffmpeg,我有这些代码行 s3.getObject(getParams, function (err, response) { ffmpeg(response.Body) .size('640x360') .videoFilter({ filter: 'scale', options: [640, -1] }) // .seekInput('3:00') .duration('0:08')

我有这些代码行

s3.getObject(getParams, function (err, response) {
        ffmpeg(response.Body)
            .size('640x360')
            .videoFilter({ filter: 'scale', options: [640, -1] })
            // .seekInput('3:00')
            .duration('0:08')
            .format('mp4')
            .on('error', function (err) {
                console.error(err, 'invalid ffmpeg conversion')
            })
            .on('start', function (start) {
                console.log(start, 'starting');
            })
            .on('progress', function (any) {
                console.log(any, 'progress')
            })
            .on('end', function () {
                s3.putObject({
                    Bucket: S3_CREDENTIALS.bucketName,
                    Key: newKey,
                    Body: fs.readSync(newKey),
                    ContentType: response.ContentType
                }, function (err, data) {
                    fs.unlinkSync(newKey)
                    if (err) {
                        res.json('ko')
                    } else {
                        res.json('ok')
                    }
                });
            })
            .output(fs.createWriteStream(newKey))
            .run()
    })
之所以创建文件,是因为我无法将fluent ffmpeg输出流式传输到putObject流体。当然,如果有办法避免创建本地文件(然后将其删除),则更好

我得到的错误是一个
fluent ffmpeg
错误,表示
error[TypeError]:无法读取未定义的属性“isStream”


非常感谢您的帮助。

此代码实际上正在运行。我们欢迎更好的解决方案

const newKey = "preview_" + req.params.key
    const source = s3.getSignedUrl('getObject',getParams)
    ffmpeg({source})
        .size('640x360')
        .videoFilter({ filter: 'scale', options: [640, -1] })
        // .seekInput('3:00')
        .duration('0:08')
        .format('mp4')
        .on('end', function () {
            s3.putObject({
                Bucket: S3_CREDENTIALS.bucketName,
                Key: newKey,
                Body: fs.readFileSync(newKey),
                ContentType: 'video/mp4'
            }, function (err, data) {
                fs.unlinkSync(newKey)
                if (err) {
                    res.json('ko')
                } else {
                    res.json('ok')
                }
            });
        })
        .outputOptions([
            '-movflags frag_keyframe+empty_moov',
            '-movflags +faststart'
        ])
        .toFormat('mp4')
        .save(newKey)

这段代码实际上正在运行。我们欢迎更好的解决方案

const newKey = "preview_" + req.params.key
    const source = s3.getSignedUrl('getObject',getParams)
    ffmpeg({source})
        .size('640x360')
        .videoFilter({ filter: 'scale', options: [640, -1] })
        // .seekInput('3:00')
        .duration('0:08')
        .format('mp4')
        .on('end', function () {
            s3.putObject({
                Bucket: S3_CREDENTIALS.bucketName,
                Key: newKey,
                Body: fs.readFileSync(newKey),
                ContentType: 'video/mp4'
            }, function (err, data) {
                fs.unlinkSync(newKey)
                if (err) {
                    res.json('ko')
                } else {
                    res.json('ok')
                }
            });
        })
        .outputOptions([
            '-movflags frag_keyframe+empty_moov',
            '-movflags +faststart'
        ])
        .toFormat('mp4')
        .save(newKey)